-
Notifications
You must be signed in to change notification settings - Fork 3
/
mainwidget.cpp
147 lines (119 loc) · 4.69 KB
/
mainwidget.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
#include "mainwidget.h"
#include <QLabel>
#include <QHBoxLayout>
#include <QFont>
#include <QFile>
#include <QDir>
#include <QDebug>
#include <QSettings>
#include <QString>
MainWidget::MainWidget(EbOptions *options, QWidget *parent)
: QWidget(parent)
{
g_opt = options;
/* Initialization interface */
initMainUI();
connect(menuBtnGroup, SIGNAL(buttonClicked(int)), this, SLOT(menuBtnGroupToggled(int)));
}
MainWidget::~MainWidget()
{
/* You do not neet to do that since used flock */
//system("rm /home/root/.lock_easybench");
}
void MainWidget::initMainUI()
{
setWindowTitle(tr("Easy Bench"));
#if FIXED_WINDOWN
setFixedSize(g_opt->fixedSize().width(), g_opt->fixedSize().height());
#else
setFixedSize(LCD_WIDTH, LCD_HEIGHT - TITLE_HEIGHT);
#endif
/* Not consistent between desktop and embedded Qt */
//setWindowFlags(Qt::FramelessWindowHint);
//---------- 标题栏 -----------
/*
titleWidget = new QWidget(this);
titleWidget->setGeometry(0, 0, 1024, 48);
titleWidget->setObjectName("titleWidget");
closeBtn = new QPushButton(tr("close"), titleWidget);
closeBtn->setGeometry(1024-100, 4, 96, 40);
connect(closeBtn, SIGNAL(clicked()), this, SLOT(close()));
*/
//---------- 菜单栏 -----------
menuWidget = new QWidget(this);
menuWidget->setGeometry(0, 0, 124, 720);
menuWidget->setObjectName("menuWidget");
//menuWidget->setStyleSheet("background-color: #202020");
menuBtnGroup = new QButtonGroup(this);
QSize size(124, 90);
QStringList menuList;
/*
menuList << tr("LCD") << tr("Touch") << tr("Camera") << tr("Network")
<< tr("Serial Port") << tr("Settings") << tr("Monitor") << tr("Version"); */
menuList << tr("显示") << tr("触摸") << tr("相机") << tr("网络")
<< tr("系统") << tr("席位") << tr("监测") << tr("版本");
for(int i=0; i<8; i++)
{
QToolButton *menuBtn = new QToolButton(menuWidget);
menuBtn->setObjectName("menuBtn");
menuBtnGroup->addButton(menuBtn, PAGE_LCD + i); // 将自定义的button加入customGroup中,并为其设置id
//menuBtn->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); //文字处于图片下方
//QPixmap pixmap(":/images/title_icon_48.png");
//QPixmap pixmap2(QString(":/images/menu_%1.png").arg(i+1));
//menuBtn->setIcon(pixmap2); // 为按钮设置图标
//menuBtn->setIconSize(size); // 设置图片大小
menuBtn->setFixedSize(size.width(), size.height()); // 设置按钮大小
menuBtn->setText(menuList.at(i)); // 设置提示文字
menuBtn->setCheckable(true);
menuBtn->setChecked(false);
//menuBtn->setStyleSheet(menuBtnUncheckedSS); // 所有按钮初始状态为unchecked
//customBtnBarLayout->addWidget(menuBtn); // 添加到布局
menuBtn->setGeometry(0, i*size.height(), size.width(), size.height());
//menuBtn->show();
}
//------------------- Page Widget ----------------------
centerPages = new QStackedWidget(this);
centerPages->setGeometry(124, 0, 900, 720);
lcdPage = new LcdPage(g_opt, this);
touchPage = new TouchPage(g_opt, this);
cameraPage = new CameraPage(g_opt, this);
//datetimePage = new DatetimePage(this);
networkPage = new NetworkPage(g_opt, this);
systemPage = new SystemPage(g_opt, this);
seatPage = new SeatPage(g_opt, this); // Settings Page
monitorPage = new MonitorPage(g_opt, this);
versionPage = new VersionPage(g_opt, this);
//realtimePage = new RealtimePage(this);
centerPages->addWidget(lcdPage);
centerPages->addWidget(touchPage);
centerPages->addWidget(cameraPage);
//centerPages->addWidget(datetimePage);
centerPages->addWidget(networkPage);
centerPages->addWidget(systemPage);
centerPages->addWidget(seatPage); // Settings Page
centerPages->addWidget(monitorPage);
centerPages->addWidget(versionPage);
//centerPages->addWidget(realtimePage);
centerPages->setCurrentWidget(lcdPage);
// 系统配置
prevPage = PAGE_LCD;
currPage = PAGE_LCD;
/*
QLabel *label = new QLabel(tr("Hello World !"), this);
label->setFixedSize(1024, 720);
label->setAlignment(Qt::AlignCenter);
QFont font;
font.setBold(true);
font.setPixelSize(36);
label->setFont(font);
label->setStyleSheet("border-style: outset; border-width: 8px; border-color: red; color: Blue; background-color: yellow");
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->addWidget(label);
setLayout(mainLayout);
*/
}
void MainWidget::menuBtnGroupToggled(int id)
{
centerPages->setCurrentIndex(id);
}