diff options
author | jkobus <jaroslaw.kobus@theqtcompany.com> | 2015-01-14 12:31:11 +0100 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@theqtcompany.com> | 2015-01-16 09:21:44 +0100 |
commit | c0d51f59bc1db86fa477c0e753f4221cd1184bc7 (patch) | |
tree | 1fc9e78dbe730321eda4ee0ead57c0391f5716a0 /src/libs/installer/packagemanagergui.cpp | |
parent | 38f4c5bf9a3beaab8d6ddb75c4847418c4254d46 (diff) |
Fix focus handling on the FinishedPage
Simplify entering() / leaving() implementation for wizard pages,
above methods are now called a bit later, when the new page is
already visible. Calling setFocus() inside entering() should
work properly right now.
Change-Id: Ic5d194f074cc4b1fc419c7be70563e105e644957
Reviewed-by: Niels Weber <niels.weber@theqtcompany.com>
Diffstat (limited to 'src/libs/installer/packagemanagergui.cpp')
-rw-r--r-- | src/libs/installer/packagemanagergui.cpp | 61 |
1 files changed, 25 insertions, 36 deletions
diff --git a/src/libs/installer/packagemanagergui.cpp b/src/libs/installer/packagemanagergui.cpp index 3447da6ce..ac258fe29 100644 --- a/src/libs/installer/packagemanagergui.cpp +++ b/src/libs/installer/packagemanagergui.cpp @@ -204,7 +204,8 @@ class PackageManagerGui::Private { public: Private() - : m_modified(false) + : m_currentId(-1) + , m_modified(false) , m_autoSwitchPage(true) , m_showSettingsButton(false) { @@ -226,7 +227,7 @@ public: QLatin1String("unknown button")); } - + int m_currentId; bool m_modified; bool m_autoSwitchPage; bool m_showSettingsButton; @@ -282,7 +283,7 @@ PackageManagerGui::PackageManagerGui(PackageManagerCore *core, QWidget *parent) connect(m_core, SIGNAL(uninstallationFinished()), this, SLOT(showFinishedPage()), Qt::QueuedConnection); - connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(executeControlScript(int))); + connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(currentPageChanged(int))); connect(this, SIGNAL(currentIdChanged(int)), m_core, SIGNAL(currentPageChanged(int))); connect(button(QWizard::FinishButton), SIGNAL(clicked()), this, SIGNAL(finishButtonClicked())); connect(button(QWizard::FinishButton), SIGNAL(clicked()), m_core, SIGNAL(finishButtonClicked())); @@ -716,12 +717,29 @@ void PackageManagerGui::dependsOnLocalInstallerBinary() } } +void PackageManagerGui::currentPageChanged(int newId) +{ + executeControlScript(newId); + + PackageManagerPage *oldPage = qobject_cast<PackageManagerPage *>(page(d->m_currentId)); + if (oldPage) { + oldPage->leaving(); + emit oldPage->left(); + } + + d->m_currentId = newId; + + PackageManagerPage *newPage = qobject_cast<PackageManagerPage *>(page(d->m_currentId)); + if (newPage) { + newPage->entering(); + emit newPage->entered(); + } +} // -- PackageManagerPage PackageManagerPage::PackageManagerPage(PackageManagerCore *core) - : m_fresh(true) - , m_complete(true) + : m_complete(true) , m_needsSettingsButton(false) , m_core(core) , validatorComponent(0) @@ -821,31 +839,6 @@ QWidget *PackageManagerPage::findWidget(const QString &objectName) const return findChild<QWidget*> (objectName); } -/*! - \internal - - Used to support some kind of initializePage() in the case the wizard has been set - to QWizard::IndependentPages. If that option has been set, initializePage() would be only - called once. So we provide entering() and leaving() based on this reimplemented function. -*/ -void PackageManagerPage::setVisible(bool visible) -{ - QWizardPage::setVisible(visible); - if (m_fresh && !visible) { - // this is only hit once when the page gets added to the wizard - m_fresh = false; - return; - } - - if (visible) { - entering(); - emit entered(); - } else { - leaving(); - emit left(); - } -} - int PackageManagerPage::nextId() const { const int next = QWizardPage::nextId(); // the page to show next @@ -1778,10 +1771,8 @@ bool TargetDirectoryPage::validatePage() void TargetDirectoryPage::entering() { - if (QPushButton *const b = qobject_cast<QPushButton *>(gui()->button(QWizard::NextButton))) { + if (QPushButton *const b = qobject_cast<QPushButton *>(gui()->button(QWizard::NextButton))) b->setDefault(true); - b->setFocus(); - } } void TargetDirectoryPage::leaving() @@ -2375,10 +2366,8 @@ void FinishedPage::entering() } else { if (packageManagerCore()->isInstaller()) { m_commitButton = wizard()->button(QWizard::FinishButton); - if (QPushButton *const b = qobject_cast<QPushButton *>(m_commitButton)) { + if (QPushButton *const b = qobject_cast<QPushButton *>(m_commitButton)) b->setDefault(true); - b->setFocus(); - } } gui()->setOption(QWizard::NoCancelButton, true); |