Warning, /utilities/filelight/src/qml/main.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0002 // SPDX-FileCopyrightText: 2021-2022 Harald Sitter <sitter@kde.org> 0003 0004 import QtQuick 2.15 0005 import QtQuick.Layouts 1.15 0006 import QtQuick.Controls 2.15 as QQC2 0007 import org.kde.kirigami 2.19 as Kirigami 0008 0009 import org.kde.filelight 1.0 0010 0011 Kirigami.ApplicationWindow { 0012 id: appWindow 0013 0014 required property bool inSandbox 0015 0016 property string status 0017 property var mapPage: null 0018 0019 title: MainContext.prettyUrl(MainContext.url) 0020 pageStack.globalToolBar.showNavigationButtons: { 0021 if (pageStack.currentItem instanceof MapPage) { 0022 return Kirigami.ApplicationHeaderStyle.NoNavigationButtons 0023 } 0024 return (Kirigami.ApplicationHeaderStyle.ShowBackButton | Kirigami.ApplicationHeaderStyle.ShowForwardButton) 0025 } 0026 0027 Kirigami.Action { 0028 id: scanFolderAction 0029 icon.name: "folder" 0030 text: i18nc("@action", "Scan Folder") 0031 onTriggered: appWindow.slotScanFolder() 0032 } 0033 0034 Kirigami.Action { 0035 id: scanHomeAction 0036 icon.name: "user-home" 0037 text: i18nc("@action", "Scan Home Folder") 0038 onTriggered: appWindow.slotScanHomeFolder() 0039 } 0040 0041 Kirigami.Action { 0042 id: scanRootAction 0043 icon.name: "folder-root" 0044 text: i18nc("@action", "Scan Root Folder") 0045 onTriggered: appWindow.slotScanRootFolder() 0046 } 0047 0048 Kirigami.Action { 0049 id: quitAction 0050 icon.name: "application-exit" 0051 text: i18nc("@action", "Quit") 0052 onTriggered: Qt.quit() 0053 } 0054 0055 Kirigami.Action { 0056 id: configureAction 0057 displayHint: Kirigami.DisplayHint.AlwaysHide 0058 icon.name: "configure" 0059 text: i18nc("@action configure app", "Configureā¦") 0060 onTriggered: { 0061 const openDialogWindow = pageStack.pushDialogLayer("qrc:/ui/SettingsPage.qml", { 0062 width: appWindow.width 0063 }, { 0064 title: i18nc("@title:window", "Configure"), 0065 width: Kirigami.Units.gridUnit * 30, 0066 height: Kirigami.Units.gridUnit * 25 0067 }); 0068 } 0069 shortcut: "Ctrl+Shift+," 0070 } 0071 0072 Kirigami.Action { 0073 id: helpAction 0074 displayHint: Kirigami.DisplayHint.AlwaysHide 0075 icon.name: "help-browser" 0076 text: i18nc("@action", "Open Handbook") 0077 onTriggered: { Qt.openUrlExternally("help:/filelight") } 0078 } 0079 0080 Kirigami.Action { 0081 id: aboutAction 0082 displayHint: Kirigami.DisplayHint.AlwaysHide 0083 icon.name: "filelight" 0084 text: i18nc("@action opens about app page", "About") 0085 onTriggered: { pageStack.layers.push("qrc:/ui/AboutPage.qml") } 0086 } 0087 0088 GlobalMenu {} 0089 0090 footer: QQC2.Control { // gives us padding and whatnot 0091 background: Rectangle { 0092 Kirigami.Theme.inherit: false 0093 Kirigami.Theme.colorSet: Kirigami.Theme.Header 0094 color: Kirigami.Theme.backgroundColor 0095 } 0096 0097 contentItem: RowLayout { 0098 QQC2.Label { 0099 Layout.fillWidth: true 0100 text: appWindow.status 0101 elide: Text.ElideLeft 0102 } 0103 QQC2.Label { 0104 text: (RadialMap.numberOfChildren == 0) ? 0105 i18nc("@info:status", "No files.") : 0106 i18ncp("@info:status", "1 file", "%1 files", RadialMap.numberOfChildren) 0107 } 0108 } 0109 } 0110 0111 minimumWidth: Kirigami.Settings.isMobile ? 0 : Kirigami.Units.gridUnit * 22 0112 minimumHeight: Kirigami.Settings.isMobile ? 0 : Kirigami.Units.gridUnit * 22 0113 0114 width: Kirigami.Units.gridUnit * 40 0115 height: Kirigami.Units.gridUnit * 30 0116 0117 pageStack.initialPage: "qrc:/ui/OverviewPage.qml" 0118 pageStack.defaultColumnWidth: appWindow.width // show single page 0119 0120 signal completed 0121 0122 function makeMap() { 0123 if (mapPage === null) { 0124 pageStack.push("qrc:/ui/MapPage.qml") 0125 } else { 0126 pageStack.pop(mapPage, QQC2.StackView.Immediate) 0127 pageStack.push(mapPage) 0128 } 0129 } 0130 0131 function slotScanFolder() { 0132 makeMap() 0133 MainContext.slotScanFolder() 0134 } 0135 0136 function slotScanUrl(url) { 0137 makeMap() 0138 MainContext.slotScanUrl(url) 0139 } 0140 0141 function slotScanHomeFolder() { 0142 makeMap() 0143 MainContext.slotScanHomeFolder() 0144 } 0145 0146 function slotScanRootFolder() { 0147 makeMap() 0148 MainContext.slotScanRootFolder() 0149 } 0150 0151 function slotUp() { 0152 makeMap() 0153 MainContext.slotUp() 0154 } 0155 0156 function updateURL(url) { 0157 MainContext.updateURL(url) 0158 } 0159 0160 function openURL(url) { 0161 MainContext.openUrl(url) 0162 } 0163 0164 function rescan() { 0165 ScanManager.emptyCache() 0166 MainContext.start(MainContext.url) 0167 } 0168 0169 function closeURL() { 0170 mapPage = null 0171 pageStack.clear() 0172 pageStack.push(pageStack.initialPage) 0173 if (ScanManager.abort()) { 0174 appWindow.status = i18nc("@info:status", "Aborting Scan...") 0175 } 0176 } 0177 0178 function rescanSingleDir(url) { 0179 MainContext.rescanSingleDir(url) 0180 } 0181 0182 Connections { 0183 target: ScanManager 0184 0185 function onRunningChanged() { 0186 // for when the url was set through the c++ side, e.g. as cmdline arg 0187 if (ScanManager.running) { 0188 makeMap() 0189 } 0190 } 0191 0192 function onAborted() { 0193 appWindow.title = "" 0194 appWindow.status = "" 0195 } 0196 } 0197 }