-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSet.cpp
83 lines (81 loc) · 1.75 KB
/
Set.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
#include "Set.h"
#include "Config.h"
#include <QtCore/qfile.h>
#include <QMessageBox>
Set::Set(QWidget* parent)
: QDialog(parent)
{
ui.setupUi(this);
this->setFixedSize(400, 300);
QMap<QString, QString> data1;
Config* config = new Config();
data1 = config->readConfig();
this->style = data1["style"];
this->key = data1["key"];
delete config;
QString stylePath = ":/qdarkstyle/light/lightstyle.qss";
if (style == "黑色")
{
stylePath = ":/qdarkstyle/dark/darkstyle.qss";
ui.comboBox->setCurrentIndex(0);
}
else
{
ui.comboBox->setCurrentIndex(1);
}
QFile f(stylePath);
if (!f.exists()) {
QMessageBox::warning(this, "警告", "没有找到样式表文件!");
}
else {
f.open(QFile::ReadOnly | QFile::Text);
QTextStream ts(&f);
qApp->setStyleSheet(ts.readAll());
}
ui.lineEdit->setText(key);
connect(ui.pushButton, &QPushButton::clicked, [=]()
{
QMap<QString, QString> data;
data.insert("key", this->key);
data.insert("style", this->style);
Config* config = new Config(data);
config->writeConfig();
delete config;
QString stylePath = ":/qdarkstyle/light/lightstyle.qss";
if (style == "黑色")
{
stylePath = ":/qdarkstyle/dark/darkstyle.qss";
}
else
{
}
QFile f(stylePath);
if (!f.exists()) {
QMessageBox::warning(this, "警告", "没有找到样式表文件!");
}
else {
f.open(QFile::ReadOnly | QFile::Text);
QTextStream ts(&f);
qApp->setStyleSheet(ts.readAll());
}
this->close();
});
connect(ui.pushButton_back, &QPushButton::clicked, [=]()
{
this->close();
});
connect(ui.comboBox, &QComboBox::currentIndexChanged, [=](int index)
{
if (index == 0)
{
this->style = "黑色";
}
else
{
this->style = "白色";
}
});
}
Set::~Set()
{
}