~danielholm/+junk/sj

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
import QtQuick 2.0
import Ubuntu.Components 0.1
import Ubuntu.Components.ListItems 0.1 as ListItem
import QtWebKit 3.0
import Ubuntu.Components.Popups 0.1 as Popups
import Ubuntu.Components.Popups 0.1

/*!
    \brief MainView with a Label and Button elements.
*/

MainView {
    // objectName for functional testing purposes (autopilot-qt5)
    objectName: "mainView"
    
    // Note! applicationName needs to match the .desktop filename
    applicationName: "sj"
    
    /* 
     This property enables the application to change orientation 
     when the device is rotated. The default is false.
    */
    automaticOrientation: true
    
    width: units.gu(50)
    height: units.gu(75)

    property string appVersion: '0.1'
    
    PageStack {
            id: pageStack
            anchors.fill: parent

        Page {
            id: startpage
            title: "SJ"

            Component {
                     id: aboutDialog
                     Dialog {
                         id: dialogueAbout
                         title: i18n.tr("About")
                         text: appVersion
                         ListItem.Subtitled {
                             id: author
                             width: units.gu(20)
                             text: i18n.tr("By Daniel Holm, Sweden")
                             subText: "admin@danielholm.se"
                             onClicked: {
                                 Qt.openUrlExternally("mailto:admin@danielholm.se")
                             }
                         }

                         Button {
                             text: i18n.tr("close")
                             onClicked: PopupUtils.close(dialogueAbout)
                         }
                     }
                }

            Column {
                spacing: units.gu(1)
                anchors {
                    margins: units.gu(2)
                    fill: parent
                }

                ListItem.Standard {
                    text: "Köp resa"
                    onClicked: {
                        usersChoice.url = "http://mobil.sj.se/timetable/searchtravel.do"
                        webviewer.title = "Köp resa"
                        usersChoice.visible = true
                        pageStack.push(webviewer)
                    }
                }

                ListItem.Standard {
                    text: "Sista minuten"
                    onClicked: {
                        usersChoice.url = "http://mobil.sj.se/portal/content.do?id=1&type=offitem"
                        webviewer.title = "Sista minuten"
                        usersChoice.visible = true
                        pageStack.push(webviewer)
                    }
                }

                ListItem.Standard {
                    text: "Res med pendlarbiljett"
                    onClicked: {
                        usersChoice.url = "http://mobil.sj.se/login/login.do?f=commuter"
                        webviewer.title = "Pendlarbiljett"
                        usersChoice.visible = true
                        pageStack.push(webviewer)
                    }
                }

                ListItem.Standard {
                    text: "Visa mina beställningar"
                    onClicked: {
                        usersChoice.url = "http://mobil.sj.se/orders/searchorder.do"
                        webviewer.title = "Beställningar"
                        usersChoice.visible = true
                        pageStack.push(webviewer)
                    }
                }

                ListItem.Standard {
                    text: "Logga in"
                    onClicked: {
                        usersChoice.url = "http://mobil.sj.se/login/login.do"
                        webviewer.title = "Logga in"
                        usersChoice.visible = true
                        pageStack.push(webviewer)
                    }
                }

                ListItem.Standard {
                    text: "Kontakt"
                    onClicked: {
                        usersChoice.url = "http://mobil.sj.se/contact/contact.do"
                        webviewer.title = "Kontakt"
                        usersChoice.visible = true
                        pageStack.push(webviewer)
                    }
                }
                // About
                ListItem.Subtitled {
                    id: about
                    text: i18n.tr("About")
                    subText: i18n.tr("Version "+appVersion)
                    progression: true
                    onClicked: PopupUtils.open(aboutDialog, about)
                }
            }
        }

        Page {
            id: webviewer
            title: "Changes"

            tools: ToolbarActions {
                Action {
                    id: getBack
                    objectName: "backaction"

                    iconSource: Qt.resolvedUrl("toolbarIcon.png")
                    text: i18n.tr("back")

                    onTriggered: {
                        console.debug('Debug: Get back to menu')
                        pageStack.push(startpage)
                    }
                }
            }

                WebView {
                        id: usersChoice
                        anchors.fill: parent
                        url: ""
                        smooth: true
                        scale: 1
                        visible: false

                        onLoadingChanged: {
                            loadProgressBarLog.visible = loading
                        }

                        onLoadProgressChanged: {
                            //console.debug('load progress of page: '+loadProgress)
                            loadProgressBarLog.value = loadProgress
                        }
                    }

                ProgressBar {
                    id: loadProgressBarLog
                    anchors.bottom: parent.bottom
                    anchors.left: parent.left
                    anchors.right: parent.right
                    minimumValue: 0
                    maximumValue: 100
                }
        }
    }
}