Settings page
[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         }
26
27         Column {
28             id: content_column
29             spacing: UIConstants.DEFAULT_MARGIN
30             width: parent.width
31
32             Text {
33                 text: qsTr("Settings")
34                 font.pixelSize: UIConstants.FONT_XLARGE
35                 color: !theme.inverted ? UIConstants.COLOR_FOREGROUND : UIConstants.COLOR_INVERTED_FOREGROUND
36                 anchors.left: parent.left
37             }
38
39             Row {
40                 anchors.left: parent.left
41                 anchors.right: parent.right
42                 Text {
43                     text: "Enable GPS"
44                     anchors.left: parent.left
45                     font.pixelSize: UIConstants.FONT_LARGE
46                     color: !theme.inverted ? UIConstants.COLOR_FOREGROUND : UIConstants.COLOR_INVERTED_FOREGROUND
47                     anchors.verticalCenter: parent.verticalCenter
48                 }
49                 CheckBox {
50                     id: gpsEnable
51                     anchors.right: parent.right
52                     checked: config.getGpsEnabled()
53
54                     onCheckedChanged: {
55                         var gps = config.setGpsEnabled(checked);
56                         if(gps !== '') {
57                             // Unable to set config
58                             console.log(gps);
59                             checked=!checked;
60                         } else {
61                             positionSource.active = checked;
62                         }
63                     }
64                 }
65             }
66
67             UpdateDialog {
68                 id:updateDialog
69             }
70
71             Row {
72                 anchors.left: parent.left
73                 anchors.right: parent.right
74                 Text {
75                     text: "Update stations"
76                     anchors.left: parent.left
77                     font.pixelSize: UIConstants.FONT_LARGE
78                     color: !theme.inverted ? UIConstants.COLOR_FOREGROUND : UIConstants.COLOR_INVERTED_FOREGROUND
79                     anchors.verticalCenter: parent.verticalCenter
80                 }
81
82                 Button {
83                     id: btnUpdate
84                     anchors.right: parent.right
85                     text: "Update"
86                     width: 100
87
88                     Component.onCompleted: {
89                         if (config.checkStationsUpdate()) {
90                             btnUpdate.color = "green"
91                         }
92                     }
93
94                     onClicked: {
95                         var updateAvailable = config.checkStationsUpdate();
96                         if (updateAvailable) {
97                             var updated = config.updateStations();
98                             if (updated !== '') {
99                                 updateDialog.text = "Stations updated"
100                                 txtLastUpdate.text = updated
101                             } else {
102                                 updateDialog.text = "[UpdateError]:\nTry again later or send me an email:\n<gotovienna@logic.at>"
103                             }
104                         } else {
105                             updateDialog.text = "No updates available";
106                         }
107                         updateDialog.open();
108                     }
109                 }
110             }
111
112             Row {
113                 anchors.left: parent.left
114                 anchors.right: parent.right
115                 Text {
116                     anchors.left: parent.left
117                     text: "Last updated:"
118                     font.pixelSize: UIConstants.FONT_LSMALL
119                     color: !theme.inverted ? UIConstants.COLOR_FOREGROUND : UIConstants.COLOR_INVERTED_FOREGROUND
120                     anchors.verticalCenter: parent.verticalCenter
121                 }
122                 Text {
123                     id: txtLastUpdate
124                     anchors.right: parent.right
125                     text: config.getLastUpdate()
126                     font.pixelSize: UIConstants.FONT_LSMALL
127                     color: !theme.inverted ? UIConstants.COLOR_FOREGROUND : UIConstants.COLOR_INVERTED_FOREGROUND
128                     anchors.verticalCenter: parent.verticalCenter
129                 }
130             }
131         }
132     }
133 }