| 1 |
// SPDX-License-Identifier: GPL-2.0-or-later |
| 2 |
// SPDX-FileCopyrightText: %{CURRENT_YEAR} %{AUTHOR} <%{EMAIL}> |
| 3 |
|
| 4 |
import QtQuick |
| 5 |
import QtQuick.Controls as QQC2 |
| 6 |
import QtQuick.Layouts |
| 7 |
import org.kde.kirigami as Kirigami |
| 8 |
import org.kde.%{APPNAMELC} |
| 9 |
|
| 10 |
Kirigami.ApplicationWindow { |
| 11 |
id: root |
| 12 |
|
| 13 |
title: i18n("%{APPNAME}") |
| 14 |
|
| 15 |
minimumWidth: Kirigami.Units.gridUnit * 20 |
| 16 |
minimumHeight: Kirigami.Units.gridUnit * 20 |
| 17 |
|
| 18 |
onClosing: App.saveWindowGeometry(root) |
| 19 |
|
| 20 |
onWidthChanged: saveWindowGeometryTimer.restart() |
| 21 |
onHeightChanged: saveWindowGeometryTimer.restart() |
| 22 |
onXChanged: saveWindowGeometryTimer.restart() |
| 23 |
onYChanged: saveWindowGeometryTimer.restart() |
| 24 |
|
| 25 |
Component.onCompleted: App.restoreWindowGeometry(root) |
| 26 |
|
| 27 |
// This timer allows to batch update the window size change to reduce |
| 28 |
// the io load and also work around the fact that x/y/width/height are |
| 29 |
// changed when loading the page and overwrite the saved geometry from |
| 30 |
// the previous session. |
| 31 |
Timer { |
| 32 |
id: saveWindowGeometryTimer |
| 33 |
interval: 1000 |
| 34 |
onTriggered: App.saveWindowGeometry(root) |
| 35 |
} |
| 36 |
|
| 37 |
property int counter: 0 |
| 38 |
|
| 39 |
globalDrawer: Kirigami.GlobalDrawer { |
| 40 |
isMenu: !Kirigami.Settings.isMobile |
| 41 |
actions: [ |
| 42 |
Kirigami.Action { |
| 43 |
text: i18n("Plus One") |
| 44 |
icon.name: "list-add" |
| 45 |
onTriggered: root.counter += 1 |
| 46 |
}, |
| 47 |
Kirigami.Action { |
| 48 |
text: i18n("About %{APPNAME}") |
| 49 |
icon.name: "help-about" |
| 50 |
onTriggered: root.pageStack.pushDialogLayer("qrc:/qt/qml/org/kde/%{APPNAME}/contents/ui/About.qml") |
| 51 |
}, |
| 52 |
Kirigami.Action { |
| 53 |
text: i18n("Quit") |
| 54 |
icon.name: "application-exit" |
| 55 |
onTriggered: Qt.quit() |
| 56 |
} |
| 57 |
] |
| 58 |
} |
| 59 |
|
| 60 |
contextDrawer: Kirigami.ContextDrawer { |
| 61 |
id: contextDrawer |
| 62 |
} |
| 63 |
|
| 64 |
pageStack.initialPage: page |
| 65 |
|
| 66 |
Kirigami.Page { |
| 67 |
id: page |
| 68 |
|
| 69 |
title: i18n("Main Page") |
| 70 |
|
| 71 |
actions: [ |
| 72 |
Kirigami.Action { |
| 73 |
text: i18n("Plus One") |
| 74 |
icon.name: "list-add" |
| 75 |
tooltip: i18n("Add one to the counter") |
| 76 |
onTriggered: root.counter += 1 |
| 77 |
} |
| 78 |
] |
| 79 |
|
| 80 |
ColumnLayout { |
| 81 |
width: page.width |
| 82 |
|
| 83 |
anchors.centerIn: parent |
| 84 |
|
| 85 |
Kirigami.Heading { |
| 86 |
Layout.alignment: Qt.AlignCenter |
| 87 |
text: root.counter === 0 ? i18n("Hello, World!") : root.counter |
| 88 |
} |
| 89 |
|
| 90 |
QQC2.Button { |
| 91 |
Layout.alignment: Qt.AlignHCenter |
| 92 |
text: i18n("+ 1") |
| 93 |
onClicked: root.counter += 1 |
| 94 |
} |
| 95 |
} |
| 96 |
} |
| 97 |
} |