From f17acb41e5d546e7f83900c5984dbb0334f6ac0f Mon Sep 17 00:00:00 2001
From: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Date: Mon, 18 Feb 2013 15:24:34 +0100
Subject: [PATCH] MenuStyle, MenuBarStyle: Port to new styling API

Change-Id: Ic41ce57586f52262f3509d69b7918fb1ad5f3ce3
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
---
 src/private/Control.qml                       |  4 +-
 src/qtdesktop/Menu.qml                        | 39 +++++----
 src/qtdesktop/MenuBar.qml                     | 37 +++++----
 src/styles/Desktop/MenuBarItemStyle.qml       | 57 -------------
 src/styles/Desktop/MenuBarStyle.qml           | 28 +++++--
 .../{MenuItemStyle.qml => MenuStyle.qml}      | 61 ++++++++++----
 src/styles/MenuBarItemStyle.qml               | 62 --------------
 src/styles/MenuBarStyle.qml                   | 28 +++++--
 src/styles/MenuFrameStyle.qml                 | 57 -------------
 src/styles/MenuItemStyle.qml                  | 81 -------------------
 .../MenuFrameStyle.qml => MenuStyle.qml}      | 56 +++++++++----
 src/styles/styles.pro                         |  8 +-
 12 files changed, 183 insertions(+), 335 deletions(-)
 delete mode 100644 src/styles/Desktop/MenuBarItemStyle.qml
 rename src/styles/Desktop/{MenuItemStyle.qml => MenuStyle.qml} (54%)
 delete mode 100644 src/styles/MenuBarItemStyle.qml
 delete mode 100644 src/styles/MenuFrameStyle.qml
 delete mode 100644 src/styles/MenuItemStyle.qml
 rename src/styles/{Desktop/MenuFrameStyle.qml => MenuStyle.qml} (58%)

diff --git a/src/private/Control.qml b/src/private/Control.qml
index 1cf753826..5ed4233ed 100644
--- a/src/private/Control.qml
+++ b/src/private/Control.qml
@@ -65,13 +65,13 @@ FocusScope {
         anchors.fill: parent
         sourceComponent: __style ? __style.panel : null
         property alias control: root
-        onStatusChanged: if (status === Loader.Error) print("Failed to load panel for " + root)
+        onStatusChanged: if (status === Loader.Error) console.error("Failed to load Style for", root)
         Loader {
             id: styleLoader
             sourceComponent: style
             onStatusChanged: {
                 if (status === Loader.Error)
-                    print("Failed to load Style for " + root)
+                    console.error("Failed to load Style for", root)
             }
         }
     }
diff --git a/src/qtdesktop/Menu.qml b/src/qtdesktop/Menu.qml
index 79dd3da36..63b9b26a6 100644
--- a/src/qtdesktop/Menu.qml
+++ b/src/qtdesktop/Menu.qml
@@ -40,6 +40,7 @@
 
 import QtQuick 2.0
 import QtDesktop 1.0
+import QtDesktop.Styles 1.0
 import "Styles/Settings.js" as Settings
 
 /*!
@@ -128,8 +129,8 @@ import "Styles/Settings.js" as Settings
 
 MenuPrivate {
     id: root
-    property Component menuFrameStyle: Qt.createComponent(Settings.THEME_PATH + "/MenuFrameStyle.qml", root)
-    property Component menuItemStyle: Qt.createComponent(Settings.THEME_PATH + "/MenuItemStyle.qml", root)
+
+    property Component style: Qt.createComponent(Settings.THEME_PATH + "/MenuStyle.qml", root)
 
     //! internal
     property var menuBar: null
@@ -146,14 +147,27 @@ MenuPrivate {
     property Component menuComponent: Loader {
         id: menuFrameLoader
 
-        property var menu: root
-        property alias menuItemsColumn: column
+        property Style __style: styleLoader.item
+        property Component menuItemStyle: __style ? __style.menuItem : null
+
+        property var control: root
+        property alias contentWidth: column.width
+        property alias contentHeight: column.height
 
         property int subMenuXPos: width + (item && item["subMenuOverlap"] || 0)
-        property int itemWidth: item ? item.implicitWidth : 0
 
-        visible: menu.popupVisible && status === Loader.Ready
-        sourceComponent: menuFrameStyle
+        visible: control.popupVisible && status === Loader.Ready
+        sourceComponent: __style ? __style.frame : undefined
+
+        Loader {
+            id: styleLoader
+            active: !root.isNative
+            sourceComponent: root.style
+            onStatusChanged: {
+                if (status === Loader.Error)
+                    console.error("Failed to load Style for", root)
+            }
+        }
 
         focus: true
         Keys.forwardTo: menuBar ? [menuBar] : []
@@ -230,8 +244,6 @@ MenuPrivate {
             Column {
                 id: column
 
-                width: Math.max(menuFrameLoader.itemWidth, implicitWidth)
-
                 Repeater {
                     id: itemsRepeater
                     model: root.menuItems
@@ -240,14 +252,13 @@ MenuPrivate {
                         id: menuItemLoader
 
                         property var menuItem: modelData
+                        property int contentWidth: column.width
+                        property int contentHeight: column.height
                         property bool isSeparator: menuItem ? !menuItem.hasOwnProperty("text") : false
                         property bool hasSubmenu: menuItem ? !!menuItem["menuItems"] : false
                         property bool selected: !isSeparator && root.currentIndex === index
 
-                        property alias mouseArea: itemMouseArea
-                        property var menuItemsColumn: column
-
-                        sourceComponent: root.menuItemStyle
+                        sourceComponent: menuFrameLoader.menuItemStyle
                         enabled: !isSeparator && !!menuItem && menuItem.enabled
 
                         MouseArea {
@@ -314,7 +325,7 @@ MenuPrivate {
                     for (var i = 0; i < children.length; i++) {
                         var item = children[i]["item"]
                         if (item)
-                            item.implicitWidth = width
+                            item.implicitWidth = Math.max(root.minimumWidth, implicitWidth)
                     }
                 }
             }
diff --git a/src/qtdesktop/MenuBar.qml b/src/qtdesktop/MenuBar.qml
index fa8682eb0..6e22e3e22 100644
--- a/src/qtdesktop/MenuBar.qml
+++ b/src/qtdesktop/MenuBar.qml
@@ -40,6 +40,8 @@
 
 import QtQuick 2.0
 import QtDesktop 1.0
+import QtDesktop.Styles 1.0
+import QtDesktop.Private 1.0
 import "Styles/Settings.js" as Settings
 
 /*!
@@ -71,24 +73,36 @@ import "Styles/Settings.js" as Settings
 MenuBarPrivate {
     id: root
 
-    height: !isNative ? menuBarLoader.height : 0
+    property Component style: Qt.createComponent(Settings.THEME_PATH + "/MenuBarStyle.qml", root)
 
+    height: !isNative ? menuBarLoader.height : 0
     data: [
         Loader {
             id: menuBarLoader
 
-            property Component menuBarStyle: Qt.createComponent(Settings.THEME_PATH + "/MenuBarStyle.qml", root)
-            property Component menuItemStyle: Qt.createComponent(Settings.THEME_PATH + "/MenuBarItemStyle.qml", root)
+            property Style __style: styleLoader.item
+            property Component menuItemStyle: __style ? __style.menuItem : null
 
-            visible: active && status === Loader.Ready
-            active: !root.isNative
-            sourceComponent: menuBarStyle
+            property alias control: root
+            onStatusChanged: if (status === Loader.Error) console.error("Failed to load panel for", root)
 
-            property var menuBar: root
-            property var menuItemsRow: row
+            visible: status === Loader.Ready
+            active: !root.isNative
+            sourceComponent: __style ? __style.frame : undefined
+
+            Loader {
+                id: styleLoader
+                active: !root.isNative
+                sourceComponent: root.style
+                onStatusChanged: {
+                    if (status === Loader.Error)
+                        console.error("Failed to load Style for", root)
+                }
+            }
 
             property int openedMenuIndex: -1
             property bool preselectMenuItem: false
+            property alias contentHeight: row.height
 
             Binding {
                 // Make sure the styled menu bar is in the background
@@ -127,14 +141,9 @@ MenuBarPrivate {
                         Loader {
                             id: menuItemLoader
 
-                            property var menuItem: modelData
+                            property var menuItem: root.isNative ? null : modelData
                             property bool selected: menuItem.popupVisible || itemMouseArea.pressed || menuBarLoader.openedMenuIndex === index
 
-                            property alias mouseArea: itemMouseArea
-                            property var menuItemsRow: row
-
-                            property bool allowMenuClose: false
-
                             sourceComponent: menuBarLoader.menuItemStyle
 
                             MouseArea {
diff --git a/src/styles/Desktop/MenuBarItemStyle.qml b/src/styles/Desktop/MenuBarItemStyle.qml
deleted file mode 100644
index be20f6494..000000000
--- a/src/styles/Desktop/MenuBarItemStyle.qml
+++ /dev/null
@@ -1,57 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-**   * Redistributions of source code must retain the above copyright
-**     notice, this list of conditions and the following disclaimer.
-**   * Redistributions in binary form must reproduce the above copyright
-**     notice, this list of conditions and the following disclaimer in
-**     the documentation and/or other materials provided with the
-**     distribution.
-**   * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-**     of its contributors may be used to endorse or promote products derived
-**     from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtDesktop 1.0
-import QtDesktop.Private 1.0
-
-StyleItem {
-    elementType: "menubaritem"
-//    x: pixelMetric("menuhmargin") + pixelMetric("menupanelwidth")
-//    y: pixelMetric("menuvmargin") + pixelMetric("menupanelwidth")
-
-    text: menuItem.text
-    contentWidth: textWidth(text)
-    contentHeight: textHeight(text)
-
-    enabled: menuItem.enabled
-    selected: parent.selected
-    sunken: parent.selected
-}
diff --git a/src/styles/Desktop/MenuBarStyle.qml b/src/styles/Desktop/MenuBarStyle.qml
index c7c312257..34ddad672 100644
--- a/src/styles/Desktop/MenuBarStyle.qml
+++ b/src/styles/Desktop/MenuBarStyle.qml
@@ -40,11 +40,29 @@
 
 import QtQuick 2.0
 import QtDesktop 1.0
+import QtDesktop.Styles 1.0
 import QtDesktop.Private 1.0
 
-StyleItem {
-    elementType: "menubar"
-    width: menuBar.width
-    height: menuItemsRow.height
-//            + 2 * (pixelMetric("menuvmargin") + pixelMetric("menupanelwidth"))
+
+Style {
+    property Component frame: StyleItem {
+        elementType: "menubar"
+        width: control.width
+        height: parent ? parent.contentHeight : 0
+        //        + 2 * (pixelMetric("menuvmargin") + pixelMetric("menupanelwidth"))
+    }
+
+    property Component menuItem: StyleItem {
+        elementType: "menubaritem"
+    //    x: pixelMetric("menuhmargin") + pixelMetric("menupanelwidth")
+    //    y: pixelMetric("menuvmargin") + pixelMetric("menupanelwidth")
+
+        text: menuItem.text
+        contentWidth: textWidth(text)
+        contentHeight: textHeight(text)
+
+        enabled: menuItem.enabled
+        selected: parent.selected
+        sunken: parent.selected
+    }
 }
diff --git a/src/styles/Desktop/MenuItemStyle.qml b/src/styles/Desktop/MenuStyle.qml
similarity index 54%
rename from src/styles/Desktop/MenuItemStyle.qml
rename to src/styles/Desktop/MenuStyle.qml
index 809163dd0..64f3fc905 100644
--- a/src/styles/Desktop/MenuItemStyle.qml
+++ b/src/styles/Desktop/MenuStyle.qml
@@ -40,27 +40,54 @@
 
 import QtQuick 2.0
 import QtDesktop 1.0
+import QtDesktop.Styles 1.0
 import QtDesktop.Private 1.0
 
-StyleItem {
-    elementType: "menuitem"
-    x: pixelMetric("menuhmargin") + pixelMetric("menupanelwidth")
-    y: pixelMetric("menuvmargin") + pixelMetric("menupanelwidth")
+Style {
+    id: styleRoot
 
-    text: isSeparator || !menuItem ? "" : menuItem.text
-    property string textAndShorcut: text + (properties.shortcut ? "\t" + properties.shortcut : "")
-    contentWidth: textWidth(textAndShorcut)
-    contentHeight: textHeight(textAndShorcut)
+    property Component frame: StyleItem {
+        elementType: "menu"
 
-    enabled: !!parent && parent.enabled
-    selected: !!parent && parent.selected
-    on: !!menuItem && !!menuItem["checkable"] && menuItem.checked
+        contentWidth: parent ? parent.contentWidth : 0
+        contentHeight: parent ? parent.contentHeight : 0
+        width: implicitWidth + 2 * (pixelMetric("menuhmargin") + pixelMetric("menupanelwidth"))
+        height: implicitHeight + 2 * (pixelMetric("menuvmargin") + pixelMetric("menupanelwidth"))
 
-    properties: {
-        "checkable": !!menuItem && !!menuItem["checkable"],
-        "exclusive": !!menuItem && !!menuItem["exclusiveGroup"],
-        "shortcut": !!menuItem && menuItem["shortcut"] || "",
-        "hasSubmenu": hasSubmenu,
-        "icon": !!menuItem && !!menuItem["action"] ? menuItem.action.__icon : null
+        property int subMenuOverlap: pixelMetric("submenuoverlap")
+
+        SystemPalette { id: syspal }
+
+        Rectangle {
+            visible: anchors.margins > 0
+            anchors {
+                fill: parent
+                margins: pixelMetric("menupanelwidth")
+            }
+            color: syspal.window
+        }
+    }
+
+    property Component menuItem: StyleItem {
+        elementType: "menuitem"
+        x: pixelMetric("menuhmargin") + pixelMetric("menupanelwidth")
+        y: pixelMetric("menuvmargin") + pixelMetric("menupanelwidth")
+
+        text: isSeparator || !menuItem ? "" : menuItem.text
+        property string textAndShorcut: text + (properties.shortcut ? "\t" + properties.shortcut : "")
+        contentWidth: textWidth(textAndShorcut)
+        contentHeight: textHeight(textAndShorcut)
+
+        enabled: !!parent && parent.enabled
+        selected: !!parent && parent.selected
+        on: !!menuItem && !!menuItem["checkable"] && menuItem.checked
+
+        properties: {
+            "checkable": !!menuItem && !!menuItem["checkable"],
+            "exclusive": !!menuItem && !!menuItem["exclusiveGroup"],
+            "shortcut": !!menuItem && menuItem["shortcut"] || "",
+            "hasSubmenu": hasSubmenu,
+            "icon": !!menuItem && !!menuItem["action"] ? menuItem.action.__icon : null
+        }
     }
 }
diff --git a/src/styles/MenuBarItemStyle.qml b/src/styles/MenuBarItemStyle.qml
deleted file mode 100644
index b2b2d5de3..000000000
--- a/src/styles/MenuBarItemStyle.qml
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-**   * Redistributions of source code must retain the above copyright
-**     notice, this list of conditions and the following disclaimer.
-**   * Redistributions in binary form must reproduce the above copyright
-**     notice, this list of conditions and the following disclaimer in
-**     the documentation and/or other materials provided with the
-**     distribution.
-**   * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-**     of its contributors may be used to endorse or promote products derived
-**     from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-/*!
-    \qmltype MenuBarItemStyle
-    \internal
-    \inqmlmodule QtDesktop.Styles 1.0
-*/
-Rectangle {
-    SystemPalette { id: syspal }
-
-    width: text.width + 12
-    height: text.height + 4
-    color: selected ? syspal.highlight : syspal.window
-
-    Text {
-        id: text
-        text: menuItem.text
-        anchors.centerIn: parent
-        renderType: Text.NativeRendering
-        color: selected ? syspal.highlightedText : syspal.windowText
-    }
-}
diff --git a/src/styles/MenuBarStyle.qml b/src/styles/MenuBarStyle.qml
index 37fdaa703..e4ccadd42 100644
--- a/src/styles/MenuBarStyle.qml
+++ b/src/styles/MenuBarStyle.qml
@@ -39,16 +39,34 @@
 ****************************************************************************/
 
 import QtQuick 2.0
