UpdateInfo: Show info when no updates are found

Show that no updates are found in the progress widget.
Also change the title to something nice and understandable.

Task-number: QTCREATORBUG-21584
Change-Id: I765509850d0454fa3c93b31586766d810ff6e392
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Eike Ziller
2019-03-29 13:48:25 +01:00
parent d2242babeb
commit fecf863b78
3 changed files with 25 additions and 2 deletions

View File

@@ -40,12 +40,17 @@ ShellCommand::ShellCommand(const QString &workingDirectory, const QProcessEnviro
this, &ShellCommand::coreAboutToClose);
}
FutureProgress *ShellCommand::futureProgress() const
{
return m_progress.data();
}
void ShellCommand::addTask(QFuture<void> &future)
{
const QString name = displayName();
const auto id = Core::Id::fromString(name + QLatin1String(".action"));
if (hasProgressParser()) {
ProgressManager::addTask(future, name, id);
m_progress = ProgressManager::addTask(future, name, id);
} else {
// add a timed tasked based on timeout
// we cannot access the future interface directly, so we need to create a new one
@@ -58,7 +63,7 @@ void ShellCommand::addTask(QFuture<void> &future)
watcher->deleteLater();
});
watcher->setFuture(future);
ProgressManager::addTimedTask(*fi, name, id, qMax(2, timeoutS() / 5)/*itsmagic*/);
m_progress = ProgressManager::addTimedTask(*fi, name, id, qMax(2, timeoutS() / 5)/*itsmagic*/);
}
}

View File

@@ -27,8 +27,12 @@
#include "core_global.h"
#include "progressmanager/futureprogress.h"
#include <utils/shellcommand.h>
#include <QPointer>
namespace Core {
class CORE_EXPORT ShellCommand : public Utils::ShellCommand
@@ -38,10 +42,15 @@ class CORE_EXPORT ShellCommand : public Utils::ShellCommand
public:
ShellCommand(const QString &workingDirectory, const QProcessEnvironment &environment);
FutureProgress *futureProgress() const;
protected:
void addTask(QFuture<void> &future) override;
virtual void coreAboutToClose();
private:
QPointer<FutureProgress> m_progress;
};
} // namespace Core

View File

@@ -67,6 +67,7 @@ class UpdateInfoPluginPrivate
public:
QString m_maintenanceTool;
QPointer<ShellCommand> m_checkUpdatesCommand;
QPointer<FutureProgress> m_progress;
QString m_collectedOutput;
QTimer *m_checkUpdatesTimer = nullptr;
@@ -124,6 +125,7 @@ void UpdateInfoPlugin::startCheckForUpdates()
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.insert(QLatin1String("QT_LOGGING_RULES"), QLatin1String("*=false"));
d->m_checkUpdatesCommand = new ShellCommand(QString(), env);
d->m_checkUpdatesCommand->setDisplayName(tr("Checking for Updates"));
connect(d->m_checkUpdatesCommand, &ShellCommand::stdOutText, this, &UpdateInfoPlugin::collectCheckForUpdatesOutput);
connect(d->m_checkUpdatesCommand, &ShellCommand::finished, this, &UpdateInfoPlugin::checkForUpdatesFinished);
d->m_checkUpdatesCommand->addJob(Utils::FileName(QFileInfo(d->m_maintenanceTool)), QStringList(QLatin1String("--checkupdates")),
@@ -131,6 +133,11 @@ void UpdateInfoPlugin::startCheckForUpdates()
/*workingDirectory=*/QString(),
[](int /*exitCode*/) { return Utils::SynchronousProcessResponse::Finished; });
d->m_checkUpdatesCommand->execute();
d->m_progress = d->m_checkUpdatesCommand->futureProgress();
if (d->m_progress) {
d->m_progress->setKeepOnFinish(FutureProgress::KeepOnFinishTillUserInteraction);
d->m_progress->setSubtitleVisibleInStatusBar(true);
}
emit checkForUpdatesRunningChanged(true);
}
@@ -168,6 +175,8 @@ void UpdateInfoPlugin::checkForUpdatesFinished()
startUpdater();
} else {
emit newUpdatesAvailable(false);
if (d->m_progress)
d->m_progress->setSubtitle(tr("No updates found."));
}
}