summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorJani Honkonen <jani.honkonen@digia.com>2012-08-06 12:02:51 +0300
committerQt by Nokia <qt-info@nokia.com>2012-08-27 10:27:30 +0200
commit547a1bea492954d828aa0798be93384669812489 (patch)
tree82805efa24f9f454830a19f83a0c52ed835e4819 /tests/auto
parent2ef52ca12416baa96feb64e02186aae04f883a12 (diff)
Fix limitting shortcuts to keypad only
The Qt::KeypadModifier modifier is internally masked away from all shortcuts. So it is not possible to set a keypad only shortcut. Changed the implementation so that first a full keysequence match is searched. Then if no match is found the same sequence is tried without the keypad modifer. Added a autotest for this also to cover the basic use cases relating to this. Task-number: QTBUG-20191 Change-Id: Ibe7740c705fd0ab1eece4809b9a0b48882172933 Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
index 7696ab2dea..7a1b3a79d2 100644
--- a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+++ b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
@@ -85,6 +85,7 @@ private slots:
void defaultAndAutoDefault();
void sizeHint_data();
void sizeHint();
+ void taskQTBUG_20191_shortcutWithKeypadModifer();
/*
void state();
void group();
@@ -658,5 +659,51 @@ void tst_QPushButton::sizeHint()
}
}
+void tst_QPushButton::taskQTBUG_20191_shortcutWithKeypadModifer()
+{
+ // setup a dialog with two buttons
+ QPushButton *button1 = new QPushButton("5");
+ QPushButton *button2 = new QPushButton("5 + KeypadModifier");
+ QVBoxLayout *layout = new QVBoxLayout();
+ layout->addWidget(button1);
+ layout->addWidget(button2);
+ QDialog dialog;
+ dialog.setLayout(layout);
+ dialog.show();
+ QTest::qWaitForWindowShown(&dialog);
+ QApplication::setActiveWindow(&dialog);
+
+ // add shortcut '5' to button1 and test with keyboard and keypad '5' keys
+ QSignalSpy spy1(button1, SIGNAL(clicked()));
+ button1->setShortcut(Qt::Key_5);
+ QTest::keyClick(&dialog, Qt::Key_5);
+ QTest::qWait(300);
+ QTest::keyClick(&dialog, Qt::Key_5, Qt::KeypadModifier);
+ QTest::qWait(300);
+ QCOMPARE(spy1.count(), 2);
+
+ // add shortcut 'keypad 5' to button2
+ spy1.clear();
+ QSignalSpy spy2(button2, SIGNAL(clicked()));
+ button2->setShortcut(Qt::Key_5 + Qt::KeypadModifier);
+ QTest::keyClick(&dialog, Qt::Key_5);
+ QTest::qWait(300);
+ QTest::keyClick(&dialog, Qt::Key_5, Qt::KeypadModifier);
+ QTest::qWait(300);
+ QCOMPARE(spy1.count(), 1);
+ QCOMPARE(spy2.count(), 1);
+
+ // remove shortcut from button1
+ spy1.clear();
+ spy2.clear();
+ button1->setShortcut(QKeySequence());
+ QTest::keyClick(&dialog, Qt::Key_5);
+ QTest::qWait(300);
+ QTest::keyClick(&dialog, Qt::Key_5, Qt::KeypadModifier);
+ QTest::qWait(300);
+ QCOMPARE(spy1.count(), 0);
+ QCOMPARE(spy2.count(), 1);
+}
+
QTEST_MAIN(tst_QPushButton)
#include "tst_qpushbutton.moc"