diff --git a/src/plugins/coreplugin/progressmanager/taskprogress.cpp b/src/plugins/coreplugin/progressmanager/taskprogress.cpp index b59d2021930..13ad40b7fa5 100644 --- a/src/plugins/coreplugin/progressmanager/taskprogress.cpp +++ b/src/plugins/coreplugin/progressmanager/taskprogress.cpp @@ -3,6 +3,7 @@ #include "taskprogress.h" +#include "futureprogress.h" #include "progressmanager.h" #include @@ -38,7 +39,11 @@ public: QTimer m_timer; QFutureWatcher m_watcher; QFutureInterface m_futureInterface; + QPointer m_futureProgress; QString m_displayName; + FutureProgress::KeepOnFinishType m_keep = FutureProgress::HideOnFinish; + bool m_isSubtitleVisibleInStatusBar = false; + QString m_subtitle; }; TaskProgressPrivate::TaskProgressPrivate(TaskProgress *progress, TaskTree *taskTree) @@ -109,7 +114,11 @@ TaskProgress::TaskProgress(TaskTree *taskTree) d->advanceProgress(0); const auto id = Id::fromString(d->m_displayName + ".action"); - ProgressManager::addTask(d->m_futureInterface.future(), d->m_displayName, id); + d->m_futureProgress = ProgressManager::addTask(d->m_futureInterface.future(), + d->m_displayName, id); + d->m_futureProgress->setKeepOnFinish(d->m_keep); + d->m_futureProgress->setSubtitleVisibleInStatusBar(d->m_isSubtitleVisibleInStatusBar); + d->m_futureProgress->setSubtitle(d->m_subtitle); d->m_timer.start(); }); connect(d->m_taskTree, &TaskTree::progressValueChanged, this, [this](int value) { @@ -129,6 +138,29 @@ TaskProgress::TaskProgress(TaskTree *taskTree) void TaskProgress::setDisplayName(const QString &name) { d->m_displayName = name; + if (d->m_futureProgress) + d->m_futureProgress->setTitle(d->m_displayName); +} + +void TaskProgress::setKeepOnFinish(FutureProgress::KeepOnFinishType keepType) +{ + d->m_keep = keepType; + if (d->m_futureProgress) + d->m_futureProgress->setKeepOnFinish(d->m_keep); +} + +void TaskProgress::setSubtitleVisibleInStatusBar(bool visible) +{ + d->m_isSubtitleVisibleInStatusBar = visible; + if (d->m_futureProgress) + d->m_futureProgress->setSubtitleVisibleInStatusBar(d->m_isSubtitleVisibleInStatusBar); +} + +void TaskProgress::setSubtitle(const QString &subtitle) +{ + d->m_subtitle = subtitle; + if (d->m_futureProgress) + d->m_futureProgress->setSubtitle(d->m_subtitle); } } // namespace Core diff --git a/src/plugins/coreplugin/progressmanager/taskprogress.h b/src/plugins/coreplugin/progressmanager/taskprogress.h index 056ebf50147..bec4254633b 100644 --- a/src/plugins/coreplugin/progressmanager/taskprogress.h +++ b/src/plugins/coreplugin/progressmanager/taskprogress.h @@ -5,6 +5,8 @@ #include +#include "futureprogress.h" // TODO: just because of KeepOnFinishType enum - move it outside + #include namespace Utils { class TaskTree; } @@ -19,6 +21,9 @@ public: TaskProgress(Utils::TaskTree *taskTree); // Makes TaskProgress a child of task tree void setDisplayName(const QString &name); + void setKeepOnFinish(FutureProgress::KeepOnFinishType keepType); + void setSubtitleVisibleInStatusBar(bool visible); + void setSubtitle(const QString &subtitle); private: TaskProgressPrivate *d;