QWizard: Do not remove the Next button's shortcut

Currently on Windows, the Next button's shortcut doesn't work, because
QWizard overrides it with an empty key sequence.
The key sequence should be changed only if isVistaThemeEnabled() returns
true.

Task-number: QTBUG-46894
Change-Id: I54f26388b167973cc8065a867d9e771c1e6a2a72
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
Maciej Czarnecki 2017-08-21 13:28:51 +02:00 committed by Liang Qi
parent abcf558e49
commit 3b8f828174
2 changed files with 22 additions and 2 deletions

View File

@ -1468,8 +1468,8 @@ void QWizardPrivate::updateButtonTexts()
// even in RTL mode, so do the same, even if it might be counter-intuitive.
// The shortcut for 'back' is set in class QVistaBackButton.
#if QT_CONFIG(shortcut)
if (btns[QWizard::NextButton])
btns[QWizard::NextButton]->setShortcut(isVistaThemeEnabled() ? QKeySequence(Qt::ALT | Qt::Key_Right) : QKeySequence());
if (btns[QWizard::NextButton] && isVistaThemeEnabled())
btns[QWizard::NextButton]->setShortcut(QKeySequence(Qt::ALT | Qt::Key_Right));
#endif
}

View File

@ -96,6 +96,7 @@ private slots:
void task248107_backButton();
void task255350_fieldObjectDestroyed();
void taskQTBUG_25691_fieldObjectDestroyed2();
void taskQTBUG_46894_nextButtonShortcut();
/*
Things that could be added:
@ -2700,5 +2701,24 @@ void tst_QWizard::taskQTBUG_25691_fieldObjectDestroyed2()
::taskQTBUG_25691_fieldObjectDestroyed2();
}
void tst_QWizard::taskQTBUG_46894_nextButtonShortcut()
{
for (int i = 0; i < QWizard::NStyles; ++i) {
QWizard wizard;
QWizard::WizardStyle style = static_cast<QWizard::WizardStyle>(i);
wizard.setWizardStyle(style);
wizard.show();
QVERIFY(QTest::qWaitForWindowExposed(&wizard));
if (wizard.button(QWizard::NextButton)->text() == "&Next") {
QCOMPARE(wizard.button(QWizard::NextButton)->shortcut(),
QKeySequence(Qt::ALT | Qt::Key_Right));
} else {
QCOMPARE(wizard.button(QWizard::NextButton)->shortcut(),
QKeySequence::mnemonic(wizard.button(QWizard::NextButton)->text()));
}
}
}
QTEST_MAIN(tst_QWizard)
#include "tst_qwizard.moc"