forked from engor/Jentos.Code
-
Notifications
You must be signed in to change notification settings - Fork 2
/
theme.cpp
executable file
·234 lines (215 loc) · 9.34 KB
/
theme.cpp
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
#include "theme.h"
#include "prefs.h"
QString Theme::_theme;
QString Theme::_prevTheme;
bool Theme::_isDark;
bool Theme::_isDark2;
bool Theme::_isDark3;
Theme::Theme(QObject *parent) : QObject(parent) {
}
void Theme::init() {
Prefs *p = Prefs::prefs();
if(!p->contains("fontFamily"))
p->setValue( "fontFamily","Courier" );
if(!p->contains("fontSize"))
p->setValue( "fontSize",12 );
if(!p->contains("tabSize"))
p->setValue( "tabSize",4 );
if(!p->contains("smoothFonts"))
p->setValue( "smoothFonts",true );
_prevTheme = "";
QString s = p->getString("theme","netbeans");
set(s);
}
void Theme::set(QString kind) {
instance()->setLocal(kind);
}
void Theme::setLocal(QString kind) {
emit beginChange();
_prevTheme = _theme;
_theme = kind;
save();
emit endChange();
}
void Theme::save() {
_isDark = (_theme=="android");
_isDark2 = (_theme=="Monokai-Dark-Soda");
_isDark3 = (_theme=="lighttable");
Prefs *prefs = Prefs::prefs();
prefs->blockEmitPrefsChanged(true);
prefs->setValue("theme", _theme);
if(_theme == "android") {
prefs->setValue( "backgroundColor",QColor( 0x2b2b2b ) );
prefs->setValue( "defaultColor",QColor( 0xAbB9C8 ) );
prefs->setValue( "numbersColor",QColor( 0x6897BB ) );
prefs->setValue( "stringsColor",QColor( 0x6A8759 ) );
prefs->setValue( "identifiersColor",QColor( 0xCEDDE5 ) );
prefs->setValue( "keywordsColor",QColor( 0xCC7832 ) );
prefs->setValue( "constantsColor",QColor( 0x9876AA ) );
prefs->setValue( "funcDeclsColor",QColor( 0xFFC66D ) );
prefs->setValue( "commentsColor",QColor( 0x808080 ) );
prefs->setValue( "highlightColor",QColor( 0x323232 ) );
prefs->setValue( "highlightColorError",QColor( 0x323232 ) );
prefs->setValue( "highlightColorCaretRow",QColor( 0x323232 ) );
prefs->setValue( "monkeywordsColor",QColor( 0xc8c8c8 ) );
prefs->setValue( "userwordsColor",QColor( 0xc8c8c8 ) );
prefs->setValue( "userwordsDeclColor",QColor( 0xFFC66D ) );
prefs->setValue( "userwordsVarColor",QColor( 0xAE8ABE ) );
prefs->setValue( "paramsColor",QColor( 0xcfefefe ) );
}
else if(_theme == "netbeans") {
prefs->setValue( "backgroundColor",QColor( 0xf5f5f5 ) );
prefs->setValue( "defaultColor",QColor( 0x000001 ) );
prefs->setValue( "numbersColor",QColor( 0x000001 ) );
prefs->setValue( "stringsColor",QColor( 0xce7b00 ) );
prefs->setValue( "identifiersColor",QColor( 0x009900 ) );
prefs->setValue( "keywordsColor",QColor( 0x0000e6 ) );
prefs->setValue( "constantsColor",QColor( 0x000001 ) );
prefs->setValue( "funcDeclsColor",QColor( 0x000001 ) );
prefs->setValue( "commentsColor",QColor( 0x606060 ) );
prefs->setValue( "highlightColor",QColor( 0xE9EFF8 ) );
prefs->setValue( "highlightColorError",QColor( 0xE9EFF8 ) );
prefs->setValue( "highlightColorCaretRow",QColor( 0xE9EFF8 ) );
prefs->setValue( "monkeywordsColor",QColor( 0xc000001 ) );
prefs->setValue( "userwordsColor",QColor( 0x000001 ) );
prefs->setValue( "userwordsDeclColor",QColor( 0x000001 ) );
prefs->setValue( "userwordsVarColor",QColor( 0x009900 ) );
prefs->setValue( "paramsColor",QColor( 0xc80808 ) );
}
else if(_theme == "qt") {
prefs->setValue( "backgroundColor",QColor( 0xfefefe ) );
prefs->setValue( "defaultColor",QColor( 0x000001 ) );
prefs->setValue( "numbersColor",QColor( 0x000080 ) );
prefs->setValue( "stringsColor",QColor( 0x008000 ) );
prefs->setValue( "identifiersColor",QColor( 0x009900 ) );
prefs->setValue( "keywordsColor",QColor( 0x808000 ) );
prefs->setValue( "constantsColor",QColor( 0x000001 ) );
prefs->setValue( "funcDeclsColor",QColor( 0x800080 ) );
prefs->setValue( "commentsColor",QColor( 0x606060 ) );
prefs->setValue( "highlightColor",QColor( 0xE9EFF8 ) );
prefs->setValue( "highlightColorError",QColor( 0xE9EFF8 ) );
prefs->setValue( "highlightColorCaretRow",QColor( 0xF7F7F7 ) );
prefs->setValue( "monkeywordsColor",QColor( 0xc800080 ) );
prefs->setValue( "userwordsColor",QColor( 0x800080 ) );
prefs->setValue( "userwordsDeclColor",QColor( 0x000001 ) );
prefs->setValue( "userwordsVarColor",QColor( 0x800000 ) );
prefs->setValue( "paramsColor",QColor( 0xc80808 ) );
//cur line #c2e1ff
}
else if(_theme == "Monokai-Dark-Soda") {
prefs->setValue( "backgroundColor",QColor( 0x242424 ) );
prefs->setValue( "defaultColor",QColor( 0xDDDDDD ) );
prefs->setValue( "numbersColor",QColor( 0xAE81FF ) );
prefs->setValue( "stringsColor",QColor( 0xE3D874 ) );
prefs->setValue( "identifiersColor",QColor( 0x009900 ) );
prefs->setValue( "keywordsColor",QColor( 0xF92672 ) );
prefs->setValue( "constantsColor",QColor( 0xA6E22E ) );
prefs->setValue( "funcDeclsColor",QColor( 0xFD971F ) );
prefs->setValue( "commentsColor",QColor( 0x8c8c8c ) );
prefs->setValue( "highlightColor",QColor( 0xB5B5B5 ) );
prefs->setValue( "highlightColorError",QColor( 0xe40000 ) );
prefs->setValue( "highlightColorCaretRow",QColor( 0x3A2A21 ) );
prefs->setValue( "monkeywordsColor",QColor( 0x2BBF1C ) );
prefs->setValue( "userwordsColor",QColor( 0xfd971f ) );
prefs->setValue( "userwordsDeclColor",QColor( 0xa6e22e ) );
prefs->setValue( "userwordsVarColor",QColor( 0x9effff ) );
prefs->setValue( "paramsColor",QColor( 0x66D9EF ) );
}
else if(_theme == "lighttable") {
prefs->setValue( "backgroundColor",QColor( 0x202020 ) );
prefs->setValue( "defaultColor",QColor( 0xc6c6c6 ) );
prefs->setValue( "numbersColor",QColor( 0xFEFEFE ) );
prefs->setValue( "stringsColor",QColor( 0x318F8F ) );
prefs->setValue( "identifiersColor",QColor( 0x009900 ) );
prefs->setValue( "keywordsColor",QColor( 0x43AA79 ) );
prefs->setValue( "constantsColor",QColor( 0xA6E22E ) );
prefs->setValue( "funcDeclsColor",QColor( 0xAACCFF ) );
prefs->setValue( "commentsColor",QColor( 0x6688CD ) );
prefs->setValue( "highlightColor",QColor( 0xea1717 ) );
prefs->setValue( "highlightColorError",QColor( 0x40000 ) );
prefs->setValue( "highlightColorCaretRow",QColor( 0x423434 ) );
prefs->setValue( "monkeywordsColor",QColor( 0xAFCDFB ) );
prefs->setValue( "userwordsColor",QColor( 0x2886AC ) );
prefs->setValue( "userwordsDeclColor",QColor( 0xCCAAFF ) );
prefs->setValue( "userwordsVarColor",QColor( 0x2CA2A2 ) );
prefs->setValue( "paramsColor",QColor( 0x66D9EF ) );
}
else if(_theme == "MondayMorning") {
prefs->setValue( "backgroundColor",QColor( 0xDCDCDE ) );
prefs->setValue( "defaultColor",QColor( 0x160050 ) );
prefs->setValue( "numbersColor",QColor( 0x3D3D3D ) );
prefs->setValue( "stringsColor",QColor( 0x226AF0 ) );
prefs->setValue( "identifiersColor",QColor( 0x009900 ) );
prefs->setValue( "keywordsColor",QColor( 0x084FD1 ) );
prefs->setValue( "constantsColor",QColor( 0x160050 ) );
prefs->setValue( "funcDeclsColor",QColor( 0x160050 ) );
prefs->setValue( "commentsColor",QColor( 0xF2740C ) );
prefs->setValue( "highlightColor",QColor( 0x40a3e1 ) );
prefs->setValue( "highlightColorError",QColor( 0x40000 ) );
prefs->setValue( "highlightColorCaretRow",QColor( 0xCEBEF7 ) );
prefs->setValue( "monkeywordsColor",QColor( 0x6969e1 ) );
prefs->setValue( "userwordsColor",QColor( 0x0073BF ) );
prefs->setValue( "userwordsDeclColor",QColor( 0x160050 ) );
prefs->setValue( "userwordsVarColor",QColor( 0x221177 ) );
prefs->setValue( "paramsColor",QColor( 0x160050 ) );
}
prefs->blockEmitPrefsChanged(false, true);
}
void Theme::load() {
/*_theme = "android";
Prefs *prefs = Prefs::prefs();
QString s = prefs->getString("theme");
if(s != "")
_theme = s;*/
}
QIcon Theme::icon(QString name) {
QString s = (_theme=="android" ? "dark" : "light");
return QIcon(":/icons/"+s+"/"+name);
}
QImage Theme::image(QString name, int theme) {
QString t = _theme;
if(theme == 1)
t = "android";
else if(theme == 2)
t = "netbeans";
QString s = (t=="android" ? "dark" : "light");
return QImage(":/icons/"+s+"/"+name);
}
bool Theme::isDark() {
return _isDark;
}
bool Theme::isDark2() {
return _isDark2;
}
bool Theme::isDark3() {
return _isDark3;
}
QString Theme::hexColor(const QColor &color) {
QString r = QString::number(color.red(),16);
if(r.length() < 2)
r = "0"+r;
QString g = QString::number(color.green(),16);
if(g.length() < 2)
g = "0"+g;
QString b = QString::number(color.blue(),16);
if(b.length() < 2)
b = "0"+b;
return "#"+r+g+b;
}
QColor Theme::selWordColor() {
static QColor c1(166,166,166);
static QColor c2(236,235,163);//(225,225,225);
static QColor c3(225,225,225);
if(_theme == "android")
return c1;
else if(_theme == "netbeans")
return c2;
else if(_theme == "Monokai-Dark-Soda")
return c1;
else if(_theme == "lighttable")
return c1;
else if(_theme == "MondayMorning")
return c2;
else
return c3;
}