merge github
[apps/navigation.git] / app / BtnGuidance.qml
1 import QtQuick 2.0\r
2 import QtQuick.Controls 1.5\r
3 import QtLocation 5.9\r
4 import QtPositioning 5.6\r
5 \r
6 Item {\r
7     id: btn_guidance\r
8 \r
9     // 0: idle\r
10     // 1: routing\r
11     // 2: on guide\r
12     property int sts_guide: 0\r
13 \r
14     onSts_guideChanged: {\r
15         console.log("onSts_guideChanged")\r
16         switch(btn_guidance.sts_guide){\r
17         case 0:\r
18             positionTimer.stop();\r
19             break\r
20         case 1:\r
21             break\r
22         case 2:\r
23             positionTimer.start();\r
24             break\r
25         default:\r
26             break\r
27         }\r
28     }\r
29 \r
30     function startGuidance() {\r
31         btn_present_position.state = "Flowing"\r
32         btn_guidance.sts_guide = 2\r
33         btn_guidance.state = "onGuide"\r
34     }\r
35 \r
36     function discardWaypoints() {\r
37         map.initDestination()\r
38 \r
39         if(btn_guidance.sts_guide != 0){\r
40             map.qmlSignalStopDemo()\r
41         }\r
42 \r
43         if(map.center !== map.currentpostion){\r
44             btn_present_position.state = "Optional"\r
45         }\r
46 \r
47         btn_guidance.sts_guide = 0\r
48         btn_guidance.state = "Idle"\r
49     }\r
50 \r
51     Timer {\r
52         id: positionTimer\r
53         interval: fileOperation.getUpdateInterval();\r
54         running: false;\r
55         repeat: true\r
56         onTriggered: map.updatePositon()\r
57     }\r
58 \r
59     Button {\r
60         id: discard\r
61         width: 100\r
62         height: 100\r
63 \r
64         visible: false\r
65 \r
66         onClicked: discardWaypoints()\r
67 \r
68         Image {\r
69             id: discard_image\r
70             width: 92\r
71             height: 92\r
72             anchors.verticalCenter: parent.verticalCenter\r
73             anchors.horizontalCenter: parent.horizontalCenter\r
74             source: "images/200px-Black_close_x.svg.png"\r
75         }\r
76     }\r
77 \r
78     Button {\r
79         id: guidance\r
80                 width: 100\r
81                 height: 100\r
82 \r
83         visible: false\r
84 \r
85         onClicked: { startGuidance() }\r
86 \r
87                 Image {\r
88             id: guidance_image\r
89                         width: 92\r
90                         height: 92\r
91                         anchors.verticalCenter: parent.verticalCenter\r
92                         anchors.horizontalCenter: parent.horizontalCenter\r
93             source: "images/124px-Pictograms-nps-land-driving_tour-2.svg.png"\r
94                 }\r
95 \r
96         }\r
97     states: [\r
98         State {\r
99             name: "Idle"\r
100             PropertyChanges { target: discard; visible: false }\r
101             PropertyChanges { target: guidance; visible: false }\r
102             PropertyChanges { target: guidance; x: 0 }\r
103             PropertyChanges { target: progress_next_cross; state: "invisible" }\r
104             PropertyChanges { target: img_destination_direction; state: "invisible" }\r
105         },\r
106         State {\r
107             name: "Routing"\r
108             PropertyChanges { target: discard; visible: true }\r
109             PropertyChanges { target: guidance; visible: true }\r
110             PropertyChanges { target: guidance; x: -150 }\r
111             PropertyChanges { target: progress_next_cross; state: "invisible" }\r
112             PropertyChanges { target: img_destination_direction; state: "invisible" }\r
113         },\r
114         State {\r
115             name: "onGuide"\r
116             PropertyChanges { target: discard; visible: true }\r
117             PropertyChanges { target: guidance; visible: false }\r
118             PropertyChanges { target: guidance; x: 0 }\r
119             PropertyChanges { target: progress_next_cross; state: "visible" }\r
120             PropertyChanges { target: img_destination_direction; state: "0" }\r
121         }\r
122     ]\r
123 \r
124     transitions: Transition {\r
125         NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad }\r
126         NumberAnimation { properties: "visible"; easing.type: Easing.InOutQuad }\r
127     }\r
128 }\r