@@ -17,7 +17,19 @@ BlockClockDial::BlockClockDial(QQuickItem *parent)
1717, m_background_color{QColor (" #2D2D2D" )}
1818, m_confirmation_colors{QList<QColor>{}}
1919, m_time_tick_color{QColor (" #000000" )}
20+ , m_animation_timer{QTimer (this )}
21+ , m_delay_timer{QTimer (this )}
2022{
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 ();
2133}
2234
2335void BlockClockDial::setupConnectingGradient (const QPen & pen)
@@ -54,7 +66,15 @@ void BlockClockDial::setVerificationProgress(double progress)
5466
5567void BlockClockDial::setConnected (bool connected)
5668{
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+ }
5878 update ();
5979}
6080
@@ -178,7 +198,6 @@ void BlockClockDial::paintConnectingAnimation(QPainter * painter)
178198 painter->setPen (pen);
179199 painter->drawArc (bounds, m_connecting_start_angle * 16 , m_connecting_end_angle * 16 );
180200 m_connecting_start_angle = decrementGradientAngle (m_connecting_start_angle);
181- update ();
182201}
183202
184203void BlockClockDial::paintBackground (QPainter * painter)
@@ -228,7 +247,7 @@ void BlockClockDial::paint(QPainter * painter)
228247
229248 if (paused ()) return ;
230249
231- if (!( connected () )) {
250+ if (m_animation_timer. isActive ( )) {
232251 paintConnectingAnimation (painter);
233252 return ;
234253 }
0 commit comments