summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <[email protected]>2015-08-29 19:34:37 +0200
committerDennis Nienhüser <[email protected]>2015-08-29 19:47:50 +0200
commitddca7640e95d0fc8e8d38b434757c019ccbfa3e7 (patch)
tree11b991c8b7868b85640c53b5c2edbffb374daceb
parent87de502f31f8eb56969c0de3c459a1e10b0d1b69 (diff)
Use main routing button on map also in dialogs
-rw-r--r--data/android/drawable-xxxhdpi/ic_directions_black_48dp.pngbin0 -> 902 bytes
-rw-r--r--src/apps/marble-maps/MainScreen.qml159
-rw-r--r--src/apps/marble-maps/MarbleMaps.qrc1
-rw-r--r--src/apps/marble-maps/NavigationManager.qml28
-rw-r--r--src/apps/marble-maps/PlacemarkDialog.qml29
-rw-r--r--src/apps/marble-maps/ProfileSelectorMenu.qml2
-rw-r--r--src/apps/marble-maps/RouteEditor.qml41
-rw-r--r--src/apps/marble-maps/RouteProfileRadioButton.qml2
8 files changed, 147 insertions, 115 deletions
diff --git a/data/android/drawable-xxxhdpi/ic_directions_black_48dp.png b/data/android/drawable-xxxhdpi/ic_directions_black_48dp.png
new file mode 100644
index 0000000..f02aee2
--- /dev/null
+++ b/data/android/drawable-xxxhdpi/ic_directions_black_48dp.png
Binary files differ
diff --git a/src/apps/marble-maps/MainScreen.qml b/src/apps/marble-maps/MainScreen.qml
index aa8038e..69aafde 100644
--- a/src/apps/marble-maps/MainScreen.qml
+++ b/src/apps/marble-maps/MainScreen.qml
@@ -141,66 +141,12 @@ ApplicationWindow {
visible: !navigationManager.visible
}
- PositionButton {
- id: zoomToPositionButton
- anchors {
- bottom: parent.bottom
- right: parent.right
- rightMargin: 0.005 * root.width
- bottomMargin: 25
- }
-
- iconSource: marbleMaps.positionAvailable ? "qrc:///gps_fixed.png" : "qrc:///gps_not_fixed.png"
-
- onClicked: marbleMaps.centerOnCurrentPosition()
-
- property real distance: 0
-
- function updateIndicator() {
- var point = marbleMaps.mapFromItem(zoomToPositionButton, diameter * 0.5, diameter * 0.5);
- distance = 0.001 * marbleMaps.distanceFromPointToCurrentLocation(point);
- angle = marbleMaps.angleFromPointToCurrentLocation(point);
- }
-
- showDirection: marbleMaps.positionAvailable && !marbleMaps.positionVisible
- }
-
- BoxedText {
- id: distanceIndicator
- text: "%1 km".arg(zoomToPositionButton.distance < 10 ? zoomToPositionButton.distance.toFixed(1) : zoomToPositionButton.distance.toFixed(0))
- anchors {
- bottom: zoomToPositionButton.top
- horizontalCenter: zoomToPositionButton.horizontalCenter
- }
-
- visible: marbleMaps.positionAvailable && !marbleMaps.positionVisible
- }
-
- CircularButton {
- id: routeEditorButton
- anchors {
- bottom: distanceIndicator.top
- horizontalCenter: zoomToPositionButton.horizontalCenter
- margins: 0.01 * root.width
- }
-
- iconSource: "qrc:///navigation.png"
- onClicked: itemStack.state = itemStack.state === "routing" ? "default" : "routing"
- }
-
- PositionMarker {
- id: positionMarker
- posX: navigationManager.visible ? navigationManager.snappedPositionMarkerScreenPosition.x : 0
- posY: navigationManager.visible ? navigationManager.snappedPositionMarkerScreenPosition.y : 0
- angle: marbleMaps.angle
- visible: navigationManager.visible
- }
-
NavigationManager {
id: navigationManager
width: parent.width
height: parent.height
visible: false
+ marbleItem: marbleMaps
}
BoxedText {
@@ -226,13 +172,6 @@ ApplicationWindow {
}
}
- BorderImage {
- anchors.fill: dialogContainer
- anchors.margins: -14
- border { top: 14; left: 14; right: 14; bottom: 14 }
- source: "qrc:///border_shadow.png"
- }
-
Item {
id: dialogContainer
anchors {
@@ -262,6 +201,98 @@ ApplicationWindow {
}
}
}
+
+ BoxedText {
+ id: distanceIndicator
+ text: "%1 km".arg(zoomToPositionButton.distance < 10 ? zoomToPositionButton.distance.toFixed(1) : zoomToPositionButton.distance.toFixed(0))
+ anchors {
+ bottom: zoomToPositionButton.top
+ horizontalCenter: zoomToPositionButton.horizontalCenter
+ }
+
+ visible: marbleMaps.positionAvailable && !marbleMaps.positionVisible
+ }
+
+ PositionButton {
+ id: zoomToPositionButton
+ anchors {
+ right: parent.right
+ rightMargin: 0.005 * root.width
+ bottom: routeEditorButton.top
+ bottomMargin: 10
+ }
+
+ iconSource: marbleMaps.positionAvailable ? "qrc:///gps_fixed.png" : "qrc:///gps_not_fixed.png"
+
+ onClicked: marbleMaps.centerOnCurrentPosition()
+
+ property real distance: 0
+
+ function updateIndicator() {
+ var point = marbleMaps.mapFromItem(zoomToPositionButton, diameter * 0.5, diameter * 0.5);
+ distance = 0.001 * marbleMaps.distanceFromPointToCurrentLocation(point);
+ angle = marbleMaps.angleFromPointToCurrentLocation(point);
+ }
+
+ showDirection: marbleMaps.positionAvailable && !marbleMaps.positionVisible
+ }
+
+ CircularButton {
+ id: routeEditorButton
+ anchors {
+ bottom: dialogContainer.height > 0 ? undefined : parent.bottom
+ verticalCenter: dialogContainer.height > 0 ? dialogContainer.top : undefined
+ horizontalCenter: zoomToPositionButton.horizontalCenter
+ margins: 0.01 * root.width
+ bottomMargin: 25
+ }
+
+ onClicked: {
+ if (itemStack.state === "routing") {
+ itemStack.state = "navigation"
+ } else if (itemStack.state === "place") {
+ placemarkDialog.addToRoute()
+ } else {
+ itemStack.state = "routing"
+ }
+ }
+ iconSource: "qrc:///directions.png";
+
+ states: [
+ State {
+ name: ""
+ AnchorChanges { target: routeEditorButton; anchors.bottom: parent.bottom; anchors.verticalCenter: undefined; }
+ PropertyChanges { target: routeEditorButton; iconSource: "qrc:///directions.png"; highlight: false }
+ },
+ State {
+ name: "routingAction"
+ when: itemStack.state == "routing"
+ AnchorChanges { target: routeEditorButton; anchors.bottom: undefined; anchors.verticalCenter: dialogContainer.top; }
+ PropertyChanges { target: routeEditorButton; iconSource: "qrc:///navigation.png"; highlight: true }
+ },
+ State {
+ name: "placeAction"
+ when: itemStack.state == "place"
+ AnchorChanges { target: routeEditorButton; anchors.bottom: undefined; anchors.verticalCenter: dialogContainer.top; }
+ PropertyChanges { target: routeEditorButton; iconSource: routeEditor.currentProfileIcon; highlight: true; }
+ }
+ ]
+ }
+
+ PositionMarker {
+ id: positionMarker
+ posX: navigationManager.visible ? navigationManager.snappedPositionMarkerScreenPosition.x : 0
+ posY: navigationManager.visible ? navigationManager.snappedPositionMarkerScreenPosition.y : 0
+ angle: marbleMaps.angle
+ visible: navigationManager.visible
+ }
+
+ BorderImage {
+ anchors.fill: dialogContainer
+ anchors.margins: -14
+ border { top: 14; left: 14; right: 14; bottom: 14 }
+ source: "qrc:///border_shadow.png"
+ }
}
}
@@ -272,6 +303,7 @@ ApplicationWindow {
PropertyChanges { target: search; visible: true }
PropertyChanges { target: placemarkDialog; visible: false }
PropertyChanges { target: routeEditor; visible: false }
+ PropertyChanges { target: navigationManager; guidanceMode: false }
StateChangeScript { script: itemStack.pop(mapItem); }
},
State {
@@ -279,6 +311,7 @@ ApplicationWindow {
PropertyChanges { target: search; visible: true }
PropertyChanges { target: placemarkDialog; visible: true }
PropertyChanges { target: routeEditor; visible: false }
+ PropertyChanges { target: navigationManager; guidanceMode: false }
StateChangeScript { script: itemStack.pop(mapItem); }
},
State {
@@ -286,6 +319,7 @@ ApplicationWindow {
PropertyChanges { target: search; visible: true }
PropertyChanges { target: placemarkDialog; visible: false }
PropertyChanges { target: routeEditor; visible: true }
+ PropertyChanges { target: navigationManager; guidanceMode: false }
StateChangeScript { script: itemStack.pop(mapItem); }
},
State {
@@ -293,6 +327,7 @@ ApplicationWindow {
PropertyChanges { target: search; visible: false }
PropertyChanges { target: placemarkDialog; visible: false }
PropertyChanges { target: routeEditor; visible: false }
+ PropertyChanges { target: navigationManager; guidanceMode: true }
StateChangeScript { script: itemStack.push(navigationManager); }
},
State {
diff --git a/src/apps/marble-maps/MarbleMaps.qrc b/src/apps/marble-maps/MarbleMaps.qrc
index 4317391..9e8903a 100644
--- a/src/apps/marble-maps/MarbleMaps.qrc
+++ b/src/apps/marble-maps/MarbleMaps.qrc
@@ -25,6 +25,7 @@
<file alias="gps_not_fixed.png">../../../data/android/drawable-xxxhdpi/gps_not_fixed.png</file>
<file alias="backdrop.png">../../../data/android/drawable-xxxhdpi/backdrop.png</file>
<file alias="border_shadow.png">../../../data/android/drawable-xxxhdpi/border_shadow.png</file>
+ <file alias="directions.png">../../../data/android/drawable-xxxhdpi/ic_directions_black_48dp.png</file>
<file alias="navigation.png">../../../data/android/drawable-xxxhdpi/navigation.png</file>
<file alias="car.png">../../../data/android/drawable-xxxhdpi/car.png</file>
<file alias="bike.png">../../../data/android/drawable-xxxhdpi/bike.png</file>
diff --git a/src/apps/marble-maps/NavigationManager.qml b/src/apps/marble-maps/NavigationManager.qml
index a9f6a6a..0f10d54 100644
--- a/src/apps/marble-maps/NavigationManager.qml
+++ b/src/apps/marble-maps/NavigationManager.qml
@@ -18,9 +18,22 @@ import org.kde.edu.marble 0.20
Item {
id: root
- property alias marbleItem: navigation.marbleQuickItem
+ property var marbleItem: null
property var tts: null
property var snappedPositionMarkerScreenPosition: null
+ property bool guidanceMode: false
+
+ onGuidanceModeChanged: {
+ if (guidanceMode && marbleItem) {
+ navigation.marbleQuickItem = marbleItem;
+ marbleItem.setZoomToMaximumLevel();
+ marbleItem.centerOnCurrentPosition();
+ } else {
+ navigation.marbleQuickItem = null
+ }
+
+ navigation.guidanceModeEnabled = guidanceMode;
+ }
Audio {
id: audioPlayer
@@ -57,7 +70,7 @@ Item {
id: speed
color: palette.window
textColor: palette.text
- text: qsTr("%1 km/h".arg((marbleItem ? marbleItem.speed * 3.6 : 0).toFixed(0)))
+ text: qsTr("%1 km/h".arg((navigation.marbleQuickItem ? navigation.marbleQuickItem.speed * 3.6 : 0).toFixed(0)))
anchors {
bottom: totalDistance.top
@@ -68,15 +81,8 @@ Item {
Navigation {
id: navigation
+ soundEnabled: false
- onMarbleQuickItemChanged: {
- if (marbleQuickItem) {
- marbleQuickItem.setZoomToMaximumLevel();
- marbleQuickItem.centerOnCurrentPosition();
- guidanceModeEnabled = true;
- soundEnabled = false;
- }
- }
onVoiceNavigationAnnouncementChanged: {
if (!parent.visible) {
return "";
@@ -142,7 +148,7 @@ Item {
function updateItem()
{
- if (marbleItem) {
+ if (navigation.marbleQuickItem) {
root.snappedPositionMarkerScreenPosition = navigation.positionOnRoute();
}
else
diff --git a/src/apps/marble-maps/PlacemarkDialog.qml b/src/apps/marble-maps/PlacemarkDialog.qml
index cfa2e05..ec160bf 100644
--- a/src/apps/marble-maps/PlacemarkDialog.qml
+++ b/src/apps/marble-maps/PlacemarkDialog.qml
@@ -22,6 +22,11 @@ Item {
height: placemark === null ? 0 : Screen.pixelDensity * 4 + Math.max(infoLayout.height, actionsLayout.height)
+ function addToRoute() {
+ viaGroup.current.execute()
+ itemStack.state = "routing"
+ }
+
SystemPalette {
id: palette
colorGroup: SystemPalette.Active
@@ -49,7 +54,7 @@ Item {
wrapMode: Text.WordWrap
elide: Text.ElideRight
maximumLineCount: 2
- font.pointSize: 18
+ font.pointSize: 20
}
Text {
@@ -65,13 +70,20 @@ Item {
Column {
id: actionsLayout
+ width: rowLayout.width
+ height: spacer.height + rowLayout.height
spacing: Screen.pixelDensity * 2
anchors {
- top: parent.top
right: parent.right
margins: Screen.pixelDensity * 2
}
+ Item {
+ id: spacer
+ height: Screen.pixelDensity * 8
+ width: 1
+ }
+
Row {
id: rowLayout
anchors.right: parent.right
@@ -86,7 +98,6 @@ Item {
visible: routing.routeRequestModel.count === 0
exclusiveGroup: viaGroup
imageSource: "qrc:///ic_place_departure.png"
- property string actionText: qsTr("Route from here")
function execute() {
routing.addViaByPlacemarkAtIndex(0, placemark)
}
@@ -95,7 +106,6 @@ Item {
anchors.margins: 0
exclusiveGroup: viaGroup
imageSource: "qrc:///ic_place_via.png"
- property string actionText: qsTr("Route via here")
function execute() {
ensureRouteHasDeparture()
routing.addViaByPlacemark(placemark)
@@ -105,7 +115,6 @@ Item {
anchors.margins: 0
checked: true
exclusiveGroup: viaGroup
- property string actionText: qsTr("Route to here")
imageSource: "qrc:///ic_place_arrival.png"
function execute() {
ensureRouteHasDeparture()
@@ -113,16 +122,6 @@ Item {
}
}
}
-
- Button {
- id: routeButton
- text: viaGroup.current.actionText
- anchors.right: parent.right
- onClicked: {
- viaGroup.current.execute()
- itemStack.state = "routing"
- }
- }
}
function ensureRouteHasDeparture() {
diff --git a/src/apps/marble-maps/ProfileSelectorMenu.qml b/src/apps/marble-maps/ProfileSelectorMenu.qml
index 4a5698d..794fa26 100644
--- a/src/apps/marble-maps/ProfileSelectorMenu.qml
+++ b/src/apps/marble-maps/ProfileSelectorMenu.qml
@@ -18,6 +18,7 @@ Item {
id: root
property string selectedProfile: qsTr("Car (fastest)")
+ property string profileIcon: "qrc:///car.png"
height: rowLayout.height
width: rowLayout.width
@@ -26,6 +27,7 @@ Item {
ExclusiveGroup {
id: profileGroup
onCurrentChanged: {
+ profileIcon = current.imageSource
selectedProfile = current.profile;
}
}
diff --git a/src/apps/marble-maps/RouteEditor.qml b/src/apps/marble-maps/RouteEditor.qml
index 3ce18d1..3a69321 100644
--- a/src/apps/marble-maps/RouteEditor.qml
+++ b/src/apps/marble-maps/RouteEditor.qml
@@ -21,6 +21,7 @@ Item {
property var routingManager: null
property alias routingProfile: profileSelector.selectedProfile
+ property alias currentProfileIcon: profileSelector.profileIcon
property alias currentIndex: waypointList.currentIndex
height: visible ? Screen.pixelDensity * 4 + column.height : 0
@@ -45,6 +46,20 @@ Item {
margins: Screen.pixelDensity * 2
}
+ Item {
+ anchors {
+ left: parent.left
+ right: parent.right
+ }
+
+ height: profileSelector.height
+
+ ProfileSelectorMenu {
+ id: profileSelector
+ anchors.left: parent.left
+ }
+ }
+
ListView {
id: waypointList
anchors {
@@ -134,32 +149,6 @@ Item {
}
}
}
-
- Item {
-
- anchors {
- left: parent.left
- right: parent.right
- }
-
- height: Math.max(profileSelector.height, navigationButton.height)
-
- ProfileSelectorMenu {
- id: profileSelector
- anchors.left: parent.left
- }
-
-
- Button {
- id: navigationButton
- anchors.right: parent.right
- text: qsTr("Start Navigation")
- onClicked: {
- navigationManager.marbleItem = marbleMaps;
- itemStack.state = "navigation"
- }
- }
- }
}
onRoutingManagerChanged: {waypointList.model = routing.routeRequestModel;}
diff --git a/src/apps/marble-maps/RouteProfileRadioButton.qml b/src/apps/marble-maps/RouteProfileRadioButton.qml
index 3966da7..4b5df57 100644
--- a/src/apps/marble-maps/RouteProfileRadioButton.qml
+++ b/src/apps/marble-maps/RouteProfileRadioButton.qml
@@ -32,7 +32,7 @@ RadioButton {
Image {
anchors.centerIn: parent
id: image
- width: Screen.pixelDensity * 6
+ width: Screen.pixelDensity * 5
height: width
fillMode: Image.PreserveAspectFit
source: root.imageSource