Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
k54kdk
PyQt Fluent Widgets
提交
69916945
P
PyQt Fluent Widgets
项目概览
k54kdk
/
PyQt Fluent Widgets
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PyQt Fluent Widgets
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
69916945
编写于
4月 23, 2023
作者:
之一Yo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
颜色对话框添加调整透明度功能
上级
640c6ed5
变更
14
展开全部
隐藏空白更改
内联
并排
Showing
14 changed file
with
53085 addition
and
52991 deletion
+53085
-52991
examples/color_dialog/demo.py
examples/color_dialog/demo.py
+1
-1
examples/settings/resource/i18n/qfluentwidgets_hk.qm
examples/settings/resource/i18n/qfluentwidgets_hk.qm
+0
-0
examples/settings/resource/i18n/qfluentwidgets_hk.ts
examples/settings/resource/i18n/qfluentwidgets_hk.ts
+4
-0
examples/settings/resource/i18n/qfluentwidgets_zh.qm
examples/settings/resource/i18n/qfluentwidgets_zh.qm
+0
-0
examples/settings/resource/i18n/qfluentwidgets_zh.ts
examples/settings/resource/i18n/qfluentwidgets_zh.ts
+4
-0
qfluentwidgets/__init__.py
qfluentwidgets/__init__.py
+1
-1
qfluentwidgets/_rc/qss/dark/color_dialog.qss
qfluentwidgets/_rc/qss/dark/color_dialog.qss
+1
-1
qfluentwidgets/_rc/qss/light/color_dialog.qss
qfluentwidgets/_rc/qss/light/color_dialog.qss
+1
-1
qfluentwidgets/_rc/resource.py
qfluentwidgets/_rc/resource.py
+52961
-52961
qfluentwidgets/common/config.py
qfluentwidgets/common/config.py
+1
-1
qfluentwidgets/components/dialog_box/color_dialog.py
qfluentwidgets/components/dialog_box/color_dialog.py
+88
-16
qfluentwidgets/components/settings/custom_color_setting_card.py
...twidgets/components/settings/custom_color_setting_card.py
+7
-3
qfluentwidgets/components/settings/setting_card.py
qfluentwidgets/components/settings/setting_card.py
+15
-5
setup.py
setup.py
+1
-1
未找到文件。
examples/color_dialog/demo.py
浏览文件 @
69916945
...
...
@@ -11,7 +11,7 @@ class Demo(QWidget):
def
__init__
(
self
):
super
().
__init__
()
self
.
button
=
ColorPickerButton
(
QColor
(
"#
12aaa2"
),
'Background Color'
,
self
)
self
.
button
=
ColorPickerButton
(
QColor
(
"#
5012aaa2"
),
'Background Color'
,
self
,
enableAlpha
=
True
)
self
.
resize
(
800
,
720
)
self
.
button
.
move
(
352
,
312
)
self
.
setStyleSheet
(
"Demo{background:white}"
)
...
...
examples/settings/resource/i18n/qfluentwidgets_hk.qm
浏览文件 @
69916945
无法预览此类型文件
examples/settings/resource/i18n/qfluentwidgets_hk.ts
浏览文件 @
69916945
...
...
@@ -28,6 +28,10 @@
<
source
>
Green
<
/source
>
<
translation
>
綠色
<
/translation
>
<
/message
>
<
message
>
<
source
>
Opacity
<
/source
>
<
translation
>
透明度
<
/translation
>
<
/message
>
<
/context
>
<
context
>
<
name
>
MessageDialog
<
/name
>
...
...
examples/settings/resource/i18n/qfluentwidgets_zh.qm
浏览文件 @
69916945
无法预览此类型文件
examples/settings/resource/i18n/qfluentwidgets_zh.ts
浏览文件 @
69916945
...
...
@@ -28,6 +28,10 @@
<
source
>
Green
<
/source
>
<
translation
>
绿色
<
/translation
>
<
/message
>
<
message
>
<
source
>
Opacity
<
/source
>
<
translation
>
透明度
<
/translation
>
<
/message
>
<
/context
>
<
context
>
<
name
>
MessageDialog
<
/name
>
...
...
qfluentwidgets/__init__.py
浏览文件 @
69916945
...
...
@@ -12,7 +12,7 @@ Examples are available at https://github.com/zhiyiYo/PyQt-Fluent-Widgets/tree/ma
:license: GPLv3, see LICENSE for more details.
"""
__version__
=
"0.7.
3
"
__version__
=
"0.7.
4
"
from
.components
import
*
from
.common
import
*
...
...
qfluentwidgets/_rc/qss/dark/color_dialog.qss
浏览文件 @
69916945
...
...
@@ -41,7 +41,7 @@ QLabel {
font-size: 16px;
}
#prefixLabel {
#prefixLabel
, #suffixLabel
{
padding: 0;
font-size: 14px;
}
...
...
qfluentwidgets/_rc/qss/light/color_dialog.qss
浏览文件 @
69916945
...
...
@@ -39,7 +39,7 @@ QLabel {
font-size: 16px;
}
#prefixLabel {
#prefixLabel
, #suffixLabel
{
padding: 0;
font-size: 14px;
}
...
...
qfluentwidgets/_rc/resource.py
浏览文件 @
69916945
此差异已折叠。
点击以展开。
qfluentwidgets/common/config.py
浏览文件 @
69916945
...
...
@@ -145,7 +145,7 @@ class ColorSerializer(ConfigSerializer):
""" QColor serializer """
def
serialize
(
self
,
value
:
QColor
):
return
value
.
name
()
return
value
.
name
(
QColor
.
HexArgb
)
def
deserialize
(
self
,
value
):
if
isinstance
(
value
,
list
):
...
...
qfluentwidgets/components/dialog_box/color_dialog.py
浏览文件 @
69916945
...
...
@@ -4,7 +4,7 @@ from PyQt5.QtGui import (QBrush, QColor, QPixmap,
QPainter
,
QPen
,
QIntValidator
,
QRegExpValidator
,
QIcon
)
from
PyQt5.QtWidgets
import
QApplication
,
QLabel
,
QWidget
,
QPushButton
,
QFrame
,
QVBoxLayout
from
...common.style_sheet
import
FluentStyleSheet
from
...common.style_sheet
import
FluentStyleSheet
,
isDarkTheme
from
..widgets
import
Slider
,
ScrollArea
,
PushButton
,
PrimaryPushButton
from
..widgets.line_edit
import
LineEdit
from
.mask_dialog_base
import
MaskDialogBase
...
...
@@ -101,7 +101,7 @@ class BrightnessSlider(Slider):
def
__onValueChanged
(
self
,
value
):
""" slider value changed slot """
self
.
color
.
setHsv
(
self
.
color
.
hue
(),
self
.
color
.
saturation
(),
value
)
self
.
color
.
setHsv
(
self
.
color
.
hue
(),
self
.
color
.
saturation
(),
value
,
self
.
color
.
alpha
()
)
self
.
setColor
(
self
.
color
)
self
.
colorChanged
.
emit
(
self
.
color
)
...
...
@@ -109,10 +109,24 @@ class BrightnessSlider(Slider):
class
ColorCard
(
QWidget
):
""" Color card """
def
__init__
(
self
,
color
,
parent
=
None
):
def
__init__
(
self
,
color
,
parent
=
None
,
enableAlpha
=
False
):
super
().
__init__
(
parent
)
self
.
setFixedSize
(
44
,
128
)
self
.
setColor
(
color
)
self
.
enableAlpha
=
enableAlpha
self
.
titledPixmap
=
self
.
_createTitledBackground
()
def
_createTitledBackground
(
self
):
pixmap
=
QPixmap
(
8
,
8
)
pixmap
.
fill
(
Qt
.
transparent
)
painter
=
QPainter
(
pixmap
)
c
=
255
if
isDarkTheme
()
else
0
color
=
QColor
(
c
,
c
,
c
,
26
)
painter
.
fillRect
(
4
,
0
,
4
,
4
,
color
)
painter
.
fillRect
(
0
,
4
,
4
,
4
,
color
)
painter
.
end
()
return
pixmap
def
setColor
(
self
,
color
):
""" set the color of card """
...
...
@@ -123,6 +137,13 @@ class ColorCard(QWidget):
painter
=
QPainter
(
self
)
painter
.
setRenderHints
(
QPainter
.
Antialiasing
)
# draw tiled background
if
self
.
enableAlpha
:
painter
.
setBrush
(
QBrush
(
self
.
titledPixmap
))
painter
.
setPen
(
QColor
(
0
,
0
,
0
,
13
))
painter
.
drawRoundedRect
(
self
.
rect
(),
4
,
4
)
# draw color
painter
.
setBrush
(
self
.
color
)
painter
.
setPen
(
QColor
(
0
,
0
,
0
,
13
))
painter
.
drawRoundedRect
(
self
.
rect
(),
4
,
4
)
...
...
@@ -152,9 +173,15 @@ class ColorLineEdit(LineEdit):
class
HexColorLineEdit
(
ColorLineEdit
):
""" Hex color line edit """
def
__init__
(
self
,
color
,
parent
=
None
):
super
().
__init__
(
QColor
(
color
).
name
()[
1
:],
parent
)
self
.
setValidator
(
QRegExpValidator
(
QRegExp
(
r
'[A-Fa-f0-9]{6}'
)))
def
__init__
(
self
,
color
,
parent
=
None
,
enableAlpha
=
False
):
f
=
QColor
.
HexArgb
if
enableAlpha
else
QColor
.
HexRgb
super
().
__init__
(
QColor
(
color
).
name
(
f
)[
1
:],
parent
)
if
enableAlpha
:
self
.
setValidator
(
QRegExpValidator
(
QRegExp
(
r
'[A-Fa-f0-9]{8}'
)))
else
:
self
.
setValidator
(
QRegExpValidator
(
QRegExp
(
r
'[A-Fa-f0-9]{6}'
)))
self
.
setTextMargins
(
4
,
0
,
33
,
0
)
self
.
prefixLabel
=
QLabel
(
'#'
,
self
)
self
.
prefixLabel
.
move
(
7
,
2
)
...
...
@@ -165,12 +192,32 @@ class HexColorLineEdit(ColorLineEdit):
self
.
setText
(
color
.
name
()[
1
:])
class
OpacityLineEdit
(
ColorLineEdit
):
""" Opacity line edit """
def
__init__
(
self
,
value
,
parent
=
None
,
enableAlpha
=
False
):
super
().
__init__
(
int
(
value
/
255
*
100
),
parent
)
self
.
setValidator
(
QRegExpValidator
(
QRegExp
(
r
'[0-9][0-9]{0,1}|100'
)))
self
.
setTextMargins
(
4
,
0
,
33
,
0
)
self
.
suffixLabel
=
QLabel
(
'%'
,
self
)
self
.
suffixLabel
.
setObjectName
(
'suffixLabel'
)
self
.
textChanged
.
connect
(
self
.
_adjustSuffixPos
)
def
showEvent
(
self
,
e
):
super
().
showEvent
(
e
)
self
.
_adjustSuffixPos
()
def
_adjustSuffixPos
(
self
):
x
=
self
.
fontMetrics
().
width
(
self
.
text
())
+
18
self
.
suffixLabel
.
move
(
x
,
2
)
class
ColorDialog
(
MaskDialogBase
):
""" Color dialog """
colorChanged
=
pyqtSignal
(
QColor
)
def
__init__
(
self
,
color
,
title
:
str
,
parent
=
None
):
def
__init__
(
self
,
color
,
title
:
str
,
parent
=
None
,
enableAlpha
=
False
):
"""
Parameters
----------
...
...
@@ -182,8 +229,16 @@ class ColorDialog(MaskDialogBase):
parent: QWidget
parent widget
enableAlpha: bool
whether to enable the alpha channel
"""
super
().
__init__
(
parent
)
self
.
enableAlpha
=
enableAlpha
if
not
enableAlpha
:
color
=
QColor
(
color
)
color
.
setAlpha
(
255
)
self
.
oldColor
=
QColor
(
color
)
self
.
color
=
QColor
(
color
)
...
...
@@ -196,18 +251,20 @@ class ColorDialog(MaskDialogBase):
self
.
titleLabel
=
QLabel
(
title
,
self
.
scrollWidget
)
self
.
huePanel
=
HuePanel
(
color
,
self
.
scrollWidget
)
self
.
newColorCard
=
ColorCard
(
color
,
self
.
scrollWidget
)
self
.
oldColorCard
=
ColorCard
(
color
,
self
.
scrollWidget
)
self
.
newColorCard
=
ColorCard
(
color
,
self
.
scrollWidget
,
enableAlpha
)
self
.
oldColorCard
=
ColorCard
(
color
,
self
.
scrollWidget
,
enableAlpha
)
self
.
brightSlider
=
BrightnessSlider
(
color
,
self
.
scrollWidget
)
self
.
editLabel
=
QLabel
(
self
.
tr
(
'Edit Color'
),
self
.
scrollWidget
)
self
.
redLabel
=
QLabel
(
self
.
tr
(
'Red'
),
self
.
scrollWidget
)
self
.
blueLabel
=
QLabel
(
self
.
tr
(
'Blue'
),
self
.
scrollWidget
)
self
.
greenLabel
=
QLabel
(
self
.
tr
(
'Green'
),
self
.
scrollWidget
)
self
.
hexLineEdit
=
HexColorLineEdit
(
color
,
self
.
scrollWidget
)
self
.
opacityLabel
=
QLabel
(
self
.
tr
(
'Opacity'
),
self
.
scrollWidget
)
self
.
hexLineEdit
=
HexColorLineEdit
(
color
,
self
.
scrollWidget
,
enableAlpha
)
self
.
redLineEdit
=
ColorLineEdit
(
self
.
color
.
red
(),
self
.
scrollWidget
)
self
.
greenLineEdit
=
ColorLineEdit
(
self
.
color
.
green
(),
self
.
scrollWidget
)
self
.
blueLineEdit
=
ColorLineEdit
(
self
.
color
.
blue
(),
self
.
scrollWidget
)
self
.
opacityLineEdit
=
OpacityLineEdit
(
self
.
color
.
alpha
(),
self
.
scrollWidget
)
self
.
vBoxLayout
=
QVBoxLayout
(
self
.
widget
)
...
...
@@ -218,9 +275,9 @@ class ColorDialog(MaskDialogBase):
self
.
scrollArea
.
setViewportMargins
(
48
,
24
,
0
,
24
)
self
.
scrollArea
.
setWidget
(
self
.
scrollWidget
)
self
.
widget
.
setMaximumSize
(
488
,
696
)
self
.
widget
.
resize
(
488
,
696
)
self
.
scrollWidget
.
resize
(
440
,
560
)
self
.
widget
.
setMaximumSize
(
488
,
696
+
40
*
self
.
enableAlpha
)
self
.
widget
.
resize
(
488
,
696
+
40
*
self
.
enableAlpha
)
self
.
scrollWidget
.
resize
(
440
,
560
+
40
*
self
.
enableAlpha
)
self
.
buttonGroup
.
setFixedSize
(
486
,
81
)
self
.
yesButton
.
setFixedWidth
(
216
)
self
.
cancelButton
.
setFixedWidth
(
216
)
...
...
@@ -247,6 +304,13 @@ class ColorDialog(MaskDialogBase):
self
.
blueLabel
.
move
(
144
,
524
)
self
.
hexLineEdit
.
move
(
196
,
381
)
if
self
.
enableAlpha
:
self
.
opacityLineEdit
.
move
(
0
,
560
)
self
.
opacityLabel
.
move
(
144
,
567
)
else
:
self
.
opacityLineEdit
.
hide
()
self
.
opacityLabel
.
hide
()
self
.
vBoxLayout
.
setSpacing
(
0
)
self
.
vBoxLayout
.
setAlignment
(
Qt
.
AlignTop
)
self
.
vBoxLayout
.
setContentsMargins
(
0
,
0
,
0
,
0
)
...
...
@@ -280,13 +344,14 @@ class ColorDialog(MaskDialogBase):
def
__onHueChanged
(
self
,
color
):
""" hue changed slot """
self
.
color
.
setHsv
(
color
.
hue
(),
color
.
saturation
(),
self
.
color
.
value
())
self
.
color
.
setHsv
(
color
.
hue
(),
color
.
saturation
(),
self
.
color
.
value
(),
self
.
color
.
alpha
())
self
.
setColor
(
self
.
color
)
def
__onBrightnessChanged
(
self
,
color
):
""" brightness changed slot """
self
.
color
.
setHsv
(
self
.
color
.
hue
(),
self
.
color
.
saturation
(),
color
.
value
())
self
.
color
.
setHsv
(
self
.
color
.
hue
(),
self
.
color
.
saturation
(),
color
.
value
(),
color
.
alpha
())
self
.
setColor
(
self
.
color
,
False
)
def
__onRedChanged
(
self
,
red
):
...
...
@@ -304,6 +369,11 @@ class ColorDialog(MaskDialogBase):
self
.
color
.
setGreen
(
int
(
green
))
self
.
setColor
(
self
.
color
)
def
__onOpacityChanged
(
self
,
opacity
):
""" opacity channel changed slot """
self
.
color
.
setAlpha
(
int
(
int
(
opacity
)
/
100
*
255
))
self
.
setColor
(
self
.
color
)
def
__onHexColorChanged
(
self
,
color
):
""" hex color changed slot """
self
.
color
.
setNamedColor
(
"#"
+
color
)
...
...
@@ -323,6 +393,7 @@ class ColorDialog(MaskDialogBase):
self
.
redLabel
.
adjustSize
()
self
.
greenLabel
.
adjustSize
()
self
.
blueLabel
.
adjustSize
()
self
.
opacityLabel
.
adjustSize
()
def
showEvent
(
self
,
e
):
self
.
updateStyle
()
...
...
@@ -340,3 +411,4 @@ class ColorDialog(MaskDialogBase):
self
.
blueLineEdit
.
valueChanged
.
connect
(
self
.
__onBlueChanged
)
self
.
greenLineEdit
.
valueChanged
.
connect
(
self
.
__onGreenChanged
)
self
.
hexLineEdit
.
valueChanged
.
connect
(
self
.
__onHexColorChanged
)
self
.
opacityLineEdit
.
valueChanged
.
connect
(
self
.
__onOpacityChanged
)
qfluentwidgets/components/settings/custom_color_setting_card.py
浏览文件 @
69916945
...
...
@@ -17,7 +17,7 @@ class CustomColorSettingCard(ExpandGroupSettingCard):
colorChanged
=
pyqtSignal
(
QColor
)
def
__init__
(
self
,
configItem
:
ColorConfigItem
,
icon
:
Union
[
str
,
QIcon
,
FluentIconBase
],
title
:
str
,
content
=
None
,
parent
=
None
):
content
=
None
,
parent
=
None
,
enableAlpha
=
False
):
"""
Parameters
----------
...
...
@@ -35,8 +35,12 @@ class CustomColorSettingCard(ExpandGroupSettingCard):
parent: QWidget
parent window
enableAlpha: bool
whether to enable the alpha channel
"""
super
().
__init__
(
icon
,
title
,
content
,
parent
=
parent
)
self
.
enableAlpha
=
enableAlpha
self
.
configItem
=
configItem
self
.
defaultColor
=
QColor
(
configItem
.
defaultValue
)
self
.
customColor
=
QColor
(
qconfig
.
get
(
configItem
))
...
...
@@ -123,8 +127,8 @@ class CustomColorSettingCard(ExpandGroupSettingCard):
def
__showColorDialog
(
self
):
""" show color dialog """
w
=
ColorDialog
(
qconfig
.
get
(
self
.
configItem
),
self
.
tr
(
'Choose color'
),
self
.
window
()
)
w
=
ColorDialog
(
qconfig
.
get
(
self
.
configItem
),
self
.
tr
(
'Choose color'
),
self
.
window
(),
self
.
enableAlpha
)
w
.
colorChanged
.
connect
(
self
.
__onCustomColorChanged
)
w
.
exec
()
...
...
qfluentwidgets/components/settings/setting_card.py
浏览文件 @
69916945
...
...
@@ -275,9 +275,10 @@ class ColorPickerButton(QToolButton):
colorChanged
=
pyqtSignal
(
QColor
)
def
__init__
(
self
,
color
:
QColor
,
title
:
str
,
parent
=
None
):
def
__init__
(
self
,
color
:
QColor
,
title
:
str
,
parent
=
None
,
enableAlpha
=
False
):
super
().
__init__
(
parent
=
parent
)
self
.
title
=
title
self
.
enableAlpha
=
enableAlpha
self
.
setFixedSize
(
96
,
32
)
self
.
setAttribute
(
Qt
.
WA_TranslucentBackground
)
...
...
@@ -288,7 +289,7 @@ class ColorPickerButton(QToolButton):
def
__showColorDialog
(
self
):
""" show color dialog """
w
=
ColorDialog
(
self
.
color
,
self
.
tr
(
'Choose '
)
+
self
.
title
,
self
.
window
())
'Choose '
)
+
self
.
title
,
self
.
window
()
,
self
.
enableAlpha
)
w
.
colorChanged
.
connect
(
self
.
__onColorChanged
)
w
.
exec
()
...
...
@@ -307,7 +308,12 @@ class ColorPickerButton(QToolButton):
painter
.
setRenderHints
(
QPainter
.
Antialiasing
)
pc
=
QColor
(
255
,
255
,
255
,
10
)
if
isDarkTheme
()
else
QColor
(
234
,
234
,
234
)
painter
.
setPen
(
pc
)
painter
.
setBrush
(
self
.
color
)
color
=
QColor
(
self
.
color
)
if
not
self
.
enableAlpha
:
color
.
setAlpha
(
255
)
painter
.
setBrush
(
color
)
painter
.
drawRoundedRect
(
self
.
rect
().
adjusted
(
1
,
1
,
-
1
,
-
1
),
5
,
5
)
...
...
@@ -316,7 +322,8 @@ class ColorSettingCard(SettingCard):
colorChanged
=
pyqtSignal
(
QColor
)
def
__init__
(
self
,
configItem
,
icon
:
Union
[
str
,
QIcon
,
FluentIconBase
],
title
,
content
=
None
,
parent
=
None
):
def
__init__
(
self
,
configItem
,
icon
:
Union
[
str
,
QIcon
,
FluentIconBase
],
title
:
str
,
content
:
str
=
None
,
parent
=
None
,
enableAlpha
=
False
):
"""
Parameters
----------
...
...
@@ -334,11 +341,14 @@ class ColorSettingCard(SettingCard):
parent: QWidget
parent widget
enableAlpha: bool
whether to enable the alpha channel
"""
super
().
__init__
(
icon
,
title
,
content
,
parent
)
self
.
configItem
=
configItem
self
.
colorPicker
=
ColorPickerButton
(
qconfig
.
get
(
configItem
),
title
,
self
)
qconfig
.
get
(
configItem
),
title
,
self
,
enableAlpha
)
self
.
hBoxLayout
.
addWidget
(
self
.
colorPicker
,
0
,
Qt
.
AlignRight
)
self
.
hBoxLayout
.
addSpacing
(
16
)
self
.
colorPicker
.
colorChanged
.
connect
(
self
.
__onColorChanged
)
...
...
setup.py
浏览文件 @
69916945
...
...
@@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f:
setuptools
.
setup
(
name
=
"PyQt-Fluent-Widgets"
,
version
=
"0.7.
3
"
,
version
=
"0.7.
4
"
,
keywords
=
"pyqt fluent widgets"
,
author
=
"zhiyiYo"
,
author_email
=
"shokokawaii@outlook.com"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录