0de4dc48f2af2996e0a867c62cec4a92ee1f59fb
[harbour-pedalo.git] / qml / pages / MainPage.qml
1 import QtQuick 2.0
2 import Sailfish.Silica 1.0
3
4 Page {
5     id: page
6
7     // The effective value will be restricted by ApplicationWindow.allowedOrientations
8     allowedOrientations: Orientation.All
9
10     // To enable PullDownMenu, place our content in a SilicaFlickable
11     SilicaFlickable {
12         anchors.fill: parent
13
14         // PullDownMenu and PushUpMenu must be declared in SilicaFlickable, SilicaListView or SilicaGridView
15         PullDownMenu {
16             MenuItem {
17                 text: qsTr("Show Page 2")
18                 onClicked: pageStack.push(Qt.resolvedUrl("SecondPage.qml"))
19             }
20         }
21
22         // Tell SilicaFlickable the height of its content.
23         contentHeight: column.height
24
25         // Place our content in a Column.  The PageHeader is always placed at the top
26         // of the page, followed by our content.
27         Column {
28             id: column
29
30             width: page.width
31             spacing: Theme.paddingLarge
32             PageHeader {
33                 title: qsTr("Pedalo")
34             }
35
36             SectionHeader {
37                 text: qsTr("Cycle!")
38             }
39
40             Button {
41                 anchors.horizontalCenter: parent.horizontalCenter
42                 text: currentStatus.cycling ? qsTr("Finish") : qsTr("Start a journey")
43                 onClicked: {
44                     if (currentStatus.cycling) {
45                         var dialog = pageStack.push(Qt.resolvedUrl("JourneyEdit.qml"), {title: "Finish journey", start: journeymodel.epochToDateTime(currentStatus.startTime), duration: currentStatus.getDuration()})
46
47                         dialog.accepted.connect(function() {
48                             currentStatus.cycling = false
49                         })
50                     }
51                     else {
52                         currentStatus.startJourney()
53                     }
54                 }
55             }
56
57             SectionHeader {
58                 text: qsTr("Add a journey")
59             }
60
61             Button {
62                 anchors.horizontalCenter: parent.horizontalCenter
63                 text: qsTr("Enter journey")
64                 onClicked: pageStack.push(Qt.resolvedUrl("JourneyEdit.qml"))
65             }
66
67             SectionHeader {
68                 text: qsTr("Latest stats")
69             }
70
71             Button {
72                 anchors.horizontalCenter: parent.horizontalCenter
73                 text: qsTr("View stats")
74                 onClicked: pageStack.push(Qt.resolvedUrl("Stats.qml"))
75             }
76
77             SectionHeader {
78                 text: qsTr("Previous journeys")
79             }
80
81             Button {
82                 anchors.horizontalCenter: parent.horizontalCenter
83                 text: qsTr("View journeys")
84                 onClicked: pageStack.push(Qt.resolvedUrl("JourneyList.qml"))
85             }
86
87         }
88     }
89 }