diff options
-rw-r--r-- | src/gui/kernel/qsoftkeymanager.cpp | 7 | ||||
-rw-r--r-- | src/gui/widgets/qdialogbuttonbox.cpp | 1 | ||||
-rw-r--r-- | tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp | 18 |
3 files changed, 24 insertions, 2 deletions
diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp index 7874622..91f4163 100644 --- a/src/gui/kernel/qsoftkeymanager.cpp +++ b/src/gui/kernel/qsoftkeymanager.cpp @@ -125,6 +125,7 @@ QAction *QSoftKeyManager::createAction(StandardSoftKey standardKey, QWidget *act break; } action->setSoftKeyRole(softKeyRole); + action->setEnabled(actionWidget->isEnabled()); return action; } @@ -251,8 +252,10 @@ bool QSoftKeyManager::handleCommand(int command) QAction *action = softKeys.at(i); if (action->softKeyRole() != QAction::NoSoftKey) { if (j == index) { - action->activate(QAction::Trigger); - return true; + if (action->isEnabled()) { + action->activate(QAction::Trigger); + return true; + } } j++; } diff --git a/src/gui/widgets/qdialogbuttonbox.cpp b/src/gui/widgets/qdialogbuttonbox.cpp index 39566ef..6cc720d 100644 --- a/src/gui/widgets/qdialogbuttonbox.cpp +++ b/src/gui/widgets/qdialogbuttonbox.cpp @@ -593,6 +593,7 @@ QAction* QDialogButtonBoxPrivate::createSoftKey(QAbstractButton *button, QDialog } QObject::connect(action, SIGNAL(triggered()), button, SIGNAL(clicked())); action->setSoftKeyRole(softkeyRole); + action->setEnabled(button->isEnabled()); return action; } #endif diff --git a/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp b/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp index 8788117..832605e 100644 --- a/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp +++ b/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp @@ -62,6 +62,7 @@ public slots: private slots: void updateSoftKeysCompressed(); void handleCommand(); + void checkSoftkeyEnableStates(); }; class EventListener : public QObject @@ -169,6 +170,23 @@ void tst_QSoftKeyManager::handleCommand() QCOMPARE(spy1.count(), 1); } +/* + This tests that softkey enable state follows the state of widget that owns the action + to which the softkey is related to. +*/ +void tst_QSoftKeyManager::checkSoftkeyEnableStates() +{ + QWidget w1, w2; + w1.setEnabled(false); + w2.setEnabled(true); + + QAction *disabledAction = QSoftKeyManager::createAction(QSoftKeyManager::OkSoftKey, &w1); + QAction *enabledAction = QSoftKeyManager::createAction(QSoftKeyManager::OkSoftKey, &w2); + + QVERIFY(disabledAction->isEnabled()==false); + QVERIFY(enabledAction->isEnabled()==true); +} + QTEST_MAIN(tst_QSoftKeyManager) #include "tst_qsoftkeymanager.moc" |