diff options
author | Katja Marttila <katja.marttila@qt.io> | 2020-06-24 08:00:52 +0300 |
---|---|---|
committer | Katja Marttila <katja.marttila@qt.io> | 2020-06-25 12:16:25 +0300 |
commit | 519899850f86cb99cdd4c2f84f63ac2a28bfe193 (patch) | |
tree | 319e17fa14ec946c85d4895fdba905ec6225ce41 /src/libs/installer/packagemanagergui.cpp | |
parent | 7ab5e03c384f0a9364697743bd274486b1b6c2dd (diff) |
Add possibility to add custom widget from script to certain position
If several custom widgets are added to same page, the order of the
widgets is arbitrary. Added a new member to addWizardPageItem which can
define the position of the widget in the page, relative to another
custom widgets. Non-custom widgets are always placed on top as before.
Task-number: QTIFW-1847
Change-Id: Iadafef3a08e60a8b05b959cb06caea2a2042b419
Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
Diffstat (limited to 'src/libs/installer/packagemanagergui.cpp')
-rw-r--r-- | src/libs/installer/packagemanagergui.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/libs/installer/packagemanagergui.cpp b/src/libs/installer/packagemanagergui.cpp index f1496ce9f..229c68d4c 100644 --- a/src/libs/installer/packagemanagergui.cpp +++ b/src/libs/installer/packagemanagergui.cpp @@ -792,14 +792,31 @@ void PackageManagerGui::wizardPageRemovalRequested(QWidget *widget) } /*! - Requests the insertion of \a widget on \a page. + Requests the insertion of \a widget on \a page. Widget with lower + \a position number will be inserted on top. */ void PackageManagerGui::wizardWidgetInsertionRequested(QWidget *widget, - QInstaller::PackageManagerCore::WizardPage page) + QInstaller::PackageManagerCore::WizardPage page, int position) { Q_ASSERT(widget); - if (QWizardPage *const p = QWizard::page(page)) { - p->layout()->addWidget(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); + } packageManagerCore()->controlScriptEngine()->addToGlobalObject(p); packageManagerCore()->componentScriptEngine()->addToGlobalObject(p); } |