CCIMXDesktop
 
Loading...
Searching...
No Matches
clockwidget.h
1#ifndef CLOCKWIDGET_H
2#define CLOCKWIDGET_H
3#include <QTime>
4#include <QWidget>
5
6namespace Ui {
7class ClockWidget;
8}
9class QTimer;
10
14class ClockWidget : public QWidget {
15 Q_OBJECT
16
17public:
23 explicit ClockWidget(QWidget* parent = nullptr);
29public slots:
33 void process_update_invokation(QTime clockTime);
34
35protected:
36 /* Yep, for the dynamic widgets, we have to, sadly, draw by ourselves */
37 /* Entry for us to draw a clock */
38
43 void paintEvent(QPaintEvent* _paintEvent) override;
48 QSize sizeHint() const override;
49
50private:
51 // Constants
52 static constexpr const int DefaultWidgetSize = 1000;
53 static constexpr const int DialSize = 200;
54 static constexpr const int OuterCircleRadius = 95;
55 static constexpr const int HourTickLength = 10;
56 static constexpr const int MinuteTickLength = 5;
57 static constexpr const int HourTickWidth = 2;
58 static constexpr const int MinuteTickWidth = 1;
59 static constexpr const int CenterDotRadius = 4;
60 static constexpr const int HourHandLength = 50;
61 static constexpr const int MinuteHandLength = 70;
62 static constexpr const int SecondHandLength = 80;
63 static constexpr const int HandWidth = 7;
64 static constexpr const int HourRotationPerHour = 30; // 360 / 12
65 static constexpr const int MinuteRotationPerMinute = 6; // 360 / 60
66 static constexpr const int SecondRotationPerSecond = 6; // 360 / 60
67
68 /* fonts */
69 static constexpr const int NumberDistanceFromCenter = 70;
70 static constexpr const int NumberFontSize = 14;
71 Ui::ClockWidget* ui;
72 QTime cur_time;
73 /* paintEvent periodly and invoke the funcList in sequence */
74 void drawBackground(QPainter* painter);
75 void drawTicks(QPainter* painter);
76 void drawHands(QPainter* painter);
77 void drawNumbers(QPainter* painter);
78 void drawCenterDot(QPainter* painter);
79};
80
81#endif // CLOCKWIDGET_H
The ClockWidget class draws the Clock Sessions.
Definition clockwidget.h:14
void process_update_invokation(QTime clockTime)
timeout hooks of the internal_updater
Definition clockwidget.cpp:36
QSize sizeHint() const override
sizeHint provides the size hint for the clock widget
Definition clockwidget.cpp:32
void paintEvent(QPaintEvent *_paintEvent) override
paintEvent the event everytime mainWidgets hopes to draw
Definition clockwidget.cpp:17
~ClockWidget()
Destroy the Clock Widget object.
Definition clockwidget.cpp:13