Skip to content

Commit 09acea4

Browse files
committed
perf:全局统一的样式风格
样式在ui\uiComponents.py中全局定义。ui文件中顶层不要再写样式,有微调在控件局部改
1 parent 76a8c2c commit 09acea4

17 files changed

+74
-809
lines changed

src/gameAbout.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,8 @@ def __init__(self, r_path, parent):
77
# 关于界面,继承一下就好
88
self.Dialog = RoundQDialog(parent)
99
self.setupUi (self.Dialog)
10-
self.Dialog.setWindowIcon (QtGui.QIcon (str(r_path.with_name('media').joinpath('cat.ico'))))
11-
# self.pushButton.setStyleSheet("border-image: url(" + str(r_path.with_name('media').joinpath('button.png')).replace("\\", "/") + ");\n"
12-
# "font: 16pt \"黑体\";\n"
13-
# "color:white;font: bold;")
14-
# self.label_6.setStyleSheet("border-image: url(" + str(r_path.with_name('media').joinpath('github.svg')).replace("\\", "/") + ");")
15-
# self.label_7.setStyleSheet("border-image: url(" + str(r_path.with_name('media').joinpath('message.svg')).replace("\\", "/") + ");")
16-
17-
10+
# self.Dialog.setWindowIcon (QtGui.QIcon (str(r_path.with_name('media').joinpath('cat.ico'))))
11+
12+
1813

1914

src/gameDefinedParameter.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,17 @@
77
from ui.ui_defined_parameter import Ui_Form
88
from ui.uiComponents import RoundQDialog
99

10+
1011
class ui_Form(Ui_Form):
1112
def __init__(self, r_path, row, column, num, parent):
1213
self.row = row
1314
self.column = column
1415
self.minenum = num
15-
# self.maxRow = 1e6
16-
# self.maxColumn = 1e6
1716
self.alter = False
1817
self.Dialog = RoundQDialog(parent)
1918
self.setupUi (self.Dialog)
2019
self.setParameter()
21-
self.Dialog.setWindowIcon (QtGui.QIcon (str(r_path.with_name('media').joinpath('cat.ico')).replace("\\", "/")))
2220
self.pushButton_3.clicked.connect (self.processParameter)
23-
self.pushButton_2.clicked.connect (self.Dialog.close)
24-
25-
self.pushButton_2.setStyleSheet("border-image: url(" + str(r_path.with_name('media').joinpath('button.png')).replace("\\", "/") + ");\n"
26-
"font: 16pt \"黑体\";\n"
27-
"color:white;font: bold;")
28-
self.pushButton_3.setStyleSheet("border-image: url(" + str(r_path.with_name('media').joinpath('button.png')).replace("\\", "/") + ");\n"
29-
"font: 16pt \"黑体\";\n"
30-
"color:white;font: bold;")
3121

3222

3323
def setParameter(self):
@@ -55,13 +45,4 @@ def processParameter(self):
5545
self.Dialog.close ()
5646

5747

58-
if __name__ == '__main__':
59-
# from PyQt5.QtWidgets import QApplication
60-
# import sys
61-
# app = QApplication(sys.argv)
62-
# demo = ui_Form(8, 8, 10)
63-
# demo.Dialog.show()
64-
# sys.exit(app.exec_())
65-
...
66-
6748

src/gameRecordPop.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
class ui_Form(Ui_Form):
66
def __init__(self, r_path, del_items: list, pb_bbbv, nf_items, parent):
7-
# 关于界面,继承一下就好
87
self.Dialog = RoundQDialog(parent)
98
self.setupUi(self.Dialog)
109
self.Dialog.setWindowIcon (QtGui.QIcon (str(r_path.with_name('media').joinpath('cat.ico'))))
@@ -46,9 +45,6 @@ def __init__(self, r_path, del_items: list, pb_bbbv, nf_items, parent):
4645
str(r_path.with_name('media').\
4746
joinpath('pb.svg')).replace("\\", "/") + ");")
4847

49-
self.pushButton.setStyleSheet("border-image: url(" + str(r_path.with_name('media').joinpath('button.png')).replace("\\", "/") + ");\n"
50-
"font: 16pt \"黑体\";\n"
51-
"color:white;font: bold;")
5248
self.label__13.setText(str(pb_bbbv) + " bv")
5349
self.label__14.setText(str(pb_bbbv) + " bv")
5450
self.label__15.setText(str(pb_bbbv) + " bv")

