diff options
Diffstat (limited to 'src/libs/installer/performinstallationform.cpp')
-rw-r--r-- | src/libs/installer/performinstallationform.cpp | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/libs/installer/performinstallationform.cpp b/src/libs/installer/performinstallationform.cpp index 28506bcde..2c5edf70f 100644 --- a/src/libs/installer/performinstallationform.cpp +++ b/src/libs/installer/performinstallationform.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. @@ -30,6 +30,7 @@ #include "lazyplaintextedit.h" #include "progresscoordinator.h" +#include "globals.h" #include <QApplication> #include <QLabel> @@ -37,6 +38,8 @@ #include <QPushButton> #include <QScrollBar> #include <QVBoxLayout> +#include <QImageReader> +#include <QScrollArea> #include <QtCore/QTimer> @@ -78,6 +81,8 @@ PerformInstallationForm::PerformInstallationForm(QObject *parent) : QObject(parent) , m_progressBar(nullptr) , m_progressLabel(nullptr) + , m_productImagesScrollArea(nullptr) + , m_productImagesLabel(nullptr) , m_detailsButton(nullptr) , m_detailsBrowser(nullptr) , m_updateTimer(nullptr) @@ -130,6 +135,19 @@ void PerformInstallationForm::setupUi(QWidget *widget) bottomLayout->setObjectName(QLatin1String("BottomLayout")); bottomLayout->addStretch(); + m_productImagesScrollArea = new QScrollArea(widget); + m_productImagesScrollArea->setObjectName(QLatin1String("ProductImagesScrollArea")); + m_productImagesScrollArea->setWidgetResizable(true); + m_productImagesScrollArea->setFrameShape(QFrame::NoFrame); + + m_productImagesLabel = new QLabel(widget); + m_productImagesLabel->setObjectName(QLatin1String("ProductImagesLabel")); + m_productImagesLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); + m_productImagesLabel->setScaledContents(true); + + m_productImagesScrollArea->setWidget(m_productImagesLabel); + bottomLayout->addWidget(m_productImagesScrollArea); + m_detailsBrowser = new LazyPlainTextEdit(widget); m_detailsBrowser->setReadOnly(true); m_detailsBrowser->setWordWrapMode(QTextOption::NoWrap); @@ -138,6 +156,7 @@ void PerformInstallationForm::setupUi(QWidget *widget) bottomLayout->addWidget(m_detailsBrowser); bottomLayout->setStretch(1, 10); + bottomLayout->setStretch(2, 10); baseLayout->addLayout(topLayout); baseLayout->addLayout(bottomLayout); @@ -200,6 +219,7 @@ void PerformInstallationForm::toggleDetails() const bool willShow = !isShowingDetails(); m_detailsButton->setText(willShow ? tr("&Hide Details") : tr("&Show Details")); m_detailsBrowser->setVisible(willShow); + m_productImagesScrollArea->setVisible(!willShow); emit showDetailsChanged(); } @@ -220,6 +240,7 @@ void PerformInstallationForm::enableDetails() m_detailsButton->setEnabled(true); m_detailsButton->setText(tr("&Show Details")); m_detailsBrowser->setVisible(false); + m_productImagesScrollArea->setVisible(true); } /*! @@ -273,3 +294,22 @@ void PerformInstallationForm::onDownloadStatusChanged(const QString &status) m_downloadStatus->setText(m_downloadStatus->fontMetrics().elidedText(status, Qt::ElideRight, m_downloadStatus->width())); } + +/*! + Sets currently shown form image specified by \a fileName. +*/ +void PerformInstallationForm::setImageFromFileName(const QString &fileName) +{ + if (!QFile::exists(fileName)) { + qCWarning(QInstaller::lcDeveloperBuild) << "Image file does not exist:" << fileName; + return; + } + QImageReader reader(fileName); + QPixmap pixmap = QPixmap::fromImageReader(&reader); + if (!pixmap.isNull()) { + m_productImagesLabel->setPixmap(pixmap); + } else { + qCWarning(QInstaller::lcDeveloperBuild) << + QString::fromLatin1("Failed to load image '%1' : %2.").arg(fileName, reader.errorString()); + } +} |