Skip to content

Commit 1f02dd6

Browse files
committed
apply theme
1 parent d09f378 commit 1f02dd6

File tree

15 files changed

+512
-52
lines changed

15 files changed

+512
-52
lines changed

.settings/org.eclipse.core.resources.prefs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ encoding//Test/SlotsByName.py=utf-8
88
encoding//Test/TestColorThief.py=utf-8
99
encoding//Test/TestDownProgress.py=utf-8
1010
encoding//Test/TestGitTree.py=utf-8
11+
encoding//Test/TestGradientUtils.py=utf-8
1112
encoding//Test/TestMainwindowStyle.py=utf-8
1213
encoding//Test/TestPreviewWidget.py=utf-8
1314
encoding//Test/TestPropertyAnimation.py=utf-8
@@ -35,6 +36,7 @@ encoding//Utils/ColorThief.py=utf-8
3536
encoding//Utils/CommonUtil.py=utf-8
3637
encoding//Utils/Constants.py=utf-8
3738
encoding//Utils/GitThread.py=utf-8
39+
encoding//Utils/GradientUtils.py=utf-8
3840
encoding//Utils/NetworkAccessManager.py=utf-8
3941
encoding//Utils/SortFilterModel.py=utf-8
4042
encoding//Utils/TestColourfulWidget.py=utf-8

Resources/Themes/Dark/style.qss

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,13 @@ ToolTip > QLabel {
304304

305305
/*捐赠,更新,错误,主题窗口*/
306306
#widgetDonate, #widgetUpdate, #widgetError, #widgetSkin {
307-
border: 1px solid rgba(200, 200, 200, 255);
307+
border: 1px solid rgba(38, 38, 38, 255);
308308
border-radius: 4px; /*窗口最外层圆角*/
309309
background: rgba(38, 38, 38, 255); /*背景颜色*/
310310
}
311311
/*捐赠窗口,更新窗口,错误,主题窗口背景*/
312312
#widgetImage, #widgetUpdateBg, #widgetErrorBg, #widgetSkinBg {
313-
border: 1px solid rgba(200, 200, 200, 255);
313+
border: 1px solid rgba(38, 38, 38, 255);
314314
border-top: none;
315315
background: rgba(235, 235, 235, 255); /*背景颜色*/
316316
border-bottom-left-radius: 4px;
@@ -371,8 +371,8 @@ ToolTip > QLabel {
371371
color: black;
372372
}
373373
#tabWidgetSkinMain > QTabBar::tab:selected {
374-
color: rgb(18, 183, 245);
375-
border-bottom: 2px solid rgb(18, 183, 245);
374+
color: rgb(38, 38, 38);
375+
border-bottom: 2px solid rgb(38, 38, 38);
376376
}
377377

378378
/*主题图片tab标签*/
@@ -386,7 +386,7 @@ ToolTip > QLabel {
386386
color: black;
387387
}
388388
#widgetCategories > QPushButton:checked {
389-
color: rgb(18, 183, 245);
389+
color: rgb(38, 38, 38);
390390
}
391391

392392
/*主题透明度调整*/
@@ -428,9 +428,15 @@ PictureWidget {
428428
qproperty-circleColor: rgb(38, 38, 38);
429429
}
430430

431+
/*主题界面中缩略图控件文字悬停颜色*/
432+
#skinBaseItemWidget {
433+
qproperty-textHoverColor: rgb(38, 38, 38);
434+
}
435+
431436
/*主题预览界面*/
432437
#FormPreviewWidget {
433-
border-radius: 4px;
438+
border-bottom-left-radius: 4px;
439+
border-bottom-right-radius: 4px;
434440
background: rgba(255, 255, 255, 240);
435441
}
436442
#buttonPreviewPrevious, #buttonPreviewNext, #buttonPreviewClose {
144 Bytes
Loading

Resources/Themes/Default/style.qss

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,13 @@ ToolTip > QLabel {
304304

305305
/*捐赠,更新,错误,主题窗口*/
306306
#widgetDonate, #widgetUpdate, #widgetError, #widgetSkin {
307-
border: 1px solid rgba(44, 144, 92, 255);
307+
border: 1px solid rgba(39, 174, 97, 255);
308308
border-radius: 4px; /*窗口最外层圆角*/
309309
background: rgba(64, 187, 107, 255); /*背景颜色*/
310310
}
311311
/*捐赠窗口,更新窗口,错误,主题窗口背景*/
312312
#widgetImage, #widgetUpdateBg, #widgetErrorBg, #widgetSkinBg {
313-
border: 1px solid rgba(44, 144, 92, 255);
313+
border: 1px solid rgba(39, 174, 97, 255);
314314
border-top: none;
315315
background: rgba(235, 235, 235, 255); /*背景颜色*/
316316
border-bottom-left-radius: 4px;
@@ -371,8 +371,8 @@ ToolTip > QLabel {
371371
color: black;
372372
}
373373
#tabWidgetSkinMain > QTabBar::tab:selected {
374-
color: rgb(18, 183, 245);
375-
border-bottom: 2px solid rgb(18, 183, 245);
374+
color: rgb(39, 174, 97);
375+
border-bottom: 2px solid rgb(39, 174, 97);
376376
}
377377

