-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.cpp
108 lines (92 loc) · 3.41 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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "debugwindow.h"
#include "QObject"
#include <QFileSystemWatcher>
#include <QFile>
#include <QTextStream>
#include <QDebug>
#include <QDir>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
platform_bat = new q_num(this);
connect(platform_bat, SIGNAL(valueChanged(int)), this, SLOT(readplatformbat()));
platform_bat->setValue(100);
platform_forward = new q_bool(this);
connect(platform_forward, SIGNAL(valueChanged(bool)), this, SLOT(readplatformforward()));
platform_forward->setValue(false);
ui->up_arrow_label->hide();
platform_backward = new q_bool(this);
connect(platform_backward, SIGNAL(valueChanged(bool)), this, SLOT(readplatformbackward()));
platform_backward->setValue(false);
ui->down_arrow_label->hide();
platform_cw = new q_bool(this);
connect(platform_cw, SIGNAL(valueChanged(bool)), this, SLOT(readplatformcw()));
platform_cw->setValue(false);
ui->turning_label->hide();
platform_ccw = new q_bool(this);
connect(platform_ccw, SIGNAL(valueChanged(bool)), this, SLOT(readplatformccw()));
platform_ccw->setValue(false);
ui->turning_label->hide();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::readplatformbat()
{
ui->progressBar_2->setValue(platform_bat->getValue());
}
void MainWindow::readplatformforward()
{
QPixmap up_arrow("../Qt_interface/resources/static_resources/up.jpg");
bool state = platform_forward->getValue();
if (state == true){
ui->up_arrow_label->show();
ui->up_arrow_label->setPixmap(up_arrow.scaled(ui->up_arrow_label->width(), ui->up_arrow_label->height(), Qt::KeepAspectRatio));
} else {
ui->up_arrow_label->hide();
}
}
void MainWindow::readplatformbackward()
{
QPixmap down_arrow("../Qt_interface/resources/static_resources/down.jpg");
bool state = platform_backward->getValue();
if (state == true){
ui->down_arrow_label->show();
ui->down_arrow_label->setPixmap(down_arrow.scaled(ui->down_arrow_label->width(), ui->down_arrow_label->height(), Qt::KeepAspectRatio));
} else {
ui->down_arrow_label->hide();
}
}
void MainWindow::readplatformcw()
{
QPixmap clockwise("../Qt_interface/resources/static_resources/cw.jpg");
bool state = platform_cw->getValue();
if (state == true){
ui->turning_label->show();
ui->turning_label->setPixmap(clockwise.scaled(ui->turning_label->width(), ui->turning_label->height(), Qt::KeepAspectRatio));
} else if (platform_cw->getValue() == false && platform_ccw->getValue() == false) {
ui->turning_label->hide();
}
}
void MainWindow::readplatformccw()
{
QPixmap counter_clockwise("../Qt_interface/resources/static_resources/ccw.jpg");
bool state = platform_ccw->getValue();
if (state == true){
ui->turning_label->show();
ui->turning_label->setPixmap(counter_clockwise.scaled(ui->turning_label->width(), ui->turning_label->height(), Qt::KeepAspectRatio));
} else if (platform_cw->getValue() == false && platform_ccw->getValue() == false) {
ui->turning_label->hide();
}
}
void MainWindow::on_debugButton_clicked()
{
DebugWindow debugwindow;
debugwindow.setModal(true);
debugwindow.exec();
}