From f6c7ab202c3e1ed63127ec4f743e6b5cd90779ff Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 16 May 2017 17:40:58 +0200 Subject: [PATCH] Reworked menu bar to use burger --- .../ui/views/App/Main/MainWindow.qml | 18 +- .../ui/views/App/Main/MainWindowMenuBar.qml | 215 +++++------------- 2 files changed, 76 insertions(+), 157 deletions(-) diff --git a/linphone-desktop/ui/views/App/Main/MainWindow.qml b/linphone-desktop/ui/views/App/Main/MainWindow.qml index 8a8f527be..0594a38d9 100644 --- a/linphone-desktop/ui/views/App/Main/MainWindow.qml +++ b/linphone-desktop/ui/views/App/Main/MainWindow.qml @@ -47,9 +47,9 @@ ApplicationWindow { // Menu bar. // --------------------------------------------------------------------------- - menuBar: MainWindowMenuBar { + /*menuBar: MainWindowMenuBar { hide: mainLoader.item ? !mainLoader.item.collapse.isCollapsed : true - } + }*/ // --------------------------------------------------------------------------- @@ -184,6 +184,20 @@ ApplicationWindow { visible: !smartSearchBar.isOpen } } + + Icon { + icon: 'burger_menu_normal' + iconSize: 16 + + MainWindowMenuBar { + id: mainmenu + } + + MouseArea { + anchors.fill: parent + onClicked: mainmenu.open() + } + } } } diff --git a/linphone-desktop/ui/views/App/Main/MainWindowMenuBar.qml b/linphone-desktop/ui/views/App/Main/MainWindowMenuBar.qml index de517093c..8095cd5ea 100644 --- a/linphone-desktop/ui/views/App/Main/MainWindowMenuBar.qml +++ b/linphone-desktop/ui/views/App/Main/MainWindowMenuBar.qml @@ -1,7 +1,8 @@ import QtQuick 2.7 -import QtQuick.Controls 1.4 +import QtQuick.Controls 2.1 import QtQuick.Controls.Styles 1.4 import QtQuick.Window 2.2 +import Qt.labs.platform 1.0 import Linphone 1.0 @@ -9,175 +10,79 @@ import App.Styles 1.0 // ============================================================================= -MenuBar { - id: container - - // --------------------------------------------------------------------------- - - property bool hide: false - - // --------------------------------------------------------------------------- - - // Workaround to hide toolbar. - // Use private properties of MenuBar. - - __contentItem.height: hide - ? 0 - : MainWindowMenuBarStyle.height - - __contentItem.transform: Scale { - yScale: Number(!hide) +Item { + function open() { + menu.open() } - // --------------------------------------------------------------------------- - - style: MenuBarStyle { - background: Rectangle { - color: MainWindowMenuBarStyle.color - - Rectangle { - anchors.bottom: parent.bottom - color: MainWindowMenuBarStyle.separator.color - height: MainWindowMenuBarStyle.separator.height - width: parent.width - } - } - - menuStyle: MenuStyle { - id: menuStyle - - font.pointSize: MainWindowMenuBarStyle.subMenu.text.fontSize - - frame: Item {} - - itemDelegate { - background: Rectangle { - color: (styleData.selected || styleData.open) - ? MainWindowMenuBarStyle.subMenu.color.selected - : MainWindowMenuBarStyle.subMenu.color.normal - } - - label: Label { - color: styleData.selected - ? MainWindowMenuBarStyle.subMenu.text.color.selected - : MainWindowMenuBarStyle.subMenu.text.color.normal - font: menuStyle.font - text: styleData.text - } - - shortcut: Label { - color: styleData.selected - ? MainWindowMenuBarStyle.subMenu.text.color.selected - : MainWindowMenuBarStyle.subMenu.text.color.normal - font: menuStyle.font - text: styleData.shortcut - } - } - } - - itemDelegate: Item { - implicitHeight: menuItem.height + MainWindowMenuBarStyle.separator.spacing - implicitWidth: menuItem.width - - Item { - id: menuItem - - implicitHeight: text.height + MainWindowMenuBarStyle.menu.text.verticalMargins * 2 - implicitWidth: text.width + MainWindowMenuBarStyle.menu.text.horizontalMargins * 2 - - Text { - id: text - - anchors.centerIn: parent - color: styleData.open - ? MainWindowMenuBarStyle.menu.text.color.selected - : MainWindowMenuBarStyle.menu.text.color.normal - - font.pointSize: MainWindowMenuBarStyle.menu.text.fontSize - text: formatMnemonic(styleData.text, styleData.underlineMnemonic) - } - - Rectangle { - anchors.bottom: parent.bottom - color: MainWindowMenuBarStyle.menu.indicator.color - visible: styleData.open - - height: MainWindowMenuBarStyle.menu.indicator.height - width: parent.width - } - } - } - } - - // --------------------------------------------------------------------------- - // Options. - // --------------------------------------------------------------------------- - Menu { + id: menu - title: qsTr('options') + Menu { + title: qsTr('options') - MenuItem { - shortcut: 'Ctrl+P' - text: qsTr('settings') + MenuItem { + shortcut: 'Ctrl+P' + text: qsTr('settings') - onTriggered: { - var window = App.getSettingsWindow() - if (window.visibility === Window.Minimized) { - window.visibility = Window.AutomaticVisibility - } else { - window.setVisible(true) + onTriggered: { + var window = App.getSettingsWindow() + if (window.visibility === Window.Minimized) { + window.visibility = Window.AutomaticVisibility + } else { + window.setVisible(true) + } } } - } - MenuSeparator {} + MenuSeparator {} - MenuItem { - shortcut: StandardKey.Quit - text: qsTr('quit') + MenuItem { + shortcut: StandardKey.Quit + text: qsTr('quit') - onTriggered: Qt.quit() - } - } - - // --------------------------------------------------------------------------- - // Tools. - // --------------------------------------------------------------------------- - - Menu { - title: qsTr('tools') - - MenuItem { - text: qsTr('audioAssistant') - - onTriggered: console.log('TODO') - } - } - - // --------------------------------------------------------------------------- - // Help. - // --------------------------------------------------------------------------- - - Menu { - title: qsTr('help') - - MenuItem { - shortcut: StandardKey.HelpContents - text: qsTr('about') - - onTriggered: { - window.detachVirtualWindow() - window.attachVirtualWindow(Qt.resolvedUrl('About.qml')) + onTriggered: Qt.quit() } } - MenuSeparator {} + // --------------------------------------------------------------------------- + // Tools. + // --------------------------------------------------------------------------- - MenuItem { - text: qsTr('checkForUpdates') + Menu { + title: qsTr('tools') - onTriggered: console.log('TODO') + MenuItem { + text: qsTr('audioAssistant') + + onTriggered: console.log('TODO') + } + } + + // --------------------------------------------------------------------------- + // Help. + // --------------------------------------------------------------------------- + + Menu { + title: qsTr('help') + + MenuItem { + shortcut: StandardKey.HelpContents + text: qsTr('about') + + onTriggered: { + window.detachVirtualWindow() + window.attachVirtualWindow(Qt.resolvedUrl('About.qml')) + } + } + + MenuSeparator {} + + MenuItem { + text: qsTr('checkForUpdates') + + onTriggered: console.log('TODO') + } } } -} +} \ No newline at end of file