Skip to content

Commit 3938dcf

Browse files
committed
dark style
1 parent 6001772 commit 3938dcf

File tree

8 files changed

+436
-4
lines changed

8 files changed

+436
-4
lines changed
4.83 KB
Loading
6.26 KB
Loading

Resources/Themes/Dark/font.ttf

3.97 KB
Binary file not shown.

Resources/Themes/Dark/preview.png

43.5 KB
Loading

Resources/Themes/Dark/style.qss

Lines changed: 400 additions & 0 deletions
Large diffs are not rendered by default.
-1.39 KB
Loading

Test/TestMainwindowStyle.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
@description:
1111
"""
1212
from PyQt5.QtCore import Qt
13-
from PyQt5.QtWidgets import QWidget
13+
from PyQt5.QtWidgets import QWidget, QListWidget
1414

1515
from UiFiles.Ui_MainWindow import Ui_FormMainWindow
1616
from Utils.ThemeManager import ThemeManager
@@ -28,6 +28,8 @@ def __init__(self, *args, **kwargs):
2828
self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
2929
self.setupUi(self)
3030
ThemeManager.loadTheme()
31+
ThemeManager.loadCursor(self)
32+
ThemeManager.loadCursor(self.buttonHead, 'pointer.png')
3133

3234

3335
if __name__ == '__main__':
@@ -40,4 +42,16 @@ def __init__(self, *args, **kwargs):
4042
w.resize(800, 770)
4143
w.show()
4244
w.grab().save('Resources/Themes/Default/preview.png')
45+
46+
lw = QListWidget()
47+
lw.show()
48+
lw.addItems(os.listdir('Resources/Themes'))
49+
50+
def setStyle(item):
51+
path = os.path.join('Resources/Themes', item.text(), 'style.qss')
52+
if os.path.isfile(path):
53+
ThemeManager.loadUserTheme(item.text())
54+
w.grab().save('Resources/Themes/{}/preview.png'.format(item.text()))
55+
lw.itemClicked.connect(setStyle)
56+
4357
sys.exit(app.exec_())

Utils/ThemeManager.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,32 @@ def loadTheme(cls):
8989
try:
9090
QApplication.instance().setStyleSheet(
9191
open(path, 'rb').read().decode('utf-8', errors='ignore'))
92+
return 1
9293
except Exception as e:
9394
AppLog.error(str(e))
9495

9596
@classmethod
96-
def loadFestivalTheme(cls, image=None):
97-
"""根据配置加载主题
97+
def loadUserTheme(cls, theme='Default'):
98+
"""加载主题目录里的主题
99+
:param cls:
100+
:param theme: 文件夹名字
101+
"""
102+
cls.ThemeName = theme
103+
if cls.loadTheme():
104+
Setting.setValue('theme', theme)
105+
106+
@classmethod
107+
def loadColourfulTheme(cls, color):
108+
"""基于当前设置主题颜色
109+
:param cls:
110+
:param color: 背景颜色
111+
"""
112+
pass
113+
114+
@classmethod
115+
def loadPictureTheme(cls, image=None):
116+
"""设置图片背景的主题
98117
:param cls:
99-
:param parent:
100118
:param image: 背景图片
101119
"""
102120
cls.ThemeName = Setting.value('theme', 'Default', str)

0 commit comments

Comments
 (0)