diff options
author | Katja Marttila <[email protected]> | 2025-05-22 11:46:16 +0300 |
---|---|---|
committer | Katja Marttila <[email protected]> | 2025-05-27 15:51:10 +0300 |
commit | f4ec5b8ef15b2574076b4f3d0dabb6e42d8bdb22 (patch) | |
tree | 316d9bc45bc861d69cbe7d5310e15af3daad8fd8 /src/libs/installer/packagemanagergui.cpp | |
parent | af6aa8d69d2633196cbe1e08b0a1709087032619 (diff) |
Introducing new invokable methods, addWizardPageWarning() and
removeWizardPageWarning() to add and remove warning messages to existing pages.
Warning messages can be added also with existing addWizardPageItem()
-function, but the new method utilizes the LabelWithPixmap -class, which
draws a warning image and a label with text wrapped.
Task-number: QTIFW-3555
Change-Id: Ie7867d369762f7616ce8c7ca47d102111d651da5
Reviewed-by: Arttu Tarkiainen <[email protected]>
Diffstat (limited to 'src/libs/installer/packagemanagergui.cpp')
-rw-r--r-- | src/libs/installer/packagemanagergui.cpp | 81 |
1 files changed, 66 insertions, 15 deletions
diff --git a/src/libs/installer/packagemanagergui.cpp b/src/libs/installer/packagemanagergui.cpp index 0412d67ef..8b3293de1 100644 --- a/src/libs/installer/packagemanagergui.cpp +++ b/src/libs/installer/packagemanagergui.cpp @@ -44,6 +44,7 @@ #include "loggingutils.h" #include "readyforinstallationpage_p.h" #include "clickablelabel.h" +#include "labelwithpixmap.h" #include "sysinfo.h" #include "globals.h" @@ -253,6 +254,25 @@ public: m_showSettingsButton = show; } + void addAndOrderCustomWidgets(PackageManagerPage *p, QWidget *widget) + { + if (p->m_customWidgets.count() > 1 ) { + //Reorder the custom widgets based on their position + QMultiMap<int, QWidget*>::Iterator it = p->m_customWidgets.begin(); + while (it != p->m_customWidgets.end()) { + p->layout()->removeWidget(it.value()); + ++it; + } + it = p->m_customWidgets.begin(); + while (it != p->m_customWidgets.end()) { + p->layout()->addWidget(it.value()); + ++it; + } + } else { + p->layout()->addWidget(widget); + } + } + PackageManagerGui *q; int m_currentId; bool m_modified; @@ -455,6 +475,10 @@ PackageManagerGui::PackageManagerGui(PackageManagerCore *core, QWidget *parent) this, &PackageManagerGui::wizardWidgetInsertionRequested); connect(m_core, &PackageManagerCore::wizardWidgetRemovalRequested, this, &PackageManagerGui::wizardWidgetRemovalRequested); + connect(m_core, &PackageManagerCore::wizardPageWarningInsertionRequested, + this, &PackageManagerGui::wizardPageWarningInsertionRequested); + connect(m_core, &PackageManagerCore::wizardPageWarningRemovalRequested, + this, &PackageManagerGui::wizardPageWarningRemovalRequested); connect(m_core, &PackageManagerCore::wizardPageVisibilityChangeRequested, this, &PackageManagerGui::wizardPageVisibilityChangeRequested, Qt::QueuedConnection); @@ -889,21 +913,7 @@ void PackageManagerGui::wizardWidgetInsertionRequested(QWidget *widget, if (PackageManagerPage *p = qobject_cast<PackageManagerPage *>(QWizard::page(page))) { p->m_customWidgets.insert(position, widget); - if (p->m_customWidgets.count() > 1 ) { - //Reorder the custom widgets based on their position - QMultiMap<int, QWidget*>::Iterator it = p->m_customWidgets.begin(); - while (it != p->m_customWidgets.end()) { - p->layout()->removeWidget(it.value()); - ++it; - } - it = p->m_customWidgets.begin(); - while (it != p->m_customWidgets.end()) { - p->layout()->addWidget(it.value()); - ++it; - } - } else { - p->layout()->addWidget(widget); - } + d->addAndOrderCustomWidgets(p, widget); packageManagerCore()->controlScriptEngine()->addToGlobalObject(p); packageManagerCore()->componentScriptEngine()->addToGlobalObject(p); } @@ -927,6 +937,47 @@ void PackageManagerGui::wizardWidgetRemovalRequested(QWidget *widget) } /*! + Requests the insertion of warning label on \a page. Warning label consists of a warning + image and \a message. Widget with lower \a position number will be inserted on top. + Warning label is identified with \a id. +*/ +void PackageManagerGui::wizardPageWarningInsertionRequested(const QString &message, PackageManagerCore::WizardPage page, const QString &id, int position) +{ + // Check if the warning is already added + if (findChild<LabelWithPixmap* >(QLatin1String("LabelWithPixmap_") + id)) { + qCDebug(QInstaller::lcDeveloperBuild) << "Warning label with id " << id << "already added"; + return; + } + + if (PackageManagerPage *p = qobject_cast<PackageManagerPage *>(QWizard::page(page))) { + LabelWithPixmap *warningLabel = new LabelWithPixmap(message, QLatin1String(":/warning.png")); + warningLabel->setObjectName(QLatin1String("LabelWithPixmap_") + id); + p->m_customWidgets.insert(position, warningLabel); + d->addAndOrderCustomWidgets(p, warningLabel); + packageManagerCore()->controlScriptEngine()->addToGlobalObject(warningLabel); + packageManagerCore()->componentScriptEngine()->addToGlobalObject(warningLabel); + } +} + +/*! + Requests the removal of the warning label, identified with \a id, from installer page. +*/ +void PackageManagerGui::wizardPageWarningRemovalRequested(const QString &id) +{ + LabelWithPixmap *warningLabel = findChild<LabelWithPixmap* >(QLatin1String("LabelWithPixmap_") + id); + if (!warningLabel) + return; + const QList<int> pages = pageIds(); + for (const int id : pages) { + PackageManagerPage *managerPage = qobject_cast<PackageManagerPage *>(page(id)); + managerPage->removeCustomWidget(warningLabel); + } + warningLabel->setParent(nullptr); + packageManagerCore()->controlScriptEngine()->removeFromGlobalObject(warningLabel); + packageManagerCore()->componentScriptEngine()->removeFromGlobalObject(warningLabel); +} + +/*! Requests changing the visibility of the page specified by \a p to \a visible. */ |