show restart notification after db update
[pywienerlinien] / qml / MainPage.qml
index 9f1a7f7..4d1947b 100644 (file)
@@ -12,6 +12,10 @@ Page {
     //property alias stationSelect: stationSelector
     property variant nearbyStations
 
+    function search() {
+        lineSearchButton.clicked()
+    }
+
     function refresh() {
         realtimeResult.refresh()
     }
@@ -32,6 +36,47 @@ Page {
         stationSelector.open()
     }
 
+    Text {
+        visible: !parent.canRefresh
+        anchors.centerIn: parent
+        font.pixelSize: 30
+        text: '<p><strong>Welcome, traveller!<br></strong></p><p>Press <img src="image://theme/icon-m-toolbar-search"> to search for<br>departure information.</p><p>Press <img src="image://theme/icon-m-toolbar-view-menu"> for nearby stations.<br></p><p><strong>Have a safe journey.</strong></p>'
+    }
+
+    Rectangle {
+        id: header
+        anchors {
+            top: parent.top
+            left: parent.left
+            right: parent.right
+            margins: -1
+        }
+        border {
+            color: 'black'
+            width: 1
+        }
+
+        gradient: Gradient {
+            GradientStop { position: 0; color: '#777' }
+            GradientStop { position: 1; color: '#aaa' }
+        }
+
+        height: 80
+        color: 'white'
+
+        Image {
+            id: logo
+            source: 'logo.png'
+
+            anchors {
+                verticalCenter: parent.verticalCenter
+                left: parent.left
+                leftMargin: 10
+            }
+        }
+
+    }
+
     PositionSource {
         id: positionSource
         updateInterval: 10000
@@ -63,6 +108,7 @@ Page {
     }
 
     TextField {
+        visible: false
         placeholderText: 'Line'
 
         id: gline
@@ -77,11 +123,6 @@ Page {
 
         onTextChanged: {
             gstation.text = ''
-
-            if (lineSelector.selectedIndex === -1) {
-                text = text.toUpperCase()
-                return
-            }
         }
 
          MouseArea {
@@ -95,11 +136,17 @@ Page {
 
     LineSheet {
         id: lineSheet
-        onAccepted: gline.text = currentLine
+        onAccepted: {
+            gline.text = currentLine
+
+            /* We usually want to select a station after selecting a line */
+            stationPickerButton.clicked()
+        }
     }
 
     Button {
         id: lineSearchButton
+        visible: false
 
         anchors {
             top: gline.top
@@ -111,12 +158,16 @@ Page {
         width: 60
         iconSource: 'image://theme/icon-m-common-search'
 
-        onClicked: lineSheet.open()
+        onClicked: {
+            lineSheet.currentLine = ''
+            lineSheet.open()
+        }
     }
 
     TextField {
         placeholderText: 'Station'
         id: gstation
+        visible: false
 
         anchors {
             top: gline.bottom
@@ -130,6 +181,19 @@ Page {
 
     StationSheet {
         id: stationSheet
+        onAccepted: {
+            gstation.text = stationSheet.currentStation
+
+            realtimeResult.gline = stationSheet.currentLine
+            realtimeResult.gstation = stationSheet.currentStation
+            realtimeResult.gdirection = stationSheet.currentDirection
+            realtimeResult.isStation = false
+
+            realtimeResult.sourceUrl = itip.get_directions_url(stationSheet.currentLine, stationSheet.currentDirection, stationSheet.currentStation)
+            console.log('url to get: ' + realtimeResult.sourceUrl)
+            realtimeResult.refresh()
+
+        }
     }
 
     Button {
@@ -142,9 +206,7 @@ Page {
             rightMargin: 10
         }
 
-        Behavior on opacity { PropertyAnimation { } }
-
-        opacity: gline.text !== '' // XXX: Check if the line is valid
+        visible: false
 
         width: lineSearchButton.width * opacity
         //iconSource: 'image://theme/icon-m-common-location-picker'
@@ -161,7 +223,7 @@ Page {
 
         anchors {
             margins: 10
-            top: gstation.bottom
+            top: header.bottom
             left: parent.left
             bottom: parent.bottom
             right: parent.right