forked from Liniyous/ElaWidgetTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathT_Setting.cpp
160 lines (150 loc) · 5.67 KB
/
T_Setting.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
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
#include "T_Setting.h"
#include <QDebug>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "ElaApplication.h"
#include "ElaComboBox.h"
#include "ElaLog.h"
#include "ElaRadioButton.h"
#include "ElaScrollPageArea.h"
#include "ElaText.h"
#include "ElaTheme.h"
#include "ElaToggleSwitch.h"
#include "ElaWindow.h"
T_Setting::T_Setting(QWidget* parent)
: T_BasePage(parent)
{
// 预览窗口标题
ElaWindow* window = dynamic_cast<ElaWindow*>(parent);
setWindowTitle("Setting");
ElaText* themeText = new ElaText("主题设置", this);
themeText->setWordWrap(false);
themeText->setTextPixelSize(18);
_themeComboBox = new ElaComboBox(this);
_themeComboBox->addItem("日间模式");
_themeComboBox->addItem("夜间模式");
ElaScrollPageArea* themeSwitchArea = new ElaScrollPageArea(this);
QHBoxLayout* themeSwitchLayout = new QHBoxLayout(themeSwitchArea);
ElaText* themeSwitchText = new ElaText("主题切换", this);
themeSwitchText->setWordWrap(false);
themeSwitchText->setTextPixelSize(15);
themeSwitchLayout->addWidget(themeSwitchText);
themeSwitchLayout->addStretch();
themeSwitchLayout->addWidget(_themeComboBox);
connect(_themeComboBox, QOverload<int>::of(&ElaComboBox::currentIndexChanged), this, [=](int index) {
if (index == 0)
{
eTheme->setThemeMode(ElaThemeType::Light);
}
else
{
eTheme->setThemeMode(ElaThemeType::Dark);
}
});
connect(eTheme, &ElaTheme::themeModeChanged, this, [=](ElaThemeType::ThemeMode themeMode) {
_themeComboBox->blockSignals(true);
if (themeMode == ElaThemeType::Light)
{
_themeComboBox->setCurrentIndex(0);
}
else
{
_themeComboBox->setCurrentIndex(1);
}
_themeComboBox->blockSignals(false);
});
ElaText* helperText = new ElaText("应用程序设置", this);
helperText->setWordWrap(false);
helperText->setTextPixelSize(18);
_micaSwitchButton = new ElaToggleSwitch(this);
ElaScrollPageArea* micaSwitchArea = new ElaScrollPageArea(this);
QHBoxLayout* micaSwitchLayout = new QHBoxLayout(micaSwitchArea);
ElaText* micaSwitchText = new ElaText("启用云母效果(跨平台)", this);
micaSwitchText->setWordWrap(false);
micaSwitchText->setTextPixelSize(15);
micaSwitchLayout->addWidget(micaSwitchText);
micaSwitchLayout->addStretch();
micaSwitchLayout->addWidget(_micaSwitchButton);
connect(_micaSwitchButton, &ElaToggleSwitch::toggled, this, [=](bool checked) {
eApp->setIsEnableMica(checked);
});
_logSwitchButton = new ElaToggleSwitch(this);
ElaScrollPageArea* logSwitchArea = new ElaScrollPageArea(this);
QHBoxLayout* logSwitchLayout = new QHBoxLayout(logSwitchArea);
ElaText* logSwitchText = new ElaText("启用日志功能", this);
logSwitchText->setWordWrap(false);
logSwitchText->setTextPixelSize(15);
logSwitchLayout->addWidget(logSwitchText);
logSwitchLayout->addStretch();
logSwitchLayout->addWidget(_logSwitchButton);
connect(_logSwitchButton, &ElaToggleSwitch::toggled, this, [=](bool checked) {
ElaLog::getInstance()->initMessageLog(checked);
if (checked)
{
qDebug() << "日志已启用!";
}
else
{
qDebug() << "日志已关闭!";
}
});
_minimumButton = new ElaRadioButton("Minimum", this);
_compactButton = new ElaRadioButton("Compact", this);
_maximumButton = new ElaRadioButton("Maximum", this);
_autoButton = new ElaRadioButton("Auto", this);
_autoButton->setChecked(true);
ElaScrollPageArea* displayModeArea = new ElaScrollPageArea(this);
QHBoxLayout* displayModeLayout = new QHBoxLayout(displayModeArea);
ElaText* displayModeText = new ElaText("导航栏模式选择", this);
displayModeText->setWordWrap(false);
displayModeText->setTextPixelSize(15);
displayModeLayout->addWidget(displayModeText);
displayModeLayout->addStretch();
displayModeLayout->addWidget(_minimumButton);
displayModeLayout->addWidget(_compactButton);
displayModeLayout->addWidget(_maximumButton);
displayModeLayout->addWidget(_autoButton);
connect(_minimumButton, &ElaRadioButton::toggled, this, [=](bool checked) {
if (checked)
{
window->setNavigationBarDisplayMode(ElaNavigationType::Minimal);
}
});
connect(_compactButton, &ElaRadioButton::toggled, this, [=](bool checked) {
if (checked)
{
window->setNavigationBarDisplayMode(ElaNavigationType::Compact);
}
});
connect(_maximumButton, &ElaRadioButton::toggled, this, [=](bool checked) {
if (checked)
{
window->setNavigationBarDisplayMode(ElaNavigationType::Maximal);
}
});
connect(_autoButton, &ElaRadioButton::toggled, this, [=](bool checked) {
if (checked)
{
window->setNavigationBarDisplayMode(ElaNavigationType::Auto);
}
});
QWidget* centralWidget = new QWidget(this);
centralWidget->setWindowTitle("Setting");
QVBoxLayout* centerLayout = new QVBoxLayout(centralWidget);
centerLayout->addSpacing(30);
centerLayout->addWidget(themeText);
centerLayout->addSpacing(10);
centerLayout->addWidget(themeSwitchArea);
centerLayout->addSpacing(15);
centerLayout->addWidget(helperText);
centerLayout->addSpacing(10);
centerLayout->addWidget(logSwitchArea);
centerLayout->addWidget(micaSwitchArea);
centerLayout->addWidget(displayModeArea);
centerLayout->addStretch();
centerLayout->setContentsMargins(0, 0, 0, 0);
addCentralWidget(centralWidget, true, true, 0);
}
T_Setting::~T_Setting()
{
}