src/gameScores.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from PyQt5.QtGui import QPainter, QPen, QBrush,QPalette,QFont,QImage,QPainterPath, QPolygon,QPixmap, QRadialGradient,QGradient,QLinearGradient,QConicalGradient
1111
import math
1212

13+
# 单局游戏结束后的分数的弹窗,已弃用。
1314
class Ui_Form(QtWidgets.QDialog):
1415
def __init__(self, scores, scoresValue):
1516
super(Ui_Form, self).__init__()

src/gameSettingShortcuts.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@ def setParameter(self):
4545
self.spinBox_minenum6.setProperty("value", self.game_setting.value("CUSTOM_PRESET_6/mine_num", None, int))
4646
self.lineEdit_constraint6.setProperty("value", self.game_setting.value("CUSTOM_PRESET_6/board_constraint", None, str))
4747

48-
self.pushButton.setStyleSheet("border-image: url(" + str(self.r_path.with_name('media').joinpath('button.png')).replace("\\", "/") + ");\n"
49-
"font: 16pt \"黑体\";\n"
50-
"color:white;font: bold;")
51-
self.pushButton_2.setStyleSheet("border-image: url(" + str(self.r_path.with_name('media').joinpath('button.png')).replace("\\", "/") + ");\n"
52-
"font: 16pt \"黑体\";\n"
53-
"color:white;font: bold;")
5448

5549
def processParameter(self):
5650
#只有点确定才能进来

src/gameSettings.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __init__(self, mainWindow):
3939

4040
self.Dialog = RoundQDialog(mainWindow.mainWindow)
4141
self.setupUi(self.Dialog)
42-
self.Dialog.setWindowIcon(QtGui.QIcon (str(self.r_path.with_name('media').joinpath('cat.ico'))))
42+
# self.Dialog.setWindowIcon(QtGui.QIcon (str(self.r_path.with_name('media').joinpath('cat.ico'))))
4343

4444
self.pushButton_yes.clicked.connect(self.processParameter)
4545
self.pushButton_no.clicked.connect(self.Dialog.close)
@@ -109,13 +109,6 @@ def setParameter(self):
109109
# 标准、win7、经典无猜、强无猜、弱无猜、准无猜、强可猜、弱可猜
110110
self.comboBox_gamemode.setCurrentIndex([0, 999, 999, 999, 1, 4, 2, 3, 5, 6, 7][self.gameMode])
111111

112-
self.pushButton_yes.setStyleSheet("border-image: url(" + str(self.r_path.with_name('media').joinpath('button.png')).replace("\\", "/") + ");\n"
113-
"font: 16pt \"黑体\";\n"
114-
"color:white;font: bold;")
115-
self.pushButton_no.setStyleSheet("border-image: url(" + str(self.r_path.with_name('media').joinpath('button.png')).replace("\\", "/") + ");\n"
116-
"font: 16pt \"黑体\";\n"
117-
"color:white;font: bold;")
118-
119112
def processParameter(self):
120113
#只有点确定才能进来
121114

src/mineSweeperGUI.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,7 @@ def screenShot(self):
12331233
# self.num_bar_ui.QWidget.show()
12341234

12351235
# self.setBoard_and_start(len(ui.board), len(ui.board[0]), ans[1][1])
1236-
self.setBoard(self.row, self.column, ans[1][1])
1236+
self.set_board_params(self.row, self.column, ans[1][1])
12371237

12381238
self.label.paintProbability = True
12391239
self.label.set_rcp(self.row, self.column, self.pixSize)

src/superGUI.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ def read_or_create_game_setting(self):
501501
self.unique_identifier = self.game_setting.get_or_set_value("DEFAULT/unique_identifier", "", str)
502502
self.country = self.game_setting.get_or_set_value("DEFAULT/country", "", str)
503503
self.autosave_video = self.game_setting.get_or_set_value("DEFAULT/autosave_video", True, bool)
504-
self.autosave_video_set = self.game_setting.get_or_set_value("DEFAULT/autosave_video_set", True, bool)
504+
self.autosave_video_set = self.game_setting.get_or_set_value("DEFAULT/autosave_video_set", False, bool)
505505
self.filter_forever = self.game_setting.get_or_set_value("DEFAULT/filter_forever", False, bool)
506506
self.language = self.game_setting.get_or_set_value("DEFAULT/language", "en_US", str)
507507
self.end_then_flag = self.game_setting.get_or_set_value("DEFAULT/end_then_flag", True, bool)

