summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-09-23 14:49:07 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-09-25 15:14:36 +0200
commit8810f82f3f9b3fe35d82fb842a5a21a098b2343f (patch)
tree71e1038f2822feb126474394d8ed3bea89c00f56
parentc3faeb852866a2fc8ae9cd6f8cf91947bd42b538 (diff)
QWizard/Aerostyle: Fix "&Next" shortcut
The fix for QTBUG-35203 set the Alt+Right shortcut on the next button, clobbering the Alt+N shortcut from parsing the text (similar for other languages). Add a separate shortcut for Alt+Right since a button may not have several shortcuts. Amends 6714196f45fbae755b26a4b2406a7bbe066084dc. Fixes: QTBUG-78604 Change-Id: I1367da739c35fbd011d11f850c9bc3915113c644 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
-rw-r--r--src/widgets/dialogs/qwizard.cpp22
-rw-r--r--tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp9
2 files changed, 20 insertions, 11 deletions
diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp
index b4a5904779..5ba48aeff3 100644
--- a/src/widgets/dialogs/qwizard.cpp
+++ b/src/widgets/dialogs/qwizard.cpp
@@ -55,10 +55,14 @@
#if QT_CONFIG(lineedit)
#include "qlineedit.h"
#endif
+#include <qpointer.h>
#include "qpainter.h"
#include "qwindow.h"
#include "qpushbutton.h"
#include "qset.h"
+#if QT_CONFIG(shortcut)
+# include "qshortcut.h"
+#endif
#include "qstyle.h"
#include "qvarlengtharray.h"
#if defined(Q_OS_MACX)
@@ -631,6 +635,9 @@ public:
#if QT_CONFIG(style_windowsvista)
QVistaHelper *vistaHelper = nullptr;
+# if QT_CONFIG(shortcut)
+ QPointer<QShortcut> vistaNextShortcut;
+# endif
bool vistaInitPending = true;
QVistaHelper::VistaState vistaState = QVistaHelper::Dirty;
bool vistaStateChanged = false;
@@ -1417,10 +1424,17 @@ void QWizardPrivate::updateButtonTexts()
// Vista: Add shortcut for 'next'. Note: native dialogs use ALT-Right
// 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] && isVistaThemeEnabled())
- btns[QWizard::NextButton]->setShortcut(QKeySequence(Qt::ALT | Qt::Key_Right));
-#endif
+#if QT_CONFIG(shortcut) && QT_CONFIG(style_windowsvista)
+ if (btns[QWizard::NextButton] && isVistaThemeEnabled()) {
+ if (vistaNextShortcut.isNull()) {
+ vistaNextShortcut =
+ new QShortcut(QKeySequence(Qt::ALT | Qt::Key_Right),
+ btns[QWizard::NextButton], SLOT(animateClick()));
+ }
+ } else {
+ delete vistaNextShortcut;
+ }
+#endif // shortcut && style_windowsvista
}
void QWizardPrivate::updateButtonLayout()
diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
index da75e64d1e..24cbd2e35c 100644
--- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
+++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
@@ -2712,13 +2712,8 @@ void tst_QWizard::taskQTBUG_46894_nextButtonShortcut()
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()));
- }
+ QCOMPARE(wizard.button(QWizard::NextButton)->shortcut(),
+ QKeySequence::mnemonic(wizard.button(QWizard::NextButton)->text()));
}
}