diff --git a/qt4/style/qtcurve.h b/qt4/style/qtcurve.h --- a/qt4/style/qtcurve.h +++ b/qt4/style/qtcurve.h @@ -436,9 +436,10 @@ mutable const QWidget *m_sbWidget; mutable QLabel *m_clickedLabel; QSet m_progressBars; - int m_progressBarAnimateTimer, + mutable int m_progressBarAnimateTimer, + m_progressBarAnimateFps, m_animateStep; - QTime m_timer; + mutable QTime m_timer; mutable QMap m_titleBarButtonsCols; mutable QList m_mdiButtons[2]; // 0=left, 1=right mutable int m_titlebarHeight; diff --git a/qt4/style/qtcurve.cpp b/qt4/style/qtcurve.cpp --- a/qt4/style/qtcurve.cpp +++ b/qt4/style/qtcurve.cpp @@ -2694,10 +2694,15 @@ if(bar) { m_progressBars.insert(bar); - if (1==m_progressBars.size()) - { - m_timer.start(); - m_progressBarAnimateTimer = startTimer(1000 / constProgressBarFps); + if (!m_progressBarAnimateTimer) { + if (opts.animatedProgress || (0 == bar->minimum() && 0 == bar->maximum())) { + // we know we'll need a timer, start it at once + if (m_timer.isNull()) { + m_timer.start(); + } + m_progressBarAnimateFps = constProgressBarFps; + m_progressBarAnimateTimer = startTimer(1000/m_progressBarAnimateFps); + } } } else if(!POPUP_MENUS_SQUARE(opts) && object->inherits("QComboBoxPrivateContainer")) { @@ -2729,6 +2734,7 @@ } break; } + case QEvent::Close: case QEvent::Destroy: case QEvent::Hide: { if((BLEND_TITLEBAR || opts.windowBorder&WINDOW_BORDER_USE_MENUBAR_COLOR_FOR_TITLEBAR || opts.menubarHiding&HIDE_KWIN) && @@ -2821,15 +2827,22 @@ void Style::timerEvent(QTimerEvent *event) { if (event->timerId() == m_progressBarAnimateTimer) { + bool hasAnimation = false; m_animateStep = m_timer.elapsed() / (1000 / constProgressBarFps); foreach (QProgressBar *bar, const_(m_progressBars)) { if ((opts.animatedProgress && 0 == m_animateStep % 2 && bar->value() != bar->minimum() && bar->value() != bar->maximum()) || (0 == bar->minimum() && 0 == bar->maximum())) { bar->update(); + hasAnimation = true; } } + if (Q_UNLIKELY(!hasAnimation && m_progressBarAnimateFps == constProgressBarFps)) { + // go back to "idling frequency" mode. + killTimer(m_progressBarAnimateTimer); + m_progressBarAnimateTimer = 0; + } } event->ignore(); @@ -5915,6 +5928,15 @@ painter->save(); + if (!m_progressBarAnimateTimer && (opts.animatedProgress || indeterminate)) { + if (m_timer.isNull()) { + m_timer.start(); + } + // now we'll need a timer, start it at the regular frequency + m_progressBarAnimateFps = constProgressBarFps; + m_progressBarAnimateTimer = const_cast(this)->startTimer(1000/m_progressBarAnimateFps); + } + if(indeterminate) //Busy indicator { int chunkSize(PROGRESS_CHUNK_WIDTH*3.4), diff --git a/qt5/style/qtcurve.h b/qt5/style/qtcurve.h --- a/qt5/style/qtcurve.h +++ b/qt5/style/qtcurve.h @@ -556,9 +556,10 @@ mutable const QWidget *m_sbWidget; mutable QLabel *m_clickedLabel; QSet m_progressBars; - int m_progressBarAnimateTimer, + mutable int m_progressBarAnimateTimer, + m_progressBarAnimateFps, m_animateStep; - QTime m_timer; + mutable QTime m_timer; mutable QMap m_titleBarButtonsCols; mutable QList m_mdiButtons[2]; // 0=left, 1=right mutable int m_titlebarHeight; diff --git a/qt5/style/qtcurve_api.cpp b/qt5/style/qtcurve_api.cpp --- a/qt5/style/qtcurve_api.cpp +++ b/qt5/style/qtcurve_api.cpp @@ -1313,10 +1313,15 @@ if(bar) { m_progressBars.insert(bar); - if (1==m_progressBars.size()) - { - m_timer.start(); - m_progressBarAnimateTimer = startTimer(1000 / constProgressBarFps); + if (!m_progressBarAnimateTimer) { + if (opts.animatedProgress || (0 == bar->minimum() && 0 == bar->maximum())) { + // we know we'll need a timer, start it at once + if (m_timer.isNull()) { + m_timer.start(); + } + m_progressBarAnimateFps = constProgressBarFps; + m_progressBarAnimateTimer = startTimer(1000/m_progressBarAnimateFps); + } } } else if (!(opts.square & SQUARE_POPUP_MENUS) && object->inherits("QComboBoxPrivateContainer")) { @@ -1351,6 +1356,7 @@ } break; } + case QEvent::Close: case QEvent::Destroy: case QEvent::Hide: { if ((BLEND_TITLEBAR || @@ -1420,15 +1426,22 @@ void Style::timerEvent(QTimerEvent *event) { if (event->timerId() == m_progressBarAnimateTimer) { + bool hasAnimation = false; m_animateStep = m_timer.elapsed() / (1000 / constProgressBarFps); for (QProgressBar *bar: const_(m_progressBars)) { if ((opts.animatedProgress && 0 == m_animateStep % 2 && bar->value() != bar->minimum() && bar->value() != bar->maximum()) || (0 == bar->minimum() && 0 == bar->maximum())) { bar->update(); + hasAnimation = true; } } + if (Q_UNLIKELY(!hasAnimation && m_progressBarAnimateFps == constProgressBarFps)) { + // go back to "idling frequency" mode. + killTimer(m_progressBarAnimateTimer); + m_progressBarAnimateTimer = 0; + } } event->ignore(); @@ -2816,6 +2829,15 @@ painter->save(); + if (!m_progressBarAnimateTimer && (opts.animatedProgress || indeterminate)) { + if (m_timer.isNull()) { + m_timer.start(); + } + // now we'll need a timer, start it at the regular frequency + m_progressBarAnimateFps = constProgressBarFps; + m_progressBarAnimateTimer = const_cast(this)->startTimer(1000/m_progressBarAnimateFps); + } + if (indeterminate) { //Busy indicator int chunkSize = PROGRESS_CHUNK_WIDTH * 3.4;