-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclock.cpp
More file actions
56 lines (44 loc) · 1.3 KB
/
clock.cpp
File metadata and controls
56 lines (44 loc) · 1.3 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
#include "clock.h"
Clock::Clock(QWidget *parent)
: QWidget{parent}
{
clockLayout = new QGridLayout(this);
labelContainer = new QWidget();
labelLayout = new QVBoxLayout(labelContainer);
lbClock = new QLabel();
lbClock->setAlignment(Qt::AlignCenter);
lbClock->setFont(QFont("Sans Serif", 32));
lbClock->setText("00:00");
lbState = new QLabel();
lbState->setAlignment(Qt::AlignCenter);
lbState->setFont(QFont("Sans Serif", 16));
lbState->setText("-");
labelLayout->addWidget(lbClock);
labelLayout->addWidget(lbState);
// Set arc
arc = new TProgressArcStatic();
arc->setPenWidth(20);
arc->setAngle(217);
arc->setMaximum(70);
arc->setValue(70);
clockLayout->addWidget(arc, 0, 0, -1, -1, Qt::AlignCenter);
clockLayout->addWidget(labelContainer, 0, 0, Qt::AlignCenter);
clockLayout->setRowStretch(0, 1);
clockLayout->setColumnStretch(0, 1);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}
void Clock::updateClock(QString text) {
lbClock->setText(text);
update();
}
void Clock::updateState(QString text) {
lbState->setText(text);
update();
}
void Clock::updateArc(int value) {
arc->setValue(value);
update();
}
void Clock::setArcColor(QColor color) {
arc->setProgressColor(color);
}