Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
k54kdk
PyQt Fluent Widgets
提交
dcdf3036
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看板
提交
dcdf3036
编写于
8月 14, 2023
作者:
之一Yo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复 FluentWindow 主题切换问题 (#437)
上级
4acae6b2
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
27 addition
and
16 deletion
+27
-16
examples/gallery/app/common/signal_bus.py
examples/gallery/app/common/signal_bus.py
+0
-1
examples/gallery/app/view/gallery_interface.py
examples/gallery/app/view/gallery_interface.py
+2
-2
examples/gallery/app/view/main_window.py
examples/gallery/app/view/main_window.py
+1
-10
examples/gallery/app/view/setting_interface.py
examples/gallery/app/view/setting_interface.py
+1
-1
qfluentwidgets/common/__init__.py
qfluentwidgets/common/__init__.py
+1
-1
qfluentwidgets/common/config.py
qfluentwidgets/common/config.py
+1
-0
qfluentwidgets/common/style_sheet.py
qfluentwidgets/common/style_sheet.py
+13
-0
qfluentwidgets/window/fluent_window.py
qfluentwidgets/window/fluent_window.py
+8
-1
未找到文件。
examples/gallery/app/common/signal_bus.py
浏览文件 @
dcdf3036
...
@@ -7,7 +7,6 @@ class SignalBus(QObject):
...
@@ -7,7 +7,6 @@ class SignalBus(QObject):
switchToSampleCard
=
pyqtSignal
(
str
,
int
)
switchToSampleCard
=
pyqtSignal
(
str
,
int
)
micaEnableChanged
=
pyqtSignal
(
bool
)
micaEnableChanged
=
pyqtSignal
(
bool
)
toggleThemeSignal
=
pyqtSignal
()
supportSignal
=
pyqtSignal
()
supportSignal
=
pyqtSignal
()
...
...
examples/gallery/app/view/gallery_interface.py
浏览文件 @
dcdf3036
...
@@ -5,7 +5,7 @@ from PyQt5.QtWidgets import QWidget, QLabel, QVBoxLayout, QHBoxLayout, QFrame
...
@@ -5,7 +5,7 @@ from PyQt5.QtWidgets import QWidget, QLabel, QVBoxLayout, QHBoxLayout, QFrame
from
qfluentwidgets
import
(
ScrollArea
,
PushButton
,
ToolButton
,
FluentIcon
,
from
qfluentwidgets
import
(
ScrollArea
,
PushButton
,
ToolButton
,
FluentIcon
,
isDarkTheme
,
IconWidget
,
Theme
,
ToolTipFilter
,
TitleLabel
,
CaptionLabel
,
isDarkTheme
,
IconWidget
,
Theme
,
ToolTipFilter
,
TitleLabel
,
CaptionLabel
,
StrongBodyLabel
,
BodyLabel
)
StrongBodyLabel
,
BodyLabel
,
toggleTheme
)
from
..common.config
import
cfg
,
FEEDBACK_URL
,
HELP_URL
,
EXAMPLE_URL
from
..common.config
import
cfg
,
FEEDBACK_URL
,
HELP_URL
,
EXAMPLE_URL
from
..common.icon
import
Icon
from
..common.icon
import
Icon
from
..common.style_sheet
import
StyleSheet
from
..common.style_sheet
import
StyleSheet
...
@@ -82,7 +82,7 @@ class ToolBar(QWidget):
...
@@ -82,7 +82,7 @@ class ToolBar(QWidget):
self
.
supportButton
.
setToolTip
(
self
.
tr
(
'Support me'
))
self
.
supportButton
.
setToolTip
(
self
.
tr
(
'Support me'
))
self
.
feedbackButton
.
setToolTip
(
self
.
tr
(
'Send feedback'
))
self
.
feedbackButton
.
setToolTip
(
self
.
tr
(
'Send feedback'
))
self
.
themeButton
.
clicked
.
connect
(
signalBus
.
toggleThemeSignal
)
self
.
themeButton
.
clicked
.
connect
(
lambda
:
toggleTheme
(
True
)
)
self
.
supportButton
.
clicked
.
connect
(
signalBus
.
supportSignal
)
self
.
supportButton
.
clicked
.
connect
(
signalBus
.
supportSignal
)
self
.
documentButton
.
clicked
.
connect
(
self
.
documentButton
.
clicked
.
connect
(
lambda
:
QDesktopServices
.
openUrl
(
QUrl
(
HELP_URL
)))
lambda
:
QDesktopServices
.
openUrl
(
QUrl
(
HELP_URL
)))
...
...
examples/gallery/app/view/main_window.py
浏览文件 @
dcdf3036
...
@@ -4,7 +4,7 @@ from PyQt5.QtGui import QIcon, QDesktopServices
...
@@ -4,7 +4,7 @@ from PyQt5.QtGui import QIcon, QDesktopServices
from
PyQt5.QtWidgets
import
QApplication
from
PyQt5.QtWidgets
import
QApplication
from
qfluentwidgets
import
(
NavigationAvatarWidget
,
NavigationItemPosition
,
MessageBox
,
FluentWindow
,
from
qfluentwidgets
import
(
NavigationAvatarWidget
,
NavigationItemPosition
,
MessageBox
,
FluentWindow
,
SplashScreen
,
Theme
,
setTheme
,
isDarkTheme
)
SplashScreen
)
from
qfluentwidgets
import
FluentIcon
as
FIF
from
qfluentwidgets
import
FluentIcon
as
FIF
from
.gallery_interface
import
GalleryInterface
from
.gallery_interface
import
GalleryInterface
...
@@ -58,10 +58,8 @@ class MainWindow(FluentWindow):
...
@@ -58,10 +58,8 @@ class MainWindow(FluentWindow):
self
.
splashScreen
.
finish
()
self
.
splashScreen
.
finish
()
def
connectSignalToSlot
(
self
):
def
connectSignalToSlot
(
self
):
cfg
.
themeChanged
.
connect
(
lambda
:
self
.
setMicaEffectEnabled
(
self
.
isMicaEffectEnabled
()))
signalBus
.
micaEnableChanged
.
connect
(
self
.
setMicaEffectEnabled
)
signalBus
.
micaEnableChanged
.
connect
(
self
.
setMicaEffectEnabled
)
signalBus
.
switchToSampleCard
.
connect
(
self
.
switchToSample
)
signalBus
.
switchToSampleCard
.
connect
(
self
.
switchToSample
)
signalBus
.
toggleThemeSignal
.
connect
(
self
.
toggleTheme
)
signalBus
.
supportSignal
.
connect
(
self
.
onSupport
)
signalBus
.
supportSignal
.
connect
(
self
.
onSupport
)
def
initNavigation
(
self
):
def
initNavigation
(
self
):
...
@@ -113,13 +111,6 @@ class MainWindow(FluentWindow):
...
@@ -113,13 +111,6 @@ class MainWindow(FluentWindow):
self
.
show
()
self
.
show
()
QApplication
.
processEvents
()
QApplication
.
processEvents
()
def
toggleTheme
(
self
):
theme
=
Theme
.
LIGHT
if
isDarkTheme
()
else
Theme
.
DARK
cfg
.
set
(
cfg
.
themeMode
,
theme
)
if
self
.
isMicaEffectEnabled
():
self
.
windowEffect
.
setMicaEffect
(
self
.
winId
(),
isDarkTheme
())
def
onSupport
(
self
):
def
onSupport
(
self
):
w
=
MessageBox
(
w
=
MessageBox
(
'支持作者🥰'
,
'支持作者🥰'
,
...
...
examples/gallery/app/view/setting_interface.py
浏览文件 @
dcdf3036
...
@@ -214,13 +214,13 @@ class SettingInterface(ScrollArea):
...
@@ -214,13 +214,13 @@ class SettingInterface(ScrollArea):
def
__connectSignalToSlot
(
self
):
def
__connectSignalToSlot
(
self
):
""" connect signal to slot """
""" connect signal to slot """
cfg
.
appRestartSig
.
connect
(
self
.
__showRestartTooltip
)
cfg
.
appRestartSig
.
connect
(
self
.
__showRestartTooltip
)
cfg
.
themeChanged
.
connect
(
setTheme
)
# music in the pc
# music in the pc
self
.
downloadFolderCard
.
clicked
.
connect
(
self
.
downloadFolderCard
.
clicked
.
connect
(
self
.
__onDownloadFolderCardClicked
)
self
.
__onDownloadFolderCardClicked
)
# personalization
# personalization
self
.
themeCard
.
optionChanged
.
connect
(
lambda
ci
:
setTheme
(
cfg
.
get
(
ci
)))
self
.
themeColorCard
.
colorChanged
.
connect
(
setThemeColor
)
self
.
themeColorCard
.
colorChanged
.
connect
(
setThemeColor
)
self
.
micaCard
.
checkedChanged
.
connect
(
signalBus
.
micaEnableChanged
)
self
.
micaCard
.
checkedChanged
.
connect
(
signalBus
.
micaEnableChanged
)
...
...
qfluentwidgets/common/__init__.py
浏览文件 @
dcdf3036
...
@@ -3,7 +3,7 @@ from .font import setFont, getFont
...
@@ -3,7 +3,7 @@ from .font import setFont, getFont
from
.auto_wrap
import
TextWrap
from
.auto_wrap
import
TextWrap
from
.icon
import
Action
,
Icon
,
getIconColor
,
drawSvgIcon
,
FluentIcon
,
drawIcon
,
FluentIconBase
,
writeSvg
from
.icon
import
Action
,
Icon
,
getIconColor
,
drawSvgIcon
,
FluentIcon
,
drawIcon
,
FluentIconBase
,
writeSvg
from
.style_sheet
import
(
setStyleSheet
,
getStyleSheet
,
setTheme
,
ThemeColor
,
themeColor
,
from
.style_sheet
import
(
setStyleSheet
,
getStyleSheet
,
setTheme
,
ThemeColor
,
themeColor
,
setThemeColor
,
applyThemeColor
,
FluentStyleSheet
,
StyleSheetBase
)
setThemeColor
,
applyThemeColor
,
FluentStyleSheet
,
StyleSheetBase
,
toggleTheme
)
from
.smooth_scroll
import
SmoothScroll
,
SmoothMode
from
.smooth_scroll
import
SmoothScroll
,
SmoothMode
from
.translator
import
FluentTranslator
from
.translator
import
FluentTranslator
from
.router
import
qrouter
,
Router
from
.router
import
qrouter
,
Router
\ No newline at end of file
qfluentwidgets/common/config.py
浏览文件 @
dcdf3036
...
@@ -258,6 +258,7 @@ class QConfig(QObject):
...
@@ -258,6 +258,7 @@ class QConfig(QObject):
appRestartSig
=
pyqtSignal
()
appRestartSig
=
pyqtSignal
()
themeChanged
=
pyqtSignal
(
Theme
)
themeChanged
=
pyqtSignal
(
Theme
)
themeChangedFinished
=
pyqtSignal
()
themeColorChanged
=
pyqtSignal
(
QColor
)
themeColorChanged
=
pyqtSignal
(
QColor
)
themeMode
=
OptionsConfigItem
(
themeMode
=
OptionsConfigItem
(
...
...
qfluentwidgets/common/style_sheet.py
浏览文件 @
dcdf3036
...
@@ -195,6 +195,19 @@ def setTheme(theme: Theme, save=False):
...
@@ -195,6 +195,19 @@ def setTheme(theme: Theme, save=False):
"""
"""
qconfig
.
set
(
qconfig
.
themeMode
,
theme
,
save
)
qconfig
.
set
(
qconfig
.
themeMode
,
theme
,
save
)
updateStyleSheet
()
updateStyleSheet
()
qconfig
.
themeChangedFinished
.
emit
()
def
toggleTheme
(
save
=
False
):
""" toggle the theme of application
Parameters
----------
save: bool
whether to save the change to config file
"""
theme
=
Theme
.
LIGHT
if
isDarkTheme
()
else
Theme
.
DARK
setTheme
(
theme
,
save
)
class
ThemeColor
(
Enum
):
class
ThemeColor
(
Enum
):
...
...
qfluentwidgets/window/fluent_window.py
浏览文件 @
dcdf3036
...
@@ -6,9 +6,10 @@ from PyQt5.QtCore import Qt
...
@@ -6,9 +6,10 @@ from PyQt5.QtCore import Qt
from
PyQt5.QtGui
import
QIcon
,
QPainter
,
QColor
from
PyQt5.QtGui
import
QIcon
,
QPainter
,
QColor
from
PyQt5.QtWidgets
import
QWidget
,
QHBoxLayout
,
QVBoxLayout
,
QLabel
from
PyQt5.QtWidgets
import
QWidget
,
QHBoxLayout
,
QVBoxLayout
,
QLabel
from
..common.config
import
qconfig
from
..common.icon
import
FluentIconBase
from
..common.icon
import
FluentIconBase
from
..common.router
import
qrouter
from
..common.router
import
qrouter
from
..common.style_sheet
import
FluentStyleSheet
,
isDarkTheme
from
..common.style_sheet
import
FluentStyleSheet
,
isDarkTheme
,
setTheme
,
Theme
from
..common.animation
import
BackgroundAnimationWidget
from
..common.animation
import
BackgroundAnimationWidget
from
..components.widgets.frameless_window
import
FramelessWindow
from
..components.widgets.frameless_window
import
FramelessWindow
from
..components.navigation
import
(
NavigationInterface
,
NavigationBar
,
NavigationItemPosition
,
from
..components.navigation
import
(
NavigationInterface
,
NavigationBar
,
NavigationItemPosition
,
...
@@ -38,6 +39,8 @@ class FluentWindowBase(BackgroundAnimationWidget, FramelessWindow):
...
@@ -38,6 +39,8 @@ class FluentWindowBase(BackgroundAnimationWidget, FramelessWindow):
# enable mica effect on win11
# enable mica effect on win11
self
.
setMicaEffectEnabled
(
True
)
self
.
setMicaEffectEnabled
(
True
)
qconfig
.
themeChangedFinished
.
connect
(
self
.
_onThemeChangedFinished
)
def
addSubInterface
(
self
,
interface
:
QWidget
,
icon
:
Union
[
FluentIconBase
,
QIcon
,
str
],
text
:
str
,
def
addSubInterface
(
self
,
interface
:
QWidget
,
icon
:
Union
[
FluentIconBase
,
QIcon
,
str
],
text
:
str
,
position
=
NavigationItemPosition
.
TOP
):
position
=
NavigationItemPosition
.
TOP
):
""" add sub interface """
""" add sub interface """
...
@@ -57,6 +60,10 @@ class FluentWindowBase(BackgroundAnimationWidget, FramelessWindow):
...
@@ -57,6 +60,10 @@ class FluentWindowBase(BackgroundAnimationWidget, FramelessWindow):
return
QColor
(
0
,
0
,
0
,
0
)
if
isDarkTheme
()
else
QColor
(
255
,
255
,
255
,
50
)
return
QColor
(
0
,
0
,
0
,
0
)
if
isDarkTheme
()
else
QColor
(
255
,
255
,
255
,
50
)
def
_onThemeChangedFinished
(
self
):
if
self
.
isMicaEffectEnabled
():
self
.
windowEffect
.
setMicaEffect
(
self
.
winId
(),
isDarkTheme
())
def
paintEvent
(
self
,
e
):
def
paintEvent
(
self
,
e
):
super
().
paintEvent
(
e
)
super
().
paintEvent
(
e
)
painter
=
QPainter
(
self
)
painter
=
QPainter
(
self
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录