4e7293c1fb217185fd219872f24740002e2f8317
[harbour-pedalo.git] / qml / pages / MainPage.qml
1 import QtQuick 2.0
2 import Sailfish.Silica 1.0
3 import "../components"
4
5 Page {
6     id: page
7
8     // The effective value will be restricted by ApplicationWindow.allowedOrientations
9     allowedOrientations: Orientation.All
10
11     // To enable PullDownMenu, place our content in a SilicaFlickable
12     SilicaFlickable {
13         anchors.fill: parent
14
15         VerticalScrollDecorator {}
16
17         // PullDownMenu and PushUpMenu must be declared in SilicaFlickable, SilicaListView or SilicaGridView
18         PullDownMenu {
19             MenuItem {
20                 text: qsTr("About")
21                 onClicked: pageStack.push(Qt.resolvedUrl("About.qml"))
22             }
23         }
24
25         // Tell SilicaFlickable the height of its content.
26         contentHeight: column.implicitHeight
27
28         Column {
29             id: column
30
31             width: isPortrait ? parent.width : parent.width / 2.0
32             height: isPortrait ? page.height / 2.0 : page.height
33             spacing: 0
34
35             BarButton {
36                 source: "image://theme/icon-launcher-component-gallery"
37                 text: currentStatus.cycling ? qsTr("Finish your journey") : qsTr("Start a journey")
38                 onClicked: {
39                     if (currentStatus.cycling) {
40                         var dialog = pageStack.push(Qt.resolvedUrl("JourneyEdit.qml"), {title: "Finish journey", start: journeymodel.epochToDateTime(currentStatus.startTime), duration: currentStatus.getDuration()})
41
42                         dialog.accepted.connect(function() {
43                             currentStatus.cycling = false
44                         })
45                     }
46                     else {
47                         currentStatus.startJourney()
48                     }
49                 }
50             }
51
52             BarButton {
53                 source: "image://theme/icon-launcher-component-gallery"
54                 text: "Add a journey"
55                 onClicked: pageStack.push(Qt.resolvedUrl("JourneyEdit.qml"))
56             }
57         }
58
59         Column {
60             id: column2
61
62             width: isPortrait ? parent.width : parent.width / 2.0
63             height: isPortrait ? page.height / 2.0 : page.height
64             spacing: 0
65             y: isPortrait ? page.height / 2: 0
66             x: isPortrait ? 0 : page.width / 2.0
67
68             BarButton {
69                 source: "image://theme/icon-launcher-component-gallery"
70                 text: "View latest stats"
71                 onClicked: pageStack.push(Qt.resolvedUrl("Stats.qml"))
72             }
73
74             BarButton {
75                 source: "image://theme/icon-launcher-component-gallery"
76                 text: "Previous journeys"
77                 onClicked: pageStack.push(Qt.resolvedUrl("JourneyList.qml"))
78             }
79         }
80     }
81 }