-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathfrmconfig.cpp
106 lines (91 loc) · 3.13 KB
/
frmconfig.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
#include "frmconfig.h"
#include "ui_frmconfig.h"
/*
* 设置页
*/
FrmConfig::FrmConfig(QWidget *parent) :
QDialog(parent),
ui(new Ui::FrmConfig)
{
ui->setupUi(this);
this->InitStyle();
this->InitForm();
MyHelper::FormInCenter(this);
}
FrmConfig::~FrmConfig()
{
delete ui;
}
void FrmConfig::InitStyle()
{
this->setProperty("Form", true);
this->setProperty("CanMove", true);
this->setWindowTitle(ui->lab_Title->text());
this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint);
IconHelper::Instance()->SetIcoMain(ui->lab_Ico);
IconHelper::Instance()->SetIcoClose(ui->btnMenu_Close);
connect(ui->btnMenu_Close, SIGNAL(clicked()), this, SLOT(close()));
}
//选择皮肤
void FrmConfig::InitForm()
{
QStringList qssName;
qssName << "黑色" << "灰黑色" << "灰色" << "浅灰色" << "深灰色" << "银色" << "淡蓝色" << "蓝色";
ui->cboxAppStyle->addItems(qssName);
if (App::AppStyle == ":/qss/black.css") {
ui->cboxAppStyle->setCurrentIndex(0);
} else if (App::AppStyle == ":/qss/brown.css") {
ui->cboxAppStyle->setCurrentIndex(1);
} else if (App::AppStyle == ":/qss/gray.css") {
ui->cboxAppStyle->setCurrentIndex(2);
} else if (App::AppStyle == ":/qss/lightgray.css") {
ui->cboxAppStyle->setCurrentIndex(3);
} else if (App::AppStyle == ":/qss/darkgray.css") {
ui->cboxAppStyle->setCurrentIndex(4);
} else if (App::AppStyle == ":/qss/silvery.css") {
ui->cboxAppStyle->setCurrentIndex(5);
} else if (App::AppStyle == ":/qss/blue.css") {
ui->cboxAppStyle->setCurrentIndex(6);
} else if (App::AppStyle == ":/qss/dev.css") {
ui->cboxAppStyle->setCurrentIndex(7);
}
connect(ui->cboxAppStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(SaveConfig()));
QList<QPushButton *> btns = ui->widget_left->findChildren<QPushButton *>();
foreach (QPushButton * btn, btns) {
connect(btn, SIGNAL(clicked()), this, SLOT(button_clicked()));
}
}
void FrmConfig::button_clicked()
{
QPushButton *btn = (QPushButton *)sender();
QString name = btn->text();
QList<QPushButton *> btns = ui->widget_left->findChildren<QPushButton *>();
foreach (QPushButton * b, btns) {
b->setChecked(false);
}
btn->setChecked(true);
}
//确认保存皮肤
void FrmConfig::SaveConfig()
{
QString style = ui->cboxAppStyle->currentText();
if (style == "黑色") {
App::AppStyle = ":/qss/black.css";
} else if (style == "灰黑色") {
App::AppStyle = ":/qss/brown.css";
} else if (style == "灰色") {
App::AppStyle = ":/qss/gray.css";
} else if (style == "浅灰色") {
App::AppStyle = ":/qss/lightgray.css";
} else if (style == "深灰色") {
App::AppStyle = ":/qss/darkgray.css";
} else if (style == "银色") {
App::AppStyle = ":/qss/silvery.css";
} else if (style == "淡蓝色") {
App::AppStyle = ":/qss/blue.css";
} else if (style == "蓝色") {
App::AppStyle = ":/qss/dev.css";
}
App::WriteConfig();
MyHelper::SetStyle(App::AppStyle);
}