summaryrefslogtreecommitdiffstats
path: root/src/controls/qquickmenuitem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/controls/qquickmenuitem.cpp')
-rw-r--r--src/controls/qquickmenuitem.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/controls/qquickmenuitem.cpp b/src/controls/qquickmenuitem.cpp
index 2f2f578fb..0167bebd1 100644
--- a/src/controls/qquickmenuitem.cpp
+++ b/src/controls/qquickmenuitem.cpp
@@ -342,6 +342,8 @@ void QQuickMenuText::updateIcon()
Emitted when either the menu item or its bound action have been activated.
\sa trigger(), Action::triggered, Action::toggled
+
+ The corresponding handler is \c onTriggered.
*/
/*! \qmlmethod MenuItem::trigger()
@@ -404,6 +406,8 @@ void QQuickMenuText::updateIcon()
This usually happens at the same time as \l triggered.
\sa checked, triggered, Action::triggered, Action::toggled
+
+ The corresponding handler is \c onToggled.
*/
/*!
@@ -426,6 +430,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 +462,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 +498,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()));
@@ -512,12 +517,7 @@ void QQuickMenuItem::setBoundAction(QQuickAction *a)
if (a == m_boundAction)
return;
- if (m_boundAction) {
- if (m_boundAction->parent() == this)
- delete m_boundAction;
- else
- unbindFromAction(m_boundAction);
- }
+ unbindFromAction(m_boundAction);
bindToAction(a);
emit actionChanged();
@@ -592,6 +592,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();