+import QtDesktop.Styles 1.0
 
 /*!
     \qmltype MenuBarStyle
     \internal
     \inqmlmodule QtDesktop.Styles 1.0
 */
-Rectangle {
-    SystemPalette { id: syspal }
 
-    width: menuBar.width
-    height: 20
-    color: syspal.window
+Style {
+    property var __syspal: SystemPalette { id: syspal }
+
+    property Component panel: Rectangle {
+        width: control.width
+        height: 20
+        color: __syspal.window
+    }
+
+    property Component menuItem: Rectangle {
+        width: text.width + 12
+        height: text.height + 4
+        color: selected ? __syspal.highlight : __syspal.window
+
+        Text {
+            id: text
+            text: menuItem.text
+            anchors.centerIn: parent
+            renderType: Text.NativeRendering
+            color: selected ? __syspal.highlightedText : __syspal.windowText
+        }
+    }
 }
diff --git a/src/styles/MenuFrameStyle.qml b/src/styles/MenuFrameStyle.qml
deleted file mode 100644
index f0b09b154..000000000
--- a/src/styles/MenuFrameStyle.qml
+++ /dev/null
@@ -1,57 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-**   * Redistributions of source code must retain the above copyright
-**     notice, this list of conditions and the following disclaimer.
-**   * Redistributions in binary form must reproduce the above copyright
-**     notice, this list of conditions and the following disclaimer in
-**     the documentation and/or other materials provided with the
-**     distribution.
-**   * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-**     of its contributors may be used to endorse or promote products derived
-**     from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtDesktop 1.0
-
-/*!
-    \qmltype MenuFrameStyle
-    \internal
-    \inqmlmodule QtDesktop.Styles 1.0
-*/
-Rectangle {
-    width: Math.max(menu.minimumWidth, menuItemsColumn.width) + 2
-    height: menuItemsColumn.implicitHeight + 2
-
-    color: "lightgray"
-    border { width: 1; color: "darkgray" }
-
-    property int subMenuOverlap: -1
-}
diff --git a/src/styles/MenuItemStyle.qml b/src/styles/MenuItemStyle.qml
deleted file mode 100644
index c61795c28..000000000
--- a/src/styles/MenuItemStyle.qml
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-**   * Redistributions of source code must retain the above copyright
-**     notice, this list of conditions and the following disclaimer.
-**   * Redistributions in binary form must reproduce the above copyright
-**     notice, this list of conditions and the following disclaimer in
-**     the documentation and/or other materials provided with the
-**     distribution.
-**   * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-**     of its contributors may be used to endorse or promote products derived
-**     from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtDesktop 1.0
-
-/*!
-    \qmltype MenuItemStyle
-    \internal
-    \inqmlmodule QtDesktop.Styles 1.0
-*/
-Rectangle {
-    width: Math.max(column.implicitWidth, text.paintedWidth + 12)
-    height: isSeparator ? text.font.pixelSize / 2 : text.paintedHeight + 4
-    color: selected ? "" : backgroundColor
-    gradient: selected ? selectedGradient : undefined
-
-    readonly property color backgroundColor: "lightgray"
-    Gradient {
-        id: selectedGradient
-        GradientStop {color: Qt.lighter(backgroundColor, 1.8)  ; position: 0}
-        GradientStop {color: backgroundColor ; position: 1.4}
-    }
-    antialiasing: true
-
-    Text {
-        id: text
-        visible: !isSeparator
-        text: menuItemData.text + (hasSubmenu ? "  \u25b6" : "")
-        x: 6
-        anchors.verticalCenter: parent.verticalCenter
-        renderType: Text.NativeRendering
-        color: "black"
-    }
-
-    Rectangle {
-        visible: isSeparator
-        width: parent.width - 2
-        height: 1
-        x: 1
-        anchors.verticalCenter: parent.verticalCenter
-        color: "darkgray"
-    }
-}
diff --git a/src/styles/Desktop/MenuFrameStyle.qml b/src/styles/MenuStyle.qml
similarity index 58%
rename from src/styles/Desktop/MenuFrameStyle.qml
rename to src/styles/MenuStyle.qml
index d7229061b..152763944 100644
--- a/src/styles/Desktop/MenuFrameStyle.qml
+++ b/src/styles/MenuStyle.qml
@@ -40,26 +40,52 @@
 
 import QtQuick 2.0
 import QtDesktop 1.0
-import QtDesktop.Private 1.0
+import QtDesktop.Styles 1.0
 
-StyleItem {
-    elementType: "menu"
+Style {
+    id: styleRoot
 
-    contentWidth: Math.max(menu.minimumWidth, menuItemsColumn.width)
-    contentHeight: menuItemsColumn.height
-    width: implicitWidth + 2 * (pixelMetric("menuhmargin") + pixelMetric("menupanelwidth"))
-    height: implicitHeight + 2 * (pixelMetric("menuvmargin") + pixelMetric("menupanelwidth"))
+    property Component frame: Rectangle {
+        width: (parent ? parent.contentWidth : 0) + 2
+        height: (parent ? parent.contentHeight : 0) + 2
 
-    property int subMenuOverlap: pixelMetric("submenuoverlap")
+        color: "lightgray"
+        border { width: 1; color: "darkgray" }
 
-    SystemPalette { id: syspal }
+        property int subMenuOverlap: -1
+    }
+
+    property Component menuItem: Rectangle {
+        width: Math.max((parent ? parent.contentWidth : 0), text.paintedWidth + 12)
+        height: isSeparator ? text.font.pixelSize / 2 : text.paintedHeight + 4
+        color: selected ? "" : backgroundColor
+        gradient: selected ? selectedGradient : undefined
+
+        readonly property color backgroundColor: "lightgray"
+        Gradient {
+            id: selectedGradient
+            GradientStop {color: Qt.lighter(backgroundColor, 1.8)  ; position: 0}
+            GradientStop {color: backgroundColor ; position: 1.4}
+        }
+        antialiasing: true
+
+        Text {
+            id: text
+            visible: !isSeparator
+            text: menuItem.text + (hasSubmenu ? "  \u25b6" : "")
+            x: 6
+            anchors.verticalCenter: parent.verticalCenter
+            renderType: Text.NativeRendering
+            color: "black"
+        }
 
-    Rectangle {
-        visible: anchors.margins > 0
-        anchors {
-            fill: parent
-            margins: pixelMetric("menupanelwidth")
+        Rectangle {
+            visible: isSeparator
+            width: parent.width - 2
+            height: 1
+            x: 1
+            anchors.verticalCenter: parent.verticalCenter
+            color: "darkgray"
         }
-        color: syspal.window
     }
 }
diff --git a/src/styles/styles.pro b/src/styles/styles.pro
index bf26dc512..7e2ff0c15 100644
--- a/src/styles/styles.pro
+++ b/src/styles/styles.pro
@@ -6,9 +6,7 @@ QML_FILES = \
     ComboBoxStyle.qml \
     GroupBoxStyle.qml \
     MenuBarStyle.qml \
-    MenuBarItemStyle.qml \
-    MenuFrameStyle.qml \
-    MenuItemStyle.qml \
+    MenuStyle.qml \
     ProgressBarStyle.qml \
     RadioButtonStyle.qml \
     ScrollAreaStyle.qml \
@@ -29,9 +27,7 @@ QML_FILES += \
     Desktop/ComboBoxStyle.qml \
     Desktop/GroupBoxStyle.qml \
     Desktop/MenuBarStyle.qml \
-    Desktop/MenuBarItemStyle.qml \
-    Desktop/MenuFrameStyle.qml \
-    Desktop/MenuItemStyle.qml \
+    Desktop/MenuStyle.qml \
     Desktop/ProgressBarStyle.qml \
     Desktop/RadioButtonStyle.qml \
     Desktop/ScrollAreaStyle.qml \
-- 
GitLab