- Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapplicationui.cpp
More file actions
Latest commit
154 lines (139 loc) · 3.22 KB
/
Copy pathapplicationui.cpp
File metadata and controls
154 lines (139 loc) · 3.22 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
#include"applicationui.hpp"
#include"uiconstants.hpp"
#include<QDebug>
usingnamespaceekke::constants;
ApplicationUI::ApplicationUI(QObject *parent) : QObject(parent)
{
// default theme is light
mIsDarkTheme = false;
m_darkTheme = false;
m_systemColor = false;
// default primary color is Teal
mPrimaryPalette = 8;
// default accent color is DeepOrange
mAccentPalette = 15;
}
/* Change Theme Palette */
QStringList ApplicationUI::swapThemePalette()
{
mIsDarkTheme = !mIsDarkTheme;
setDarkTheme(mIsDarkTheme);
if (mIsDarkTheme) {
return darkPalette;
}
return lightPalette;
}
/* Get current default Theme Palette */
QStringList ApplicationUI::defaultThemePalette()
{
if (mIsDarkTheme) {
return darkPalette;
}
return lightPalette;
}
/* Get one of the Primary Palettes */
QStringList ApplicationUI::primaryPalette(constint paletteIndex)
{
mPrimaryPalette = paletteIndex;
switch (paletteIndex) {
case0:
return materialRed;
break;
case1:
return materialPink;
break;
case2:
return materialPurple;
break;
case3:
return materialDeepPurple;
break;
case4:
return materialIndigo;
break;
case5:
return materialBlue;
break;
case6:
return materialLightBlue;
break;
case7:
return materialCyan;
break;
case8:
return materialTeal;
break;
case9:
return materialGreen;
break;
case10:
return materialLightGreen;
break;
case11:
return materialLime;
break;
case12:
return materialYellow;
break;
case13:
return materialAmber;
break;
case14:
return materialOrange;
break;
case15:
return materialDeepOrange;
break;
case16:
return materialBrown;
break;
case17:
return materialGrey;
break;
default:
return materialBlueGrey;
break;
}
}
/* Get one of the Accent Palettes */
QStringList ApplicationUI::accentPalette(constint paletteIndex)
{
mAccentPalette = paletteIndex;
int currentPrimary = mPrimaryPalette;
QStringList thePalette = primaryPalette(paletteIndex);
mPrimaryPalette = currentPrimary;
// we need: primaryColor, textOnPrimary, iconOnPrimaryFolder
return QStringList{thePalette.at(1), thePalette.at(4), thePalette.at(7)};
}
/* Get Default Primary Palette */
QStringList ApplicationUI::defaultPrimaryPalette()
{
returnprimaryPalette(mPrimaryPalette);
}
/* Get Default Accent Palette */
QStringList ApplicationUI::defaultAccentPalette()
{
returnaccentPalette(mAccentPalette);
}
boolApplicationUI::darkTheme() const
{
return m_darkTheme;
}
voidApplicationUI::setDarkTheme(bool newDarkTheme)
{
if (m_darkTheme == newDarkTheme)
return;
m_darkTheme = newDarkTheme;
emit darkThemeChanged();
}
boolApplicationUI::systemColor() const
{
return m_systemColor;
}
voidApplicationUI::setSystemColor(bool newSystemColor)
{
if (m_systemColor == newSystemColor)
return;
m_systemColor = newSystemColor;
emit systemColorChanged();
}