提交 57b407db 编写于 作者: 之一Yo's avatar 之一Yo

添加修改主题色的功能, #34

上级 1734a8ae
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import sys import sys
from PyQt5.QtCore import Qt from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication, QWidget, QHBoxLayout from PyQt5.QtWidgets import QApplication, QWidget, QHBoxLayout
from qfluentwidgets import ComboBox, setTheme, Theme from qfluentwidgets import ComboBox, setTheme, Theme, setThemeColor
class Demo(QWidget): class Demo(QWidget):
...@@ -17,8 +17,9 @@ class Demo(QWidget): ...@@ -17,8 +17,9 @@ class Demo(QWidget):
self.resize(500, 500) self.resize(500, 500)
self.setStyleSheet('Demo{background:white}') self.setStyleSheet('Demo{background:white}')
# setTheme(Theme.DARK) # setTheme(Theme.DARK)
# setThemeColor('#0078d4')
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -5,7 +5,7 @@ from PyQt5.QtGui import QIcon, QPainter, QImage, QBrush, QColor, QFont ...@@ -5,7 +5,7 @@ from PyQt5.QtGui import QIcon, QPainter, QImage, QBrush, QColor, QFont
from PyQt5.QtWidgets import QApplication, QFrame, QStackedWidget, QHBoxLayout, QLabel from PyQt5.QtWidgets import QApplication, QFrame, QStackedWidget, QHBoxLayout, QLabel
from qfluentwidgets import (NavigationInterface, NavigationItemPostion, NavigationWidget, MessageBox, from qfluentwidgets import (NavigationInterface, NavigationItemPostion, NavigationWidget, MessageBox,
isDarkTheme, setTheme, Theme) isDarkTheme, setTheme, Theme, setThemeColor)
from qfluentwidgets import FluentIcon as FIF from qfluentwidgets import FluentIcon as FIF
from qframelesswindow import FramelessWindow, StandardTitleBar from qframelesswindow import FramelessWindow, StandardTitleBar
...@@ -68,6 +68,9 @@ class Window(FramelessWindow): ...@@ -68,6 +68,9 @@ class Window(FramelessWindow):
# use dark theme mode # use dark theme mode
setTheme(Theme.DARK) setTheme(Theme.DARK)
# change the theme color
# setThemeColor('#0078d4')
self.hBoxLayout = QHBoxLayout(self) self.hBoxLayout = QHBoxLayout(self)
self.navigationInterface = NavigationInterface(self, showMenuButton=True) self.navigationInterface = NavigationInterface(self, showMenuButton=True)
self.stackWidget = QStackedWidget(self) self.stackWidget = QStackedWidget(self)
......
...@@ -3,7 +3,7 @@ from config import cfg, HELP_URL, FEEDBACK_URL, AUTHOR, VERSION, YEAR ...@@ -3,7 +3,7 @@ from config import cfg, HELP_URL, FEEDBACK_URL, AUTHOR, VERSION, YEAR
from qfluentwidgets import (SettingCardGroup, SwitchSettingCard, FolderListSettingCard, from qfluentwidgets import (SettingCardGroup, SwitchSettingCard, FolderListSettingCard,
OptionsSettingCard, RangeSettingCard, PushSettingCard, OptionsSettingCard, RangeSettingCard, PushSettingCard,
ColorSettingCard, HyperlinkCard, PrimaryPushSettingCard, ScrollArea, ColorSettingCard, HyperlinkCard, PrimaryPushSettingCard, ScrollArea,
ComboBoxSettingCard, ExpandLayout, Theme, ToastToolTip, setTheme) ComboBoxSettingCard, ExpandLayout, Theme, ToastToolTip, setTheme, setThemeColor)
from qfluentwidgets import FluentIcon as FIF from qfluentwidgets import FluentIcon as FIF
from PyQt5.QtCore import Qt, pyqtSignal, QUrl, QStandardPaths from PyQt5.QtCore import Qt, pyqtSignal, QUrl, QStandardPaths
from PyQt5.QtGui import QDesktopServices from PyQt5.QtGui import QDesktopServices
......
...@@ -26,7 +26,7 @@ if __name__ == '__main__': ...@@ -26,7 +26,7 @@ if __name__ == '__main__':
Qt.HighDpiScaleFactorRoundingPolicy.PassThrough) Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling) QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps) QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
app = QApplication(sys.argv) app = QApplication(sys.argv)
w = Window() w = Window()
w.show() w.show()
......
PushButton {
background: rgb(45, 45, 45);
border: 1px solid rgb(48, 48, 48);
border-top: 1px solid rgb(53, 53, 53);
border-radius: 4px;
color: white;
font: 14px 'Segoe UI', 'Microsoft YaHei';
padding: 6px 0;
}
PushButton:hover {
background: rgb(50, 50, 50);
}
PushButton:pressed {
color: rgba(255, 255, 255, 0.63);
background: rgb(39, 39, 39);
border: 1px solid rgb(48, 48, 48);
}
PushButton:disabled {
color: rgba(255, 255, 255, 0.63);
background: rgb(59, 59, 59);
border: 1px solid rgb(80, 80, 80);
}
PrimaryPushButton {
color: black;
background-color: --ThemeColorPrimary;
border: 1px solid --ThemeColorLight1;
border-bottom: 1px solid --ThemeColorLight2;
}
PrimaryPushButton:hover {
background-color: --ThemeColorDark1;
border: 1px solid --ThemeColorLight1;
border-bottom: 1px solid --ThemeColorLight2;
}
PrimaryPushButton:pressed {
color: rgba(0, 0, 0, 0.63);
background-color: --ThemeColorDark2;
border: 1px solid --ThemeColorDark2;
}
PrimaryPushButton:disabled {
color: rgb(82, 82, 82);
background-color: rgb(52, 52, 52);
border: 1px solid rgb(52, 52, 52);
}
HyperlinkButton {
font: 14px 'Segoe UI', 'Microsoft YaHei';
padding: 6px 12px 6px 12px;
color: --ThemeColorPrimary;
border: none;
border-radius: 6px;
background-color: transparent;
}
HyperlinkButton:hover {
background-color: rgba(255, 255, 255, 10);
}
HyperlinkButton:pressed {
background-color: rgba(255, 255, 255, 7);
}
\ No newline at end of file
...@@ -46,44 +46,7 @@ QLabel { ...@@ -46,44 +46,7 @@ QLabel {
font-size: 14px; font-size: 14px;
} }
QPushButton {
background: rgb(45, 45, 45);
border: 1px solid rgb(48, 48, 48);
border-top: 1px solid rgb(53, 53, 53);
border-radius: 4px;
font: 14px 'Segoe UI', 'Microsoft YaHei';
padding: 6px 0;
color: white;
}
QPushButton:hover {
background: rgb(50, 50, 50);
}
QPushButton:pressed {
background: rgb(39, 39, 39);
border: 1px solid rgb(48, 48, 48);
}
QPushButton#yesButton {
color: black;
background-color: rgb(41, 247, 255);
border: 1px solid rgb(58, 248, 255);
border-bottom: 1px solid rgb(35, 213, 255);
}
QPushButton#yesButton:hover {
background-color: rgb(39, 225, 232);
border: 1px solid rgb(56, 227, 234);
border-bottom: 1px solid rgb(15, 73, 85);
}
QPushButton#yesButton:pressed {
background-color: rgb(38, 203, 210);
border: 1px solid rgb(38, 203, 210);
}
/* 滑动条 */
QSlider:horizontal { QSlider:horizontal {
min-width: 332px; min-width: 332px;
min-height: 24px; min-height: 24px;
......
...@@ -43,41 +43,3 @@ QLabel#windowTitleLabel { ...@@ -43,41 +43,3 @@ QLabel#windowTitleLabel {
padding: 6px 6px; padding: 6px 6px;
background-color: rgb(32, 32, 32); background-color: rgb(32, 32, 32);
} }
QPushButton {
background: rgb(45, 45, 45);
border: 1px solid rgb(48, 48, 48);
border-top: 1px solid rgb(53, 53, 53);
border-radius: 4px;
color: white;
font: 14px 'Segoe UI', 'Microsoft YaHei';
padding-top: 6px;
padding-bottom: 6px;
}
QPushButton:hover {
background: rgb(50, 50, 50);
}
QPushButton:pressed {
background: rgb(39, 39, 39);
border: 1px solid rgb(48, 48, 48);
}
QPushButton#yesButton {
color: black;
background-color: rgb(41, 247, 255);
border: 1px solid rgb(58, 248, 255);
border-bottom: 1px solid rgb(35, 213, 255);
}
QPushButton#yesButton:hover {
background-color: rgb(39, 225, 232);
border: 1px solid rgb(56, 227, 234);
border-bottom: 1px solid rgb(15, 73, 85);
}
QPushButton#yesButton:pressed {
background-color: rgb(38, 203, 210);
border: 1px solid rgb(38, 203, 210);
}
\ No newline at end of file
...@@ -122,24 +122,24 @@ QRadioButton::indicator:checked { ...@@ -122,24 +122,24 @@ QRadioButton::indicator:checked {
background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
stop:0 rgb(0, 0, 0), stop:0 rgb(0, 0, 0),
stop:0.5 rgb(0, 0, 0), stop:0.5 rgb(0, 0, 0),
stop:0.6 rgb(72, 210, 242), stop:0.6 --ThemeColorPrimary,
stop:1 rgb(72, 210, 242)); stop:1 --ThemeColorPrimary);
} }
QRadioButton::indicator:checked:hover { QRadioButton::indicator:checked:hover {
background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
stop:0 rgb(0, 0, 0), stop:0 rgb(0, 0, 0),
stop:0.6 rgb(0, 0, 0), stop:0.6 rgb(0, 0, 0),
stop:0.7 rgb(72, 210, 242), stop:0.7 --ThemeColorPrimary,
stop:1 rgb(72, 210, 242)); stop:1 --ThemeColorPrimary);
} }
QRadioButton::indicator:checked:pressed { QRadioButton::indicator:checked:pressed {
background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
stop:0 rgb(0, 0, 0), stop:0 rgb(0, 0, 0),
stop:0.5 rgb(0, 0, 0), stop:0.5 rgb(0, 0, 0),
stop:0.6 rgb(72, 210, 242), stop:0.6 --ThemeColorPrimary,
stop:1 rgb(72, 210, 242)); stop:1 --ThemeColorPrimary);
} }
QRadioButton:disabled { QRadioButton:disabled {
......
...@@ -31,7 +31,7 @@ QSlider::groove:horizontal { ...@@ -31,7 +31,7 @@ QSlider::groove:horizontal {
} }
QSlider::sub-page:horizontal { QSlider::sub-page:horizontal {
background: rgb(41, 247, 255); background: --ThemeColorPrimary;
height: 4px; height: 4px;
border-radius: 2px; border-radius: 2px;
} }
...@@ -43,24 +43,24 @@ QSlider::handle:horizontal { ...@@ -43,24 +43,24 @@ QSlider::handle:horizontal {
margin: -9px 0; margin: -9px 0;
border-radius: 11px; border-radius: 11px;
background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
stop:0 rgb(41, 247, 255), stop:0 --ThemeColorPrimary,
stop:0.5 rgb(41, 247, 255), stop:0.5 --ThemeColorPrimary,
stop:0.6 rgb(69, 69, 69), stop:0.6 rgb(69, 69, 69),
stop:1 rgb(69, 69, 69)); stop:1 rgb(69, 69, 69));
} }
QSlider::handle:horizontal:hover { QSlider::handle:horizontal:hover {
background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
stop:0 rgb(41, 247, 255), stop:0 --ThemeColorPrimary,
stop:0.6 rgb(41, 247, 255), stop:0.6 --ThemeColorPrimary,
stop:0.7 rgb(69, 69, 69), stop:0.7 rgb(69, 69, 69),
stop:1 rgb(69, 69, 69)); stop:1 rgb(69, 69, 69));
} }
QSlider::handle:horizontal:pressed { QSlider::handle:horizontal:pressed {
background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
stop:0 rgb(41, 247, 255), stop:0 --ThemeColorPrimary,
stop:0.4 rgb(41, 247, 255), stop:0.4 --ThemeColorPrimary,
stop:0.5 rgb(69, 69, 69), stop:0.5 rgb(69, 69, 69),
stop:1 rgb(69, 69, 69)); stop:1 rgb(69, 69, 69));
} }
...@@ -70,67 +70,6 @@ RangeSettingCard > QLabel#valueLabel{ ...@@ -70,67 +70,6 @@ RangeSettingCard > QLabel#valueLabel{
} }
/* 切换开关 */
SwitchButton {
qproperty-spacing: 12;
}
SwitchButton>QLabel {
color: white;
font: 14px 'Segoe UI', 'Microsoft YaHei';
background-color: transparent;
border: none;
}
Indicator {
height: 16px;
width: 37px;
qproperty-sliderOnColor: black;
qproperty-sliderOffColor: rgb(210, 211, 210);
qproperty-sliderDisabledColor: rgb(155, 154, 153);
border-radius: 10px;
}
Indicator:!checked {
background-color: rgb(58, 60, 59);
border: 1px solid rgb(162, 163, 162);
}
Indicator:!checked:hover {
background-color: rgb(58, 60, 59);
border: 1px solid rgb(160, 161, 161);
qproperty-sliderOffColor: rgb(91, 91, 91);
}
Indicator:!checked:pressed {
background-color: rgb(162, 163, 163);
border: 1px solid rgb(133, 133, 133);
qproperty-sliderOffColor: rgb(87, 87, 87);
}
Indicator:checked {
border: 1px solid rgb(41, 247, 255);
background-color: rgb(41, 247, 255);
}
Indicator:checked:hover {
border: 1px solid rgb(41, 227, 234);
background-color: rgb(41, 227, 234);
}
Indicator:checked:pressed {
border: 1px solid rgb(45, 210, 217);
background-color: rgb(45, 210, 217);
}
Indicator:disabled {
border: 1px solid #646464;
background-color: transparent;
}
/* QPushButton */
QPushButton { QPushButton {
border: 1px solid rgba(255, 255, 255, 24); border: 1px solid rgba(255, 255, 255, 24);
border-radius: 5px; border-radius: 5px;
...@@ -151,41 +90,24 @@ QPushButton:pressed { ...@@ -151,41 +90,24 @@ QPushButton:pressed {
color: rgba(255, 255, 255, 0.63); color: rgba(255, 255, 255, 0.63);
} }
#hyperlinkButton {
font: 14px 'Segoe UI', 'Microsoft YaHei';
padding: 6px 12px 6px 12px;
color: rgb(41, 243, 255);
border: none;
border-radius: 6px;
background-color: transparent;
}
#hyperlinkButton:hover {
background-color: rgba(255, 255, 255, 10);
}
#hyperlinkButton:pressed {
background-color: rgba(255, 255, 255, 7);
}
#primaryButton { #primaryButton {
color: black; color: black;
background-color: rgb(41, 243, 255); background-color: --ThemeColorPrimary;
border: 1px solid rgb(58, 248, 255); border: 1px solid --ThemeColorLight1;
border-bottom: 1px solid rgb(35, 213, 220); border-bottom: 1px solid --ThemeColorLight2;
padding: 5px 12px 5px 12px; padding: 5px 12px 5px 12px;
} }
#primaryButton:hover { #primaryButton:hover {
background-color: rgb(41, 227, 234); background-color: --ThemeColorDark1;
border: 1px solid rgb(58, 229, 236); border: 1px solid --ThemeColorLight1;
border-bottom: 1px solid rgb(35, 196, 202); border-bottom: 1px solid --ThemeColorLight2;
} }
#primaryButton:pressed { #primaryButton:pressed {
background-color: rgb(42, 207, 214);
border: 1px solid rgb(42, 207, 214);
color: rgba(0, 0, 0, 0.63); color: rgba(0, 0, 0, 0.63);
background-color: --ThemeColorDark2;
border: 1px solid --ThemeColorDark2;
} }
ColorPickerButton { ColorPickerButton {
......
StateToolTip, StateToolTip,
ToastToolTip { ToastToolTip {
background-color: rgb(0, 107, 131); background-color: --ThemeColorDark1;
border: none; border: none;
border-radius: 7px; border-radius: 7px;
} }
......
...@@ -18,44 +18,45 @@ SwitchButton>QLabel { ...@@ -18,44 +18,45 @@ SwitchButton>QLabel {
Indicator { Indicator {
height: 16px; height: 16px;
width: 37px; width: 37px;
qproperty-sliderOnColor: white; qproperty-sliderOnColor: black;
qproperty-sliderOffColor: white; qproperty-sliderOffColor: rgb(210, 211, 210);
qproperty-sliderDisabledColor: rgb(155, 154, 153); qproperty-sliderDisabledColor: rgb(155, 154, 153);
border-radius: 10px; border-radius: 10px;
} }
Indicator:!checked { Indicator:!checked {
background-color: transparent; background-color: rgb(45, 45, 45);
border: 1px solid rgb(102, 102, 102); border: 1px solid rgb(162, 163, 162);
} }
Indicator:!checked:hover { Indicator:!checked:hover {
border: 1px solid rgb(204, 204, 204); background-color: rgb(58, 60, 59);
background-color: transparent; border: 1px solid rgb(160, 161, 161);
qproperty-sliderOffColor: rgb(91, 91, 91);
} }
Indicator:!checked:pressed { Indicator:!checked:pressed {
border: 1px solid rgb(102, 102, 102); background-color: rgb(64, 65, 64);
background-color: rgb(102, 102, 102); border: 1px solid rgb(164, 165, 165);
qproperty-sliderOffColor: rgb(87, 87, 87);
} }
Indicator:checked { Indicator:checked {
border: 1px solid rgb(0, 153, 188); border: 1px solid --ThemeColorPrimary;
background-color: rgb(0, 153, 188); background-color: --ThemeColorPrimary;
} }
Indicator:checked:hover { Indicator:checked:hover {
border: 1px solid rgb(72, 210, 242); border: 1px solid --ThemeColorDark1;
background-color: rgb(72, 210, 242); background-color: --ThemeColorDark1;
} }
Indicator:checked:pressed { Indicator:checked:pressed {
border: 1px solid rgb(0, 107, 131); border: 1px solid --ThemeColorDark2;
background-color: rgb(0, 107, 131); background-color: --ThemeColorDark2;
} }
Indicator:disabled { Indicator:disabled {
border: 1px solid rgb(194, 194, 191); border: 1px solid rgb(100, 100, 100);
background-color: rgb(194, 194, 191); background-color: transparent;
} }
\ No newline at end of file
PushButton {
color: black;
background: rgb(251, 251, 251);
border: 1px solid rgb(229, 229, 229);
border-bottom: 1px solid rgb(204, 204, 204);
border-radius: 4px;
font: 14px 'Segoe UI', 'Microsoft YaHei';
padding: 6px 0;
}
PushButton:hover {
background: rgb(246, 246, 246);
}
PushButton:pressed {
color: rgba(0, 0, 0, 0.63);
background: rgb(245, 245, 245);
border-bottom: 1px solid rgb(229, 229, 229);
}
PushButton:disabled {
color: rgba(0, 0, 0, 0.63);
background: rgb(252, 252, 252);
border: 1px solid rgb(223, 223, 223);
}
PrimaryPushButton {
color: white;
background-color: --ThemeColorPrimary;
border: 1px solid --ThemeColorLight1;
border-bottom: 1px solid --ThemeColorDark1;
}
PrimaryPushButton:hover {
background-color: --ThemeColorLight1;
border: 1px solid --ThemeColorLight2;
border-bottom: 1px solid --ThemeColorDark1;
}
PrimaryPushButton:pressed {
color: rgba(255, 255, 255, 0.63);
background-color: --ThemeColorLight3;
border: 1px solid --ThemeColorLight3;
}
PrimaryPushButton:disabled {
color: rgba(255, 255, 255, 0.63);
background-color: rgb(199, 199, 199);
border: 1px solid rgb(199, 199, 199);
}
HyperlinkButton {
font: 14px 'Segoe UI', 'Microsoft YaHei';
padding: 6px 12px 6px 12px;
color: --ThemeColorPrimary;
border: none;
border-radius: 6px;
background-color: transparent;
}
HyperlinkButton:hover {
background-color: rgba(0, 0, 0, 15);
}
HyperlinkButton:pressed {
background-color: rgba(0, 0, 0, 7);
}
\ No newline at end of file
...@@ -44,44 +44,7 @@ QLabel { ...@@ -44,44 +44,7 @@ QLabel {
font-size: 14px; font-size: 14px;
} }
QPushButton {
color: black;
background: rgb(251, 251, 251);
border: 1px solid rgb(229, 229, 229);
border-bottom: 1px solid rgb(204, 204, 204);
border-radius: 4px;
font: 14px 'Segoe UI', 'Microsoft YaHei';
padding: 6px 0;
}
QPushButton:hover {
background: rgb(246, 246, 246);
}
QPushButton:pressed {
background: rgb(245, 245, 245);
border-bottom: 1px solid rgb(229, 229, 229);
}
QPushButton#yesButton {
color: white;
background-color: rgb(0, 107, 131);
border: 1px solid rgb(20, 119, 141);
border-bottom: 1px solid rgb(0, 64, 79);
}
QPushButton#yesButton:hover {
background-color: rgb(25, 121, 142);
border: 1px solid rgb(43, 132, 151);
border-bottom: 1px solid rgb(15, 73, 85);
}
QPushButton#yesButton:pressed {
background-color: rgb(49, 134, 153);
border: 1px solid rgb(49, 134, 153);
}
/* 滑动条 */
QSlider:horizontal { QSlider:horizontal {
min-width: 332px; min-width: 332px;
min-height: 24px; min-height: 24px;
......
...@@ -43,41 +43,3 @@ QLabel#windowTitleLabel { ...@@ -43,41 +43,3 @@ QLabel#windowTitleLabel {
padding: 6px 6px; padding: 6px 6px;
background-color: rgb(243, 243, 243); background-color: rgb(243, 243, 243);
} }
QPushButton {
color: black;
background: rgb(251, 251, 251);
border: 1px solid rgb(229, 229, 229);
border-bottom: 1px solid rgb(204, 204, 204);
border-radius: 4px;
font: 14px 'Segoe UI', 'Microsoft YaHei';
padding-top: 6px;
padding-bottom: 6px;
}
QPushButton:hover {
background: rgb(246, 246, 246);
}
QPushButton:pressed {
background: rgb(245, 245, 245);
border-bottom: 1px solid rgb(229, 229, 229);
}
QPushButton#yesButton {
color: white;
background-color: rgb(0, 107, 131);
border: 1px solid rgb(20, 119, 141);
border-bottom: 1px solid rgb(0, 64, 79);
}
QPushButton#yesButton:hover {
background-color: rgb(25, 121, 142);
border: 1px solid rgb(43, 132, 151);
border-bottom: 1px solid rgb(15, 73, 85);
}
QPushButton#yesButton:pressed {
background-color: rgb(49, 134, 153);
border: 1px solid rgb(49, 134, 153);
}
\ No newline at end of file
...@@ -122,24 +122,24 @@ QRadioButton::indicator:checked { ...@@ -122,24 +122,24 @@ QRadioButton::indicator:checked {
background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
stop:0 rgb(255, 255, 255), stop:0 rgb(255, 255, 255),
stop:0.5 rgb(255, 255, 255), stop:0.5 rgb(255, 255, 255),
stop:0.6 rgb(72, 210, 242), stop:0.6 --ThemeColorPrimary,
stop:1 rgb(72, 210, 242)); stop:1 --ThemeColorPrimary);
} }
QRadioButton::indicator:checked:hover { QRadioButton::indicator:checked:hover {
background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
stop:0 rgb(255, 255, 255), stop:0 rgb(255, 255, 255),
stop:0.6 rgb(255, 255, 255), stop:0.6 rgb(255, 255, 255),
stop:0.7 rgb(72, 210, 242), stop:0.7 --ThemeColorPrimary,
stop:1 rgb(72, 210, 242)); stop:1 --ThemeColorPrimary);
} }
QRadioButton::indicator:checked:pressed { QRadioButton::indicator:checked:pressed {
background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
stop:0 rgb(255, 255, 255), stop:0 rgb(255, 255, 255),
stop:0.5 rgb(255, 255, 255), stop:0.5 rgb(255, 255, 255),
stop:0.6 rgb(72, 210, 242), stop:0.6 --ThemeColorPrimary,
stop:1 rgb(72, 210, 242)); stop:1 --ThemeColorPrimary);
} }
QRadioButton:disabled { QRadioButton:disabled {
......
...@@ -31,7 +31,7 @@ QSlider::groove:horizontal { ...@@ -31,7 +31,7 @@ QSlider::groove:horizontal {
} }
QSlider::sub-page:horizontal { QSlider::sub-page:horizontal {
background: rgb(0, 159, 170); background: --ThemeColorPrimary;
height: 4px; height: 4px;
border-radius: 2px; border-radius: 2px;
} }
...@@ -43,24 +43,24 @@ QSlider::handle:horizontal { ...@@ -43,24 +43,24 @@ QSlider::handle:horizontal {
margin: -9px 0; margin: -9px 0;
border-radius: 11px; border-radius: 11px;
background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
stop:0 rgb(0, 159, 170), stop:0 --ThemeColorPrimary,
stop:0.5 rgb(0, 159, 170), stop:0.5 --ThemeColorPrimary,
stop:0.6 rgb(255, 255, 255), stop:0.6 rgb(255, 255, 255),
stop:1 rgb(255, 255, 255)); stop:1 rgb(255, 255, 255));
} }
QSlider::handle:horizontal:hover { QSlider::handle:horizontal:hover {
background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
stop:0 rgb(0, 159, 170), stop:0 --ThemeColorPrimary,
stop:0.6 rgb(0, 159, 170), stop:0.6 --ThemeColorPrimary,
stop:0.7 rgb(255, 255, 255), stop:0.7 rgb(255, 255, 255),
stop:1 rgb(255, 255, 255)); stop:1 rgb(255, 255, 255));
} }
QSlider::handle:horizontal:pressed { QSlider::handle:horizontal:pressed {
background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
stop:0 rgb(0, 159, 170), stop:0 --ThemeColorPrimary,
stop:0.4 rgb(0, 159, 170), stop:0.4 --ThemeColorPrimary,
stop:0.5 rgb(255, 255, 255), stop:0.5 rgb(255, 255, 255),
stop:1 rgb(255, 255, 255)); stop:1 rgb(255, 255, 255));
} }
...@@ -79,67 +79,6 @@ RangeSettingCard > QLabel#valueLabel{ ...@@ -79,67 +79,6 @@ RangeSettingCard > QLabel#valueLabel{
} }
/* 切换开关 */
SwitchButton {
qproperty-spacing: 12;
}
SwitchButton>QLabel {
color: black;
font: 14px 'Segoe UI', 'Microsoft YaHei';
background-color: transparent;
border: none;
}
Indicator {
height: 16px;
width: 37px;
qproperty-sliderOnColor: white;
qproperty-sliderOffColor: rgb(96, 96, 96);
qproperty-sliderDisabledColor: rgb(155, 154, 153);
border-radius: 10px;
}
Indicator:!checked {
background-color: rgb(247, 247, 247);
border: 1px solid rgb(139, 139, 139);
}
Indicator:!checked:hover {
border: 1px solid rgb(136, 136, 136);
background-color: rgb(238, 238, 238);
qproperty-sliderOffColor: rgb(91, 91, 91);
}
Indicator:!checked:pressed {
border: 1px solid rgb(133, 133, 133);
background-color: rgb(229, 229, 229);
qproperty-sliderOffColor: rgb(87, 87, 87);
}
Indicator:checked {
border: 1px solid rgb(0, 159, 170);
background-color: rgb(0, 159, 170);
}
Indicator:checked:hover {
border: 1px solid rgb(26, 169, 179);
background-color: rgb(26, 169, 179);
}
Indicator:checked:pressed {
border: 1px solid rgb(46, 173, 182);
background-color: rgb(46, 173, 182);
}
Indicator:disabled {
border: 1px solid rgb(194, 194, 191);
background-color: rgb(194, 194, 191);
}
/* QPushButton */
QPushButton { QPushButton {
border: 1px solid rgb(238, 239, 238); border: 1px solid rgb(238, 239, 238);
border-radius: 5px; border-radius: 5px;
...@@ -160,41 +99,25 @@ QPushButton:pressed { ...@@ -160,41 +99,25 @@ QPushButton:pressed {
color: rgba(0, 0, 0, 0.63); color: rgba(0, 0, 0, 0.63);
} }
#hyperlinkButton {
font: 14px 'Segoe UI', 'Microsoft YaHei';
padding: 6px 12px 6px 12px;
color: rgb(0, 107, 133);
border: none;
border-radius: 6px;
background-color: transparent;
}
#hyperlinkButton:hover {
background-color: rgba(0, 0, 0, 15);
}
#hyperlinkButton:pressed {
background-color: rgba(0, 0, 0, 7);
}
#primaryButton { #primaryButton {
color: white; color: white;
background-color: rgb(0, 159, 170); background-color: --ThemeColorPrimary;
border: 1px solid rgb(20, 167, 177); border: 1px solid --ThemeColorLight1;
border-bottom: 1px solid rgb(0, 95, 102); border-bottom: 1px solid --ThemeColorDark1;
padding: 5px 12px 5px 12px; padding: 5px 12px 5px 12px;
} }
#primaryButton:hover { #primaryButton:hover {
background-color: rgb(26, 169, 179); background-color: --ThemeColorLight1;
border: 1px solid rgb(44, 176, 185); border: 1px solid --ThemeColorLight2;
border-bottom: 1px solid rgb(16, 101, 107); border-bottom: 1px solid --ThemeColorDark1;
} }
#primaryButton:pressed { #primaryButton:pressed {
background-color: rgb(51, 178, 187);
border: 1px solid rgb(51, 178, 187);
color: rgba(255, 255, 255, 0.63); color: rgba(255, 255, 255, 0.63);
background-color: --ThemeColorLight3;
border: 1px solid --ThemeColorLight3;
} }
ColorPickerButton { ColorPickerButton {
......
StateToolTip, StateToolTip,
ToastToolTip { ToastToolTip {
background-color: rgb(0, 107, 131); background-color: --ThemeColorDark1;
border: none; border: none;
border-radius: 7px; border-radius: 7px;
} }
......
...@@ -19,40 +19,41 @@ Indicator { ...@@ -19,40 +19,41 @@ Indicator {
height: 16px; height: 16px;
width: 37px; width: 37px;
qproperty-sliderOnColor: white; qproperty-sliderOnColor: white;
qproperty-sliderOffColor: black; qproperty-sliderOffColor: rgb(96, 96, 96);
qproperty-sliderDisabledColor: rgb(155, 154, 153); qproperty-sliderDisabledColor: rgb(155, 154, 153);
border-radius: 10px; border-radius: 10px;
} }
Indicator:!checked { Indicator:!checked {
background-color: transparent; background-color: rgb(247, 247, 247);
border: 1px solid rgb(102, 102, 102); border: 1px solid rgb(139, 139, 139);
} }
Indicator:!checked:hover { Indicator:!checked:hover {
border: 1px solid rgb(51, 51, 51); border: 1px solid rgb(136, 136, 136);
background-color: transparent; background-color: rgb(238, 238, 238);
qproperty-sliderOffColor: rgb(91, 91, 91);
} }
Indicator:!checked:pressed { Indicator:!checked:pressed {
border: 1px solid rgb(0, 0, 0); border: 1px solid rgb(133, 133, 133);
background-color: rgb(153, 153, 153); background-color: rgb(229, 229, 229);
qproperty-sliderOffColor: rgb(87, 87, 87);
} }
Indicator:checked { Indicator:checked {
border: 1px solid rgb(0, 153, 188); border: 1px solid --ThemeColorPrimary;
background-color: rgb(0, 153, 188); background-color: --ThemeColorPrimary;
} }
Indicator:checked:hover { Indicator:checked:hover {
border: 1px solid rgb(72, 210, 242); border: 1px solid --ThemeColorLight1;
background-color: rgb(72, 210, 242); background-color: --ThemeColorLight1;
} }
Indicator:checked:pressed { Indicator:checked:pressed {
border: 1px solid rgb(0, 107, 131); border: 1px solid --ThemeColorLight2;
background-color: rgb(0, 107, 131); background-color: --ThemeColorLight2;
} }
Indicator:disabled { Indicator:disabled {
......
此差异已折叠。
...@@ -104,6 +104,7 @@ ...@@ -104,6 +104,7 @@
<file>qss/dark/folder_list_dialog.qss</file> <file>qss/dark/folder_list_dialog.qss</file>
<file>qss/dark/combo_box.qss</file> <file>qss/dark/combo_box.qss</file>
<file>qss/dark/navigation_interface.qss</file> <file>qss/dark/navigation_interface.qss</file>
<file>qss/dark/button.qss</file>
<file>qss/light/color_dialog.qss</file> <file>qss/light/color_dialog.qss</file>
<file>qss/light/dialog.qss</file> <file>qss/light/dialog.qss</file>
...@@ -118,5 +119,6 @@ ...@@ -118,5 +119,6 @@
<file>qss/light/folder_list_dialog.qss</file> <file>qss/light/folder_list_dialog.qss</file>
<file>qss/light/combo_box.qss</file> <file>qss/light/combo_box.qss</file>
<file>qss/light/navigation_interface.qss</file> <file>qss/light/navigation_interface.qss</file>
<file>qss/light/button.qss</file>
</qresource> </qresource>
</RCC> </RCC>
\ No newline at end of file
from .config import * from .config import *
from .auto_wrap import TextWrap from .auto_wrap import TextWrap
from .icon import Icon, getIconColor, drawSvgIcon, FluentIcon, drawIcon, FluentIconBase from .icon import Icon, getIconColor, drawSvgIcon, FluentIcon, drawIcon, FluentIconBase
from .style_sheet import setStyleSheet, getStyleSheet, setTheme from .style_sheet import setStyleSheet, getStyleSheet, setTheme, ThemeColor, themeColor, setThemeColor
from .smooth_scroll import SmoothScroll, SmoothMode from .smooth_scroll import SmoothScroll, SmoothMode
\ No newline at end of file
...@@ -251,9 +251,11 @@ class QConfig(QObject): ...@@ -251,9 +251,11 @@ class QConfig(QObject):
appRestartSig = pyqtSignal() appRestartSig = pyqtSignal()
themeChanged = pyqtSignal(Theme) themeChanged = pyqtSignal(Theme)
themeColorChanged = pyqtSignal(QColor)
themeMode = OptionsConfigItem( themeMode = OptionsConfigItem(
"QFluentWidgets", "ThemeMode", Theme.AUTO, OptionsValidator(Theme), EnumSerializer(Theme)) "QFluentWidgets", "ThemeMode", Theme.AUTO, OptionsValidator(Theme), EnumSerializer(Theme))
themeColor = ColorConfigItem("QFluentWidgets", "ThemeColor", '#009faa')
def __init__(self): def __init__(self):
super().__init__() super().__init__()
...@@ -266,7 +268,19 @@ class QConfig(QObject): ...@@ -266,7 +268,19 @@ class QConfig(QObject):
return item.value return item.value
def set(self, item, value, save=True): def set(self, item, value, save=True):
""" set the value of config item """ """ set the value of config item
Parameters
----------
item: ConfigItem
config item
value:
the new value of config item
save: bool
whether to save the change to config file
"""
if item.value == value: if item.value == value:
return return
...@@ -282,6 +296,9 @@ class QConfig(QObject): ...@@ -282,6 +296,9 @@ class QConfig(QObject):
self.theme = value self.theme = value
self._cfg.themeChanged.emit(value) self._cfg.themeChanged.emit(value)
if item is self._cfg.themeColor:
self._cfg.themeColorChanged.emit(value)
def toDict(self, serialize=True): def toDict(self, serialize=True):
""" convert config items to `dict` """ """ convert config items to `dict` """
items = {} items = {}
...@@ -371,4 +388,8 @@ qconfig = QConfig() ...@@ -371,4 +388,8 @@ qconfig = QConfig()
def isDarkTheme(): def isDarkTheme():
""" whether the theme is dark mode """ """ whether the theme is dark mode """
return qconfig.theme == Theme.DARK return qconfig.theme == Theme.DARK
\ No newline at end of file
def theme():
""" get theme mode """
return qconfig.theme
\ No newline at end of file
# coding:utf-8 # coding:utf-8
from enum import Enum
from string import Template
import weakref import weakref
import darkdetect import darkdetect
from PyQt5.QtCore import QFile, QObject from PyQt5.QtCore import QFile, QObject
from PyQt5.QtGui import QColor
from PyQt5.QtWidgets import QWidget from PyQt5.QtWidgets import QWidget
from .config import qconfig, Theme from .config import qconfig, Theme, isDarkTheme
class StyleSheetManager(QObject): class StyleSheetManager(QObject):
...@@ -44,6 +47,12 @@ class StyleSheetManager(QObject): ...@@ -44,6 +47,12 @@ class StyleSheetManager(QObject):
styleSheetManager = StyleSheetManager() styleSheetManager = StyleSheetManager()
class QssTemplate(Template):
""" style sheet template """
delimiter = '--'
def getStyleSheet(file, theme=Theme.AUTO): def getStyleSheet(file, theme=Theme.AUTO):
""" get style sheet from `qfluentwidgets` embedded qss file """ get style sheet from `qfluentwidgets` embedded qss file
...@@ -58,9 +67,11 @@ def getStyleSheet(file, theme=Theme.AUTO): ...@@ -58,9 +67,11 @@ def getStyleSheet(file, theme=Theme.AUTO):
theme = qconfig.theme if theme == Theme.AUTO else theme theme = qconfig.theme if theme == Theme.AUTO else theme
f = QFile(f":/qfluentwidgets/qss/{theme.value.lower()}/{file}.qss") f = QFile(f":/qfluentwidgets/qss/{theme.value.lower()}/{file}.qss")
f.open(QFile.ReadOnly) f.open(QFile.ReadOnly)
qss = str(f.readAll(), encoding='utf-8') template = QssTemplate(str(f.readAll(), encoding='utf-8'))
f.close() f.close()
return qss
mappings = {c.value: c.name() for c in ThemeColor._member_map_.values()}
return template.safe_substitute(mappings)
def setStyleSheet(widget, file, theme=Theme.AUTO, register=True): def setStyleSheet(widget, file, theme=Theme.AUTO, register=True):
...@@ -117,3 +128,82 @@ def setTheme(theme: Theme, save=False): ...@@ -117,3 +128,82 @@ def setTheme(theme: Theme, save=False):
qconfig.set(qconfig.themeMode, theme, save) qconfig.set(qconfig.themeMode, theme, save)
updateStyleSheet() updateStyleSheet()
class ThemeColor(Enum):
""" Theme color type """
PRIMARY = "ThemeColorPrimary"
DARK_1 = "ThemeColorDark1"
DARK_2 = "ThemeColorDark2"
DARK_3 = "ThemeColorDark3"
LIGHT_1 = "ThemeColorLight1"
LIGHT_2 = "ThemeColorLight2"
LIGHT_3 = "ThemeColorLight3"
def name(self):
return self.color().name()
def color(self):
color = qconfig.get(qconfig.themeColor) # type:QColor
# transform color into hsv space
h, s, v, _ = color.getHsvF()
if isDarkTheme():
s *= 0.84
v = 1
if self == self.DARK_1:
v *= 0.9
elif self == self.DARK_2:
s *= 0.977
v *= 0.82
elif self == self.DARK_3:
s *= 0.95
v *= 0.7
elif self == self.LIGHT_1:
s *= 0.92
elif self == self.LIGHT_2:
s *= 0.78
elif self == self.LIGHT_3:
s *= 0.65
else:
if self == self.DARK_1:
v *= 0.75
elif self == self.DARK_2:
s *= 1.05
v *= 0.5
elif self == self.DARK_3:
s *= 1.1
v *= 0.4
elif self == self.LIGHT_1:
v *= 1.05
elif self == self.LIGHT_2:
s *= 0.75
v *= 1.05
elif self == self.LIGHT_3:
s *= 0.65
v *= 1.05
return QColor.fromHsvF(h, min(s, 1), min(v, 1))
def themeColor():
""" get theme color """
return ThemeColor.PRIMARY.color()
def setThemeColor(color, save=False):
""" set theme color
Parameters
----------
color: QColor | Qt.GlobalColor | str
theme color
save: bool
whether to save to change to config file
"""
color = QColor(color)
qconfig.set(qconfig.themeColor, color, save=save)
updateStyleSheet()
# coding:utf-8 # coding:utf-8
from PyQt5.QtCore import Qt, pyqtSignal, QPoint, QRegExp, QSize, QCoreApplication from PyQt5.QtCore import Qt, pyqtSignal, QPoint, QRegExp, QSize
from PyQt5.QtGui import (QBrush, QColor, QMouseEvent, QPixmap, from PyQt5.QtGui import (QBrush, QColor, QPixmap,
QPainter, QPen, QIntValidator, QRegExpValidator, QIcon) QPainter, QPen, QIntValidator, QRegExpValidator, QIcon)
from PyQt5.QtWidgets import (QApplication, QLabel, QLineEdit, QWidget, from PyQt5.QtWidgets import (QApplication, QLabel, QLineEdit, QWidget,
QToolButton, QPushButton, QFrame, QVBoxLayout) QToolButton, QFrame, QVBoxLayout)
from ...common.icon import Icon, getIconColor from ...common.icon import getIconColor
from ...common.style_sheet import setStyleSheet, getStyleSheet from ...common.style_sheet import setStyleSheet, getStyleSheet
from ..widgets import LineEditMenu, Slider, ScrollArea from ..widgets import LineEditMenu, Slider, ScrollArea, PushButton, PrimaryPushButton
from .mask_dialog_base import MaskDialogBase from .mask_dialog_base import MaskDialogBase
...@@ -219,8 +219,8 @@ class ColorDialog(MaskDialogBase): ...@@ -219,8 +219,8 @@ class ColorDialog(MaskDialogBase):
self.scrollWidget = QWidget(self.scrollArea) self.scrollWidget = QWidget(self.scrollArea)
self.buttonGroup = QFrame(self.widget) self.buttonGroup = QFrame(self.widget)
self.yesButton = QPushButton(self.tr('OK'), self.buttonGroup) self.yesButton = PrimaryPushButton(self.tr('OK'), self.buttonGroup)
self.cancelButton = QPushButton(self.tr('Cancel'), self.buttonGroup) self.cancelButton = PushButton(self.tr('Cancel'), self.buttonGroup)
self.titleLabel = QLabel(title, self.scrollWidget) self.titleLabel = QLabel(title, self.scrollWidget)
self.huePanel = HuePanel(color, self.scrollWidget) self.huePanel = HuePanel(color, self.scrollWidget)
......
# coding:utf-8 # coding:utf-8
from PyQt5.QtCore import Qt, pyqtSignal, QObject, QEvent from PyQt5.QtCore import Qt, pyqtSignal, QObject, QEvent
from PyQt5.QtGui import QColor from PyQt5.QtGui import QColor
from PyQt5.QtWidgets import QLabel, QPushButton, QFrame, QVBoxLayout, QHBoxLayout from PyQt5.QtWidgets import QLabel, QFrame, QVBoxLayout, QHBoxLayout
from qframelesswindow import FramelessDialog from qframelesswindow import FramelessDialog
from ...common.auto_wrap import TextWrap from ...common.auto_wrap import TextWrap
from ...common.style_sheet import setStyleSheet from ...common.style_sheet import setStyleSheet
from ..widgets.button import PushButton, PrimaryPushButton
from .mask_dialog_base import MaskDialogBase from .mask_dialog_base import MaskDialogBase
...@@ -22,8 +23,8 @@ class Ui_MessageBox(QObject): ...@@ -22,8 +23,8 @@ class Ui_MessageBox(QObject):
self.contentLabel = QLabel(content, parent) self.contentLabel = QLabel(content, parent)
self.buttonGroup = QFrame(parent) self.buttonGroup = QFrame(parent)
self.yesButton = QPushButton(self.tr('OK'), self.buttonGroup) self.yesButton = PrimaryPushButton(self.tr('OK'), self.buttonGroup)
self.cancelButton = QPushButton(self.tr('Cancel'), self.buttonGroup) self.cancelButton = PushButton(self.tr('Cancel'), self.buttonGroup)
self.vBoxLayout = QVBoxLayout(parent) self.vBoxLayout = QVBoxLayout(parent)
self.textLayout = QVBoxLayout() self.textLayout = QVBoxLayout()
...@@ -89,7 +90,6 @@ class Ui_MessageBox(QObject): ...@@ -89,7 +90,6 @@ class Ui_MessageBox(QObject):
""" 设置层叠样式 """ """ 设置层叠样式 """
self.titleLabel.setObjectName("titleLabel") self.titleLabel.setObjectName("titleLabel")
self.contentLabel.setObjectName("contentLabel") self.contentLabel.setObjectName("contentLabel")
self.yesButton.setObjectName('yesButton')
self.buttonGroup.setObjectName('buttonGroup') self.buttonGroup.setObjectName('buttonGroup')
setStyleSheet(self, 'dialog') setStyleSheet(self, 'dialog')
......
...@@ -6,6 +6,7 @@ from PyQt5.QtGui import QColor, QPainter, QPen, QIcon ...@@ -6,6 +6,7 @@ from PyQt5.QtGui import QColor, QPainter, QPen, QIcon
from PyQt5.QtWidgets import QWidget from PyQt5.QtWidgets import QWidget
from ...common.config import isDarkTheme from ...common.config import isDarkTheme
from ...common.style_sheet import themeColor
from ...common.icon import drawIcon from ...common.icon import drawIcon
from ...common.icon import FluentIcon as FIF from ...common.icon import FluentIcon as FIF
...@@ -113,8 +114,7 @@ class NavigationPushButton(NavigationWidget): ...@@ -113,8 +114,7 @@ class NavigationPushButton(NavigationWidget):
painter.drawRoundedRect(self.rect(), 5, 5) painter.drawRoundedRect(self.rect(), 5, 5)
# draw indicator # draw indicator
color = QColor(41, 247, 255) if isDarkTheme() else QColor(0, 153, 188) painter.setBrush(themeColor())
painter.setBrush(color)
painter.drawRoundedRect(0, 10, 3, 16, 1.5, 1.5) painter.drawRoundedRect(0, 10, 3, 16, 1.5, 1.5)
elif self.isEnter and self.isEnabled(): elif self.isEnter and self.isEnabled():
painter.setBrush(QColor(c, c, c, 10)) painter.setBrush(QColor(c, c, c, 10))
......
...@@ -11,6 +11,7 @@ from ..widgets.combo_box import ComboBox ...@@ -11,6 +11,7 @@ from ..widgets.combo_box import ComboBox
from ..widgets.switch_button import SwitchButton, IndicatorPosition from ..widgets.switch_button import SwitchButton, IndicatorPosition
from ..widgets.slider import Slider from ..widgets.slider import Slider
from ..widgets.icon_widget import IconWidget from ..widgets.icon_widget import IconWidget
from ..widgets.button import HyperlinkButton
from ...common.style_sheet import setStyleSheet from ...common.style_sheet import setStyleSheet
from ...common.config import qconfig, isDarkTheme from ...common.config import qconfig, isDarkTheme
from ...common.icon import FluentIconBase from ...common.icon import FluentIconBase
...@@ -111,8 +112,6 @@ class SwitchSettingCard(SettingCard): ...@@ -111,8 +112,6 @@ class SwitchSettingCard(SettingCard):
if configItem: if configItem:
self.setChecked(qconfig.get(configItem)) self.setChecked(qconfig.get(configItem))
setStyleSheet(self.switchButton, 'setting_card')
# add switch button to layout # add switch button to layout
self.hBoxLayout.addWidget(self.switchButton, 0, Qt.AlignRight) self.hBoxLayout.addWidget(self.switchButton, 0, Qt.AlignRight)
self.hBoxLayout.addSpacing(16) self.hBoxLayout.addSpacing(16)
...@@ -256,14 +255,7 @@ class HyperlinkCard(SettingCard): ...@@ -256,14 +255,7 @@ class HyperlinkCard(SettingCard):
parent widget parent widget
""" """
super().__init__(icon, title, content, parent) super().__init__(icon, title, content, parent)
self.url = QUrl(url) self.linkButton = HyperlinkButton(url, text, self)
self.linkButton = QPushButton(text, self)
self.linkButton.setObjectName('hyperlinkButton')
self.linkButton.setCursor(Qt.PointingHandCursor)
self.linkButton.clicked.connect(
lambda i: QDesktopServices.openUrl(self.url))
self.hBoxLayout.addWidget(self.linkButton, 0, Qt.AlignRight) self.hBoxLayout.addWidget(self.linkButton, 0, Qt.AlignRight)
self.hBoxLayout.addSpacing(16) self.hBoxLayout.addSpacing(16)
......
...@@ -5,4 +5,5 @@ from .stacked_widget import PopUpAniStackedWidget, OpacityAniStackedWidget ...@@ -5,4 +5,5 @@ from .stacked_widget import PopUpAniStackedWidget, OpacityAniStackedWidget
from .switch_button import SwitchButton, IndicatorPosition from .switch_button import SwitchButton, IndicatorPosition
from .state_tool_tip import StateToolTip, ToastToolTip from .state_tool_tip import StateToolTip, ToastToolTip
from .scroll_area import ScrollArea, SmoothMode, SmoothScrollArea, SmoothScrollBar from .scroll_area import ScrollArea, SmoothMode, SmoothScrollArea, SmoothScrollBar
from .tool_tip import ToolTip, ToolTipFilter from .tool_tip import ToolTip, ToolTipFilter
\ No newline at end of file from .button import PrimaryPushButton, PushButton
\ No newline at end of file
# coding:utf-8
from PyQt5.QtCore import QUrl, Qt
from PyQt5.QtGui import QDesktopServices
from PyQt5.QtWidgets import QPushButton
from ...common.style_sheet import setStyleSheet
class PushButton(QPushButton):
""" push button """
def __init__(self, text: str, parent=None):
super().__init__(text=text, parent=parent)
setStyleSheet(self, 'button')
class PrimaryPushButton(PushButton):
""" Primary color push button """
class HyperlinkButton(QPushButton):
""" Hyperlink button """
def __init__(self, url: str, text: str, parent=None):
super().__init__(text, parent)
self.url = QUrl(url)
self.clicked.connect(lambda i: QDesktopServices.openUrl(self.url))
setStyleSheet(self, 'button')
self.setCursor(Qt.PointingHandCursor)
\ No newline at end of file
...@@ -6,7 +6,7 @@ from PyQt5.QtWidgets import QAction, QPushButton, QWidget ...@@ -6,7 +6,7 @@ from PyQt5.QtWidgets import QAction, QPushButton, QWidget
from .menu import RoundMenu from .menu import RoundMenu
from ...common.config import isDarkTheme from ...common.config import isDarkTheme
from ...common.icon import FluentIcon as FIF from ...common.icon import FluentIcon as FIF
from ...common.style_sheet import setStyleSheet from ...common.style_sheet import setStyleSheet, themeColor
class ComboBox(QPushButton): class ComboBox(QPushButton):
...@@ -132,7 +132,7 @@ class ComboBox(QPushButton): ...@@ -132,7 +132,7 @@ class ComboBox(QPushButton):
menu.view.setMinimumWidth(self.width()) menu.view.setMinimumWidth(self.width())
menu.adjustSize() menu.adjustSize()
# set the selected item # set the selected item
menu.setDefaultAction(menu.menuActions()[self.currentIndex()]) menu.setDefaultAction(menu.menuActions()[self.currentIndex()])
...@@ -202,11 +202,7 @@ class ComboBoxMenuItemWidget(QWidget): ...@@ -202,11 +202,7 @@ class ComboBoxMenuItemWidget(QWidget):
return return
painter.setPen(Qt.NoPen) painter.setPen(Qt.NoPen)
if isLight: painter.setBrush(themeColor())
painter.setBrush(QColor(0, 159, 170))
else:
painter.setBrush(QColor(41, 247, 255))
painter.drawRoundedRect(0, 8, 3, 16, 1.5, 1.5) painter.drawRoundedRect(0, 8, 3, 16, 1.5, 1.5)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册