summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Knight <andrew.knight@digia.com>2014-03-10 15:23:53 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-10 14:32:54 +0100
commitbfaba2f3b81f70e1c26269084a961bf0d2560990 (patch)
tree13686739eea9a65524eef98a488bfa6f3d6b53a9 /src
parentde35432376a215587e05b4817f2a1ddc7ac221fa (diff)
downloadqtquickcontrols-bfaba2f3b81f70e1c26269084a961bf0d2560990.tar.gz
MenuItem: Update platform menu item when checkable changes
This is required to inform the platform backend to change the menu item's appearance. Change-Id: I326ac2d79b4f9e7646c2c01b7f41662310736b18 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/controls/qquickmenuitem.cpp15
-rw-r--r--src/controls/qquickmenuitem_p.h1
2 files changed, 14 insertions, 2 deletions
diff --git a/src/controls/qquickmenuitem.cpp b/src/controls/qquickmenuitem.cpp
index 2f2f578f..1788f423 100644
--- a/src/controls/qquickmenuitem.cpp
+++ b/src/controls/qquickmenuitem.cpp
@@ -426,6 +426,7 @@ QQuickMenuItem::QQuickMenuItem(QObject *parent)
connect(action(), SIGNAL(shortcutChanged(QVariant)), this, SLOT(updateShortcut()));
connect(action(), SIGNAL(triggered()), this, SIGNAL(triggered()));
+ connect(action(), SIGNAL(checkableChanged()), this, SLOT(updateCheckable()));
connect(action(), SIGNAL(toggled(bool)), this, SLOT(updateChecked()));
if (platformItem())
connect(platformItem(), SIGNAL(activated()), this, SLOT(trigger()), Qt::QueuedConnection);
@@ -457,7 +458,7 @@ void QQuickMenuItem::bindToAction(QQuickAction *action)
connect(m_boundAction, SIGNAL(enabledChanged()), this, SLOT(updateEnabled()));
connect(m_boundAction, SIGNAL(textChanged()), this, SLOT(updateText()));
connect(m_boundAction, SIGNAL(shortcutChanged(QVariant)), this, SLOT(updateShortcut()));
- connect(m_boundAction, SIGNAL(checkableChanged()), this, SIGNAL(checkableChanged()));
+ connect(m_boundAction, SIGNAL(checkableChanged()), this, SLOT(updateCheckable()));
connect(m_boundAction, SIGNAL(iconNameChanged()), this, SLOT(updateIcon()));
connect(m_boundAction, SIGNAL(iconNameChanged()), this, SIGNAL(iconNameChanged()));
connect(m_boundAction, SIGNAL(iconSourceChanged()), this, SLOT(updateIcon()));
@@ -493,7 +494,7 @@ void QQuickMenuItem::unbindFromAction(QObject *o)
disconnect(action, SIGNAL(enabledChanged()), this, SLOT(updateEnabled()));
disconnect(action, SIGNAL(textChanged()), this, SLOT(updateText()));
disconnect(action, SIGNAL(shortcutChanged(QVariant)), this, SLOT(updateShortcut()));
- disconnect(action, SIGNAL(checkableChanged()), this, SIGNAL(checkableChanged()));
+ disconnect(action, SIGNAL(checkableChanged()), this, SLOT(updateCheckable()));
disconnect(action, SIGNAL(iconNameChanged()), this, SLOT(updateIcon()));
disconnect(action, SIGNAL(iconNameChanged()), this, SIGNAL(iconNameChanged()));
disconnect(action, SIGNAL(iconSourceChanged()), this, SLOT(updateIcon()));
@@ -592,6 +593,16 @@ void QQuickMenuItem::setCheckable(bool checkable)
action()->setCheckable(checkable);
}
+void QQuickMenuItem::updateCheckable()
+{
+ if (platformItem()) {
+ platformItem()->setCheckable(checkable());
+ syncWithPlatformMenu();
+ }
+
+ emit checkableChanged();
+}
+
bool QQuickMenuItem::checked() const
{
return action()->isChecked();
diff --git a/src/controls/qquickmenuitem_p.h b/src/controls/qquickmenuitem_p.h
index a2e74d7f..bb1686f7 100644
--- a/src/controls/qquickmenuitem_p.h
+++ b/src/controls/qquickmenuitem_p.h
@@ -225,6 +225,7 @@ public:
protected Q_SLOTS:
void updateShortcut();
+ void updateCheckable();
void updateChecked();
void bindToAction(QQuickAction *action);
void unbindFromAction(QObject *action);