aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2018-03-01 15:30:50 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2018-03-01 14:39:12 +0000
commitb4db69eee6dc2f381b24aa24586171dbaf8d116e (patch)
tree38a3f32c84058aec4cfac674061518aea93c28ab /src
parent01b0e2316771b495e3ef3586585f2bc626557394 (diff)
Platform: fix checkable MenuItem
Update the internal checked state before emitting triggered() Task-number: QTBUG-66386 Change-Id: If120955681b2011bf88126a1ca6032f0af482824 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/imports/platform/qquickplatformmenuitem.cpp17
-rw-r--r--src/imports/platform/qquickplatformmenuitem_p.h1
2 files changed, 8 insertions, 10 deletions
diff --git a/src/imports/platform/qquickplatformmenuitem.cpp b/src/imports/platform/qquickplatformmenuitem.cpp
index 61a4daab..bc6d97e1 100644
--- a/src/imports/platform/qquickplatformmenuitem.cpp
+++ b/src/imports/platform/qquickplatformmenuitem.cpp
@@ -144,10 +144,8 @@ QPlatformMenuItem *QQuickPlatformMenuItem::create()
m_handle = QWidgetPlatform::createMenuItem();
if (m_handle) {
- connect(m_handle, &QPlatformMenuItem::activated, this, &QQuickPlatformMenuItem::triggered);
+ connect(m_handle, &QPlatformMenuItem::activated, this, &QQuickPlatformMenuItem::activate);
connect(m_handle, &QPlatformMenuItem::hovered, this, &QQuickPlatformMenuItem::hovered);
- if (m_checkable)
- connect(m_handle, &QPlatformMenuItem::activated, this, &QQuickPlatformMenuItem::toggle);
}
}
return m_handle;
@@ -354,13 +352,6 @@ void QQuickPlatformMenuItem::setCheckable(bool checkable)
if (m_checkable == checkable)
return;
- if (m_handle) {
- if (checkable)
- connect(m_handle, &QPlatformMenuItem::activated, this, &QQuickPlatformMenuItem::toggle);
- else
- disconnect(m_handle, &QPlatformMenuItem::activated, this, &QQuickPlatformMenuItem::toggle);
- }
-
m_checkable = checkable;
sync();
emit checkableChanged();
@@ -602,6 +593,12 @@ QQuickPlatformIconLoader *QQuickPlatformMenuItem::iconLoader() const
return m_iconLoader;
}
+void QQuickPlatformMenuItem::activate()
+{
+ toggle();
+ emit triggered();
+}
+
void QQuickPlatformMenuItem::updateIcon()
{
if (!m_handle || !m_iconLoader)
diff --git a/src/imports/platform/qquickplatformmenuitem_p.h b/src/imports/platform/qquickplatformmenuitem_p.h
index 0c1a7c6d..6ff3ad81 100644
--- a/src/imports/platform/qquickplatformmenuitem_p.h
+++ b/src/imports/platform/qquickplatformmenuitem_p.h
@@ -161,6 +161,7 @@ protected:
QQuickPlatformIconLoader *iconLoader() const;
private Q_SLOTS:
+ void activate();
void updateIcon();
private: