summaryrefslogtreecommitdiffstats
path: root/src/libs/installer
diff options
context:
space:
mode:
authorArttu Tarkiainen <arttu.tarkiainen@qt.io>2020-02-25 09:18:19 +0200
committerArttu Tarkiainen <arttu.tarkiainen@qt.io>2020-03-09 11:35:57 +0000
commit3c7b8025e0db7607ee6ca718a3faf6ddfc677a51 (patch)
tree4f00e363cf18080114ad89f74665d41f46cabfae /src/libs/installer
parent76e113b90afe5555f39b2aa37edc8137d661a1ac (diff)
Show progress in CLI when performing time consuming operations
Add a bottom scrolling progress indicator that is shown during meta job progresses and installation phase. Also add printing of messages previously shown only on the GUI Wizard's progress bar labels. Task-number: QTIFW-1625 Change-Id: Ic3f92a31c98e41686517f49bbe98fd81fe11d13f Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'src/libs/installer')
-rw-r--r--src/libs/installer/metadatajob.cpp4
-rw-r--r--src/libs/installer/packagemanagercore.cpp6
-rw-r--r--src/libs/installer/progresscoordinator.cpp34
-rw-r--r--src/libs/installer/progresscoordinator.h14
4 files changed, 53 insertions, 5 deletions
diff --git a/src/libs/installer/metadatajob.cpp b/src/libs/installer/metadatajob.cpp
index 68d40bc9f..7976be8ee 100644
--- a/src/libs/installer/metadatajob.cpp
+++ b/src/libs/installer/metadatajob.cpp
@@ -1,6 +1,6 @@
/**************************************************************************
**
-** Copyright (C) 2018 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Installer Framework.
@@ -184,6 +184,8 @@ void MetadataJob::startXMLTask(const QList<FileTaskItem> items)
{
DownloadFileTask *const xmlTask = new DownloadFileTask(items);
xmlTask->setProxyFactory(m_core->proxyFactory());
+ connect(&m_xmlTask, &QFutureWatcher<FileTaskResult>::progressValueChanged, this,
+ &MetadataJob::progressChanged);
m_xmlTask.setFuture(QtConcurrent::run(&DownloadFileTask::doTask, xmlTask));
}
diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp
index 5cf251ec3..878737dc1 100644
--- a/src/libs/installer/packagemanagercore.cpp
+++ b/src/libs/installer/packagemanagercore.cpp
@@ -1,6 +1,6 @@
/**************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Installer Framework.
@@ -1055,6 +1055,10 @@ PackageManagerCore::PackageManagerCore(qint64 magicmaker, const QList<OperationB
} else {
qCDebug(QInstaller::lcGeneral) << "Operations sanity check succeeded.";
}
+ connect(this, &PackageManagerCore::metaJobProgress,
+ ProgressCoordinator::instance(), &ProgressCoordinator::printProgressPercentage);
+ connect(this, &PackageManagerCore::metaJobInfoMessage,
+ ProgressCoordinator::instance(), &ProgressCoordinator::printProgressMessage);
}
class VerboseWriterAdminOutput : public VerboseWriterOutput
diff --git a/src/libs/installer/progresscoordinator.cpp b/src/libs/installer/progresscoordinator.cpp
index ab0133048..333c9608e 100644
--- a/src/libs/installer/progresscoordinator.cpp
+++ b/src/libs/installer/progresscoordinator.cpp
@@ -1,6 +1,6 @@
/**************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Installer Framework.
@@ -28,6 +28,8 @@
#include "progresscoordinator.h"
+#include <iostream>
+
#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
@@ -53,10 +55,13 @@ ProgressCoordinator::ProgressCoordinator(QObject *parent)
{
// it has to be in the main thread to be able refresh the ui with processEvents
Q_ASSERT(thread() == qApp->thread());
+ m_progressSpinner = new ProgressSpinner();
}
ProgressCoordinator::~ProgressCoordinator()
{
+ delete m_progressSpinner;
+ m_progressSpinner = nullptr;
}
ProgressCoordinator *ProgressCoordinator::instance()
@@ -197,6 +202,7 @@ void ProgressCoordinator::partProgressChanged(double fraction)
m_senderPendingCalculatedPercentageHash.insert(sender(), pendingCalculatedPartPercentage);
}
} //if (m_undoMode)
+ printProgressPercentage(progressInPercentage());
}
@@ -259,6 +265,11 @@ void ProgressCoordinator::setLabelText(const QString &text)
if (m_installationLabelText == text)
return;
m_installationLabelText = text;
+
+ // Refresh both message & progress percentage on console
+ // when the label text is changed
+ printProgressMessage(text);
+ printProgressPercentage(progressInPercentage());
}
/*!
@@ -277,7 +288,7 @@ void ProgressCoordinator::emitDetailTextChanged(const QString &text)
void ProgressCoordinator::emitLabelAndDetailTextChanged(const QString &text)
{
emit detailTextChanged(text);
- m_installationLabelText = QString(text).remove(QLatin1String("\n"));
+ setLabelText(QString(text).remove(QLatin1String("\n")));
qApp->processEvents(); //makes the result available in the ui
}
@@ -297,3 +308,22 @@ void ProgressCoordinator::emitDownloadStatus(const QString &status)
{
emit downloadStatusChanged(status);
}
+
+void ProgressCoordinator::printProgressPercentage(int progress)
+{
+ Q_ASSERT(m_progressSpinner->currentIndex < m_progressSpinner->spinnerChars.size());
+
+ QString formatted = QString::fromLatin1("[%1 %2%] ").arg(
+ m_progressSpinner->spinnerChars.at(m_progressSpinner->currentIndex), QString::number(progress));
+
+ std::cout << formatted.toStdString() << "\r" << std::flush;
+
+ m_progressSpinner->currentIndex == (m_progressSpinner->spinnerChars.size() - 1)
+ ? m_progressSpinner->currentIndex = 0
+ : m_progressSpinner->currentIndex++;
+}
+
+void ProgressCoordinator::printProgressMessage(const QString &message)
+{
+ qCDebug(QInstaller::lcInstallerInstallLog) << message;
+}
diff --git a/src/libs/installer/progresscoordinator.h b/src/libs/installer/progresscoordinator.h
index ec02b8296..380c90df0 100644
--- a/src/libs/installer/progresscoordinator.h
+++ b/src/libs/installer/progresscoordinator.h
@@ -1,6 +1,6 @@
/**************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Installer Framework.
@@ -41,6 +41,15 @@ class INSTALLER_EXPORT ProgressCoordinator : public QObject
{
Q_OBJECT
+ struct ProgressSpinner {
+ ProgressSpinner()
+ : spinnerChars(QLatin1String("/-\\|"))
+ , currentIndex(0) {}
+
+ const QString spinnerChars;
+ quint8 currentIndex;
+ };
+
public:
static ProgressCoordinator *instance();
~ProgressCoordinator();
@@ -64,6 +73,8 @@ public slots:
void emitLabelAndDetailTextChanged(const QString &text);
void emitDownloadStatus(const QString &status);
+ void printProgressPercentage(int progress);
+ void printProgressMessage(const QString &message);
signals:
void detailTextChanged(const QString &text);
@@ -80,6 +91,7 @@ private:
private:
QHash<QPointer<QObject>, double> m_senderPendingCalculatedPercentageHash;
QHash<QPointer<QObject>, double> m_senderPartProgressSizeHash;
+ ProgressSpinner *m_progressSpinner;
QString m_installationLabelText;
double m_currentCompletePercentage;
double m_currentBasePercentage;