5c0c16bdda3d7867c75a938ff70ecdf0abaa8790
[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         VerticalScrollDecorator {}
15
16         // PullDownMenu and PushUpMenu must be declared in SilicaFlickable, SilicaListView or SilicaGridView
17         PullDownMenu {
18             MenuItem {
19                 text: qsTr("About")
20                 onClicked: pageStack.push(Qt.resolvedUrl("About.qml"))
21             }
22         }
23
24         // Tell SilicaFlickable the height of its content.
25         contentHeight: column.implicitHeight + Theme.paddingLarge
26
27         // Place our content in a Column.  The PageHeader is always placed at the top
28         // of the page, followed by our content.
29         Column {
30             id: column
31
32             width: page.width
33             spacing: Theme.paddingLarge
34             PageHeader {
35                 title: qsTr("Pedalo")
36             }
37
38             SectionHeader {
39                 text: qsTr("Cycle!")
40             }
41
42             Button {
43                 anchors.horizontalCenter: parent.horizontalCenter
44                 text: currentStatus.cycling ? qsTr("Finish") : qsTr("Start a journey")
45                 onClicked: {
46                     if (currentStatus.cycling) {
47                         var dialog = pageStack.push(Qt.resolvedUrl("JourneyEdit.qml"), {title: "Finish journey", start: journeymodel.epochToDateTime(currentStatus.startTime), duration: currentStatus.getDuration()})
48
49                         dialog.accepted.connect(function() {
50                             currentStatus.cycling = false
51                         })
52                     }
53                     else {
54                         currentStatus.startJourney()
55                     }
56                 }
57             }
58
59             SectionHeader {
60                 text: qsTr("Add a journey")
61             }
62
63             Button {
64                 anchors.horizontalCenter: parent.horizontalCenter
65                 text: qsTr("Enter journey")
66                 onClicked: pageStack.push(Qt.resolvedUrl("JourneyEdit.qml"))
67             }
68
69             SectionHeader {
70                 text: qsTr("Latest stats")
71             }
72
73             Button {
74                 anchors.horizontalCenter: parent.horizontalCenter
75                 text: qsTr("View stats")
76                 onClicked: pageStack.push(Qt.resolvedUrl("Stats.qml"))
77             }
78
79             SectionHeader {
80                 text: qsTr("Previous journeys")
81             }
82
83             Button {
84                 anchors.horizontalCenter: parent.horizontalCenter
85                 text: qsTr("View journeys")
86                 onClicked: pageStack.push(Qt.resolvedUrl("JourneyList.qml"))
87             }
88
89         }
90     }
91 }