~costales/unav/0.59-menu-structure-i18n

« back to all changes in this revision

Viewing changes to qml/RoutePage.qml

  • Committer: Nekhelesh Ramananthan
  • Date: 2016-04-16 22:29:22 UTC
  • Revision ID: krnekhelesh@gmail.com-20160416222922-g3u671c10fwtyacr
Removed the unnecessary route page, share page and nearby page

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * uNav http://launchpad.net/unav
3
 
 * Copyright (C) 2015-2016 Marcos Alvarez Costales https://launchpad.net/~costales
4
 
 * Copyright (C) 2015-2016 JkB https://launchpad.net/~joergberroth
5
 
 * Copyright (C) 2016 Nekhelesh Ramananthan https://launchpad.net/~nik90
6
 
 *
7
 
 * uNav is free software; you can redistribute it and/or modify
8
 
 * it under the terms of the GNU General Public License as published by
9
 
 * the Free Software Foundation; either version 3 of the License, or
10
 
 * (at your option) any later version.
11
 
 *
12
 
 * uNav is distributed in the hope that it will be useful,
13
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
 * GNU General Public License for more details.
16
 
 */
17
 
 
18
 
import QtQuick 2.4
19
 
import Ubuntu.Components 1.3
20
 
import "components"
21
 
 
22
 
Page {
23
 
    id: routePage
24
 
 
25
 
    header: UNavHeader {
26
 
        title: i18n.tr("Menu")
27
 
        flickable: flickable
28
 
        
29
 
        // #FIXME: This back button is only here to allow the user to press Escape keyboard key to go back.
30
 
        // This feature will be implemented upstream by the SDK devs when they add keyboard shortcuts to pages,
31
 
        // at which point this back button can be removed.
32
 
        leadingActionBar.actions: Action {
33
 
            iconName: "back"
34
 
            text: i18n.tr("Back")
35
 
            shortcut: "Escape"
36
 
            onTriggered: {
37
 
                mainPageStack.pop();
38
 
            }
39
 
        }
40
 
    }
41
 
 
42
 
    Component.onCompleted: mainPageStack.executeJavaScript("qml_set_route_status();")
43
 
 
44
 
    Flickable {
45
 
        id: flickable
46
 
 
47
 
        anchors { fill: parent; margins: units.gu(2); topMargin: units.gu(4) }
48
 
        height: contentItem.childrenRect.height
49
 
        boundsBehavior: (contentHeight > routePage.height) ? Flickable.DragAndOvershootBounds : Flickable.StopAtBounds
50
 
 
51
 
        ListModel {
52
 
            id: routePageModel
53
 
            Component.onCompleted: initialize()
54
 
 
55
 
            function initialize() {
56
 
                routePageModel.append({mode: "SEARCH", text: i18n.tr("Search"), iconName: "find", visible: true})
57
 
                routePageModel.append({mode: "FAVORITES", text: i18n.tr("Favorites"), iconName: "starred", visible: true})
58
 
                routePageModel.append({mode: "NEARBY", text: i18n.tr("Nearby"), iconName: "location", visible: true})
59
 
                routePageModel.append({mode: "COORDINATES", text: i18n.tr("Coordinates"), iconName: "webbrowser-app-symbolic", visible: true})
60
 
                routePageModel.append({mode: "SHARE", text: i18n.tr("Share"), iconName: "share", visible: true})
61
 
                routePageModel.append({mode: "CANCEL", text: i18n.tr("Cancel"), iconName: "dialog-error-symbolic", visible: mainPageStack.routeState !== 'no'})
62
 
            }
63
 
        }
64
 
 
65
 
        CustomGridView {
66
 
            id: routePageGrid
67
 
 
68
 
            model: routePageModel
69
 
            delegate: GridDelegate {
70
 
                id: delegate
71
 
 
72
 
                title: model.text
73
 
                icon.name: model.iconName
74
 
                visible: model.visible
75
 
 
76
 
                onClicked: {
77
 
                    if (model.mode === "FAVORITES") {
78
 
                        mainPageStack.push(Qt.resolvedUrl("FavoritesPage.qml"))
79
 
                    } else if (model.mode === "SEARCH") {
80
 
                        mainPageStack.push(Qt.resolvedUrl("SearchPage.qml"))
81
 
                    } else if (model.mode === "NEARBY") {
82
 
                        mainPageStack.push(Qt.resolvedUrl("Nearby.qml"))
83
 
                    } else if (model.mode === "COORDINATES") {
84
 
                        mainPageStack.push(Qt.resolvedUrl("Coordinate.qml"))
85
 
                    } else if (model.mode === "SHARE") {
86
 
                        mainPageStack.push(Qt.resolvedUrl("SharePage.qml"))
87
 
                    } else if (model.mode === "CANCEL") {
88
 
                        mainPageStack.routeState = 'no';
89
 
                        mainPageStack.executeJavaScript("click_cancel_route();");
90
 
                        mainPageStack.pop();
91
 
                    }
92
 
                }
93
 
            }
94
 
        }
95
 
    }
96
 
}
97