-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstyle.cpp
More file actions
165 lines (130 loc) · 3.66 KB
/
Copy pathstyle.cpp
File metadata and controls
165 lines (130 loc) · 3.66 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
// ===========================================================================
/// <summary>
/// style.cpp
/// QtIntroduction
/// created by Mehrdad Soleimanimajd on 12.09.2019
/// </summary>
/// <created>ʆϒʅ, 12.09.2019</created>
/// <changed>ʆϒʅ, 27.06.2023</changed>
// ===========================================================================
#include "style.h"
AppStyle::AppStyle () :
current ( 0 ), loaded ( false )
{
try
{
paths [0] = "defaults";
paths [1] = "./theme.css";
setDefaults ();
}
catch (const std::exception& ex)
{
}
};
//AppStyle::~AppStyle ( void )
//{
//
//};
bool AppStyle::load ( void )
{
try
{
std::ifstream file ( paths [current] );
if (file.is_open ())
{
std::string input { "" };
std::string strSphere { "" };
unsigned short sphere { 0 };
std::stringstream stream;
std::getline ( file, input );
std::getline ( file, input );
if (input != "")
{
do
{
stream << input << std::endl;
input = "";
stream >> strSphere;
if (strSphere == "form")
sphere = enumForm;
else
if (strSphere == "menu")
sphere = enumMenu;
else
if (strSphere == "statusBar")
sphere = enumStatusBar;
strSphere = "";
std::getline ( file, input );
if (input == "")
break;
stream.str ( "" );
stream.clear ();
do
{
if (input != "}")
{
switch (sphere)
{
case enumForm:
theme.form.append ( input.c_str () );
break;
case enumMenu:
theme.menu.append ( input.c_str () );
break;
case enumStatusBar:
theme.status.append ( input.c_str () );
break;
}
}
input = "";
std::getline ( file, input );
} while (input != "");
std::getline ( file, input );
} while (input != "");
} else
{
return false;
}
file.close ();
return true;
} else
{
return false;
}
}
catch (const std::exception& ex)
{
return false;
}
};
void AppStyle::setDefaults ( void )
{
theme.form = "background-color: rgb(90, 90, 90);";
theme.menu = "background-color: rgb(85, 170, 255);color: rgb(9, 9, 9);";
theme.status = "background-color: rgb(85, 170, 255);";
};
void AppStyle::set ( unsigned char index )
{
if (index)
{
unsigned short temp { current };
loaded = false;
current = index;
theme.form = "";
theme.menu = "";
theme.status = "";
if (load ())
loaded = true;
else
{
current = temp;
setDefaults ();
}
} else
setDefaults ();
};
const bool AppStyle::getLoaded ( void )
{
return loaded;
};