diff options
author | Philip Schuchardt <vpicaver@gmail.com> | 2012-04-16 02:24:26 -0700 |
---|---|---|
committer | Jens Bache-Wiig <jens.bache-wiig@nokia.com> | 2012-04-16 02:24:26 -0700 |
commit | 3d3f439a15f496eeabb1cb51ebca5d4ea6e50779 (patch) | |
tree | 6cc214a8a90b3e92923680805888edc1faf05197 | |
parent | f6bc3efa92659679f1c2a4b5c628e6d7595d2d7b (diff) |
Added enabled property to MenuItem
This allows the menu item to be disabled/enabled from QML.
Merge-request: 18
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@nokia.com>
-rw-r--r-- | src/qtmenuitem.cpp | 11 | ||||
-rw-r--r-- | src/qtmenuitem.h | 4 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/qtmenuitem.cpp b/src/qtmenuitem.cpp index 34be067e5..0ee7afd16 100644 --- a/src/qtmenuitem.cpp +++ b/src/qtmenuitem.cpp @@ -88,6 +88,7 @@ QtMenuItem::QtMenuItem(QObject *parent) { connect(_action, SIGNAL(triggered()), this, SIGNAL(triggered())); connect(_action, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool))); + connect(_action, SIGNAL(changed()), this, SIGNAL(enabledChanged())); } QtMenuItem::~QtMenuItem() @@ -116,6 +117,11 @@ void QtMenuItem::setChecked(bool checked) _action->setChecked(checked); } +void QtMenuItem::setEnabled(bool enabled) +{ + _action->setEnabled(enabled); +} + QString QtMenuItem::text() const { return _action->text(); @@ -136,6 +142,11 @@ bool QtMenuItem::checked() const return _action->isChecked(); } +bool QtMenuItem::enabled() const +{ + return _action->isEnabled(); +} + QAction * QtMenuItem::action() { return _action; diff --git a/src/qtmenuitem.h b/src/qtmenuitem.h index 7fff9e590..d94a1cbb4 100644 --- a/src/qtmenuitem.h +++ b/src/qtmenuitem.h @@ -87,6 +87,7 @@ class QtMenuItem: public QtMenuBase Q_PROPERTY(QString shortcut READ shortcut WRITE setShortcut NOTIFY shortcutChanged) Q_PROPERTY(bool checkable READ checkable WRITE setCheckable) Q_PROPERTY(bool checked READ checked WRITE setChecked NOTIFY toggled) + Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) public: QtMenuItem(QObject *parent = 0); @@ -96,11 +97,13 @@ public: void setShortcut(const QString &shortcut); void setCheckable(bool checkable); void setChecked(bool checked); + void setEnabled(bool enabled); QString text() const; QString shortcut() const; bool checkable() const; bool checked() const; + bool enabled() const; QAction* action(); @@ -109,6 +112,7 @@ Q_SIGNALS: void textChanged(); void shortcutChanged(); void toggled(bool); + void enabledChanged(); private: QAction *_action; |