| 1 |
// SPDX-License-Identifier: GPL-2.0-or-later |
| 2 |
// SPDX-FileCopyrightText: %{CURRENT_YEAR} %{AUTHOR} <%{EMAIL}> |
| 3 |
|
| 4 |
import QtQuick 2.15 |
| 5 |
import QtQuick.Controls 2.15 as Controls |
| 6 |
import QtQuick.Layouts 1.15 |
| 7 |
import org.kde.kirigami 2.19 as Kirigami |
| 8 |
import org.kde.%{APPNAMELC} 1.0 |
| 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 |
title: i18n("%{APPNAME}") |
| 41 |
titleIcon: "applications-graphics" |
| 42 |
isMenu: !root.isMobile |
| 43 |
actions: [ |
| 44 |
Kirigami.Action { |
| 45 |
text: i18n("Plus One") |
| 46 |
icon.name: "list-add" |
| 47 |
onTriggered: counter += 1 |
| 48 |
}, |
| 49 |
Kirigami.Action { |
| 50 |
text: i18n("About %{APPNAME}") |
| 51 |
icon.name: "help-about" |
| 52 |
onTriggered: pageStack.layers.pushDialogLayer('qrc:About.qml') |
| 53 |
}, |
| 54 |
Kirigami.Action { |
| 55 |
text: i18n("Quit") |
| 56 |
icon.name: "application-exit" |
| 57 |
onTriggered: Qt.quit() |
| 58 |
} |
| 59 |
] |
| 60 |
} |
| 61 |
|
| 62 |
contextDrawer: Kirigami.ContextDrawer { |
| 63 |
id: contextDrawer |
| 64 |
} |
| 65 |
|
| 66 |
pageStack.initialPage: page |
| 67 |
|
| 68 |
Kirigami.Page { |
| 69 |
id: page |
| 70 |
|
| 71 |
title: i18n("Main Page") |
| 72 |
|
| 73 |
actions.main: Kirigami.Action { |
| 74 |
text: i18n("Plus One") |
| 75 |
icon.name: "list-add" |
| 76 |
tooltip: i18n("Add one to the counter") |
| 77 |
onTriggered: counter += 1 |
| 78 |
} |
| 79 |
|
| 80 |
ColumnLayout { |
| 81 |
width: page.width |
| 82 |
|
| 83 |
anchors.centerIn: parent |
| 84 |
|
| 85 |
Kirigami.Heading { |
| 86 |
Layout.alignment: Qt.AlignCenter |
| 87 |
text: counter == 0 ? i18n("Hello, World!") : counter |
| 88 |
} |
| 89 |
|
| 90 |
Controls.Button { |
| 91 |
Layout.alignment: Qt.AlignHCenter |
| 92 |
text: i18n("+ 1") |
| 93 |
onClicked: counter += 1 |
| 94 |
} |
| 95 |
} |
| 96 |
} |
| 97 |
} |