2
//#include "../component/commontoolbutton.h"
3
#include <QSignalMapper>
5
#include "mainwindow.h"
7
HomePage::HomePage(QWidget *parent) :
10
this->setFixedSize(900, 326);
12
//set white background color
13
this->setAutoFillBackground(true);
15
palette.setBrush(QPalette::Window, QBrush(Qt::white));
16
this->setPalette(palette);
18
//// QPixmap label_pixmap("");
19
//// movie_label->setPixmap(label_pixmap);
20
//// movie_label->setFixedSize(label_pixmap.size());
22
// scan_button->setFocusPolicy(Qt::NoFocus);
23
// QPixmap pixmap("://res/scan.png");
24
// scan_button->setIcon(pixmap);
25
// scan_button->setIconSize(pixmap.size());
27
version_logo = new QLabel();
28
version_title = new QLabel();
29
version_tip = new QLabel();
30
check_btn = new QPushButton();
31
box_logo = new QLabel();
32
box_title = new QLabel();
33
box_tip = new QLabel();
34
more_text_btn = new QPushButton();
35
more_btn = new QPushButton();
38
camera_manager = NULL;
40
// software_btn = new CommonToolButton();
41
// boot_btn = new CommonToolButton();
42
// camera_btn = new CommonToolButton();
43
// more_text_btn->setAlignment(Qt::AlignCenter);
44
more_text_btn->setObjectName("checkButton");
45
more_text_btn->setCursor(Qt::PointingHandCursor);
46
more_text_btn->setFocusPolicy(Qt::NoFocus);
47
check_btn->setObjectName("checkButton");
48
check_btn->setCursor(Qt::PointingHandCursor);
49
check_btn->setFocusPolicy(Qt::NoFocus);
50
version_title->setObjectName("bigblackLabel");
51
box_title->setObjectName("bigblackLabel");
52
version_tip->setAlignment(Qt::AlignLeft);
53
version_tip->setObjectName("smallgrayLabel");
54
box_tip->setAlignment(Qt::AlignLeft);
55
box_tip->setObjectName("smallgrayLabel");
56
version_tip->setWordWrap(true);//QLabel自动换行
57
box_tip->setWordWrap(true);//QLabel自动换行
58
more_btn->setObjectName("transparentButton");
59
more_btn->setCursor(Qt::PointingHandCursor);
61
version_logo->setFixedSize(65, 65);
62
version_logo->setPixmap(QPixmap("://res/version.png"));
63
box_logo->setFixedSize(65, 65);
64
box_logo->setPixmap(QPixmap("://res/box.png"));
73
if(auto_start != NULL)
78
if(camera_manager != NULL)
80
delete camera_manager;
81
camera_manager = NULL;
85
void HomePage::initUI()
87
QHBoxLayout *layout1 = new QHBoxLayout();
88
layout1->addWidget(version_title);
89
layout1->addWidget(check_btn);
90
layout1->addStretch();
91
layout1->setMargin(0);
92
layout1->setSpacing(5);
93
layout1->setContentsMargins(0,0,0,0);
94
QVBoxLayout *layout2 = new QVBoxLayout();
95
layout2->addStretch();
96
layout2->addLayout(layout1);
97
layout2->addWidget(version_tip);
98
layout2->addStretch();
99
layout2->setMargin(0);
100
layout2->setSpacing(5);
101
layout2->setContentsMargins(0,0,0,0);
102
QHBoxLayout *layout3 = new QHBoxLayout();
103
layout3->addWidget(version_logo/* ,0, Qt::AlignVCenter*/);
104
layout3->addLayout(layout2);
105
layout3->addStretch();
106
layout3->setMargin(0);
107
layout3->setSpacing(5);
108
layout3->setContentsMargins(0,0,0,0);
110
QVBoxLayout *layout4 = new QVBoxLayout();
111
layout4->addStretch();
112
layout4->addWidget(box_title);
113
layout4->addWidget(box_tip);
114
layout4->addStretch();
115
layout4->setMargin(0);
116
layout4->setSpacing(5);
117
layout4->setContentsMargins(0,0,0,0);
122
QStringList icon_list;
123
// icon_list<<"://res/ubuntukylin-software-center"<<"://res/boot"<<"://res/camera";
124
icon_list<<"://res/boot"<<"://res/camera";
125
QStringList text_list;
126
// text_list<< tr("Youker Softeware Center") << tr("Boot Manager") << tr("Camera");
127
text_list << tr("Boot Manager") << tr("Camera");
128
QHBoxLayout *button_layout = new QHBoxLayout();
129
QSignalMapper *signal_mapper = new QSignalMapper(this);
130
for(int i=0; i<icon_list.size(); i++)
132
QToolButton *tool_button = new QToolButton();
133
tool_button->setFocusPolicy(Qt::NoFocus);
134
tool_button->setText(text_list.at(i));
135
tool_button->setIcon(QIcon(icon_list.at(i)));
136
tool_button->setIconSize(QPixmap(icon_list.at(i)).size());
137
tool_button->setAutoRaise(true);
138
tool_button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
139
tool_button->setObjectName("commonToolButton");
140
tool_button->setFixedSize(110, 110);
141
// tool_button->setContentsMargins(0, 20, 0, 30);
143
button_list.append(tool_button);
144
connect(tool_button, SIGNAL(clicked()), signal_mapper, SLOT(map()));
145
signal_mapper->setMapping(tool_button, QString::number(i, 10));
146
button_layout->addWidget(tool_button, 0, Qt::AlignBottom);
148
connect(signal_mapper, SIGNAL(mapped(QString)), this, SLOT(switchPageIndex(QString)));
151
more_btn->setFocusPolicy(Qt::NoFocus);
152
QPixmap pixmap("://res/more.png");
153
more_btn->setIcon(pixmap);
154
more_btn->setIconSize(pixmap.size());
156
QVBoxLayout *more_layout = new QVBoxLayout();
157
more_layout->addStretch();
158
more_layout->addWidget(more_btn);
159
more_layout->addWidget(more_text_btn);
160
more_layout->addStretch();
161
more_layout->setSpacing(0);
162
more_layout->setMargin(0);
163
more_layout->setContentsMargins(0, 0, 0, 0);
165
button_layout->addStretch();
166
button_layout->addLayout(more_layout);
167
// button_layout->addWidget(more_btn, 0, Qt::AlignTop);
168
button_layout->setSpacing(20);
169
button_layout->setMargin(0);
170
button_layout->setContentsMargins(0, 0, 0, 0);
172
QHBoxLayout *layout5 = new QHBoxLayout();
173
layout5->addWidget(box_logo);
174
layout5->addLayout(layout4);
175
layout5->addStretch();
176
layout5->addLayout(button_layout);
177
layout5->setMargin(0);
178
layout5->setSpacing(5);
179
layout5->setContentsMargins(0,0,0,0);
183
QVBoxLayout *main_layout = new QVBoxLayout();
184
main_layout->addLayout(layout3);
185
main_layout->addLayout(layout5);
186
main_layout->setMargin(0);
187
main_layout->setSpacing(50);
188
main_layout->setContentsMargins(60,50,60,80);
190
this->setLayout(main_layout);
193
void HomePage::initConnect()
195
connect(more_btn, SIGNAL(clicked()), p_mainwindow, SLOT(showBoxWidget()));
196
connect(more_btn, SIGNAL(clicked()), p_mainwindow, SIGNAL(chanegBoxToolStatus()));
197
connect(more_text_btn, SIGNAL(clicked()), p_mainwindow, SLOT(showBoxWidget()));
198
connect(more_text_btn, SIGNAL(clicked()), p_mainwindow, SIGNAL(chanegBoxToolStatus()));
201
void HomePage::setLanguage()
203
version_title->setText(tr("Current Version Number") + " " + "V2.0.0");
204
version_tip->setText(tr("Update to the lastest version, make it work better"));
205
check_btn->setText(tr("Check new version"));
206
box_title->setText(tr("Common toolbox"));
207
box_tip->setText(tr("Fast and practical, making the system more personalized"));
208
more_text_btn->setText(tr("More"));
209
more_btn->setToolTip(tr("More"));
212
void HomePage::initBoxTool()
217
void HomePage::switchPageIndex(QString index)
220
// int current_index = index.toInt(&ok, 10);
221
// qDebug() << index;
225
if(auto_start == NULL) {
226
auto_start = new AutoStartWidget(0, sessionProxy);
227
connect(sessionProxy, SIGNAL(tellAutoModel(QStringList)), auto_start, SLOT(readyReciveData(QStringList)));
228
connect(sessionProxy, SIGNAL(showAutoModel()), auto_start, SLOT(readyShowUI()));
229
auto_start->initData();
230
int w_x = p_mainwindow->frameGeometry().topLeft().x() + (900 / 2) - (560 / 2);
231
int w_y = p_mainwindow->frameGeometry().topLeft().y() + (600 /2) - (398 / 2);
232
auto_start->move(w_x, w_y);
237
int w_x = p_mainwindow->frameGeometry().topLeft().x() + (900 / 2) - (560 / 2);
238
int w_y = p_mainwindow->frameGeometry().topLeft().y() + (600 /2) - (398 / 2);
239
auto_start->move(w_x, w_y);
245
else if(index == "1")
247
if(camera_manager == NULL) {
248
camera_manager = new CameraManager(0, sessionProxy);
249
if(sessionProxy->judge_camera_qt())
251
camera_manager->setOKButtonEnable(true);
254
camera_manager->setOKButtonEnable(false);
256
int w_x = p_mainwindow->frameGeometry().topLeft().x() + (900 / 2) - (524 / 2);
257
int w_y = p_mainwindow->frameGeometry().topLeft().y() + (600 /2) - (277 / 2);
258
camera_manager->move(w_x, w_y);
259
camera_manager->show();
260
camera_manager->raise();
263
int w_x = p_mainwindow->frameGeometry().topLeft().x() + (900 / 2) - (524 / 2);
264
int w_y = p_mainwindow->frameGeometry().topLeft().y() + (600 /2) - (277 / 2);
265
camera_manager->move(w_x, w_y);
266
camera_manager->show();
267
camera_manager->raise();
270
// for(int i=0; i<button_list.count(); i++)
272
//// CommonToolButton *tool_button = button_list.at(i);
273
// QToolButton *tool_button = button_list.at(i);
274
// if(current_index == i)
276
// tool_button->setMousePress(true);
280
// tool_button->setMousePress(false);