summaryrefslogtreecommitdiff
path: root/src/controls/qquickmenuitem.cpp
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@digia.com>2013-12-17 17:16:12 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-17 18:21:00 +0100
commitae380584de53cf927fe4a7bd62ffb41f73b1faa1 (patch)
tree1152f59c2af60aa35bfb550915286a0b146d98b2 /src/controls/qquickmenuitem.cpp
parent67b523661037cf807974f256f1146d441d8e7d40 (diff)
downloadqtquickcontrols-ae380584de53cf927fe4a7bd62ffb41f73b1faa1.tar.gz
Menu: Don't create platform item for QQuickMenuItemContainers
They don't have any QPA counterpart as they're just plain containers. This also removes that "Menu does not contain the item to be removed" warning on Mac. Task-Number: QTBUG-32197 Change-Id: I06e08817194c2e3ad3efd7ded193bfac9d3a1948 Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src/controls/qquickmenuitem.cpp')
-rw-r--r--src/controls/qquickmenuitem.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/controls/qquickmenuitem.cpp b/src/controls/qquickmenuitem.cpp
index 60d882c4..105b66ac 100644
--- a/src/controls/qquickmenuitem.cpp
+++ b/src/controls/qquickmenuitem.cpp
@@ -51,12 +51,15 @@
QT_BEGIN_NAMESPACE
-QQuickMenuBase::QQuickMenuBase(QObject *parent)
- : QObject(parent), m_visible(true), m_parentMenu(0), m_container(0), m_visualItem(0)
-{
- m_platformItem = QGuiApplicationPrivate::platformTheme()->createPlatformMenuItem();
- if (m_platformItem)
- m_platformItem->setRole(QPlatformMenuItem::TextHeuristicRole);
+QQuickMenuBase::QQuickMenuBase(QObject *parent, int type)
+ : QObject(parent), m_visible(true), m_type(static_cast<QQuickMenuItemType::MenuItemType>(type))
+ , m_parentMenu(0), m_container(0), m_platformItem(0), m_visualItem(0)
+{
+ if (type >= 0) {
+ m_platformItem = QGuiApplicationPrivate::platformTheme()->createPlatformMenuItem();
+ if (m_platformItem)
+ m_platformItem->setRole(QPlatformMenuItem::TextHeuristicRole);
+ }
}
QQuickMenuBase::~QQuickMenuBase()
@@ -98,7 +101,7 @@ QQuickMenu *QQuickMenuBase::parentMenu() const
void QQuickMenuBase::setParentMenu(QQuickMenu *parentMenu)
{
- if (m_parentMenu && m_parentMenu->platformMenu())
+ if (m_platformItem && m_parentMenu && m_parentMenu->platformMenu())
m_parentMenu->platformMenu()->removeMenuItem(m_platformItem);
m_parentMenu = parentMenu;
@@ -155,14 +158,14 @@ void QQuickMenuBase::setVisualItem(QQuickItem *item)
*/
QQuickMenuSeparator::QQuickMenuSeparator(QObject *parent)
- : QQuickMenuBase(parent)
+ : QQuickMenuBase(parent, QQuickMenuItemType::Separator)
{
if (platformItem())
platformItem()->setIsSeparator(true);
}
-QQuickMenuText::QQuickMenuText(QObject *parent)
- : QQuickMenuBase(parent), m_action(new QQuickAction(this))
+QQuickMenuText::QQuickMenuText(QObject *parent, QQuickMenuItemType::MenuItemType type)
+ : QQuickMenuBase(parent, type), m_action(new QQuickAction(this))
{
connect(m_action, SIGNAL(enabledChanged()), this, SLOT(updateEnabled()));
connect(m_action, SIGNAL(textChanged()), this, SLOT(updateText()));
@@ -417,7 +420,7 @@ void QQuickMenuText::updateIcon()
*/
QQuickMenuItem::QQuickMenuItem(QObject *parent)
- : QQuickMenuText(parent), m_boundAction(0)
+ : QQuickMenuText(parent, QQuickMenuItemType::Item), m_boundAction(0)
{
connect(this, SIGNAL(__textChanged()), this, SIGNAL(textChanged()));