TaskProgress: Add missing features needed by UpdateInfoPlugin

Change-Id: Iabfbebd07699fbe45da6007347ed45517d593cfd
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2022-11-25 11:35:15 +01:00
parent d90b1946d4
commit bcdfe1cedc
2 changed files with 38 additions and 1 deletions

View File

@@ -3,6 +3,7 @@
#include "taskprogress.h"
#include "futureprogress.h"
#include "progressmanager.h"
#include <utils/qtcassert.h>
@@ -38,7 +39,11 @@ public:
QTimer m_timer;
QFutureWatcher<void> m_watcher;
QFutureInterface<void> m_futureInterface;
QPointer<FutureProgress> 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

View File

@@ -5,6 +5,8 @@
#include <coreplugin/core_global.h>
#include "futureprogress.h" // TODO: just because of KeepOnFinishType enum - move it outside
#include <QObject>
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;