-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path_event.cpp
More file actions
92 lines (66 loc) · 3.13 KB
/
Copy path_event.cpp
File metadata and controls
92 lines (66 loc) · 3.13 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
#include "_event.h"
void _Event::initializeDefaults() {
this->color_eventName.setRgb(0, 0, 0);
this->color_eventCountdown.setRgb(0, 0, 0);
this->backgroundColor.setRgb(255, 255, 255, 32);
this->font_eventName.setFamily("微软雅黑");
this->font_eventCountdown.setFamily("微软雅黑");
this->font_eventName.setPointSize(25);
this->font_eventCountdown.setPointSize(30);
this->font_eventName.setBold(true);
this->font_eventCountdown.setBold(true);
this->widget_border = "2px solid black";
// this->shadow_enabled = false;
this->otherStylesheet = "";
}
void setColorFromJson(QColor& color, const QJsonObject& jsonObject, const QString& key) {
if (jsonObject.contains(key)) {
color = QColor::fromString(jsonObject.value(key).toString());
}
}
void setFontFamilyFromJson(QFont& font, const QJsonObject& jsonObject, const QString& key) {
if (jsonObject.contains(key)) {
font.setFamily(jsonObject.value(key).toString());
}
}
void setFontSizeFromJson(QFont& font, const QJsonObject& jsonObject, const QString& key) {
if (jsonObject.contains(key)) {
font.setPointSize(jsonObject.value(key).toInt());
}
}
void setFontBoldFromJson(QFont& font, const QJsonObject& jsonObject, const QString& key) {
if (jsonObject.contains(key)) {
font.setBold(jsonObject.value(key).toBool());
}
}
void _Event::parseJsonObject(const QJsonObject& jsonObject) {
eventName = jsonObject.value("eventName").toString();
eventDate = jsonObject.value("eventDate").toString();
setColorFromJson(color_eventName, jsonObject, "color_eventName");
setColorFromJson(color_eventCountdown, jsonObject, "color_eventCountdown");
setColorFromJson(backgroundColor, jsonObject, "color_background");
setFontFamilyFromJson(font_eventName, jsonObject, "fontFamily_eventName");
setFontFamilyFromJson(font_eventCountdown, jsonObject, "fontFamily_eventCountdown");
setFontSizeFromJson(font_eventName, jsonObject, "fontSize_eventName");
setFontSizeFromJson(font_eventCountdown, jsonObject, "fontSize_eventCountdown");
setFontBoldFromJson(font_eventName, jsonObject, "bold_eventName");
setFontBoldFromJson(font_eventCountdown, jsonObject, "bold_eventCountdown");
widget_border = jsonObject.value("border").toString();
if(!widget_border.size()) widget_border = "2px solid black";
if (jsonObject.contains("other_stylesheet")){
otherStylesheet = jsonObject.value("other_stylesheet").toString();
}
// if (jsonObject.contains("shadow")) {
// QJsonObject shadowJsonObject = jsonObject.value("shadow").toObject();
// shadow_enabled = true;
// shadow_offset_x = shadowJsonObject.value("offset_x").toInt();
// shadow_offset_y = shadowJsonObject.value("offset_y").toInt();
// shadow_blur_radius = shadowJsonObject.value("blur_radius").toInt();
// shadow_color = QColor::fromString(shadowJsonObject.value("color").toString());
// }
}
_Event::_Event() = default;
_Event::_Event(const QJsonObject& eventJsonObj, int eventId) : eventId(eventId) {
initializeDefaults();
parseJsonObject(eventJsonObj);
}