-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstyles.cpp
More file actions
171 lines (167 loc) · 5.4 KB
/
Copy pathstyles.cpp
File metadata and controls
171 lines (167 loc) · 5.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#include "game.hpp"
#include "base/svgRend.hpp"
#include "base/font.hpp"
#include <QDialog>
static QString rgba(const QColor& c, double a) {
return QString("rgba(%1,%2,%3,%4)")
.arg(c.red()).arg(c.green()).arg(c.blue()).arg(std::clamp(int(std::round(a * 255)), 0, 255));
}
void MainGame::initStyles() {
QString globals = QString(
"color: %1;"
)
.arg(getCol("alight", 100, 150, 10)) // %1 - color
;
QString treeWidAndMenu = QString(
"QTreeWidget::item {"
"background: %1;"
"padding: 3px 0;"
"}"
"QTreeWidget {"
"border: 1px solid #333;"
"padding: 4px;"
"}"
"QTreeWidget::item:hover { background-color: %2; }"
"QTreeWidget::item:selected { background-color: %3; }"
"QHeaderView::section {"
"background-color: %4;"
"border: 1px solid #666;"
"padding: 4px;"
"}"
"QHeaderView::section:first {"
"border-top-left-radius: 10px;"
"}"
"QHeaderView::section:last {"
"border-top-right-radius: 10px;"
"}"
"QMenuBar {"
"background: %6;"
"}"
"QMenuBar::item {"
"padding: 4px;"
"background: %5;"
"border-radius: 6px;"
"}"
"QMenuBar::item:hover { background: %2; }"
"QMenuBar::item:selected { background: %3; }"
"QMenu {"
"background: %1;"
"border-radius: 6px;"
"}"
"QMenu::item {"
"background: %1;"
"border-radius: 4px;"
"padding: 4px;"
"}"
"QMenu::item:hover { background: %2; }"
"QMenu::item:selected { background: %3; }"
) // QTreeWidget/some of QMenuBar
.arg(getCol("alight", -20, -10)) // %1 - item
.arg(getCol("alight", -10, -5)) // %2 - item hover
.arg(getCol("alight", 0, 5)) // %3 - item select
.arg(getCol("adark", -10, 10)) // %4 - header
// QMenuBar overrides
.arg(getCol("adark", 50, 20)) // %5 - item
.arg(getCol("adark", 30, 10, 10)) // %6 - header
;
QString textEdit = QString(
"QTextEdit, QLineEdit {"
"color: white;"
"background-color: %1;"
"border-radius: 6px;"
"border: 1px solid #666;"
"margin: 4px;"
"padding: 4px;"
"}"
"QTextEdit:focus, QLineEdit:focus {"
"border: 2px solid #333;"
"}"
"QTextEdit:disabled, QTextEdit[Disabled='true'], QLineEdit:disabled {"
"background-color: %2;"
"color: #DADADA;"
"border: 1px solid #999;"
"}"
"QLabel { color: %3; }"
)
.arg(getCol("alight", 0, -18)) // %1 - QTextEdit bg
.arg(rgba(getQCol("alight", 10, 0), 0.86)) // %2 - Disabled QTextEdit bg
.arg(getCol("adark", -100, 70)) // %3 - QLabel text colour
;
QString comboBox = QString(
"QComboBox {"
"color: %2;"
"padding: 4px;"
"background-color: %1;"
"border-radius: 6px;"
"border: 1px solid #666;"
"margin: 2px;"
"}"
"QComboBox::drop-down {"
"image: none;"
"}"
"QComboBox QAbstractItemView {"
"color: %2;"
"padding: 4px;"
"background-color: %1;"
"border-radius: 6px;"
"border: 1px solid #666;"
"}"
"QComboBox:focus {"
"border: 2px solid #333;"
"}"
)
.arg(rgba(getQCol("adark", -100, 70), 0.86)) // %1 - bg
.arg(getCol("alight", 30, 120)) // %2 - text colour
;
QString misc = QString(
"QSplitter::handle {"
"background-color: %1;"
"border-radius: 6px;"
"}"
"QDialog * {" // Because otherwise text in e.g. file dialogs are white on white
"color: black;"
"}"
)
.arg(getCol("alight", -100, 0, 20)) // %1 - QSplitter handle colour
;
setStyleSheet(
"QWidget {" + globals + "}" +
treeWidAndMenu +
textEdit +
comboBox +
misc
);
styls.dialogStyl = QString(
"background-color: %1;"
"color: %2;"
"border-radius: 6px;"
)
.arg(getCol("alight", -200, 111)) // %1 - bg colour
.arg(getCol("dark", 100, -70)) // %2 - text colour
;
styls.listWidCol = getCol("alight", -42, 10);
styls.logBgCol = getCol("shadow", -200, 20);
styls.mdHlCol = getCol("light", 20, -60);
styls.secretCol = getCol("blue", 20, 20, 10);
styls.pbcols = {
getQCol("adark", 5, 10), // The dark border
getQCol("alight", -40, 70, 10), // The light, faded bg
getQCol("light", 20, -50, 10), // The default progressbar colour
// The rest of the progressbar colour options
getQCol("alight", -30, -30, 20),
getQCol("alight", 0, 0, 20),
getQCol("red", -20, -20, 20),
getQCol("red", 0, 0, 20),
getQCol("adark", -20, 25, 20),
getQCol("adark", 15, 60, 20),
getQCol("shadow", -40, 0, 20),
getQCol("shadow", -5, 35, 20),
getQCol("blue", 10, -10, 20),
getQCol("blue", 40, 20, 20),
};
setFont(getFont(1.2));
}
void MainGame::styliseDialog(QDialog* dialog, const QString& xtraStyl) {
dialog->setStyleSheet(styls.dialogStyl + xtraStyl);
dialog->setFont(font());
}