Skip to content
This repository was archived by the owner on Jul 22, 2021. It is now read-only.

Commit e7f9d11

Browse files
Bugfixes + settings
1 parent b6adf91 commit e7f9d11

File tree

13 files changed

+317
-54
lines changed

13 files changed

+317
-54
lines changed

harbour-berail.pro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,8 @@ DISTFILES += \
462462
qml/pages/js/disturbances.js \
463463
qml/pages/components/DisturbancesView.qml \
464464
translations/harbour-berail-nl.ts \
465-
qml/pages/DisturbancesPage.qml
465+
qml/pages/DisturbancesPage.qml \
466+
qml/pages/SettingsPage.qml
466467

467468
RESOURCES += \
468469
qml/resources/resources.qrc

harbour-berail.pro.user

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE QtCreatorProject>
3-
<!-- Written by QtCreator 4.0.1, 2017-05-23T07:50:14. -->
3+
<!-- Written by QtCreator 4.0.1, 2017-05-31T17:29:28. -->
44
<qtcreator>
55
<data>
66
<variable>EnvironmentId</variable>
77
<value type="QByteArray">{f3ecafd1-b01f-4e43-9e3b-2de7d2f262d2}</value>
88
</data>
99
<data>
1010
<variable>ProjectExplorer.Project.ActiveTarget</variable>
11-
<value type="int">1</value>
11+
<value type="int">0</value>
1212
</data>
1313
<data>
1414
<variable>ProjectExplorer.Project.EditorSettings</variable>
@@ -63,7 +63,7 @@
6363
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">MerSDK-SailfishOS-i486</value>
6464
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{cb74bcd0-7fb5-4819-a1e0-d9d5bf1ecfcb}</value>
6565
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
66-
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
66+
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">2</value>
6767
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
6868
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
6969
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/dylan/Programmes/SailfishApps/build-harbour-berail-MerSDK_SailfishOS_i486-Debug</value>

qml/harbour-berail.qml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ ApplicationWindow
4646
readonly property string version: "V0.1"
4747

4848
// Colors
49-
readonly property string blue: "#2196f3"
49+
readonly property string blue: "#3f51b5"
5050
readonly property string red: "#f44336"
5151
readonly property string green: "#43a047"
5252
readonly property string orange: "#f9a825"
@@ -57,6 +57,18 @@ ApplicationWindow
5757

5858
property bool pythonReady
5959

