diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-12-10 06:04:25 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-12-10 06:04:25 (GMT) |
commit | 4768a1ee67945e09d7f94cf881eb9c4a56e9c969 (patch) | |
tree | 938783a50f745c16156a15a0323c344b38ef90f9 /src/gui/widgets/qdialogbuttonbox.cpp | |
parent | a02104fec44e2ea1953f73881d4d6c6cf12974e4 (diff) | |
parent | 94d45cc06dabb8b1f8fc98e9f9b3dfaf49d0c4d7 (diff) | |
download | Qt-4768a1ee67945e09d7f94cf881eb9c4a56e9c969.zip Qt-4768a1ee67945e09d7f94cf881eb9c4a56e9c969.tar.gz Qt-4768a1ee67945e09d7f94cf881eb9c4a56e9c969.tar.bz2 |
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt into kinetic-declarativeui
Diffstat (limited to 'src/gui/widgets/qdialogbuttonbox.cpp')
-rw-r--r-- | src/gui/widgets/qdialogbuttonbox.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/gui/widgets/qdialogbuttonbox.cpp b/src/gui/widgets/qdialogbuttonbox.cpp index 0e859f1..f2ef941 100644 --- a/src/gui/widgets/qdialogbuttonbox.cpp +++ b/src/gui/widgets/qdialogbuttonbox.cpp @@ -46,6 +46,7 @@ #include <QtGui/qdialog.h> #include <QtGui/qapplication.h> #include <QtGui/private/qwidget_p.h> +#include <QtGui/qaction.h> #include "qdialogbuttonbox.h" @@ -259,6 +260,31 @@ 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); + target->setEnabled(source->isEnabled()); + } + ~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 +574,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(); |