summaryrefslogtreecommitdiff
path: root/src/controls/qquickmenubar.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2014-09-19 19:34:05 +0200
committerJ-P Nurmi <jpnurmi@digia.com>2014-09-22 09:56:29 +0200
commit6c47fb0d80a720d44b6fafcd873dac2dafefcf0c (patch)
treecf51d4d11128dfa346af6026d6b4ce892bd2ad51 /src/controls/qquickmenubar.cpp
parentc3b5a796820d792c5c36e472b917e5a47b28763b (diff)
downloadqtquickcontrols-6c47fb0d80a720d44b6fafcd873dac2dafefcf0c.tar.gz
Fix QQuickMenuBar::setNative()
Due to evaluation order, menus can be appended to the default property before the native property is set => sync the items as appropriate. Technically it's now even possible to toggle between a native and non-native menubar even though it doesn't sound like a sane use-case. Change-Id: I513f133a085ffd980a4000afe2a992cb47b7448e Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'src/controls/qquickmenubar.cpp')
-rw-r--r--src/controls/qquickmenubar.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/controls/qquickmenubar.cpp b/src/controls/qquickmenubar.cpp
index d3503f89..33a1e9ef 100644
--- a/src/controls/qquickmenubar.cpp
+++ b/src/controls/qquickmenubar.cpp
@@ -85,9 +85,19 @@ void QQuickMenuBar::setNative(bool native)
{
bool wasNative = isNative();
if (native) {
- if (!m_platformMenuBar)
+ if (!m_platformMenuBar) {
m_platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar();
+ if (m_platformMenuBar) {
+ m_platformMenuBar->handleReparent(m_parentWindow);
+ foreach (QQuickMenu *menu, m_menus)
+ m_platformMenuBar->insertMenu(menu->platformMenu(), 0 /* append */);
+ }
+ }
} else {
+ if (m_platformMenuBar) {
+ foreach (QQuickMenu *menu, m_menus)
+ m_platformMenuBar->removeMenu(menu->platformMenu());
+ }
delete m_platformMenuBar;
m_platformMenuBar = 0;
}