-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmainwindow.cpp
140 lines (116 loc) · 2.75 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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QGraphicsDropShadowEffect>
#include <QButtonGroup>
#include "devicesystem.h"
#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
//导航按键组
QButtonGroup *buttonGroupPage = new QButtonGroup(this);
buttonGroupPage->addButton(ui->buttonInfo);
buttonGroupPage->addButton(ui->buttonMeasure);
buttonGroupPage->addButton(ui->buttonTrack);
buttonGroupPage->addButton(ui->buttonReport);
buttonGroupPage->addButton(ui->buttonHelp);
//设置阴影
QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(this);
shadow->setOffset(2, 2);
shadow->setColor(QColor(QRgb(0x0)));
shadow->setBlurRadius(30);
ui->stackedWidget->setGraphicsEffect(shadow);
ui->stackedWidget->setCurrentIndex(0);
//qDebug() << "mainwindow: " << QThread::currentThreadId();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_buttonInfo_pressed()
{
ui->stackedWidget->setCurrentIndex(0);
}
void MainWindow::on_buttonMeasure_pressed()
{
ui->stackedWidget->setCurrentIndex(1);
}
void MainWindow::on_buttonTrack_pressed()
{
ui->stackedWidget->setCurrentIndex(2);
ui->pageTrack->paintChart();
}
void MainWindow::on_buttonReport_pressed()
{
ui->stackedWidget->setCurrentIndex(3);
ui->pageTrack->paintChart();
ui->pageReport->loadReport();
}
void MainWindow::on_buttonHelp_pressed()
{
ui->stackedWidget->setCurrentIndex(4);
}
void MainWindow::on_buttonMin_clicked()
{
showMinimized();
}
void MainWindow::on_buttonMax_clicked(bool checked)
{
if(checked)
{
showMaximized();
}
else
{
showNormal();
}
}
void MainWindow::on_buttonClose_clicked()
{
close();
}
void MainWindow::on_pushButtonLogo_clicked()
{
DeviceSystem::getInstance()->getSerialPort()->writeData();
}
void MainWindow::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
{
m_leftButtonPressed = true;
m_start = event->globalPos();
}
}
void MainWindow::mouseMoveEvent(QMouseEvent *event)
{
if(m_leftButtonPressed)
{
move(geometry().topLeft() + event->globalPos() - m_start);
m_start = event->globalPos();
}
}
void MainWindow::mouseReleaseEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
{
m_leftButtonPressed = false;
}
}
void MainWindow::mouseDoubleClickEvent(QMouseEvent *event)
{
static bool noraml=true;
Q_UNUSED(event);
if(noraml)
{
showMaximized();
noraml = false;
}
else
{
showNormal();
noraml = true;
}
}