forked from kakaZzzz/dpc_linux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
156 lines (136 loc) · 3.94 KB
/
mainwindow.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
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
// init ui control
initUI();
}
MainWindow::~MainWindow()
{
delete ui;
delete m_customkey_widget;
delete m_customknob_widget;
delete m_radilight_widget;
delete m_keyset_widget;
delete m_tab_customkey;
delete m_tab_customknob;
delete m_tab_light;
delete m_tab_config;
delete m_label_area;
delete m_device_comm;
delete m_dev_db;
}
// init ui control
void MainWindow::initUI()
{
m_current_profile = 1;
MainWindow::m_device_comm = new DeviceComm();
QString device_name = MainWindow::m_device_comm->enumerateDevice();
setWindowTitle(device_name);
MainWindow::m_dev_db = new DeviceDB();
MainWindow::m_dev_db->writeRadiData(1);
m_current_tab = 1;
// control
m_tab_customkey = new tabButton(":/image/button/icon_menu_customkey.png", this);
m_tab_customkey->setGeometry(1, 20, 44, 44);
m_tab_customkey->setTabCheck(true);
m_tab_customkey->show();
m_tab_customknob = new tabButton(":/image/button/icon_menu_knob.png", this);
m_tab_customknob->setGeometry(1, 20 + 44, 44, 44);
m_tab_customknob->show();
m_tab_light = new tabButton(":/image/button/icon_menu_radi.png", this);
m_tab_light->setGeometry(1, 20 + 44 * 2, 44, 44);
m_tab_light->show();
m_tab_config = new tabButton(":/image/button/icon_menu_set.png", this);
m_tab_config->setGeometry(1, 20 + 44 * 3, 44, 44);
m_tab_config->show();
m_label_area = new QLabel(this);
m_label_area->setStyleSheet("border-image:url(:/image/img_area_opera.png)");
m_label_area->setGeometry(45, 0, 307, 700);
m_label_area->show();
connect(m_tab_customkey, SIGNAL(clicked()), this, SLOT(slot_click_customkey()));
connect(m_tab_customknob, SIGNAL(clicked()), this, SLOT(slot_click_customknob()));
connect(m_tab_light, SIGNAL(clicked()), this, SLOT(slot_click_light()));
connect(m_tab_config, SIGNAL(clicked()), this, SLOT(slot_click_config()));
// child window
m_customkey_widget = new CustomKeyWidget(this);
m_customkey_widget->move(45, 20);
m_customkey_widget->show();
m_customknob_widget = new CustomKnobWidget(this);
m_customknob_widget->move(45, 20);
m_customknob_widget->hide();
m_radilight_widget = new RadiLightWidget(this, m_device_comm, m_dev_db);
m_radilight_widget->move(45, 20);
m_radilight_widget->hide();
m_keyset_widget = new KeySetwidget(this);
m_keyset_widget->move(45, 20);
m_keyset_widget->hide();
}
// set tab status
void MainWindow::setTabStatus(int tab)
{
if (m_current_tab == 1)
{
m_tab_customkey->setTabCheck(false);
m_customkey_widget->hide();
}
else if (m_current_tab == 2)
{
m_tab_customknob->setTabCheck(false);
m_customknob_widget->hide();
}
else if (m_current_tab == 3)
{
m_tab_light->setTabCheck(false);
m_radilight_widget->hide();
}
else if (m_current_tab == 4)
{
m_tab_config->setTabCheck(false);
m_keyset_widget->hide();
}
if (tab == 1)
{
m_tab_customkey->setTabCheck(true);
m_customkey_widget->show();;
}
else if (tab == 2)
{
m_tab_customknob->setTabCheck(true);
m_customknob_widget->show();
}
else if (tab == 3)
{
m_tab_light->setTabCheck(true);
m_radilight_widget->show();
}
else if (tab == 4)
{
m_tab_config->setTabCheck(true);
m_keyset_widget->show();
}
m_current_tab = tab;
}
void MainWindow::slot_click_customkey()
{
// set tab status
setTabStatus(1);
}
void MainWindow::slot_click_customknob()
{
// set tab status
setTabStatus(2);
}
void MainWindow::slot_click_light()
{
// set tab status
setTabStatus(3);
}
void MainWindow::slot_click_config()
{
// set tab status
setTabStatus(4);
}