-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.qml
84 lines (70 loc) · 1.84 KB
/
main.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
import QtQuick.Controls.Material 2.15
import Qt.labs.settings 1.1
import QtSensors 5.15
import QtGraphicalEffects 1.0
import QtLevel 1.0
import "Util.js" as Util
Window {
id: rootWindow
title: "QtLevel"
width: 640
height: 480
visible: true
// this back key handling method comes from https://stackoverflow.com/a/67357598/12533859
Component.onCompleted: {
contentItem.Keys.released.connect(function(event) {
if (event.key === Qt.Key_Back && stack.depth > 1) {
event.accepted = true
stack.pop()
}
else
event.accepted = false
})
}
Material.theme: settings.theme
Material.primary: settings.primary
Material.accent: settings.accent
Settings {
id: settings
property int theme: Material.Dark
property int primary: Material.Indigo
property int accent: Material.Pink
property int decimalPlaces: 0
}
SettingsPage {
id: settingsPage
}
Drawer {
id: drawer
edge: Qt.LeftEdge
width: rootWindow.width * 2 / 3
height: rootWindow.height
dragMargin: 10
ItemDelegate {
text: qsTr("Settings")
width: parent.width
onClicked: {
if (stack.currentItem != settingsPage)
stack.push(settingsPage)
drawer.close()
}
}
}
StackView {
id: stack
Keys.onBackPressed: {
if (stack.depth > 1)
{
stack.pop()
event.accepted = true
}
else
event.accepted = false
}
anchors.fill: parent
initialItem: LevelPage {}
}
}