summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanne Anttila <janne.anttila@digia.com>2009-12-07 12:05:01 (GMT)
committerJanne Anttila <janne.anttila@digia.com>2009-12-07 12:05:45 (GMT)
commit245c9cc07ff1581dd126f213985c3557b2667aca (patch)
tree8f0d5da7330b0a5a89ef1aeb9948eb7c49397453
parent91b4a40bd3cc9d004baddd9c19ced07ed37afef2 (diff)
downloadQt-245c9cc07ff1581dd126f213985c3557b2667aca.zip
Qt-245c9cc07ff1581dd126f213985c3557b2667aca.tar.gz
Qt-245c9cc07ff1581dd126f213985c3557b2667aca.tar.bz2
Added dimming support for disabled softkeys in Symbian.
If QAction::setEnabled(false) is called, the CBA buttons are dimmed to have visual indication about disabled state. Since enabled/disabled state of buttons in QDialogButtonBox is controlled via QPushButton::setEnabled API, and because button box content in Symbian is mapped to sofkkeys we also need to have proxy for button enabled state to forward the information for underlying QAction. Reviewed-by: Sami Merila
-rw-r--r--src/gui/kernel/qsoftkeymanager.cpp5
-rw-r--r--src/gui/widgets/qdialogbuttonbox.cpp28
2 files changed, 31 insertions, 2 deletions
diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp
index 30c67f4..464a250 100644
--- a/src/gui/kernel/qsoftkeymanager.cpp
+++ b/src/gui/kernel/qsoftkeymanager.cpp
@@ -254,7 +254,10 @@ void QSoftKeyManagerPrivate::updateSoftKeys_sys(const QList<QAction*> &softkeys)
const int underlineShortCut = QApplication::style()->styleHint(QStyle::SH_UnderlineShortcut);
QString iconText = softKeyAction->iconText();
TPtrC text = qt_QString2TPtrC( underlineShortCut ? softKeyAction->text() : iconText);
- QT_TRAP_THROWING(nativeContainer->SetCommandL(position, command, text));
+ QT_TRAP_THROWING(
+ nativeContainer->SetCommandL(position, command, text);
+ nativeContainer->DimCommand(command, !softKeyAction->isEnabled());
+ );
}
}
diff --git a/src/gui/widgets/qdialogbuttonbox.cpp b/src/gui/widgets/qdialogbuttonbox.cpp
index 0e859f1..56cf545 100644
--- a/src/gui/widgets/qdialogbuttonbox.cpp
+++ b/src/gui/widgets/qdialogbuttonbox.cpp
@@ -259,6 +259,30 @@ static const int layouts[2][5][14] =
}
};
+class QDialogButtonEnabledProxy : public QObject
+{
+public:
+ QDialogButtonEnabledProxy(QObject *parent, QWidget *src, QAction *trg) : QObject(parent), source(src), target(trg)
+ {
+ source->installEventFilter(this);
+ }
+ ~QDialogButtonEnabledProxy()
+ {
+ source->removeEventFilter(this);
+ }
+ bool eventFilter(QObject *object, QEvent *event)
+ {
+ if (object == source && event->type() == QEvent::EnabledChange) {
+ target->setEnabled(source->isEnabled());
+ }
+ return false;
+ };
+private:
+ QWidget *source;
+ QAction *target;
+};
+
+
class QDialogButtonBoxPrivate : public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QDialogButtonBox)
@@ -548,7 +572,9 @@ void QDialogButtonBoxPrivate::addButton(QAbstractButton *button, QDialogButtonBo
QObject::connect(button, SIGNAL(destroyed()), q, SLOT(_q_handleButtonDestroyed()));
buttonLists[role].append(button);
#ifdef QT_SOFTKEYS_ENABLED
- softKeyActions.insert(button, createSoftKey(button, role));
+ QAction *action = createSoftKey(button, role);
+ softKeyActions.insert(button, action);
+ new QDialogButtonEnabledProxy(action, button, action);
#endif
if (doLayout)
layoutButtons();