378378
/*主题图片tab标签*/
@@ -386,7 +386,7 @@ ToolTip > QLabel {
386386
color: black;
387387
}
388388
#widgetCategories > QPushButton:checked {
389-
color: rgb(18, 183, 245);
389+
color: rgb(39, 174, 97);
390390
}
391391

392392
/*主题透明度调整*/
@@ -428,9 +428,15 @@ PictureWidget {
428428
qproperty-circleColor: rgb(39, 174, 97);
429429
}
430430

431+
/*主题界面中缩略图控件文字悬停颜色*/
432+
#skinBaseItemWidget {
433+
qproperty-textHoverColor: rgb(39, 174, 97);
434+
}
435+
431436
/*主题预览界面*/
432437
#FormPreviewWidget {
433-
border-radius: 4px;
438+
border-bottom-left-radius: 4px;
439+
border-bottom-right-radius: 4px;
434440
background: rgba(255, 255, 255, 240);
435441
}
436442
#buttonPreviewPrevious, #buttonPreviewNext, #buttonPreviewClose {

Resources/Themes/春节/style.qss

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,13 @@ ToolTip > QLabel {
305305

306306
/*捐赠,更新,错误,主题窗口*/
307307
#widgetDonate, #widgetUpdate, #widgetError, #widgetSkin {
308-
border: 1px solid rgba(200, 200, 200, 255);
308+
border: 1px solid rgba(200, 47, 10, 255);
309309
border-radius: 4px; /*窗口最外层圆角*/
310310
background: rgba(200, 47, 10, 255); /*背景颜色*/
311311
}
312312
/*捐赠窗口,更新窗口,错误,主题窗口背景*/
313313
#widgetImage, #widgetUpdateBg, #widgetErrorBg, #widgetSkinBg {
314-
border: 1px solid rgba(200, 200, 200, 255);
314+
border: 1px solid rgba(200, 47, 10, 255);
315315
border-top: none;
316316
background: rgba(235, 235, 235, 255); /*背景颜色*/
317317
border-bottom-left-radius: 4px;
@@ -372,8 +372,8 @@ ToolTip > QLabel {
372372
color: black;
373373
}
374374
#tabWidgetSkinMain > QTabBar::tab:selected {
375-
color: rgb(18, 183, 245);
376-
border-bottom: 2px solid rgb(18, 183, 245);
375+
color: rgb(200, 47, 10);
376+
border-bottom: 2px solid rgb(200, 47, 10);
377377
}
378378

379379
/*主题图片tab标签*/
@@ -387,7 +387,7 @@ ToolTip > QLabel {
387387
color: black;
388388
}
389389
#widgetCategories > QPushButton:checked {
390-
color: rgb(18, 183, 245);
390+
color: rgb(200, 47, 10);
391391
}
392392

393393
/*主题透明度调整*/
@@ -429,9 +429,15 @@ PictureWidget {
429429
qproperty-circleColor: rgb(200, 47, 10);
430430
}
431431

432+
/*主题界面中缩略图控件文字悬停颜色*/
433+
#skinBaseItemWidget {
434+
qproperty-textHoverColor: rgb(200, 47, 10);
435+
}
436+
432437
/*主题预览界面*/
433438
#FormPreviewWidget {
434-
border-radius: 4px;
439+
border-bottom-left-radius: 4px;
440+
border-bottom-right-radius: 4px;
435441
background: rgba(255, 255, 255, 240);
436442
}
437443
#buttonPreviewPrevious, #buttonPreviewNext, #buttonPreviewClose {

Test/TestGradientUtils.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
"""
5+
Created on 2019年1月31日
6+
@author: Irony
7+
@site: https://pyqt5.com https://github.com/892768447
8+
@email: 892768447@qq.com
9+
@file: Test.TestGradientUtils
10+
@description:
11+
"""
12+
from PyQt5.QtCore import Qt
13+
from PyQt5.QtGui import QLinearGradient, QRadialGradient, QConicalGradient,\
14+
QColor
15+
16+
from Utils.GradientUtils import GradientUtils
17+
18+
19+
__Author__ = 'Irony'
20+
__Copyright__ = 'Copyright (c) 2019'
21+
22+
# 线性渐变
23+
linearGradient = QLinearGradient(0, 0, 1, 1)
24+
linearGradient.setColorAt(0.0, Qt.green)
25+
linearGradient.setColorAt(0.2, Qt.white)
26+
linearGradient.setColorAt(0.4, Qt.blue)
27+
linearGradient.setColorAt(0.6, Qt.red)
28+
linearGradient.setColorAt(1.0, Qt.yellow)
29+
30+
print(GradientUtils.styleSheetCode(linearGradient))
31+
32+
# 辐射渐变
33+
radialGradient = QRadialGradient(0, 0, 1, 1, 110)
34+
radialGradient.setColorAt(0, Qt.green)
35+
radialGradient.setColorAt(0.4, Qt.blue)
36+
radialGradient.setColorAt(1.0, Qt.yellow)
37+
38+
print(GradientUtils.styleSheetCode(radialGradient))
39+
40+
41+
# 弧度渐变
42+
conicalGradient = QConicalGradient(0.5, 0.5, 0)
43+
conicalGradient.setAngle(0.5)
44+
conicalGradient.setColorAt(0, Qt.green)
45+
conicalGradient.setColorAt(0.2, Qt.white)
46+
conicalGradient.setColorAt(0.4, Qt.blue)
47+
conicalGradient.setColorAt(0.6, Qt.red)
48+
conicalGradient.setColorAt(0.8, Qt.yellow)
49+
50+
print(GradientUtils.styleSheetCode(conicalGradient))
51+
52+
53+
print(GradientUtils.styleSheetCode(QColor(Qt.blue)))

