Warning, /frameworks/kirigami/templates/kirigami6/src/contents/ui/main.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 // SPDX-FileCopyrightText: %{CURRENT_YEAR} %{AUTHOR} <%{EMAIL}>
0003 
0004 import QtQuick
0005 import QtQuick.Controls as Controls
0006 import QtQuick.Layouts
0007 import org.kde.kirigami as Kirigami
0008 import org.kde.%{APPNAMELC}
0009 
0010 Kirigami.ApplicationWindow {
0011     id: root
0012 
0013     title: i18n("%{APPNAME}")
0014 
0015     minimumWidth: Kirigami.Units.gridUnit * 20
0016     minimumHeight: Kirigami.Units.gridUnit * 20
0017 
0018     onClosing: App.saveWindowGeometry(root)
0019 
0020     onWidthChanged: saveWindowGeometryTimer.restart()
0021     onHeightChanged: saveWindowGeometryTimer.restart()
0022     onXChanged: saveWindowGeometryTimer.restart()
0023     onYChanged: saveWindowGeometryTimer.restart()
0024 
0025     Component.onCompleted: App.restoreWindowGeometry(root)
0026 
0027     // This timer allows to batch update the window size change to reduce
0028     // the io load and also work around the fact that x/y/width/height are
0029     // changed when loading the page and overwrite the saved geometry from
0030     // the previous session.
0031     Timer {
0032         id: saveWindowGeometryTimer
0033         interval: 1000
0034         onTriggered: App.saveWindowGeometry(root)
0035     }
0036 
0037     property int counter: 0
0038 
0039     globalDrawer: Kirigami.GlobalDrawer {
0040         isMenu: !Kirigami.Settings.isMobile
0041         actions: [
0042             Kirigami.Action {
0043                 text: i18n("Plus One")
0044                 icon.name: "list-add"
0045                 onTriggered: root.counter += 1
0046             },
0047             Kirigami.Action {
0048                 text: i18n("About %{APPNAME}")
0049                 icon.name: "help-about"
0050                 onTriggered: root.pageStack.pushDialogLayer("qrc:About.qml")
0051             },
0052             Kirigami.Action {
0053                 text: i18n("Quit")
0054                 icon.name: "application-exit"
0055                 onTriggered: Qt.quit()
0056             }
0057         ]
0058     }
0059 
0060     contextDrawer: Kirigami.ContextDrawer {
0061         id: contextDrawer
0062     }
0063 
0064     pageStack.initialPage: page
0065 
0066     Kirigami.Page {
0067         id: page
0068 
0069         title: i18n("Main Page")
0070 
0071         actions: [
0072             Kirigami.Action {
0073                 text: i18n("Plus One")
0074                 icon.name: "list-add"
0075                 tooltip: i18n("Add one to the counter")
0076                 onTriggered: root.counter += 1
0077             }
0078         ]
0079 
0080         ColumnLayout {
0081             width: page.width
0082 
0083             anchors.centerIn: parent
0084 
0085             Kirigami.Heading {
0086                 Layout.alignment: Qt.AlignCenter
0087                 text: root.counter === 0 ? i18n("Hello, World!") : root.counter
0088             }
0089 
0090             Controls.Button {
0091                 Layout.alignment: Qt.AlignHCenter
0092                 text: i18n("+ 1")
0093                 onClicked: root.counter += 1
0094             }
0095         }
0096     }
0097 }