-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathGlobal.qml
130 lines (110 loc) · 3.53 KB
/
Global.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
/*
** Copyright (C) 2023 Victron Energy B.V.
** See LICENSE.txt for license information.
*/
pragma Singleton
import QtQuick
import Victron.VenusOS
QtObject {
property var main
property var pageManager
property var mainView
property var mockDataSimulator // only valid when mock mode is active
property var dataManager
property VeQItemTableModel dataServiceModel: null
property var firmwareUpdate
property var allDevicesModel
property bool applicationActive: true
readonly property string fontFamily: _defaultFontLoader.name
readonly property string quantityFontFamily: _quantityFontLoader.name
property var dialogLayer
property var notificationLayer
property ScreenBlanker screenBlanker
property bool displayCpuUsage
property bool pauseElectronAnimations
// data sources
property var acInputs
property var dcInputs
property var environmentInputs
property var ess
property var evChargers
property var generators
property var inverterChargers
property var notifications
property var pvInverters
property var solarChargers
property var system
property var systemSettings
property var tanks
property var venusPlatform
property bool splashScreenVisible: true
property bool dataManagerLoaded
property bool allPagesLoaded
property string firmwareInstalledBuild // don't clear this on UI reload. it needs to survive reconnection.
property bool firmwareInstalledBuildUpdated // as above.
property bool needPageReload: Qt.platform.os == "wasm" && firmwareInstalledBuildUpdated // as above.
property bool isDesktop
property bool isGxDevice: Qt.platform.os === "linux" && !isDesktop
property real scalingRatio: 1.0
property bool animationEnabled: true // for mock mode only.
readonly property int int32Max: _intValidator.top
readonly property int int32Min: _intValidator.bottom
signal aboutToFocusTextField(var textField, var textFieldContainer, var flickable)
signal keyPressed(var event)
function showToastNotification(category, text, autoCloseInterval = 0) {
if (!!notificationLayer) {
return notificationLayer.showToastNotification(category, text, autoCloseInterval)
}
return null
}
function deviceModelsForClass(deviceClass) {
if (deviceClass === "com.victronenergy.battery") {
return [allDevicesModel.batteryDevices]
} else if (deviceClass === "com.victronenergy.solarcharger" || deviceClass === "solarcharger") {
return [solarChargers.model]
} else if (deviceClass === "analog") {
return Global.tanks.allTankModels.concat([Global.environmentInputs.model])
}
return []
}
function reset() {
// unload the gui.
dataManagerLoaded = false
// note: we don't reset `main
// as main will never be destroyed during the ui rebuild.
pageManager = null
mainView = null
mockDataSimulator = null
dataManager = null
dataServiceModel = null
firmwareUpdate = null
allDevicesModel = null
dialogLayer = null
notificationLayer = null
acInputs = null
dcInputs = null
environmentInputs = null
ess = null
evChargers = null
generators = null
inverterChargers = null
notifications = null
pvInverters = null
solarChargers = null
system = null
systemSettings = null
tanks = null
venusPlatform = null
// The last thing we do is set the splash screen visible.
allPagesLoaded = false
splashScreenVisible = true
}
readonly property FontLoader _defaultFontLoader: FontLoader {
source: Language.fontFileUrl
}
readonly property FontLoader _quantityFontLoader: FontLoader {
source: "qrc:/fonts/Roboto-Regular.ttf"
}
readonly property IntValidator _intValidator: IntValidator {
}
}