Utils/GradientUtils.py

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
"""
5+
Created on 2019年1月31日
6+
@author: Irony
7+
@site: https://pyqt5.com https://github.com/892768447
8+
@email: 892768447@qq.com
9+
@file: Utils.GradientUtils
10+
@description: 渐变颜色工具类
11+
"""
12+
from PyQt5.QtGui import QGradient, QColor
13+
14+
15+
__Author__ = 'Irony'
16+
__Copyright__ = 'Copyright (c) 2019'
17+
18+
19+
class GradientUtils:
20+
21+
@classmethod
22+
def _getValue(cls, value):
23+
"""把大范围的数字转成小范围
24+
:param cls:
25+
:param value:
26+
"""
27+
length = len(str(int(value)))
28+
if length == 1:
29+
return value
30+
if length > 2:
31+
length = 2
32+
value = value % 100
33+
return value / (10**length)
34+
35+
@classmethod
36+
def _styleSheetParameters(cls, gradient):
37+
result = []
38+
39+
if gradient.type() != QGradient.ConicalGradient:
40+
if gradient.spread() == QGradient.PadSpread:
41+
result.append('spread:pad')
42+
elif gradient.spread() == QGradient.ReflectSpread:
43+
result.append('spread:reflect')
44+
elif gradient.spread() == QGradient.RepeatSpread:
45+
result.append('spread:repeat')
46+
else:
47+
print('GradientUtils::_styleSheetParameters(): gradient spread ',
48+
gradient.spread(), ' not supported!')
49+
result.append('')
50+
51+
if gradient.type() == QGradient.LinearGradient:
52+
result.append('x1:%s' % gradient.start().x())
53+
result.append('y1:%s' % gradient.start().y())
54+
if hasattr(gradient, 'ex'):
55+
result.append('x2:%s' % gradient.ex)
56+
else:
57+
result.append('x2:%s' % gradient.finalStop().x())
58+
if hasattr(gradient, 'ey'):
59+
result.append('y2:%s' % gradient.ey)
60+
else:
61+
result.append('y2:%s' % gradient.finalStop().y())
62+
elif gradient.type() == QGradient.RadialGradient:
63+
result.append('cx:%s' % gradient.center().x())
64+
result.append('cy:%s' % gradient.center().y())
65+
result.append('radius:%s' % gradient.radius())
66+
result.append('fx:%s' % gradient.focalPoint().x())
67+
result.append('fy:%s' % gradient.focalPoint().y())
68+
elif gradient.type() == QGradient.ConicalGradient:
69+
result.append('cx:%s' % gradient.center().x())
70+
result.append('cy:%s' % gradient.center().y())
71+
result.append('angle:%s' % gradient.angle())
72+
else:
73+
print('GradientUtils::_styleSheetParameters(): gradient type ',
74+
gradient.type(), ' not supported!')
75+
76+
return result
77+
78+
@classmethod
79+
def _styleSheetStops(cls, gradient):
80+
result = []
81+
82+
for stop, color in gradient.stops():
83+
result.append('stop:{} rgba({}, {}, {}, {})'.format(
84+
stop, color.red(), color.green(), color.blue(), color.alpha()))
85+
86+
return result
87+
88+
@classmethod
89+
def _styleSheetFillName(cls, gradient):
90+
if gradient.type() == QGradient.LinearGradient:
91+
return 'qlineargradient'
92+
elif gradient.type() == QGradient.RadialGradient:
93+
return 'qradialgradient'
94+
elif gradient.type() == QGradient.ConicalGradient:
95+
return 'qconicalgradient'
96+
else:
97+
print('GradientUtils::_styleSheetFillName(): gradient type ',
98+
gradient.type(), ' not supported!')
99+
return ''
100+
101+
@classmethod
102+
def styleSheetCode(cls, colorgradient):
103+
"""颜色或渐变转字符串
104+
:param cls:
105+
:param gradient:
106+
"""
107+
if isinstance(colorgradient, QColor):
108+
return 'rgba({}, {}, {}, {})'.format(
109+
colorgradient.red(), colorgradient.green(),
110+
colorgradient.blue(), colorgradient.alpha())
111+
gradientParameters = cls._styleSheetParameters(
112+
colorgradient) + cls._styleSheetStops(colorgradient)
113+
return cls._styleSheetFillName(colorgradient) + '(' + ', '.join(gradientParameters) + ')'

0 commit comments

Comments
 (0)