@@ -17,7 +17,19 @@ BlockClockDial::BlockClockDial(QQuickItem *parent)
17
17
, m_background_color{QColor (" #2D2D2D" )}
18
18
, m_confirmation_colors{QList<QColor>{}}
19
19
, m_time_tick_color{QColor (" #000000" )}
20
+ , m_animation_timer{QTimer (this )}
21
+ , m_delay_timer{QTimer (this )}
20
22
{
23
+ m_animation_timer.setTimerType (Qt::PreciseTimer);
24
+ m_animation_timer.setInterval (16 );
25
+ m_delay_timer.setTimerType (Qt::PreciseTimer);
26
+ m_delay_timer.setSingleShot (true );
27
+ m_delay_timer.setInterval (5000 );
28
+ connect (&m_animation_timer, &QTimer::timeout,
29
+ this , [=]() { this ->update (); });
30
+ connect (&m_delay_timer, &QTimer::timeout,
31
+ this , [=]() { this ->m_animation_timer .start (); });
32
+ m_delay_timer.start ();
21
33
}
22
34
23
35
void BlockClockDial::setupConnectingGradient (const QPen & pen)
@@ -54,7 +66,15 @@ void BlockClockDial::setVerificationProgress(double progress)
54
66
55
67
void BlockClockDial::setConnected (bool connected)
56
68
{
57
- m_is_connected = connected;
69
+ if (m_is_connected != connected) {
70
+ m_is_connected = connected;
71
+ m_delay_timer.stop ();
72
+ if (m_is_connected) {
73
+ m_animation_timer.stop ();
74
+ } else {
75
+ m_delay_timer.start ();
76
+ }
77
+ }
58
78
update ();
59
79
}
60
80
@@ -178,7 +198,6 @@ void BlockClockDial::paintConnectingAnimation(QPainter * painter)
178
198
painter->setPen (pen);
179
199
painter->drawArc (bounds, m_connecting_start_angle * 16 , m_connecting_end_angle * 16 );
180
200
m_connecting_start_angle = decrementGradientAngle (m_connecting_start_angle);
181
- update ();
182
201
}
183
202
184
203
void BlockClockDial::paintBackground (QPainter * painter)
@@ -228,7 +247,7 @@ void BlockClockDial::paint(QPainter * painter)
228
247
229
248
if (paused ()) return ;
230
249
231
- if (!( connected () )) {
250
+ if (m_animation_timer. isActive ( )) {
232
251
paintConnectingAnimation (painter);
233
252
return ;
234
253
}
0 commit comments