• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • apps
  • marble-touch
  • activities
Navigation.qml
Go to the documentation of this file.
1 // This file is part of the Marble Virtual Globe.
2 //
3 // This program is free software licensed under the GNU LGPL. You can
4 // find a copy of this license in LICENSE.txt in the top directory of
5 // the source code.
6 //
7 // Copyright 2011 Dennis Nienhüser <earthwings@gentoo.org>
8 
9 import QtQuick 1.0
10 import com.nokia.meego 1.0
11 import QtMobility.systeminfo 1.1
12 import QtMultimediaKit 1.1
13 import org.kde.edu.marble 0.11
14 import ".."
15 
16 /*
17  * Page for navigation activity.
18  */
19 Page {
20  id: navigationActivityPage
21  anchors.fill: parent
22 
23  tools: ToolBarLayout {
24  MarbleToolIcon {
25  iconSource: main.icon( "actions/go-home", 48 );
26  onClicked: main.showNavigation()
27  }
28  ToolButton {
29  iconSource: main.icon( "actions/text-speak", 48 );
30  checkable: true
31  checked: !settings.voiceNavigationMuted
32  onCheckedChanged: settings.voiceNavigationMuted = !checked
33  width: 60
34  flat: true
35  }
36  ToolButton {
37  iconSource: main.icon( "devices/network-wireless", 48 );
38  checkable: true
39  checked: !settings.workOffline
40  onCheckedChanged: settings.workOffline = !checked
41  width: 60
42  flat: true
43  }
44  MarbleToolIcon {
45  id: menuIcon
46  iconSource: main.icon( "actions/show-menu", 48 );
47  onClicked: {
48  if (main.components === "plasma") {
49  pageMenu.visualParent = menuIcon
50  }
51  pageMenu.open()
52  }
53  }
54  }
55 
56  Menu {
57  id: pageMenu
58  content: MarbleMenuLayout {
59  MenuItemSwitch {
60  text: "Elevation Profile"
61  checked: false
62  onCheckedChanged: {
63  var plugins = settings.activeRenderPlugins
64  if ( checked ) {
65  plugins.push("elevationprofile")
66  } else {
67  settings.removeElementsFromArray(plugins, ["elevationprofile"])
68  }
69  settings.activeRenderPlugins = plugins
70  marbleWidget.setGeoSceneProperty( "hillshading", checked )
71  }
72  }
73  }
74  }
75 
76  Rectangle {
77  id: instructionItem
78  color: marbleWidget.navigation.deviated ? Qt.rgba(156/255, 15/255, 15/255, 1) : Qt.rgba(0/255, 67/255, 138/255, 1)
79 
80  anchors.top: parent.top
81  anchors.left: parent.left
82  anchors.right: parent.right
83  height: Math.max(instructionImage.height, instructionDistance.height)
84 
85  Image {
86  id: instructionImage
87  anchors.verticalCenter: parent.verticalCenter
88  width: 64
89  height: 64
90  smooth: true
91  source: marbleWidget.navigation.nextInstructionImage
92  onSourceChanged: {
93  fadeAnimation.running = true
94  }
95  }
96 
97  Label {
98  id: instructionDistance
99  anchors.left: instructionImage.right
100  anchors.verticalCenter: parent.verticalCenter
101  anchors.right: parent.right
102 
103  property bool isMeter: marbleWidget.navigation.nextInstructionDistance < 1000
104  property real distance: isMeter ? Math.round( marbleWidget.navigation.nextInstructionDistance / 10 ) * 10 : Math.round( marbleWidget.navigation.nextInstructionDistance / 100 ) / 10
105  property string distanceUnit: isMeter ? "m" : "km"
106 
107  color: Qt.rgba(238/255, 238/255, 236/255, 1)
108  text: "<font size=\"+2\">" + distance + "</font>" + "<font size=\"-1\"> " + distanceUnit + "</font>" + "<font size=\"+2\"> " + marbleWidget.navigation.nextRoad + "</font>"
109  wrapMode: Text.WrapAtWordBoundaryOrAnywhere
110  }
111 
112  PropertyAnimation {
113  id: fadeAnimation;
114  target: instructionItem;
115  property: "opacity";
116  from: 0.2;
117  to: 1.0;
118  duration: 200
119  }
120  }
121 
122  Rectangle {
123  id: searchResultView
124  anchors.left: navigationActivityPage.left
125  anchors.bottom: navigationActivityPage.bottom
126  anchors.right: navigationActivityPage.right
127 
128  gradient: Gradient {
129  GradientStop { position: 0.0; color: Qt.rgba(46/255, 52/255, 54/255, 1) }
130  GradientStop { position: 0.8; color: Qt.rgba(36/255, 42/255, 44/255, 1) }
131  GradientStop { position: 1.0; color: Qt.rgba(26/255, 32/255, 34/255, 1) }
132  }
133 
134  Grid {
135  anchors.fill: parent
136  anchors.margins: 5
137  spacing: 20
138  property bool portrait: main.inPortrait
139 
140  columns: portrait ? 4 : 1
141  rows: portrait ? 1 : 4
142 
143  Label {
144  id: currentSpeed
145  width: parent.portrait ? parent.width / 2 : parent.width - 10
146  color: Qt.rgba(238/255, 238/255, 236/255, 1)
147  text: "<font size=\"+2\">" + Math.round( marbleWidget.tracking.positionSource.speed ) + "</font><font size=\"-1\"> km/h</font>"
148  horizontalAlignment: parent.portrait ? Text.AlignHCenter : Text.AlignRight
149 
150  MouseArea {
151  anchors.fill: parent
152  onClicked: marbleWidget.centerOn( marbleWidget.tracking.lastKnownPosition.longitude, marbleWidget.tracking.lastKnownPosition.latitude )
153  }
154  }
155 
156  Rectangle {
157  id: distanceSeparator
158  visible: !parent.portrait
159  width: parent.portrait ? 1 : parent.width
160  height: parent.portrait ? parent.height - 20 : 1
161  anchors.verticalCenter: parent.portrait ? parent.verticalCenter : undefined
162  color: currentSpeed.color
163  }
164 
165  Label {
166  id: destinationDistance
167  width: parent.portrait ? parent.width / 2 : parent.width - 10
168  color: currentSpeed.color
169  property bool isMeter: marbleWidget.navigation.destinationDistance < 1000
170  property real distance: isMeter ? Math.round( marbleWidget.navigation.destinationDistance / 10 ) * 10 : Math.round( marbleWidget.navigation.destinationDistance / 100 ) / 10
171  property string distanceUnit: isMeter ? "m" : "km"
172  text: "<img src=\"qrc:/marble/flag-green.svg\"> <font size=\"+2\">" + distance + "</font><font size=\"-1\"> " + distanceUnit + "</font>"
173  horizontalAlignment: parent.portrait ? Text.AlignHCenter : Text.AlignRight
174  }
175  }
176  }
177 
178  Item {
179  id: mapContainer
180  clip: true
181  anchors.top: instructionItem.bottom
182  anchors.right: navigationActivityPage.right
183  anchors.left: navigationActivityPage.left
184  anchors.bottom: searchResultView.top
185 
186  function embedMarbleWidget() {
187  marbleWidget.parent = mapContainer
188  settings.projection = "Mercator"
189  var plugins = settings.defaultRenderPlugins
190  settings.removeElementsFromArray(plugins, ["coordinate-grid", "sun", "stars", "compass", "crosshairs"])
191  settings.activeRenderPlugins = plugins
192  settings.mapTheme = settings.streetMapTheme
193  settings.gpsTracking = true
194  settings.showPositionIndicator = true
195  settings.showTrack = true
196  marbleWidget.tracking.positionMarkerType = Tracking.Arrow
197  marbleWidget.navigation.guidanceModeEnabled = true
198  marbleWidget.visible = true
199  }
200 
201  Component.onDestruction: {
202  if ( marbleWidget.parent === mapContainer ) {
203  marbleWidget.parent = null
204  marbleWidget.visible = false
205  }
206  }
207  }
208 
209  StateGroup {
210  // Here be dragons. Order is crucial in the changes below
211  states: [
212  State { // Horizontal
213  when: (navigationActivityPage.width / navigationActivityPage.height) > 1.20
214  AnchorChanges { target: searchResultView; anchors.top: instructionItem.bottom; anchors.right: undefined }
215  AnchorChanges { target: mapContainer; anchors.left: searchResultView.right; anchors.bottom: navigationActivityPage.bottom; }
216  PropertyChanges { target: searchResultView; height: navigationActivityPage.height-instructionItem.height; width: navigationActivityPage.width * 0.2; }
217  },
218  State { // Vertical
219  when: (true)
220  AnchorChanges { target: searchResultView; anchors.top: undefined; anchors.right: navigationActivityPage.right }
221  AnchorChanges { target: mapContainer; anchors.left: navigationActivityPage.left; anchors.bottom: searchResultView.top; }
222  PropertyChanges { target: searchResultView; height: destinationDistance.height+7; width: navigationActivityPage.width }
223  }
224  ]
225  }
226 
227  ScreenSaver {
228  id: saver
229  }
230 
231  onStatusChanged: {
232  if ( status === PageStatus.Activating ) {
233  mapContainer.embedMarbleWidget()
234  saver.screenSaverDelayed = settings.inhibitScreensaver
235  if (!settings.navigationStartupWarningEverShown || settings.navigationStartupWarning) {
236  safetyWarningDialog.open()
237  }
238  } else if ( status === PageStatus.Deactivating ) {
239  saver.screenSaverDelayed = false
240  }
241  }
242 
243  Audio {
244  id: playback
245  }
246 
247  Dialog {
248  id: safetyWarningDialog
249 
250  content: Column {
251  width: parent.width
252  spacing: 10
253 
254  Label {
255  id: textLabel
256  width: parent.width
257  color: main.components === "harmattan" ? "white" : "black"
258  text: "<p>Caution: Driving instructions may be incomplete or wrong. Road construction, weather and other unforeseen variables can result in the suggested route not to be the most expedient or safest route to your destination. Please use common sense while navigating.</p><p>The Marble development team wishes you a pleasant and safe journey.</p>"
259  wrapMode: Text.Wrap
260  }
261 
262  Row {
263  CheckBox {
264  id: startupCheckbox
265  checked: settings.navigationStartupWarning
266  onCheckedChanged: settings.navigationStartupWarning = checked
267  }
268  Label {
269  text: "Show again";
270  color: textLabel.color
271  anchors.verticalCenter: startupCheckbox.verticalCenter
272  }
273  }
274 
275  Item {
276  height: 5; width: 1
277  }
278  }
279 
280  buttons: ButtonRow {
281  anchors.horizontalCenter: parent.horizontalCenter
282  Button { text: "OK"; onClicked: safetyWarningDialog.accept() }
283  }
284 
285  onAccepted: settings.navigationStartupWarningEverShown = true
286  }
287 
288  Connections { target: marbleWidget.navigation; onVoiceNavigationAnnouncementChanged: voiceAnnouncement() }
289 
290  function voiceAnnouncement() {
291  playback.source = "file://" + marbleWidget.navigation.voiceNavigationAnnouncement
292  playback.play()
293  }
294 }
MarbleWindow::components
string components
Definition: harmattan/MarbleWindow.qml:19
Tracking
Definition: Tracking.qml:16
Button
Definition: cloud-sync/Button.qml:11
Tracking::Arrow
Definition: Tracking.h:49
Rectangle
MenuItemSwitch
Definition: harmattan/MenuItemSwitch.qml:49
MarbleWindow::inPortrait
bool inPortrait
Definition: harmattan/MarbleWindow.qml:17
MarbleWindow::icon
void icon(name, size)
MarbleMenuLayout
Definition: harmattan/MarbleMenuLayout.qml:10
MarbleToolIcon
Definition: harmattan/MarbleToolIcon.qml:10
MarbleWindow::showNavigation
void showNavigation()
main
Definition: examples/cpp/marbleQuick2/main.qml:3
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:41 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal