From 45c98836a97eb3158a06f0d60afbb1857b15bb6c Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 4 Jan 2023 16:12:55 +0100 Subject: ProcessProgress: Add setKeepOnFinish() Change-Id: I327cf309081d432b11a85bd98bc9f42de65313da Reviewed-by: Eike Ziller --- .../coreplugin/progressmanager/processprogress.cpp | 16 +++++++++++++--- src/plugins/coreplugin/progressmanager/processprogress.h | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/coreplugin/progressmanager/processprogress.cpp b/src/plugins/coreplugin/progressmanager/processprogress.cpp index 4b5aa0322b..d2109f072a 100644 --- a/src/plugins/coreplugin/progressmanager/processprogress.cpp +++ b/src/plugins/coreplugin/progressmanager/processprogress.cpp @@ -28,7 +28,9 @@ public: ProgressParser m_parser = {}; QFutureWatcher m_watcher; QFutureInterface m_futureInterface; + QPointer m_futureProgress; QString m_displayName; + FutureProgress::KeepOnFinishType m_keep = FutureProgress::HideOnFinish; }; ProcessProgressPrivate::ProcessProgressPrivate(ProcessProgress *progress, QtcProcess *process) @@ -91,11 +93,12 @@ ProcessProgress::ProcessProgress(QtcProcess *process) const QString name = d->displayName(); const auto id = Id::fromString(name + ".action"); if (d->m_parser) { - ProgressManager::addTask(d->m_futureInterface.future(), name, id); + d->m_futureProgress = ProgressManager::addTask(d->m_futureInterface.future(), name, id); } else { - ProgressManager::addTimedTask(d->m_futureInterface, name, id, - qMax(2, d->m_process->timeoutS() / 5)); + d->m_futureProgress = ProgressManager::addTimedTask(d->m_futureInterface, name, id, + qMax(2, d->m_process->timeoutS() / 5)); } + d->m_futureProgress->setKeepOnFinish(d->m_keep); }); connect(d->m_process, &QtcProcess::done, this, [this] { if (d->m_process->result() != ProcessResult::FinishedWithSuccess) @@ -109,6 +112,13 @@ void ProcessProgress::setDisplayName(const QString &name) d->m_displayName = name; } +void ProcessProgress::setKeepOnFinish(FutureProgress::KeepOnFinishType keepType) +{ + d->m_keep = keepType; + if (d->m_futureProgress) + d->m_futureProgress->setKeepOnFinish(d->m_keep); +} + void ProcessProgress::setProgressParser(const ProgressParser &parser) { if (d->m_parser) { diff --git a/src/plugins/coreplugin/progressmanager/processprogress.h b/src/plugins/coreplugin/progressmanager/processprogress.h index 4d80a99bd8..d6e1721622 100644 --- a/src/plugins/coreplugin/progressmanager/processprogress.h +++ b/src/plugins/coreplugin/progressmanager/processprogress.h @@ -26,6 +26,7 @@ public: ProcessProgress(Utils::QtcProcess *process); // Makes ProcessProgress a child of process void setDisplayName(const QString &name); + void setKeepOnFinish(FutureProgress::KeepOnFinishType keepType); void setProgressParser(const ProgressParser &parser); private: -- cgit v1.2.1