-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatusbarwidgets.cpp
More file actions
112 lines (92 loc) · 3.13 KB
/
statusbarwidgets.cpp
File metadata and controls
112 lines (92 loc) · 3.13 KB
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
#include <QDateTime>
#include "statusbarwidgets.hpp"
#include "utility.hpp"
StatusBarWidgets::StatusBarWidgets(QObject *parent) : QObject(parent)
{
config = Configuration::getInstance();
time = new QLabel();
initLabelStyle(time);
initTime();
habSerial = new QLabel();
initLabelStyle(habSerial);
initHabSerial();
localGpsSerial = new QLabel();
initLabelStyle(localGpsSerial);
initLocalGpsSerial();
serverSync = new QLabel();
initLabelStyle(serverSync);
initServerSync();
timeTimer = new QTimer();
initTimeTimer();
updateFromConfig();
}
StatusBarWidgets::~StatusBarWidgets()
{
delete time;
}
void StatusBarWidgets::initLabelStyle(QLabel* label)
{
label->setFrameShape(QFrame::StyledPanel);
// label->setFrameShadow(QFrame::Sunken);
label->setAlignment(Qt::AlignCenter);
label->setMinimumWidth(50);
label->setStyleSheet("padding-left: 3px; padding-right: 3px;");
}
void StatusBarWidgets::initTime()
{
time->setText("time");
}
void StatusBarWidgets::initHabSerial()
{
habSerial->setText("habSerial");
}
void StatusBarWidgets::initLocalGpsSerial()
{
localGpsSerial->setText("localGps");
}
void StatusBarWidgets::initServerSync()
{
serverSync->setText("serverSync");
}
void StatusBarWidgets::initTimeTimer()
{
timeTimer->setInterval(1000);
timeTimer->setSingleShot(false);
timeTimer->setTimerType(Qt::VeryCoarseTimer);
timeTimer->start();
connect(timeTimer, SIGNAL(timeout()), this, SLOT(updateTime()));
updateTime();
}
void StatusBarWidgets::updateTime()
{
time->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"));
}
void StatusBarWidgets::updateFromConfig()
{
QString text;
text = QString("<strong>HAB:</strong> %1 %2 %3")
.arg(config->getHabSerialPort())
.arg(config->getHabSerialSpeed())
.arg(Utility::serialPortParams(QSerialPort::Data8, QSerialPort::NoParity, QSerialPort::OneStop));
habSerial->setText(text);
habSerial->setEnabled(config->getHabRunning());
text = "<strong>Local GPS:</strong> disabled";
if(config->getLocalGpsSerialEnable() && config->getLocalGpsSerialPort().length() > 0) {
QString serialPortParams = Utility::serialPortParams(config->getLocalGpsSerialDataBits(),
config->getLocalGpsSerialParity(),
config->getLocalGpsSerialStopBits());
text = QString("<strong>Local GPS:</strong> %1 %2 %3")
.arg(config->getLocalGpsSerialPort())
.arg(config->getLocalGpsSerialSpeed())
.arg(serialPortParams);
}
localGpsSerial->setText(text);
localGpsSerial->setEnabled(config->getLocalGpsRunning());
text = "<strong>Server SYNC:</strong> disabled";
if(config->getServerSyncEnable() && config->getServerSyncAddress().length() > 0)
text = QString("<strong>Server SYNC:</strong> %1:%2")
.arg(config->getServerSyncAddress())
.arg(config->getServerSyncPort());
serverSync->setText(text);
serverSync->setEnabled(config->getServerSyncRunning());
}