Commit 7d815c9f authored by Matthieu Gallien's avatar Matthieu Gallien 🎵

Add global menu by using qml native menu components

Summary:
Seems to do the job by providing a global menu and not clutering the UI
when plasma-workspace does not provide a global menu.

BUG: 400335

Test Plan: Works with Plasma 5.14 and a global menu applet

Reviewers: #elisa, ngraham

Reviewed By: #elisa, ngraham

Subscribers: trmdi

Tags: #elisa

Differential Revision: https://phabricator.kde.org/D21006
parent 7885c843
......@@ -349,6 +349,7 @@ if (Qt5Quick_FOUND AND Qt5Widgets_FOUND)
qml/ElisaMainWindow.qml
qml/ApplicationMenu.qml
qml/NativeApplicationMenu.qml
qml/BaseTheme.qml
qml/Theme.qml
qml/PlatformIntegration.qml
......
......@@ -21,6 +21,7 @@ import QtQuick.Layouts 1.1
import QtQuick.Window 2.2
import org.kde.elisa 1.0
import Qt.labs.settings 1.0
import Qt.labs.platform 1.0 as NativeMenu
ApplicationWindow {
id: mainWindow
......@@ -78,6 +79,11 @@ ApplicationWindow {
id: applicationMenu
}
NativeMenu.MenuBar {
NativeApplicationMenu {
}
}
SystemPalette {
id: myPalette
colorGroup: SystemPalette.Active
......
/*
* Copyright 2016-2018 Matthieu Gallien <matthieu_gallien@yahoo.fr>
* Copyright 2018 Alexander Stippich <a.stippich@gmx.net>
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import QtQuick 2.7
//explore menu from Qt 5.10 once we can require it, but it is item-based
import Qt.labs.platform 1.0
import org.kde.elisa 1.0
Menu {
id: applicationMenu
title: i18nc("open application menu", "Application Menu")
property var helpAction: elisa.action("help_contents")
property var quitApplication: elisa.action("file_quit")
property var reportBugAction: elisa.action("help_report_bug")
property var aboutAppAction: elisa.action("help_about_app")
property var configureShortcutsAction: elisa.action("options_configure_keybinding")
property var configureAction: elisa.action("options_configure")
property var togglePlaylistAction: elisa.action("toggle_playlist")
MenuItem {
text: i18nc("Refresh Music Collection application menu entry", "Refresh Music Collection")
iconName: "collection-rescan-amarok"
onTriggered: elisa.musicManager.resetMusicData()
}
MenuSeparator {
}
MenuItem {
text: configureAction.text
shortcut: configureAction.shortcut
iconName: elisa.iconName(configureAction.icon)
onTriggered: configureAction.trigger()
visible: configureAction.text !== ""
}
MenuItem {
text: configureShortcutsAction.text
shortcut: configureShortcutsAction.shortcut
iconName: elisa.iconName(configureShortcutsAction.icon)
onTriggered: configureShortcutsAction.trigger()
visible: configureShortcutsAction.text !== ""
}
MenuItem {
shortcut: togglePlaylistAction.shortcut
text: contentView.showPlaylist ? i18nc("Hide playlist", "Hide Playlist") : i18nc("Show playlist", "Show Playlist")
iconName: "view-media-playlist"
onTriggered: contentView.showPlaylist = !contentView.showPlaylist
enabled: contentView.currentViewIndex != 0
}
MenuSeparator {
visible: reportBugAction.text !== ""
}
MenuItem {
text: reportBugAction.text
shortcut: reportBugAction.shortcut
iconName: elisa.iconName(reportBugAction.icon)
onTriggered: reportBugAction.trigger()
visible: reportBugAction.text !== ""
}
MenuSeparator {
visible: helpAction.text !== ""
}
MenuItem {
text: helpAction.text
shortcut: helpAction.shortcut
iconName: elisa.iconName(helpAction.icon)
onTriggered: helpAction.trigger()
visible: helpAction.text !== ""
}
MenuItem {
text: aboutAppAction.text
shortcut: aboutAppAction.shortcut
iconName: elisa.iconName(aboutAppAction.icon)
onTriggered: aboutAppAction.trigger()
visible: aboutAppAction.text !== ""
}
MenuSeparator {
visible: quitApplication.text !== ""
}
MenuItem {
text: quitApplication.text
shortcut: quitApplication.shortcut
iconName: elisa.iconName(quitApplication.icon)
onTriggered: quitApplication.trigger()
visible: quitApplication.text !== ""
}
}
......@@ -38,6 +38,7 @@
<file>qml/ViewSelectorDelegate.qml</file>
<file>qml/HeaderFooterToolbar.qml</file>
<file>qml/TracksDiscHeader.qml</file>
<file>qml/NativeApplicationMenu.qml</file>
</qresource>
<qresource prefix="/qml/+windows">
<file alias="Theme.qml">windows/WindowsTheme.qml</file>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment