-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathApplicationContent.qml
170 lines (143 loc) · 5.13 KB
/
ApplicationContent.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*
** Copyright (C) 2023 Victron Energy B.V.
** See LICENSE.txt for license information.
*/
import QtQuick
import QtQuick.Window
import QtQuick.Controls as QtQuickControls
import Victron.VenusOS
Item {
id: root
property alias mainView: mainView
property var _inputComponent
readonly property bool _goToNotifications: Global.allPagesLoaded && Global.notifications.alarm
on_GoToNotificationsChanged: {
if (_goToNotifications) {
notificationLayer.popAndGoToNotifications()
}
}
PageManager {
id: pageManager
Component.onCompleted: Global.pageManager = pageManager
}
MainView {
id: mainView
anchors.fill: parent
pageManager: pageManager
Component.onCompleted: Global.mainView = mainView
}
AllDevicesModel {
id: allDevicesModel
Component.onCompleted: Global.allDevicesModel = allDevicesModel
}
FirmwareUpdate {
id: firmwareUpdate
Component.onCompleted: Global.firmwareUpdate = firmwareUpdate
}
ScreenBlanker {
id: screenBlanker
enabled: !Global.splashScreenVisible && !(!!Global.pageManager && Global.pageManager.statusBar.notificationButtonVisible)
displayOffTime: displayOffItem.isValid ? 1000*displayOffItem.value : 0.0
window: root.Window.window
property VeQuickItem displayOffItem: VeQuickItem {
uid: !!Global.systemSettings ? Global.systemSettings.serviceUid + "/Settings/Gui/DisplayOff" : ""
}
Component.onCompleted: Global.screenBlanker = screenBlanker
}
MouseArea {
id: idleModeMouseArea
VeQuickItem {
id: touchEnabled
property bool _initialized: false
uid: BackendConnection.serviceUidForType("settings") + "/Settings/Gui/TouchEnabled"
onValueChanged: {
if (_initialized) { // Only show the notification when the value changes, not when the application is loaded
Global.showToastNotification(VenusOS.Notification_Info,
(value ?
//% "Touch input on"
qsTrId("application_content_touch_input_on") :
//% "Touch input off"
qsTrId("application_content_touch_input_off")),
3000)
}
_initialized = true
}
}
anchors.fill: parent
onPressed: function(mouse) {
Global.applicationActive = true
appIdleTimer.restart()
if (Global.isGxDevice && !touchEnabled.value) {
//% "Touch input disabled"
Global.showToastNotification(VenusOS.Notification_Info, qsTrId("application_content_touch_input_disabled"), 1000)
mouse.accepted = true
return
}
// block touch during navigation bar fadeout
mouse.accepted = mainView.navBarAnimatingOut
if (pageManager.idleModeTimer.running) {
pageManager.idleModeTimer.restart()
}
if (pageManager.interactivity === VenusOS.PageManager_InteractionMode_Idle) {
mouse.accepted = true
pageManager.interactivity = VenusOS.PageManager_InteractionMode_EndFullScreen
}
if (keyboardHandlerLoader.item && keyboardHandlerLoader.item.acceptMouseEvent(idleModeMouseArea, mouse.x, mouse.y)) {
mouse.accepted = true
}
}
}
Timer {
id: appIdleTimer
running: true
interval: 60000
onTriggered: Global.applicationActive = false
}
// We rely on the implicit Z ordering, so dialog/notification layers be declared after the other views.
DialogLayer {
id: dialogLayer
anchors.fill: parent
Component.onCompleted: Global.dialogLayer = dialogLayer
}
NotificationLayer {
id: notificationLayer
anchors.fill: parent
Component.onCompleted: Global.notificationLayer = notificationLayer
// technically, the notification layer is not related to the notifications page
// but we need to way to expose the "go to notifications page" functionality
// and the notifications layer is already part of the global object.
function popAndGoToNotifications() {
pageManager.popAllPages()
mainView.controlsActive = false
pageManager.navBar.setCurrentPage("NotificationsPage.qml")
}
}
// Keyboard handling:
// - On CerboGX/EkranoGX devices, show the Qt VKB using components/InputPanel.qml.
// - On Wasm mobile, the mobile OS shows the native VKB. If in landscape orientation, use
// components/WasmVirtualKeyboardHandler.qml to auto-scroll flickables and ensure the active
// text field is not obscured by the native VKB.
// - On Wasm desktop and desktop platforms, no special input handling is required, as the
// hardware keyboard can be used for text input.
//
// Note this Loader is the top-most layer, to allow the idleModeMouseArea beneath to call
// acceptMouseEvent() when clicking outside of the focused text field, to auto-close the Qt VKB.
Loader {
id: keyboardHandlerLoader
asynchronous: true
active: Global.isGxDevice
|| (BackendConnection.needsWasmKeyboardHandler && Global.main.width > Global.main.height)
source: Global.isGxDevice
? "qrc:/qt/qml/Victron/VenusOS/components/InputPanel.qml"
: "qrc:/qt/qml/Victron/VenusOS/components/WasmVirtualKeyboardHandler.qml"
parent: QtQuickControls.Overlay.overlay
z: 1
}
// Sometimes, the wasm code may crash. Use a watchdog to detect this and reload the page when necessary.
Timer {
running: Qt.platform.os === "wasm" && BackendConnection.state === BackendConnection.Ready
repeat: true
interval: 1000
onTriggered: BackendConnection.hitWatchdog()
}
}