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

Commit

Permalink
Bugfixes + settings
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanVanAssche committed May 31, 2017
1 parent b6adf91 commit e7f9d11
Show file tree
Hide file tree
Showing 13 changed files with 317 additions and 54 deletions.
3 changes: 2 additions & 1 deletion harbour-berail.pro
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,8 @@ DISTFILES += \
qml/pages/js/disturbances.js \
qml/pages/components/DisturbancesView.qml \
translations/harbour-berail-nl.ts \
qml/pages/DisturbancesPage.qml
qml/pages/DisturbancesPage.qml \
qml/pages/SettingsPage.qml

RESOURCES += \
qml/resources/resources.qrc
6 changes: 3 additions & 3 deletions harbour-berail.pro.user
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.0.1, 2017-05-23T07:50:14. -->
<!-- Written by QtCreator 4.0.1, 2017-05-31T17:29:28. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{f3ecafd1-b01f-4e43-9e3b-2de7d2f262d2}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">1</value>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
Expand Down Expand Up @@ -63,7 +63,7 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">MerSDK-SailfishOS-i486</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{cb74bcd0-7fb5-4819-a1e0-d9d5bf1ecfcb}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">2</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/dylan/Programmes/SailfishApps/build-harbour-berail-MerSDK_SailfishOS_i486-Debug</value>
Expand Down
14 changes: 13 additions & 1 deletion qml/harbour-berail.qml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ ApplicationWindow
readonly property string version: "V0.1"

// Colors
readonly property string blue: "#2196f3"
readonly property string blue: "#3f51b5"
readonly property string red: "#f44336"
readonly property string green: "#43a047"
readonly property string orange: "#f9a825"
Expand All @@ -57,6 +57,18 @@ ApplicationWindow

property bool pythonReady

// App settings
ConfigurationGroup {
id: settings
path: "/apps/harbour-berail/settings"

property bool rememberLiveboardStation: true
property bool favouriteStations
property string lastLiveboardStation
property string favouriteDepartStation
property string favouriteArriveStation
}

Python {
id: python
property bool _networkWasLost
Expand Down
33 changes: 26 additions & 7 deletions qml/pages/FirstPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Page {
id: page

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

MenuItem {
text: qsTr("Settings")
onClicked: pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
}

MenuItem {
text: qsTr("Liveboard")
onClicked: pageStack.push(Qt.resolvedUrl("LiveboardPage.qml"))
Expand All @@ -61,8 +66,22 @@ Page {
width: parent.width
Column {
width: parent.width-Theme.itemSizeMedium
GlassButton { id: departure; link: Qt.resolvedUrl("StationListPage.qml"); type: 1; iconSource: "qrc:///icons/icon-train.png"; iconText: departureText; itemScale: 0.75 }
GlassButton { id: destination; link: Qt.resolvedUrl("StationListPage.qml"); type: 1; iconSource: "qrc:///icons/icon-train.png"; iconText: destinationText; itemScale: 0.75 }
GlassButton {
id: departure
link: Qt.resolvedUrl("StationListPage.qml")
type: 1
iconSource: "qrc:///icons/icon-train.png"
iconText: settings.favouriteStations? settings.favouriteDepartStation: departureText
itemScale: 0.75
}
GlassButton {
id: arrival
link: Qt.resolvedUrl("StationListPage.qml")
type: 1
iconSource: "qrc:///icons/icon-train.png"
iconText: settings.favouriteStations? settings.favouriteArriveStation: arriveText
itemScale: 0.75
}
}
BackgroundItem {
width: Theme.itemSizeMedium
Expand All @@ -71,8 +90,8 @@ Page {
opacity: enabled? 1.0: 0.25
onClicked: { // Switch
var temp = departure.iconText;
departure.iconText = destination.iconText;
destination.iconText = temp;
departure.iconText = arrival.iconText;
arrival.iconText = temp;
}

Image {
Expand Down Expand Up @@ -126,7 +145,7 @@ Page {
enabled: readyToPlan
onClicked: pageStack.push(Qt.resolvedUrl("TripPage.qml"), {
from: departure.iconText,
to: destination.iconText,
to: arrival.iconText,
time: time.value,
date: date.value
})
Expand Down
40 changes: 33 additions & 7 deletions qml/pages/LiveboardPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,25 @@ import "./js/liveboard.js" as LiveBoard

Page {
id: page
property string station: "Brussels-Central"
property string station
property string currentTime: LiveBoard.getTimeString()
property bool succes: true
property bool _loading: liveboardModel.count==0 && succes
property bool _firstLaunch: settings.lastLiveboardStation.length == 0
property bool _loading: liveboardModel.count==0 && succes && !_firstLaunch

onStationChanged: LiveBoard.load(station)
Component.onCompleted: LiveBoard.load(station)
on_FirstLaunchChanged: _firstLaunch? hint.start(): hint.stop()

onStationChanged: {
LiveBoard.load(station)
settings.rememberLiveboardStation? settings.lastLiveboardStation = station: undefined // Only save when activated in settings
_firstLaunch = false
}
Component.onCompleted: {
if(!_firstLaunch) {
station = settings.lastLiveboardStation
LiveBoard.load(station)
}
}

Timer { // Update the clock
running: Qt.application.active
Expand All @@ -26,7 +38,7 @@ Page {
width: parent.width; height: parent.height
model: liveboardModel
header: Rectangle {
color: "#3f51b5"
color: app.blue
width: parent.width
height: Theme.itemSizeHuge*1.2

Expand All @@ -39,7 +51,7 @@ Page {
font.bold: true
truncationMode: TruncationMode.Fade
horizontalAlignment: Text.AlignHCenter
text: station
text: _firstLaunch? qsTr("Liveboard"): station
}

// Time
Expand Down Expand Up @@ -105,6 +117,20 @@ Page {
hintText: qsTr("No data available")
}

// When no data, show a hint and a placeholder
InteractionHintLabel {
anchors.bottom: parent.bottom
opacity: _firstLaunch ? 1.0 : 0.0
Behavior on opacity { FadeAnimation {} }
text: qsTr("Select a station")
}

TouchInteractionHint {
id: hint
loops: Animation.Infinite
direction: TouchInteraction.Down
}

delegate: ListItem {
width: ListView.view.width
contentHeight: item.height
Expand All @@ -125,7 +151,7 @@ Page {
Rectangle {
id: background
z:-1 // Make ListItem Highlight visible
color: index%2? "#263238": "#37474f"
color: index%2? app.black: app.grey
anchors { fill: parent }
}
onClicked: {
Expand Down
74 changes: 74 additions & 0 deletions qml/pages/SettingsPage.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import QtQuick 2.2
import Sailfish.Silica 1.0
import "./components"

Page {

Component.onDestruction: { // Save the values when user is done
settings.rememberLiveboardStation = rememberLiveboardStation.checked
if(!rememberLiveboardStation.checked) { // reset to default
settings.lastLiveboardStation = ""
}
settings.favouriteStations = favouriteStations.checked
settings.favouriteDepartStation = favouriteStations.checked? favouriteDepartStation.iconText: "" // reset to default
settings.favouriteArriveStation = favouriteStations.checked? favouriteArriveStation.iconText: "" // reset to default
}

SilicaFlickable {
anchors.fill: parent
contentHeight: settingsColumn.height

VerticalScrollDecorator {}

Column {
id: settingsColumn
width: parent.width
spacing: Theme.paddingLarge

PageHeader { title: qsTr("Settings") }

SectionHeader { text: qsTr("Liveboard") }

TextSwitch {
id: rememberLiveboardStation
text: qsTr("Remember liveboard station")
description: qsTr("Save time by automatically saving your last used station!")
checked: settings.rememberLiveboardStation
}

SectionHeader { text: qsTr("Favourite stations") }

TextSwitch {
id: favouriteStations
text: qsTr("Enable favourite stations")
description: qsTr("Travelling from/to work or school? Then is this option for you! Select your favourite stations below.")
checked: settings.favouriteStations
}

GlassButton {
id: favouriteDepartStation
link: Qt.resolvedUrl("StationListPage.qml")
type: 1
iconSource: "qrc:///icons/icon-train.png"
iconText: settings.favouriteDepartStation.length > 0? settings.favouriteDepartStation: qsTr("From")
itemScale: 0.75
enabled: favouriteStations.checked
opacity: enabled? 1.0: 0.2

Behavior on opacity { FadeAnimation {} }
}
GlassButton {
id: favouriteArriveStation
link: Qt.resolvedUrl("StationListPage.qml")
type: 1
iconSource: "qrc:///icons/icon-train.png"
iconText: settings.favouriteArriveStation.length > 0? settings.favouriteArriveStation: qsTr("To")
itemScale: 0.75
enabled: favouriteStations.checked
opacity: enabled? 1.0: 0.2

Behavior on opacity { FadeAnimation {} }
}
}
}
}
2 changes: 1 addition & 1 deletion qml/pages/TripDetailPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Page {
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
vias: tripModel.get(indexModel).vias.number
viasModel: tripModel.get(indexModel).vias.via
alertsModel: tripModel.get(indexModel).alerts.alerts
alerts: tripModel.get(indexModel).alerts.alert
showAlerts: false
Component.onCompleted: expanded = true
}
Expand Down
2 changes: 1 addition & 1 deletion qml/pages/TripPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Page {
canceled: model.depart.canceled || model.arrival.canceled? true: false // When arrive or depart is canceled then this connection is not valid
vias: model.vias.number
viasModel: model.vias.via
alertsModel: model.alerts.alert
alerts: model.alerts.alert
showAlerts: false
expanded: false
}
Expand Down
30 changes: 17 additions & 13 deletions qml/pages/components/TripItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,15 @@ Item { // Reuse it for TripDetailPage and TripDetail
property bool showAlerts: true
property var vias
property var viasModel
property var alertsModel
property var alerts
property var stopsModel: viasModel // BeRail V1.X build stopsModel with intermediate stops

// Internal variables
property var _hasDelay: [departDelay > 0, arriveDelay > 0]
property int _changeIndex
property bool _hasAlert: alerts.count > 0
property bool _hasAlert: alerts.length > 0

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

Column {
id: tripColumn
Expand Down Expand Up @@ -80,7 +76,7 @@ Item { // Reuse it for TripDetailPage and TripDetail
// Depart station name
Label {
id: departStationLabel
width: parent.width - departTimeItem.width - journeyInformation.width - 2*Theme.paddingLarge
width: parent.width - departTimeItem.width - journeyInformation.width - 3*Theme.paddingLarge
anchors { left: departTimeItem.right; leftMargin: Theme.paddingLarge }
truncationMode: TruncationMode.Fade
font.capitalization: Font.AllUppercase
Expand Down Expand Up @@ -145,7 +141,7 @@ Item { // Reuse it for TripDetailPage and TripDetail
Label {
id: alertsLabel;
anchors { top: changeIcon.bottom; topMargin: Theme.paddingMedium }
text: alertsModel.length
text: alerts.length
visible: _hasAlert
}

Expand Down Expand Up @@ -190,7 +186,7 @@ Item { // Reuse it for TripDetailPage and TripDetail
// Progress indicator stops
Column {
anchors { horizontalCenter: traject.horizontalCenter; top: parent.top; topMargin: Theme.itemSizeSmall }
spacing: Theme.paddingLarge*2
spacing: Theme.paddingLarge*3
Repeater {
id: stopsProgress
model: viasModel
Expand Down Expand Up @@ -244,10 +240,17 @@ Item { // Reuse it for TripDetailPage and TripDetail

// Stop name
Label {
id: viaStopStationLabel
anchors { left: viaStopBullet.visible? viaStopBullet.right: stopBullet.right; leftMargin: Theme.paddingLarge; right: parent.right; rightMargin: Theme.paddingMedium; verticalCenter: parent.verticalCenter }
font.capitalization: Font.SmallCaps
text: modelData.station
}

Label {
anchors { left: viaStopBullet.visible? viaStopBullet.right: stopBullet.right; leftMargin: Theme.paddingLarge; right: parent.right; rightMargin: Theme.paddingMedium; top: viaStopStationLabel.bottom; topMargin: Theme.paddingSmall }
font.pixelSize: Theme.fontSizeTiny
text: qsTr("Track %1 → Track %2").arg(modelData.arrival.platform).arg(modelData.depart.platform) + " | ⏱" + modelData.timebetween
}
}
}
}
Expand Down Expand Up @@ -291,7 +294,7 @@ Item { // Reuse it for TripDetailPage and TripDetail
// Arrive station name
Label {
id: arriveStationLabel
width: parent.width - arriveTimeItem.width - journeyInformation.width - 2*Theme.paddingLarge
width: parent.width - arriveTimeItem.width - journeyInformation.width - 3*Theme.paddingLarge
anchors { left: arriveTimeItem.right; leftMargin: Theme.paddingLarge }
truncationMode: TruncationMode.Fade
font.capitalization: Font.AllUppercase
Expand Down Expand Up @@ -336,13 +339,14 @@ Item { // Reuse it for TripDetailPage and TripDetail
}

ListModel {
id: alerts
id: alertsModel
}

DisturbancesView {
id: alertsView
model: alerts
model: alertsModel
showStation: false
visible: expanded // Only visible when expanded
}
}

Expand Down
Loading

0 comments on commit e7f9d11

Please sign in to comment.