Index: qt4/style/qtcurve.h =================================================================== --- qt4/style/qtcurve.h +++ qt4/style/qtcurve.h @@ -437,6 +437,7 @@ mutable QLabel *m_clickedLabel; QSet m_progressBars; int m_progressBarAnimateTimer, + m_progressBarAnimateFps, m_animateStep; QTime m_timer; mutable QMap m_titleBarButtonsCols; Index: qt4/style/qtcurve.cpp =================================================================== --- qt4/style/qtcurve.cpp +++ qt4/style/qtcurve.cpp @@ -576,6 +576,7 @@ static const int constWindowMargin = 2; static const int constProgressBarFps = 20; +static const int constProgressBarIdleFps = 2; static const int constTabPad = 6; static const QLatin1String constDwtClose("qt_dockwidget_closebutton"); @@ -2694,10 +2695,15 @@ if(bar) { m_progressBars.insert(bar); - if (1==m_progressBars.size()) + if (!m_progressBarAnimateTimer) { m_timer.start(); - m_progressBarAnimateTimer = startTimer(1000 / constProgressBarFps); + // set the short interval when required, otherwise a less expensive "idling" interval + // that still maintains a reasonable reaction time when a progress bar is toggled + // into "busy" (animated) mode. + m_progressBarAnimateFps = (opts.animatedProgress || (0 == bar->minimum() && 0 == bar->maximum())) ? + constProgressBarFps : constProgressBarIdleFps; + m_progressBarAnimateTimer = startTimer(1000/m_progressBarAnimateFps); } } else if(!POPUP_MENUS_SQUARE(opts) && object->inherits("QComboBoxPrivateContainer")) { @@ -2821,14 +2827,28 @@ 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 (hasAnimation && m_progressBarAnimateFps == constProgressBarIdleFps) { + // go into "high frequency" mode because we're no longer firing + // idly. + killTimer(m_progressBarAnimateTimer); + m_progressBarAnimateFps = constProgressBarFps; + m_progressBarAnimateTimer = startTimer(1000/m_progressBarAnimateFps); + } else if (!hasAnimation && m_progressBarAnimateFps == constProgressBarFps) { + // go back to "idling frequency" mode. + killTimer(m_progressBarAnimateTimer); + m_progressBarAnimateFps = constProgressBarIdleFps; + m_progressBarAnimateTimer = startTimer(1000/m_progressBarAnimateFps); } } Index: qt5/style/qtcurve.h =================================================================== --- qt5/style/qtcurve.h +++ qt5/style/qtcurve.h @@ -557,6 +557,7 @@ mutable QLabel *m_clickedLabel; QSet m_progressBars; int m_progressBarAnimateTimer, + m_progressBarAnimateFps, m_animateStep; QTime m_timer; mutable QMap m_titleBarButtonsCols; Index: qt5/style/qtcurve_api.cpp =================================================================== --- qt5/style/qtcurve_api.cpp +++ qt5/style/qtcurve_api.cpp @@ -1313,10 +1313,15 @@ if(bar) { m_progressBars.insert(bar); - if (1==m_progressBars.size()) + if (!m_progressBarAnimateTimer) { m_timer.start(); - m_progressBarAnimateTimer = startTimer(1000 / constProgressBarFps); + // set the short interval when required, otherwise a less expensive "idling" interval + // that still maintains a reasonable reaction time when a progress bar is toggled + // into "busy" (animated) mode. + m_progressBarAnimateFps = (opts.animatedProgress || (0 == bar->minimum() && 0 == bar->maximum())) ? + constProgressBarFps : constProgressBarIdleFps; + m_progressBarAnimateTimer = startTimer(1000/m_progressBarAnimateFps); } } else if (!(opts.square & SQUARE_POPUP_MENUS) && object->inherits("QComboBoxPrivateContainer")) { @@ -1420,14 +1425,28 @@ 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 (hasAnimation && m_progressBarAnimateFps == constProgressBarIdleFps) { + // go into "high frequency" mode because we're no longer firing + // idly. + killTimer(m_progressBarAnimateTimer); + m_progressBarAnimateFps = constProgressBarFps; + m_progressBarAnimateTimer = startTimer(1000/m_progressBarAnimateFps); + } else if (!hasAnimation && m_progressBarAnimateFps == constProgressBarFps) { + // go back to "idling frequency" mode. + killTimer(m_progressBarAnimateTimer); + m_progressBarAnimateFps = constProgressBarIdleFps; + m_progressBarAnimateTimer = startTimer(1000/m_progressBarAnimateFps); } } Index: qt5/style/qtcurve_p.h =================================================================== --- qt5/style/qtcurve_p.h +++ qt5/style/qtcurve_p.h @@ -44,6 +44,7 @@ static const int constMenuPixmapWidth = 22; static const int constWindowMargin = 2; static const int constProgressBarFps = 20; +static const int constProgressBarIdleFps = 2; static const int constTabPad = 6; static const QLatin1String constDwtClose("qt_dockwidget_closebutton");