Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
k54kdk
PyQt Fluent Widgets
提交
506f4ef2
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看板
提交
506f4ef2
编写于
7月 30, 2021
作者:
之一Yo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
对话框添加淡入淡出动画
上级
2bef699a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
53 addition
and
14 deletion
+53
-14
screenshot/dialog_with_mask.gif
screenshot/dialog_with_mask.gif
+0
-0
widgets/dialog_with_mask/dialog.py
widgets/dialog_with_mask/dialog.py
+35
-8
widgets/switch_button/resource/switch_button.qss
widgets/switch_button/resource/switch_button.qss
+1
-2
widgets/switch_button/switch_button.py
widgets/switch_button/switch_button.py
+17
-4
未找到文件。
screenshot/dialog_with_mask.gif
查看替换文件 @
2bef699a
浏览文件 @
506f4ef2
31.2 KB
|
W:
|
H:
100.4 KB
|
W:
|
H:
2-up
Swipe
Onion skin
widgets/dialog_with_mask/dialog.py
浏览文件 @
506f4ef2
# coding:utf-8
# coding:utf-8
import
textwrap
import
textwrap
from
PyQt5.QtCore
import
Qt
,
pyqtSignal
from
PyQt5.QtCore
import
Qt
,
pyqtSignal
,
QPropertyAnimation
,
QEasingCurve
,
QAbstractAnimation
from
PyQt5.QtGui
import
QColor
from
PyQt5.QtWidgets
import
(
QDialog
,
QGraphicsDropShadowEffect
,
from
PyQt5.QtWidgets
import
QDialog
,
QGraphicsDropShadowEffect
,
QLabel
,
QPushButton
,
QWidget
QGraphicsOpacityEffect
,
QLabel
,
QPushButton
,
QWidget
)
class
MaskDialog
(
QDialog
):
class
MaskDialog
(
QDialog
):
...
@@ -24,6 +25,8 @@ class MaskDialog(QDialog):
...
@@ -24,6 +25,8 @@ class MaskDialog(QDialog):
def
__initWidget
(
self
):
def
__initWidget
(
self
):
""" 初始化小部件 """
""" 初始化小部件 """
self
.
__setShadowEffect
()
self
.
widget
.
setWindowOpacity
(
0.1
)
self
.
setWindowFlags
(
Qt
.
FramelessWindowHint
)
self
.
setWindowFlags
(
Qt
.
FramelessWindowHint
)
self
.
setAttribute
(
Qt
.
WA_TranslucentBackground
)
self
.
setAttribute
(
Qt
.
WA_TranslucentBackground
)
self
.
setGeometry
(
0
,
0
,
self
.
parent
().
width
(),
self
.
parent
().
height
())
self
.
setGeometry
(
0
,
0
,
self
.
parent
().
width
(),
self
.
parent
().
height
())
...
@@ -31,7 +34,6 @@ class MaskDialog(QDialog):
...
@@ -31,7 +34,6 @@ class MaskDialog(QDialog):
self
.
widget
.
setMaximumWidth
(
675
)
self
.
widget
.
setMaximumWidth
(
675
)
self
.
titleLabel
.
move
(
30
,
30
)
self
.
titleLabel
.
move
(
30
,
30
)
self
.
contentLabel
.
move
(
30
,
70
)
self
.
contentLabel
.
move
(
30
,
70
)
self
.
__setShadowEffect
()
self
.
contentLabel
.
setText
(
'
\n
'
.
join
(
textwrap
.
wrap
(
self
.
content
,
36
)))
self
.
contentLabel
.
setText
(
'
\n
'
.
join
(
textwrap
.
wrap
(
self
.
content
,
36
)))
# 设置层叠样式
# 设置层叠样式
self
.
windowMask
.
setObjectName
(
'windowMask'
)
self
.
windowMask
.
setObjectName
(
'windowMask'
)
...
@@ -52,6 +54,33 @@ class MaskDialog(QDialog):
...
@@ -52,6 +54,33 @@ class MaskDialog(QDialog):
shadowEffect
.
setOffset
(
0
,
5
)
shadowEffect
.
setOffset
(
0
,
5
)
self
.
widget
.
setGraphicsEffect
(
shadowEffect
)
self
.
widget
.
setGraphicsEffect
(
shadowEffect
)
def
showEvent
(
self
,
e
):
""" 淡入 """
opacityEffect
=
QGraphicsOpacityEffect
(
self
)
self
.
setGraphicsEffect
(
opacityEffect
)
opacityAni
=
QPropertyAnimation
(
opacityEffect
,
b
'opacity'
,
self
)
opacityAni
.
setStartValue
(
0
)
opacityAni
.
setEndValue
(
1
)
opacityAni
.
setDuration
(
200
)
opacityAni
.
setEasingCurve
(
QEasingCurve
.
InSine
)
opacityAni
.
finished
.
connect
(
opacityEffect
.
deleteLater
)
opacityAni
.
start
()
super
().
showEvent
(
e
)
def
closeEvent
(
self
,
e
):
""" 淡出 """
self
.
widget
.
setGraphicsEffect
(
None
)
opacityEffect
=
QGraphicsOpacityEffect
(
self
)
self
.
setGraphicsEffect
(
opacityEffect
)
opacityAni
=
QPropertyAnimation
(
opacityEffect
,
b
'opacity'
,
self
)
opacityAni
.
setStartValue
(
1
)
opacityAni
.
setEndValue
(
0
)
opacityAni
.
setDuration
(
100
)
opacityAni
.
setEasingCurve
(
QEasingCurve
.
OutCubic
)
opacityAni
.
finished
.
connect
(
self
.
deleteLater
)
opacityAni
.
start
()
e
.
ignore
()
def
__initLayout
(
self
):
def
__initLayout
(
self
):
""" 初始化布局 """
""" 初始化布局 """
self
.
contentLabel
.
adjustSize
()
self
.
contentLabel
.
adjustSize
()
...
@@ -67,10 +96,8 @@ class MaskDialog(QDialog):
...
@@ -67,10 +96,8 @@ class MaskDialog(QDialog):
def
__onCancelButtonClicked
(
self
):
def
__onCancelButtonClicked
(
self
):
self
.
cancelSignal
.
emit
()
self
.
cancelSignal
.
emit
()
self
.
deleteLater
()
self
.
close
()
def
__onYesButtonClicked
(
self
):
def
__onYesButtonClicked
(
self
):
self
.
yesSignal
.
emit
()
self
.
yesSignal
.
emit
()
self
.
deleteLater
()
self
.
close
()
widgets/switch_button/resource/switch_button.qss
浏览文件 @
506f4ef2
...
@@ -17,6 +17,7 @@ Indicator {
...
@@ -17,6 +17,7 @@ Indicator {
width: 50px;
width: 50px;
qproperty-sliderOnColor: white;
qproperty-sliderOnColor: white;
qproperty-sliderOffColor: black;
qproperty-sliderOffColor: black;
qproperty-sliderDisabledColor: rgb(155, 154, 153);
border-radius: 13px;
border-radius: 13px;
}
}
...
@@ -52,8 +53,6 @@ Indicator:checked:pressed {
...
@@ -52,8 +53,6 @@ Indicator:checked:pressed {
}
}
Indicator:disabled{
Indicator:disabled{
qproperty-sliderOffColor: rgb(155, 154, 153);
qproperty-sliderOnColor: rgb(155, 154, 153);
border: 1px solid rgb(194, 194, 191);
border: 1px solid rgb(194, 194, 191);
background-color: rgb(194, 194, 191);
background-color: rgb(194, 194, 191);
}
}
\ No newline at end of file
widgets/switch_button/switch_button.py
浏览文件 @
506f4ef2
...
@@ -17,15 +17,16 @@ class Indicator(QToolButton):
...
@@ -17,15 +17,16 @@ class Indicator(QToolButton):
self
.
resize
(
50
,
26
)
self
.
resize
(
50
,
26
)
self
.
__sliderOnColor
=
QColor
(
Qt
.
white
)
self
.
__sliderOnColor
=
QColor
(
Qt
.
white
)
self
.
__sliderOffColor
=
QColor
(
Qt
.
black
)
self
.
__sliderOffColor
=
QColor
(
Qt
.
black
)
self
.
__sliderDisabledColor
=
QColor
(
QColor
(
155
,
154
,
153
))
self
.
timer
=
QTimer
(
self
)
self
.
timer
=
QTimer
(
self
)
self
.
padding
=
self
.
height
()
//
4
self
.
padding
=
self
.
height
()
//
4
self
.
sliderX
=
self
.
padding
self
.
sliderX
=
self
.
padding
self
.
sliderRadius
=
(
self
.
height
()
-
2
*
self
.
padding
)
//
2
self
.
sliderRadius
=
(
self
.
height
()
-
2
*
self
.
padding
)
//
2
self
.
sliderEndX
=
self
.
width
()
-
2
*
self
.
sliderRadius
self
.
sliderEndX
=
self
.
width
()
-
2
*
self
.
sliderRadius
self
.
sliderStep
=
self
.
width
()
/
50
self
.
sliderStep
=
self
.
width
()
/
50
self
.
timer
.
timeout
.
connect
(
self
.
updateSliderPos
)
self
.
timer
.
timeout
.
connect
(
self
.
__
updateSliderPos
)
def
updateSliderPos
(
self
):
def
__
updateSliderPos
(
self
):
""" 更新滑块位置 """
""" 更新滑块位置 """
if
self
.
isChecked
():
if
self
.
isChecked
():
if
self
.
sliderX
+
self
.
sliderStep
<
self
.
sliderEndX
:
if
self
.
sliderX
+
self
.
sliderStep
<
self
.
sliderEndX
:
...
@@ -48,7 +49,7 @@ class Indicator(QToolButton):
...
@@ -48,7 +49,7 @@ class Indicator(QToolButton):
return
return
super
().
setChecked
(
isChecked
)
super
().
setChecked
(
isChecked
)
self
.
sliderEndX
=
self
.
width
()
-
2
*
self
.
sliderRadius
-
\
self
.
sliderEndX
=
self
.
width
()
-
2
*
self
.
sliderRadius
-
\
self
.
padding
if
self
.
isChecked
()
else
self
.
padding
self
.
padding
if
self
.
isChecked
()
else
self
.
padding
self
.
timer
.
start
(
5
)
self
.
timer
.
start
(
5
)
def
mouseReleaseEvent
(
self
,
e
):
def
mouseReleaseEvent
(
self
,
e
):
...
@@ -73,7 +74,10 @@ class Indicator(QToolButton):
...
@@ -73,7 +74,10 @@ class Indicator(QToolButton):
painter
=
QPainter
(
self
)
painter
=
QPainter
(
self
)
painter
.
setRenderHints
(
QPainter
.
Antialiasing
)
painter
.
setRenderHints
(
QPainter
.
Antialiasing
)
painter
.
setPen
(
Qt
.
NoPen
)
painter
.
setPen
(
Qt
.
NoPen
)
color
=
self
.
__sliderOnColor
if
self
.
isChecked
()
else
self
.
__sliderOffColor
if
self
.
isEnabled
():
color
=
self
.
sliderOnColor
if
self
.
isChecked
()
else
self
.
sliderOffColor
else
:
color
=
self
.
sliderDisabledColor
painter
.
setBrush
(
color
)
painter
.
setBrush
(
color
)
painter
.
drawEllipse
(
self
.
sliderX
,
self
.
padding
,
painter
.
drawEllipse
(
self
.
sliderX
,
self
.
padding
,
self
.
sliderRadius
*
2
,
self
.
sliderRadius
*
2
)
self
.
sliderRadius
*
2
,
self
.
sliderRadius
*
2
)
...
@@ -92,8 +96,17 @@ class Indicator(QToolButton):
...
@@ -92,8 +96,17 @@ class Indicator(QToolButton):
self
.
__sliderOffColor
=
color
self
.
__sliderOffColor
=
color
self
.
update
()
self
.
update
()
def
getSliderDisabledColor
(
self
):
return
self
.
__sliderDisabledColor
def
setSliderDisabledColor
(
self
,
color
:
QColor
):
self
.
__sliderDisabledColor
=
color
self
.
update
()
sliderOnColor
=
pyqtProperty
(
QColor
,
getSliderOnColor
,
setSliderOnColor
)
sliderOnColor
=
pyqtProperty
(
QColor
,
getSliderOnColor
,
setSliderOnColor
)
sliderOffColor
=
pyqtProperty
(
QColor
,
getSliderOffColor
,
setSliderOffColor
)
sliderOffColor
=
pyqtProperty
(
QColor
,
getSliderOffColor
,
setSliderOffColor
)
sliderDisabledColor
=
pyqtProperty
(
QColor
,
getSliderDisabledColor
,
setSliderDisabledColor
)
class
SwitchButton
(
QWidget
):
class
SwitchButton
(
QWidget
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录