src/ui/uiComponents.py

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,19 @@
1717
from PyQt5.QtCore import QStringListModel, QSortFilterProxyModel
1818
# ui相关的小组件,非窗口
1919

20-
BLUE_BUTTON_QSS = """
20+
GLOBAL_QSS = """
21+
QSpinBox, QLineEdit {
22+
border-width: 2px;
23+
border-radius: 8px;
24+
border-style: solid;
25+
border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 #85b7e3, stop:1 #9ec1db);
26+
border-right-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 #85b7e3, stop:1 #9ec1db);
27+
border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 #85b7e3, stop:1 #9ec1db);
28+
border-left-color: qlineargradient(spread:pad, x1:1, y1:0, x2:0, y2:0, stop:0 #85b7e3, stop:1 #9ec1db);
29+
background-color: #f4f4f4;
30+
color: #3d3d3d;
31+
}
32+
2133
QPushButton {
2234
background-color: #00A2E8;
2335
color: white;
@@ -27,6 +39,27 @@
2739
font-size: 16pt;
2840
font-weight: bold;
2941
}
42+
43+
QComboBox {
44+
border-width: 2px;
45+
border-radius: 8px;
46+
border-style: solid;
47+
border-top-color: qlineargradient(spread:pad, x1:0.5, y1:1, x2:0.5, y2:0, stop:0 #85b7e3, stop:1 #9ec1db);
48+
border-right-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 #85b7e3, stop:1 #9ec1db);
49+
border-bottom-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 #85b7e3, stop:1 #9ec1db);
50+
border-left-color: qlineargradient(spread:pad, x1:1, y1:0, x2:0, y2:0, stop:0 #85b7e3, stop:1 #9ec1db);
51+
background-color: rgba(244,244,244,0);
52+
color: #3d3d3d;
53+
font: 12pt "微软雅黑";
54+
}
55+
QComboBox::drop-down {
56+
width: 26px;
57+
}
58+
59+
QLabel {
60+
font: 12pt "微软雅黑";
61+
}
62+
3063
"""
3164

3265

@@ -39,9 +72,7 @@ def _init_round(self):
3972
self.setWindowFlags(Qt.FramelessWindowHint | Qt.Window)
4073

4174
def paintEvent(self, event):
42-
# # 阴影
43-
# path = QPainterPath()
44-
# path.setFillRule(Qt.WindingFill)
75+
# 阴影
4576

4677
p = QPainter(self)
4778
p.setRenderHint(p.Antialiasing)
@@ -93,6 +124,8 @@ class RoundQWidget(QWidget, RoundMixin):
93124
def __init__(self, parent=None):
94125
super().__init__(parent)
95126
self._init_round()
127+
self.setStyleSheet(GLOBAL_QSS)
128+
96129
def closeEvent(self, event):
97130
self.closeEvent_.emit()
98131
event.accept()
@@ -102,8 +135,8 @@ def closeEvent(self, event):
102135
class RoundQDialog(QDialog, RoundMixin):
103136
def __init__(self, parent=None):
104137
super().__init__(parent)
105-
self.setStyleSheet(BLUE_BUTTON_QSS)
106138
self._init_round()
139+
self.setStyleSheet(GLOBAL_QSS)
107140

108141

109142

src/ui/ui_about.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ def setupUi(self, Form):
1919
Form.setMaximumSize(QtCore.QSize(600, 580))
2020
Form.setSizeIncrement(QtCore.QSize(0, 0))
2121
Form.setWindowTitle("")
22+
icon = QtGui.QIcon()
23+
icon.addPixmap(QtGui.QPixmap("media/cat.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
24+
Form.setWindowIcon(icon)
2225
Form.setWindowOpacity(10.0)
2326
self.verticalLayout_7 = QtWidgets.QVBoxLayout(Form)
2427
self.verticalLayout_7.setContentsMargins(20, 20, 20, -1)

0 commit comments

Comments
 (0)