diff --git a/src/plugins/autotest/testrunner.cpp b/src/plugins/autotest/testrunner.cpp index 31aeeccdbcb..d5f96fa4758 100644 --- a/src/plugins/autotest/testrunner.cpp +++ b/src/plugins/autotest/testrunner.cpp @@ -74,7 +74,8 @@ TestRunner::TestRunner() auto progress = new TaskProgress(taskTree); progress->setDisplayName(Tr::tr("Running Tests")); progress->setAutoStopOnCancel(false); - progress->setHalfLifeTimePerTask(10000); // 10 seconds + using namespace std::chrono_literals; + progress->setHalfLifeTimePerTask(10s); connect(progress, &TaskProgress::canceled, this, [this, progress] { // Progress was a child of task tree which is going to be deleted directly. // Unwind properly. diff --git a/src/plugins/coreplugin/progressmanager/taskprogress.cpp b/src/plugins/coreplugin/progressmanager/taskprogress.cpp index 7f9de529033..b903b74dcc5 100644 --- a/src/plugins/coreplugin/progressmanager/taskprogress.cpp +++ b/src/plugins/coreplugin/progressmanager/taskprogress.cpp @@ -21,7 +21,7 @@ using namespace Tasking; namespace Core { static const int ProgressResolution = 100; // 100 discrete values -static const int TimerInterval = 20; // 20 ms = 50 Hz +static const std::chrono::milliseconds TimerInterval{20}; // 20 ms = 50 Hz class TaskProgressPrivate : public QObject { @@ -44,7 +44,7 @@ public: QPointer m_futureProgress; Id m_id; bool m_isAutoStopOnCancel = true; - int m_halfLifeTimePerTask = 1000; // 1000 ms + std::chrono::milliseconds m_halfLifeTimePerTask{1000}; QString m_displayName; FutureProgress::KeepOnFinishType m_keep = FutureProgress::HideOnFinish; bool m_isSubtitleVisibleInStatusBar = false; @@ -83,7 +83,8 @@ void TaskProgressPrivate::advanceProgress(int newValue) void TaskProgressPrivate::updateProgress() { - const int halfLife = qRound(double(m_halfLifeTimePerTask) / TimerInterval); + using double_millis = std::chrono::duration; + const int halfLife = qRound(m_halfLifeTimePerTask / double_millis(TimerInterval)); const int pMin = ProgressResolution * m_currentProgress; const int pMax = ProgressResolution * (m_currentProgress + 1); const int newValue = MathUtils::interpolateExponential(m_currentTick, halfLife, pMin, pMax); @@ -148,9 +149,9 @@ void TaskProgress::setAutoStopOnCancel(bool enable) d->m_isAutoStopOnCancel = enable; } -void TaskProgress::setHalfLifeTimePerTask(int msecs) +void TaskProgress::setHalfLifeTimePerTask(std::chrono::milliseconds duration) { - d->m_halfLifeTimePerTask = msecs; + d->m_halfLifeTimePerTask = duration; } void TaskProgress::setDisplayName(const QString &name) diff --git a/src/plugins/coreplugin/progressmanager/taskprogress.h b/src/plugins/coreplugin/progressmanager/taskprogress.h index d82fc433d5e..fbdb84e9c4f 100644 --- a/src/plugins/coreplugin/progressmanager/taskprogress.h +++ b/src/plugins/coreplugin/progressmanager/taskprogress.h @@ -9,6 +9,8 @@ #include +#include + namespace Tasking { class TaskTree; } namespace Core { @@ -25,7 +27,7 @@ public: void setId(Utils::Id id); void setAutoStopOnCancel(bool enable); // Default is true - void setHalfLifeTimePerTask(int msecs); // Default is 1000 ms + void setHalfLifeTimePerTask(std::chrono::milliseconds duration); // Default is 1000 ms void setDisplayName(const QString &name); void setKeepOnFinish(FutureProgress::KeepOnFinishType keepType); void setSubtitleVisibleInStatusBar(bool visible); diff --git a/src/plugins/updateinfo/updateinfoplugin.cpp b/src/plugins/updateinfo/updateinfoplugin.cpp index 8aa8fae6287..a23d6c7cfc2 100644 --- a/src/plugins/updateinfo/updateinfoplugin.cpp +++ b/src/plugins/updateinfo/updateinfoplugin.cpp @@ -121,7 +121,8 @@ void UpdateInfoPlugin::startCheckForUpdates() const auto onTreeSetup = [this](TaskTree *taskTree) { d->m_progress = new TaskProgress(taskTree); - d->m_progress->setHalfLifeTimePerTask(30000); // 30 seconds + using namespace std::chrono_literals; + d->m_progress->setHalfLifeTimePerTask(30s); d->m_progress->setDisplayName(Tr::tr("Checking for Updates")); d->m_progress->setKeepOnFinish(FutureProgress::KeepOnFinishTillUserInteraction); d->m_progress->setSubtitleVisibleInStatusBar(true);