Wizards: Close wizards with escape

Since they are no longer modal, the "return to editor" shortcut was
executed for the escape key instead.

Change-Id: I4505f49105ad46f7c5f9e0257e77a8ca4652ef06
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
Eike Ziller
2014-07-14 14:55:00 +02:00
parent bef7181ed0
commit 82296d3209
2 changed files with 20 additions and 4 deletions

View File

@@ -30,13 +30,14 @@
#include "wizard.h"
#include "hostosinfo.h"
#include <QMap>
#include <QHash>
#include <QKeyEvent>
#include <QLabel>
#include <QMap>
#include <QStyle>
#include <QVBoxLayout>
#include <QVariant>
#include <QLabel>
#include <QVBoxLayout>
#include <QStyle>
/*! \class Utils::Wizard
@@ -376,6 +377,18 @@ bool Wizard::validateCurrentPage()
return QWizard::validateCurrentPage();
}
bool Wizard::event(QEvent *event)
{
if (event->type() == QEvent::ShortcutOverride) {
auto ke = static_cast<QKeyEvent *>(event);
if (ke->key() == Qt::Key_Escape && !ke->modifiers()) {
ke->accept();
return true;
}
}
return QWizard::event(event);
}
void Wizard::_q_currentPageChanged(int pageId)
{
Q_D(Wizard);

View File

@@ -72,6 +72,9 @@ signals:
void nextClicked(); /* workaround for QWizard behavior where page->initialize is
* called before currentIdChanged */
protected:
bool event(QEvent *event);
private slots:
void _q_currentPageChanged(int pageId);
void _q_pageAdded(int pageId);