diff options
author | Janne Anttila <janne.anttila@digia.com> | 2009-12-02 13:08:53 (GMT) |
---|---|---|
committer | Janne Anttila <janne.anttila@digia.com> | 2009-12-02 13:08:53 (GMT) |
commit | 855d2702ffff37452ff3bc0e1576d1d17fdb76c2 (patch) | |
tree | 16cfc4e38166a843003aaaaa5cd088bf75fb04a6 | |
parent | 7c70e69511817127aa4691339af4a6aa07c1502a (diff) | |
download | Qt-855d2702ffff37452ff3bc0e1576d1d17fdb76c2.zip Qt-855d2702ffff37452ff3bc0e1576d1d17fdb76c2.tar.gz Qt-855d2702ffff37452ff3bc0e1576d1d17fdb76c2.tar.bz2 |
Fixed softkey merging/traversing over window boundaries.
If current dialog implementation had parent and no softkeys set,
the dialog got softkeys from parent. This commit changes the behaviour
so that softkeys are not traversed over window boundaries.
Also added autotest for the bug report.
Task-number: QTBUG-6163
Reviewed-by: Jason Barron
-rw-r--r-- | src/gui/kernel/qsoftkeymanager.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp | 62 |
2 files changed, 63 insertions, 1 deletions
diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp index 775d773..1acc9b3 100644 --- a/src/gui/kernel/qsoftkeymanager.cpp +++ b/src/gui/kernel/qsoftkeymanager.cpp @@ -190,7 +190,7 @@ bool QSoftKeyManager::event(QEvent *e) } QWidget *parent = source->parentWidget(); - if (parent && softKeys.isEmpty()) + if (parent && softKeys.isEmpty() && !source->isWindow()) source = parent; else break; diff --git a/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp b/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp index 87e0533..f923739 100644 --- a/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp +++ b/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp @@ -73,6 +73,7 @@ private slots: void updateSoftKeysCompressed(); void handleCommand(); void checkSoftkeyEnableStates(); + void noMergingOverWindowBoundary(); private: // utils inline void simulateSymbianCommand(int command) @@ -235,5 +236,66 @@ void tst_QSoftKeyManager::checkSoftkeyEnableStates() QCOMPARE(spy1.count(), 5); } +/* + This tests that the softkeys are not merged over window boundaries. I.e. dialogs + don't get softkeys of base widget by default - QTBUG-6163. +*/ +void tst_QSoftKeyManager::noMergingOverWindowBoundary() +{ + // Create base window against which the dialog softkeys will ve verified + QWidget base; + + QAction* baseLeft = new QAction(tr("BaseLeft"), &base); + baseLeft->setSoftKeyRole(QAction::PositiveSoftKey); + base.addAction(baseLeft); + + QAction* baseRight = new QAction(tr("BaseRight"), &base); + baseRight->setSoftKeyRole(QAction::NegativeSoftKey); + base.addAction(baseRight); + + base.showMaximized(); + QApplication::processEvents(); + + QSignalSpy baseLeftSpy(baseLeft, SIGNAL(triggered())); + QSignalSpy baseRightSpy(baseRight, SIGNAL(triggered())); + + //Verify that both base softkeys emit triggered signals + simulateSymbianCommand(s60CommandStart); + simulateSymbianCommand(s60CommandStart + 1); + + QCOMPARE(baseLeftSpy.count(), 1); + QCOMPARE(baseRightSpy.count(), 1); + baseLeftSpy.clear(); + baseRightSpy.clear(); + + // Verify that no softkey merging when using dialog without parent + QDialog dlg; + dlg.show(); + + QApplication::processEvents(); + + simulateSymbianCommand(s60CommandStart); + simulateSymbianCommand(s60CommandStart + 1); + + QCOMPARE(baseLeftSpy.count(), 0); + QCOMPARE(baseRightSpy.count(), 0); + + // Ensure base view has focus again + dlg.hide(); + base.showMaximized(); + + // Verify that no softkey merging when using dialog with parent + QDialog dlg2(&base); + dlg2.show(); + + QApplication::processEvents(); + + simulateSymbianCommand(s60CommandStart); + simulateSymbianCommand(s60CommandStart + 1); + + QCOMPARE(baseLeftSpy.count(), 0); + QCOMPARE(baseRightSpy.count(), 0); +} + QTEST_MAIN(tst_QSoftKeyManager) #include "tst_qsoftkeymanager.moc" |