This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsettingWindow.cpp
126 lines (108 loc) · 3.5 KB
/
settingWindow.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
#include "settingWindow.h"
setting::setting(QWidget* parent) :
QDialog(parent),
ui(new Ui::setting)
{
ui->setupUi(this);
this->setFixedSize(this->width(), this->height());//固定窗口尺寸
QString iniPath(QApplication::applicationDirPath() + "/aria2Launcher.ini");
bool flag = QFile::exists(iniPath); //检测aria2Launcher.ini是否存在
QFile Ini(iniPath); //有则打开,无则新建
iniSetting = new QSettings(iniPath, QSettings::IniFormat); //ini读写
if (flag) { //如果存在,读取数据,初始化单选项
Ini.open(QIODevice::ReadWrite);
settingInitialize();
}
else { //如果没有ini,即第一次打开程序,配置默认选项
startWithWindows(Qt::Unchecked);
startHide(Qt::Unchecked);
trayNotice(Qt::Checked);
showWebui(Qt::Checked);
}
connect(ui->sww, SIGNAL(stateChanged(int)), this, SLOT(startWithWindows(int)));
connect(ui->sh, SIGNAL(stateChanged(int)), this, SLOT(startHide(int)));
connect(ui->tn, SIGNAL(stateChanged(int)), this, SLOT(trayNotice(int)));
connect(ui->isWebui, SIGNAL(stateChanged(int)), this, SLOT(showWebui(int)));
connect(ui->yaaw, SIGNAL(clicked()), this, SLOT(yaaw()));
connect(ui->ariang, SIGNAL(clicked()), this, SLOT(ariang()));
}
setting::~setting() {
delete ui;
}
void setting::settingInitialize() { //读取数据,初始化单选项
QVariant sww = iniSetting->value("setting/startWithWindows").toString();
if (sww.toBool() == true) {
ui->sww->setCheckState(Qt::Checked);
}
else {
ui->sww->setCheckState(Qt::Unchecked);
}
QVariant sh = iniSetting->value("setting/startHide").toString();
if (sh.toBool() == true) {
ui->sh->setCheckState(Qt::Checked);
}
else {
ui->sh->setCheckState(Qt::Unchecked);
}
QVariant tn = iniSetting->value("setting/trayNotice").toString();
if (tn.toBool() == true) {
ui->tn->setCheckState(Qt::Checked);
}
else {
ui->tn->setCheckState(Qt::Unchecked);
}
QVariant sw = iniSetting->value("setting/showWebui").toString();
if (sw.toBool() == true) {
ui->isWebui->setCheckState(Qt::Checked);
}
else {
ui->isWebui->setCheckState(Qt::Unchecked);
}
QVariant ws = iniSetting->value("setting/webuiStyle").toString();
switch (ws.toInt()) {
case 1:
ui->yaaw->setChecked(true);
break;
case 2:
ui->ariang->setChecked(true);
break;
}
}
void setting::startWithWindows(int state) {
if (state == Qt::Checked) {
iniSetting->setValue("setting/startWithWindows", "true");
}
else {
iniSetting->setValue("setting/startWithWindows", "false");
}
}
void setting::startHide(int state) {
if (state == Qt::Checked) {
iniSetting->setValue("setting/startHide", "true");
}
else {
iniSetting->setValue("setting/startHide", "false");
}
}
void setting::trayNotice(int state) {
if (state == Qt::Checked) {
iniSetting->setValue("setting/trayNotice", "true");
}
else {
iniSetting->setValue("setting/trayNotice", "false");
}
}
void setting::showWebui(int state) {
if (state == Qt::Checked) {
iniSetting->setValue("setting/showWebui", "true");
}
else {
iniSetting->setValue("setting/showWebui", "false");
}
}
void setting::yaaw() {
iniSetting->setValue("setting/webuiStyle", "1");
}
void setting::ariang() {
iniSetting->setValue("setting/webuiStyle", "2");
}