This repository has been archived by the owner on Jul 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathharbour-berail.qml
116 lines (103 loc) · 3.53 KB
/
harbour-berail.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
/*
* This file is part of BeRail.
*
* BeRail is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BeRail is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with BeRail. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.2
import Sailfish.Silica 1.0
import Nemo.Configuration 1.0
import Nemo.DBus 2.0
import Harbour.BeRail.API 1.0
import Harbour.BeRail.SFOS 1.0
import "pages"
import "components"
ApplicationWindow
{
property bool networkStatus
id: app
initialPage: Component { FirstPage { } }
cover: Qt.resolvedUrl("cover/CoverPage.qml")
allowedOrientations: Orientation.All
_defaultPageOrientations: Orientation.All
// Colors
readonly property string blue: "#3f51b5"
readonly property string red: "#f44336"
readonly property string green: "#43a047"
readonly property string orange: "#f9a825"
readonly property string yellow: "#ffeb3b"
readonly property string grey: "#37474f"
readonly property string black: "#263238"
readonly property string white: "#fffde7"
readonly property string transparent: "transparent"
// Enable/Disable fade values
readonly property real fadeOutValue: 0.4
readonly property real fadeInValue: 1.0
readonly property real fadeSeeThroughValue: 0.7
// App settings
ConfigurationGroup {
id: settings
path: "/apps/harbour-berail/settings"
property int timeIs
property int transportFilter: 1 // Default only locale trains (iRail API bug #335)
property bool favouriteStationsEnabled
property string favouriteFromStation
property string favouriteToStation
property string savedLiveboardStation
property string recentConnections: "[]" // Avoid JSON parsing errors
}
SFOS {
id: sfos
}
API {
id: api
onErrorOccurred: sfos.createToaster(errorText, "icon-s-high-importance", "x-harbour-berail")
}
DBusInterface {
bus: DBus.SystemBus
service: "net.connman"
path: "/"
iface: "net.connman.Manager"
signalsEnabled: true
Component.onCompleted: getStatus() // Init
// Methods
function getStatus() {
typedCall("GetProperties", [], function(properties) {
if(properties["State"] == "online") {
console.debug("Network connected, loading...")
networkStatus = true
}
else {
console.debug("Offline!")
networkStatus = false
}
},
function(trace) {
console.error("Network state couldn't be retrieved: " + trace)
})
}
// Signals
function propertyChanged(name, value) {
if(name == "State") {
if(value == "online") {
console.debug("Network connected, reloading...")
networkStatus = true
}
else {
console.debug("Offline!")
networkStatus = false
}
}
}
}
}