60+
// App settings
61+
ConfigurationGroup {
62+
id: settings
63+
path: "/apps/harbour-berail/settings"
64+
65+
property bool rememberLiveboardStation: true
66+
property bool favouriteStations
67+
property string lastLiveboardStation
68+
property string favouriteDepartStation
69+
property string favouriteArriveStation
70+
}
71+
6072
Python {
6173
id: python
6274
property bool _networkWasLost

qml/pages/FirstPage.qml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Page {
88
id: page
99

1010
property string departureText: qsTr("From")
11-
property string destinationText: qsTr("To")
12-
property bool readyToPlan: departure.iconText != departureText && destination.iconText != destinationText // Enable when the user added his stations
11+
property string arriveText: qsTr("To")
12+
property bool readyToPlan: departure.iconText != departureText && arrival.iconText != arriveText // Enable when the user added his stations
1313
property bool hasAnnoucement: true
1414
property bool succes: true
1515
property bool _loading: alertsModel.count==0 && succes
@@ -35,6 +35,11 @@ Page {
3535
onClicked: pageStack.push(Qt.resolvedUrl("AboutPage.qml"))
3636
}
3737

38+
MenuItem {
39+
text: qsTr("Settings")
40+
onClicked: pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
41+
}
42+
3843
MenuItem {
3944
text: qsTr("Liveboard")
4045
onClicked: pageStack.push(Qt.resolvedUrl("LiveboardPage.qml"))
@@ -61,8 +66,22 @@ Page {
6166
width: parent.width
6267
Column {
6368
width: parent.width-Theme.itemSizeMedium
64-
GlassButton { id: departure; link: Qt.resolvedUrl("StationListPage.qml"); type: 1; iconSource: "qrc:///icons/icon-train.png"; iconText: departureText; itemScale: 0.75 }
65-
GlassButton { id: destination; link: Qt.resolvedUrl("StationListPage.qml"); type: 1; iconSource: "qrc:///icons/icon-train.png"; iconText: destinationText; itemScale: 0.75 }
69+
GlassButton {
70+
id: departure
71+
link: Qt.resolvedUrl("StationListPage.qml")
72+
type: 1
73+
iconSource: "qrc:///icons/icon-train.png"
74+
iconText: settings.favouriteStations? settings.favouriteDepartStation: departureText
75+
itemScale: 0.75
76+
}
77+
GlassButton {
78+
id: arrival
79+
link: Qt.resolvedUrl("StationListPage.qml")
80+
type: 1
81+
iconSource: "qrc:///icons/icon-train.png"
82+
iconText: settings.favouriteStations? settings.favouriteArriveStation: arriveText
83+
itemScale: 0.75
84+
}
6685
}
6786
BackgroundItem {
6887
width: Theme.itemSizeMedium
@@ -71,8 +90,8 @@ Page {
7190
opacity: enabled? 1.0: 0.25
7291
onClicked: { // Switch
7392
var temp = departure.iconText;
74-
departure.iconText = destination.iconText;
75-
destination.iconText = temp;
93+
departure.iconText = arrival.iconText;
94+
arrival.iconText = temp;
7695
}
7796

7897
Image {
@@ -126,7 +145,7 @@ Page {
126145
enabled: readyToPlan
127146
onClicked: pageStack.push(Qt.resolvedUrl("TripPage.qml"), {
128147
from: departure.iconText,
129-
to: destination.iconText,
148+
to: arrival.iconText,
130149
time: time.value,
131150
date: date.value
132151
})

qml/pages/LiveboardPage.qml

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,25 @@ import "./js/liveboard.js" as LiveBoard
55

66
Page {
77
id: page
8-
property string station: "Brussels-Central"
8+
property string station
99
property string currentTime: LiveBoard.getTimeString()
1010
property bool succes: true
11-
property bool _loading: liveboardModel.count==0 && succes
11+
property bool _firstLaunch: settings.lastLiveboardStation.length == 0
12+
property bool _loading: liveboardModel.count==0 && succes && !_firstLaunch
1213

13-
onStationChanged: LiveBoard.load(station)
14-
Component.onCompleted: LiveBoard.load(station)
14+
on_FirstLaunchChanged: _firstLaunch? hint.start(): hint.stop()
15+
16+
onStationChanged: {
17+
LiveBoard.load(station)
18+
settings.rememberLiveboardStation? settings.lastLiveboardStation = station: undefined // Only save when activated in settings
19+
_firstLaunch = false
20+
}
21+
Component.onCompleted: {
22+
if(!_firstLaunch) {
23+
station = settings.lastLiveboardStation
24+
LiveBoard.load(station)
25+
}
26+
}
1527

1628
Timer { // Update the clock
1729
running: Qt.application.active
@@ -26,7 +38,7 @@ Page {
2638
width: parent.width; height: parent.height
2739
model: liveboardModel
2840
header: Rectangle {
29-
color: "#3f51b5"
41+
color: app.blue
3042
width: parent.width
3143
height: Theme.itemSizeHuge*1.2
3244

@@ -39,7 +51,7 @@ Page {
3951
font.bold: true
4052
truncationMode: TruncationMode.Fade
4153
horizontalAlignment: Text.AlignHCenter
42-
text: station
54+
text: _firstLaunch? qsTr("Liveboard"): station
4355
}
4456

4557
// Time
@@ -105,6 +117,20 @@ Page {
105117
hintText: qsTr("No data available")
106118
}
107119

120+
// When no data, show a hint and a placeholder
121+
InteractionHintLabel {
122+
anchors.bottom: parent.bottom
123+
opacity: _firstLaunch ? 1.0 : 0.0
124+
Behavior on opacity { FadeAnimation {} }
125+
text: qsTr("Select a station")
126+
}
127+
128+
TouchInteractionHint {
129+
id: hint
130+
loops: Animation.Infinite
131+
direction: TouchInteraction.Down
132+
}
133+
108134
delegate: ListItem {
109135
width: ListView.view.width
110136
contentHeight: item.height
@@ -125,7 +151,7 @@ Page {
125151
Rectangle {
126152
id: background
127153
z:-1 // Make ListItem Highlight visible
128-
color: index%2? "#263238": "#37474f"
154+
color: index%2? app.black: app.grey
129155
anchors { fill: parent }
130156
}
131157
onClicked: {

qml/pages/SettingsPage.qml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import QtQuick 2.2
2+
import Sailfish.Silica 1.0
3+
import "./components"
4+
5+
Page {
6+
7+
Component.onDestruction: { // Save the values when user is done
8+
settings.rememberLiveboardStation = rememberLiveboardStation.checked
9+
if(!rememberLiveboardStation.checked) { // reset to default
10+
settings.lastLiveboardStation = ""
11+
}
12+
settings.favouriteStations = favouriteStations.checked
13+
settings.favouriteDepartStation = favouriteStations.checked? favouriteDepartStation.iconText: "" // reset to default
14+
settings.favouriteArriveStation = favouriteStations.checked? favouriteArriveStation.iconText: "" // reset to default
15+
}
16+
17+
SilicaFlickable {
18+
anchors.fill: parent
19+
contentHeight: settingsColumn.height
20+
21+
VerticalScrollDecorator {}
22+
23+
Column {
24+
id: settingsColumn
25+
width: parent.width
26+
spacing: Theme.paddingLarge
27+
28+
PageHeader { title: qsTr("Settings") }
29+
30+
SectionHeader { text: qsTr("Liveboard") }
31+
32+
TextSwitch {
33+
id: rememberLiveboardStation
34+
text: qsTr("Remember liveboard station")
35+
description: qsTr("Save time by automatically saving your last used station!")
36+
checked: settings.rememberLiveboardStation
37+
}
38+
39+
SectionHeader { text: qsTr("Favourite stations") }
40+
41+
TextSwitch {
42+
id: favouriteStations
43+
text: qsTr("Enable favourite stations")
44+
description: qsTr("Travelling from/to work or school? Then is this option for you! Select your favourite stations below.")
45+
checked: settings.favouriteStations
46+
}
47+
48+
GlassButton {
49+
id: favouriteDepartStation
50+
link: Qt.resolvedUrl("StationListPage.qml")
51+
type: 1
52+
iconSource: "qrc:///icons/icon-train.png"
53+
iconText: settings.favouriteDepartStation.length > 0? settings.favouriteDepartStation: qsTr("From")
54+
itemScale: 0.75
55+
enabled: favouriteStations.checked
56+
opacity: enabled? 1.0: 0.2
57+
58+
Behavior on opacity { FadeAnimation {} }
59+
}
60+
GlassButton {
61+
id: favouriteArriveStation
62+
link: Qt.resolvedUrl("StationListPage.qml")
63+
type: 1
64+
iconSource: "qrc:///icons/icon-train.png"
65+
iconText: settings.favouriteArriveStation.length > 0? settings.favouriteArriveStation: qsTr("To")
66+
itemScale: 0.75
67+
enabled: favouriteStations.checked
68+
opacity: enabled? 1.0: 0.2
69+
70+
Behavior on opacity { FadeAnimation {} }
71+
}
72+
}
73+
}
74+
}

qml/pages/TripDetailPage.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Page {
3535
canceled: tripModel.get(indexModel).depart.canceled || tripModel.get(indexModel).arrival.canceled? true: false // When arrive or depart is canceled then this connection is not valid
3636
vias: tripModel.get(indexModel).vias.number
3737
viasModel: tripModel.get(indexModel).vias.via
38-
alertsModel: tripModel.get(indexModel).alerts.alerts
38+
alerts: tripModel.get(indexModel).alerts.alert
3939
showAlerts: false
4040
Component.onCompleted: expanded = true
4141
}

qml/pages/TripPage.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Page {
3737
canceled: model.depart.canceled || model.arrival.canceled? true: false // When arrive or depart is canceled then this connection is not valid
3838
vias: model.vias.number
3939
viasModel: model.vias.via
40-
alertsModel: model.alerts.alert
40+
alerts: model.alerts.alert
4141
showAlerts: false
4242
expanded: false
4343
}

qml/pages/components/TripItem.qml

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,15 @@ Item { // Reuse it for TripDetailPage and TripDetail
2525
property bool showAlerts: true
2626
property var vias
2727
property var viasModel
28-
property var alertsModel
28+
property var alerts
2929
property var stopsModel: viasModel // BeRail V1.X build stopsModel with intermediate stops
3030

3131
// Internal variables
3232
property var _hasDelay: [departDelay > 0, arriveDelay > 0]
3333
property int _changeIndex
34-
property bool _hasAlert: alerts.count > 0
34+
property bool _hasAlert: alerts.length > 0
3535

36-
onAlertsModelChanged: { // Convert to ListModel
37-
for(var i=0; i < alertsModel.length; i++) {
38-
alerts.append(alertsModel[i]);
39-
}
40-
}
36+
onAlertsChanged: Trip.convertAlertsToListmodel(alerts)
4137

4238
Column {
4339
id: tripColumn
@@ -80,7 +76,7 @@ Item { // Reuse it for TripDetailPage and TripDetail
8076
// Depart station name
8177
Label {
8278
id: departStationLabel
83-
width: parent.width - departTimeItem.width - journeyInformation.width - 2*Theme.paddingLarge
79+
width: parent.width - departTimeItem.width - journeyInformation.width - 3*Theme.paddingLarge
8480
anchors { left: departTimeItem.right; leftMargin: Theme.paddingLarge }
8581
truncationMode: TruncationMode.Fade
8682
font.capitalization: Font.AllUppercase
@@ -145,7 +141,7 @@ Item { // Reuse it for TripDetailPage and TripDetail
145141
Label {
146142
id: alertsLabel;
147143
anchors { top: changeIcon.bottom; topMargin: Theme.paddingMedium }
148-
text: alertsModel.length
144+
text: alerts.length
149145
visible: _hasAlert
150146
}
151147

@@ -190,7 +186,7 @@ Item { // Reuse it for TripDetailPage and TripDetail
190186
// Progress indicator stops
191187
Column {
192188
anchors { horizontalCenter: traject.horizontalCenter; top: parent.top; topMargin: Theme.itemSizeSmall }
193-
spacing: Theme.paddingLarge*2
189+
spacing: Theme.paddingLarge*3
194190
Repeater {
195191
id: stopsProgress
196192
model: viasModel
@@ -244,10 +240,17 @@ Item { // Reuse it for TripDetailPage and TripDetail
244240

245241
// Stop name
246242
Label {
243+
id: viaStopStationLabel
247244
anchors { left: viaStopBullet.visible? viaStopBullet.right: stopBullet.right; leftMargin: Theme.paddingLarge; right: parent.right; rightMargin: Theme.paddingMedium; verticalCenter: parent.verticalCenter }
248245
font.capitalization: Font.SmallCaps
249246
text: modelData.station
250247
}
248+
249+
Label {
250+
anchors { left: viaStopBullet.visible? viaStopBullet.right: stopBullet.right; leftMargin: Theme.paddingLarge; right: parent.right; rightMargin: Theme.paddingMedium; top: viaStopStationLabel.bottom; topMargin: Theme.paddingSmall }
251+
font.pixelSize: Theme.fontSizeTiny
252+
text: qsTr("Track %1 → Track %2").arg(modelData.arrival.platform).arg(modelData.depart.platform) + " | ⏱" + modelData.timebetween
253+
}
251254
}
252255
}
253256
}
@@ -291,7 +294,7 @@ Item { // Reuse it for TripDetailPage and TripDetail
291294
// Arrive station name
292295
Label {
293296
id: arriveStationLabel
294-
width: parent.width - arriveTimeItem.width - journeyInformation.width - 2*Theme.paddingLarge
297+
width: parent.width - arriveTimeItem.width - journeyInformation.width - 3*Theme.paddingLarge
295298
anchors { left: arriveTimeItem.right; leftMargin: Theme.paddingLarge }
296299
truncationMode: TruncationMode.Fade
297300
font.capitalization: Font.AllUppercase
@@ -336,13 +339,14 @@ Item { // Reuse it for TripDetailPage and TripDetail
336339
}
337340

338341
ListModel {
339-
id: alerts
342+
id: alertsModel
340343
}
341344

342345
DisturbancesView {
343346
id: alertsView
344-
model: alerts
347+
model: alertsModel
345348
showStation: false
349+
visible: expanded // Only visible when expanded
346350
}
347351
}
348352

0 commit comments

Comments
 (0)