Commit 232c9190 authored by Harald Sitter's avatar Harald Sitter 🏳️‍🌈 Committed by Nate Graham
Browse files

remove in-app menubar

move all its functionality to the context actions.
also relabel the actions a tad since they are a bit too verbose

for global menus we have a new globalmenu item that takes care of
exporting the actions to the native platform menubar. concept borrowed
from elisa
parent b3c3919e
Pipeline #170846 passed with stage
in 2 minutes and 36 seconds
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
// SPDX-FileCopyrightText: 2022 Harald Sitter <sitter@kde.org>
import QtQuick 2.15
import Qt.labs.platform 1.1 as Platform
Platform.MenuItem {
required property var action
checkable: action.checkable
checked: action.checked
icon.name: action.iconName
icon.source: action.iconSource
shortcut: action.shortcut
separator: action.separator
text: action.text
visible: action.visible
onTriggered: action.triggered(this)
}
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
// SPDX-FileCopyrightText: 2022 Harald Sitter <sitter@kde.org>
import QtQuick 2.15
import Qt.labs.platform 1.1 as Platform
import org.kde.kirigami 2.19 as Kirigami
Platform.MenuBar {
Platform.Menu {
title: i18nc("@item:inmenu", "Scan")
ActionMenuItem { action: scanFolderAction }
ActionMenuItem { action: Kirigami.Action { separator: true } }
ActionMenuItem { action: scanHomeAction }
ActionMenuItem { action: scanRootAction }
ActionMenuItem { action: Kirigami.Action { separator: true } }
ActionMenuItem { action: quitAction }
}
Platform.Menu {
title: i18nc("@item:inmenu", "Settings")
ActionMenuItem { action: configureAction }
}
Platform.Menu {
title: i18nc("@item:inmenu", "Help")
ActionMenuItem { action: helpAction }
ActionMenuItem { action: aboutAction }
}
}
......@@ -74,7 +74,10 @@ Kirigami.Page {
stopAction,
zoomInAction,
zoomOutAction,
saveSVGAction
saveSVGAction,
configureAction,
helpAction,
aboutAction
])
RowLayout {
......
......@@ -14,6 +14,12 @@ Kirigami.Page {
title: i18nc("@title", "Overview")
contextualActions: [
configureAction,
helpAction,
aboutAction
]
ColumnLayout {
spacing: Kirigami.Units.gridUnit
width: parent.width - (Kirigami.Units.largeSpacing * 4)
......@@ -38,33 +44,21 @@ Kirigami.Page {
icon.width: Kirigami.Units.iconSizes.huge
icon.height: Kirigami.Units.iconSizes.huge
display: QQC2.AbstractButton.TextUnderIcon
action: Kirigami.Action {
iconName: "folder"
text: i18nc("@action", "Scan Folder")
onTriggered: appWindow.slotScanFolder()
}
action: scanFolderAction
}
QQC2.ToolButton {
id: button2
icon.width: Kirigami.Units.iconSizes.huge
icon.height: Kirigami.Units.iconSizes.huge
display: QQC2.AbstractButton.TextUnderIcon
action: Kirigami.Action {
iconName: "user-home"
text: i18nc("@action", "Scan Home Folder")
onTriggered: appWindow.slotScanHomeFolder()
}
action: scanHomeAction
}
QQC2.ToolButton {
id: button3
icon.width: Kirigami.Units.iconSizes.huge
icon.height: Kirigami.Units.iconSizes.huge
display: QQC2.AbstractButton.TextUnderIcon
action: Kirigami.Action {
iconName: "folder-root"
text: i18nc("@action", "Scan Root Folder")
onTriggered: appWindow.slotScanRootFolder()
}
action: scanRootAction
}
}
......
......@@ -8,6 +8,8 @@ import org.kde.kirigami 2.19 as Kirigami
import org.kde.filelight 1.0
import Qt.labs.platform 1.1 as Platform
Kirigami.ApplicationWindow {
id: appWindow
......@@ -16,60 +18,61 @@ Kirigami.ApplicationWindow {
property var mapItem: null
property var mapPage: null
menuBar: QQC2.MenuBar {
Kirigami.Theme.inherit: false
Kirigami.Theme.colorSet: Kirigami.Theme.Header
Kirigami.Action {
id: scanFolderAction
iconName: "folder"
text: i18nc("@action", "Scan Folder")
onTriggered: appWindow.slotScanFolder()
}
QQC2.Menu {
title: i18nc("@item:inmenu", "Scan")
Kirigami.Action {
iconName: "document-open-folder"
text: i18nc("@action", "Scan Folder")
onTriggered: appWindow.slotScanFolder()
}
Kirigami.Action {
id: scanHomeAction
iconName: "user-home"
text: i18nc("@action", "Scan Home Folder")
onTriggered: appWindow.slotScanHomeFolder()
}
QQC2.MenuSeparator { }
Kirigami.Action {
iconName: "user-home"
text: i18nc("@action", "Scan Home Folder")
onTriggered: appWindow.slotScanHomeFolder()
}
Kirigami.Action {
iconName: "folder-root"
text: i18nc("@action", "Scan Root Folder")
onTriggered: appWindow.slotScanRootFolder()
}
QQC2.MenuSeparator { }
Kirigami.Action {
iconName: "application-exit"
text: i18nc("@action", "Quit")
onTriggered: Qt.quit()
}
}
QQC2.Menu {
title: i18nc("@item:inmenu", "Settings")
Kirigami.Action {
iconName: "configure"
text: i18nc("@action", "Configure Filelight…")
onTriggered: MainContext.configFilelight()
shortcut: "Ctrl+Shift+,"
}
}
QQC2.Menu {
title: i18nc("@item:inmenu", "Help")
Kirigami.Action {
iconName: "help-browser"
text: i18nc("@action", "Filelight Handbook")
onTriggered: { Qt.openUrlExternally("help:/filelight") }
}
Kirigami.Action {
iconName: "filelight"
text: i18nc("@action", "About Filelight")
onTriggered: { pageStack.layers.push("qrc:/ui/AboutPage.qml") }
}
}
Kirigami.Action {
id: scanRootAction
iconName: "folder-root"
text: i18nc("@action", "Scan Root Folder")
onTriggered: appWindow.slotScanRootFolder()
}
Kirigami.Action {
id: quitAction
iconName: "application-exit"
text: i18nc("@action", "Quit")
onTriggered: Qt.quit()
}
Kirigami.Action {
id: configureAction
displayHint: Kirigami.Action.AlwaysHide
iconName: "configure"
text: i18nc("@action configure app", "Configure…")
onTriggered: MainContext.configFilelight()
shortcut: "Ctrl+Shift+,"
}
Kirigami.Action {
id: helpAction
displayHint: Kirigami.Action.AlwaysHide
iconName: "help-browser"
text: i18nc("@action", "Open Handbook")
onTriggered: { Qt.openUrlExternally("help:/filelight") }
}
Kirigami.Action {
id: aboutAction
displayHint: Kirigami.Action.AlwaysHide
iconName: "filelight"
text: i18nc("@action opens about app page", "About")
onTriggered: { pageStack.layers.push("qrc:/ui/AboutPage.qml") }
}
GlobalMenu {}
footer: QQC2.Control { // gives us padding and whatnot
background: Rectangle {
Kirigami.Theme.inherit: false
......
......@@ -9,5 +9,7 @@
<file>MapPage.qml</file>
<file>Action.qml</file>
<file>AboutPage.qml</file>
<file>ActionMenuItem.qml</file>
<file>GlobalMenu.qml</file>
</qresource>
</RCC>
Supports Markdown
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