diff options
Diffstat (limited to 'src/libs/installer/performinstallationform.cpp')
-rw-r--r-- | src/libs/installer/performinstallationform.cpp | 64 |
1 files changed, 43 insertions, 21 deletions
diff --git a/src/libs/installer/performinstallationform.cpp b/src/libs/installer/performinstallationform.cpp index 31b61ceeb..0e4c561f6 100644 --- a/src/libs/installer/performinstallationform.cpp +++ b/src/libs/installer/performinstallationform.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2020 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -30,6 +30,10 @@ #include "progresscoordinator.h" #include "globals.h" +#include "aspectratiolabel.h" +#include "packagemanagercore.h" +#include "settings.h" +#include "fileutils.h" #include <QApplication> #include <QLabel> @@ -39,13 +43,17 @@ #include <QVBoxLayout> #include <QImageReader> #include <QScrollArea> +#include <QTextEdit> +#include <QFileInfo> #include <QtCore/QTimer> #ifdef Q_OS_WIN +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) # include <QWinTaskbarButton> # include <QWinTaskbarProgress> #endif +#endif using namespace QInstaller; @@ -74,20 +82,23 @@ using namespace QInstaller; */ /*! - Constructs the perform installation UI with \a parent as parent. + Constructs the perform installation UI with package manager specified by \a core and + with \a parent as parent. */ -PerformInstallationForm::PerformInstallationForm(QObject *parent) +PerformInstallationForm::PerformInstallationForm(PackageManagerCore *core, QObject *parent) : QObject(parent) , m_progressBar(nullptr) , m_progressLabel(nullptr) - , m_downloadStatus(nullptr) + , m_additionalProgressStatus(nullptr) , m_productImagesScrollArea(nullptr) , m_productImagesLabel(nullptr) , m_detailsButton(nullptr) , m_detailsBrowser(nullptr) , m_updateTimer(nullptr) + , m_core(core) { #ifdef Q_OS_WIN +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS7) { m_taskButton = new QWinTaskbarButton(this); m_taskButton->progress()->setVisible(true); @@ -95,6 +106,7 @@ PerformInstallationForm::PerformInstallationForm(QObject *parent) m_taskButton = nullptr; } #endif +#endif } /*! @@ -118,12 +130,14 @@ void PerformInstallationForm::setupUi(QWidget *widget) m_progressLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); topLayout->addWidget(m_progressLabel); - m_downloadStatus = new QLabel(widget); - m_downloadStatus->setObjectName(QLatin1String("DownloadStatus")); - m_downloadStatus->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); - topLayout->addWidget(m_downloadStatus); - connect(ProgressCoordinator::instance(), &ProgressCoordinator::downloadStatusChanged, this, - &PerformInstallationForm::onDownloadStatusChanged); + m_additionalProgressStatus = new QLabel(widget); + m_additionalProgressStatus->setObjectName(QLatin1String("DownloadStatus")); + m_additionalProgressStatus->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); + m_additionalProgressStatus->setWordWrap(true); + m_additionalProgressStatus->setTextFormat(Qt::TextFormat::RichText); + topLayout->addWidget(m_additionalProgressStatus); + connect(ProgressCoordinator::instance(), &ProgressCoordinator::additionalProgressStatusChanged, this, + &PerformInstallationForm::onAdditionalProgressStatusChanged); m_detailsButton = new QPushButton(tr("&Show Details"), widget); m_detailsButton->setObjectName(QLatin1String("DetailsButton")); @@ -194,12 +208,14 @@ void PerformInstallationForm::updateProgress() m_progressBar->setValue(progressPercentage); #ifdef Q_OS_WIN +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) if (m_taskButton) { if (!m_taskButton->window() && QApplication::activeWindow()) m_taskButton->setWindow(QApplication::activeWindow()->windowHandle()); m_taskButton->progress()->setValue(progressPercentage); } #endif +#endif static QString lastLabelText; if (lastLabelText == progressCoordninator->labelText()) @@ -280,27 +296,33 @@ bool PerformInstallationForm::isShowingDetails() const Changes the label text according to the changes in the download status specified by \a status. */ -void PerformInstallationForm::onDownloadStatusChanged(const QString &status) +void PerformInstallationForm::onAdditionalProgressStatusChanged(const QString &status) { - m_downloadStatus->setText(m_downloadStatus->fontMetrics().elidedText(status, Qt::ElideRight, - m_downloadStatus->width())); + m_additionalProgressStatus->setText(status); } /*! - Sets currently shown form image specified by \a fileName. + Sets currently shown form image specified by \a fileName. When clicking the image, + \a url is opened in a browser. If the \a url is a reference to a file, it will + be opened with a suitable application instead of a Web browser. \a url can be empty. */ -void PerformInstallationForm::setImageFromFileName(const QString &fileName) +void PerformInstallationForm::setImageFromFileName(const QString &fileName, const QString &url) { - if (!QFile::exists(fileName)) { - qCWarning(QInstaller::lcDeveloperBuild) << "Image file does not exist:" << fileName; + QString imagePath = QFileInfo(fileName).isAbsolute() + ? fileName + : m_core->settings().value(QLatin1String("Prefix")).toString() + QLatin1Char('/') + fileName; + QInstaller::replaceHighDpiImage(imagePath); + + if (!QFile::exists(imagePath)) { + qCWarning(QInstaller::lcInstallerInstallLog) << "Image file does not exist:" << fileName; return; } - QImageReader reader(fileName); + QImageReader reader(imagePath); QPixmap pixmap = QPixmap::fromImageReader(&reader); if (!pixmap.isNull()) { - m_productImagesLabel->setPixmap(pixmap); + m_productImagesLabel->setPixmapAndUrl(pixmap, url); } else { - qCWarning(QInstaller::lcDeveloperBuild) << - QString::fromLatin1("Failed to load image '%1' : %2.").arg(fileName, reader.errorString()); + qCWarning(QInstaller::lcInstallerInstallLog) << + QString::fromLatin1("Failed to load image '%1' : %2.").arg(imagePath, reader.errorString()); } } |