fixing routing.py bug, if time is 24:00
[pywienerlinien] / qml / Settings.qml
1 import QtQuick 1.1
2 import com.nokia.meego 1.0
3 import "UIConstants.js" as UIConstants
4 import "ExtrasConstants.js" as ExtrasConstants
5
6 Page {
7     tools: settingsTools
8
9     ToolBarLayout {
10         id: settingsTools
11         x: 0
12         y: 0
13         ToolIcon { iconId: "toolbar-back"; onClicked: { menu.close(); pageStack.pop(null,false); } }
14     }
15
16     Flickable {
17         id: settingsContent
18         anchors.fill: parent
19         anchors.margins: UIConstants.DEFAULT_MARGIN
20
21         //contentHeight: content_column.height + 2 * UIConstants.DEFAULT_MARGIN
22         flickableDirection: Flickable.VerticalFlick
23
24         Component.onCompleted: {
25             var updateAvailable = config.checkStationsUpdate();
26             if (updateAvailable) {
27                 btnUpdate.color = "green"
28             }
29         }
30
31         Column {
32             id: content_column
33             spacing: UIConstants.DEFAULT_MARGIN
34             width: parent.width
35
36             Text {
37                 text: qsTr("Settings")
38                 font.pixelSize: UIConstants.FONT_XLARGE
39                 color: !theme.inverted ? UIConstants.COLOR_FOREGROUND : UIConstants.COLOR_INVERTED_FOREGROUND
40                 anchors.left: parent.left
41             }
42
43             SettingsHeader {
44                 text: 'Location'
45             }
46
47             Row {
48                 anchors.left: parent.left
49                 anchors.right: parent.right
50                 Text {
51                     text: "Enable GPS"
52                     anchors.left: parent.left
53                     font.pixelSize: UIConstants.FONT_LARGE
54                     color: !theme.inverted ? UIConstants.COLOR_FOREGROUND : UIConstants.COLOR_INVERTED_FOREGROUND
55                     anchors.verticalCenter: parent.verticalCenter
56                 }
57                 Switch {
58                     id: gpsEnable
59                     anchors.right: parent.right
60                     checked: config.getGpsEnabled()
61
62                     onCheckedChanged: {
63                         var gps = config.setGpsEnabled(checked);
64                         if (gps !== '') {
65                             // Unable to set config
66                             console.log(gps);
67                             checked=!checked;
68                         } else {
69                             positionSource.active = checked;
70                         }
71                         if (checked) {
72                             positionSource.start();
73                         } else {
74                             positionSource.stop();
75                         }
76                     }
77                 }
78             }
79
80             UpdateDialog {
81                 id:updateDialog
82             }
83
84             SettingsHeader {
85                 text: 'Station List'
86             }
87
88             Button {
89                 id: btnUpdate
90                 anchors.horizontalCenter: parent.horizontalCenter
91                 text: "Update stations"
92                 width: parent.width * .7
93
94                 Component.onCompleted: {
95                     if (config.checkStationsUpdate()) {
96                         btnUpdate.color = "green"
97                     }
98                 }
99
100                 onClicked: {
101                     var updateAvailable = config.checkStationsUpdate();
102                     if (updateAvailable) {
103                         var updated = config.updateStations();
104                         if (updated !== '') {
105                             updateDialog.text = "Stations updated\nPlease restart app"
106                             txtLastUpdate.text = updated
107                         } else {
108                             updateDialog.text = "[UpdateError]:\nTry again later or send me an email:\n<gotovienna@logic.at>"
109                         }
110                     } else {
111                         updateDialog.text = "No updates available";
112                     }
113                     updateDialog.open();
114                 }
115             }
116
117             Row {
118                 anchors.left: parent.left
119                 anchors.right: parent.right
120                 Text {
121                     anchors.left: parent.left
122                     text: "Last updated:"
123                     font.pixelSize: UIConstants.FONT_LSMALL
124                     color: !theme.inverted ? UIConstants.COLOR_FOREGROUND : UIConstants.COLOR_INVERTED_FOREGROUND
125                     anchors.verticalCenter: parent.verticalCenter
126                 }
127                 Text {
128                     id: txtLastUpdate
129                     anchors.right: parent.right
130                     text: config.getLastUpdate()
131                     font.pixelSize: UIConstants.FONT_LSMALL
132                     color: !theme.inverted ? UIConstants.COLOR_FOREGROUND : UIConstants.COLOR_INVERTED_FOREGROUND
133                     anchors.verticalCenter: parent.verticalCenter
134                 }
135             }
136         }
137     }
138 }