aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/DefaultMapControls.qml30
-rw-r--r--src/MainMapView.qml50
-rw-r--r--src/MapWaypoint.qml20
-rw-r--r--src/SetPointMapControls.qml28
-rw-r--r--src/SetPointPage.qml9
-rw-r--r--src/SettingsPage.qml12
-rw-r--r--src/main.qml11
-rw-r--r--src/resources.qrc1
8 files changed, 143 insertions, 18 deletions
diff --git a/src/DefaultMapControls.qml b/src/DefaultMapControls.qml
index 9698d21..079aefa 100644
--- a/src/DefaultMapControls.qml
+++ b/src/DefaultMapControls.qml
@@ -1,11 +1,13 @@
import QtQuick 2.0
import org.asteroid.controls 1.0
+import org.asteroid.utils 1.0
Item {
IconButton {
iconName: "ios-add-circle-outline"
anchors.right: parent.right
- anchors.bottom: parent.verticalCenter
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.verticalCenterOffset: - height/2 + DeviceInfo.flatTireHeight/2
height: parent.height*0.2
width: height
iconColor: "blue"
@@ -15,17 +17,39 @@ Item {
IconButton {
iconName: "ios-remove-circle-outline"
anchors.right: parent.right
- anchors.top: parent.verticalCenter
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.verticalCenterOffset: height/2 + DeviceInfo.flatTireHeight/2
height: parent.height*0.2
width: height
iconColor: "blue"
z: 2
onClicked: mapView.zoomLevel = mapView.zoomLevel - 0.3
}
+ MouseArea {
+ anchors.left: parent.left
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.verticalCenterOffset: - height/2 + DeviceInfo.flatTireHeight/2
+ height: parent.height*0.2
+ width: height
+ z: 2
+ rotation: compassMode.value == 1 ? 360 - compass.reading.azimuth : 45
+ onClicked: compassMode.value = enableCompass.value ? (compassMode.value+1)%3 : 0
+ onPressAndHold: {
+ if (compassMode.value == 2) {compassMode.value = 0}
+ mapView.bearing = 0
+ }
+ Icon {
+ anchors.fill: parent
+ name: compass.reading.calibrationLevel > 0 ? "ios-compass-outline" : "ios-infinite-outline"
+ rotation: -45
+ color: "blue"
+ }
+ }
IconButton {
iconName: "ios-locate-outline"
- anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
+ anchors.verticalCenterOffset: height/2 + DeviceInfo.flatTireHeight/2
+ anchors.left: parent.left
height: parent.height*0.2
width: height
iconColor: "blue"
diff --git a/src/MainMapView.qml b/src/MainMapView.qml
index 5042d24..00f0ef2 100644
--- a/src/MainMapView.qml
+++ b/src/MainMapView.qml
@@ -3,26 +3,40 @@ import org.asteroid.controls 1.0
import Nemo.Configuration 1.0
import QtPositioning 5.15
import QtLocation 5.15
+import QtSensors 5.3
Item {
ConfigurationValue {
id: mapZoom
- key: "/map/zoomlevel"
+ key: "/map/view/zoomlevel"
defaultValue: 3.4
}
ConfigurationValue {
id: mapCenterLat
- key: "/map/location/lat"
- defaultValue: 0
+ key: "/map/view/location/lat"
+ defaultValue: ""
}
ConfigurationValue {
id: mapCenterLong
- key: "/map/location/long"
+ key: "/map/view/location/long"
+ defaultValue: ""
+ }
+ ConfigurationValue {
+ id: compassMode
+ key: "/map/view/compassMode"
defaultValue: 0
}
+ ConfigurationValue {
+ id: waypointSource
+ key: "/map/waypointList"
+ defaultValue: ""
+ onValueChanged: mapView.updateWaypoints()
+ Component.onCompleted: mapView.updateWaypoints()
+ }
+
Label {
text: "Map Data from OpenStreetMap"
- font.pixelSize: parent.width*0.02
+ font.pixelSize: parent.width*0.03
anchors.centerIn: parent
z: 0
}
@@ -42,6 +56,27 @@ Item {
center = positionProvider.position.coordinate
}
}
+ Connections {
+ target: compass
+ function onReadingChanged() {
+ if (compassMode.value == 2) {
+ mapView.bearing = compass.reading.azimuth
+ }
+ }
+ }
+ property MapQuickItem mapItem
+ function updateWaypoints() {
+ var waypointsList = waypointSource.value.split(">")
+ for(var i = 0, size = waypointsList.length-1; i < size ; i++){
+ var currWaypointData = waypointsList[i].split(";")
+ var currWaypointCoord = currWaypointData[1].split(",")
+ mapItem = waypoint.createObject(mapView)
+ mapItem.coordinate = QtPositioning.coordinate(currWaypointCoord[0],currWaypointCoord[1])
+ mapItem.iconName = currWaypointData[0]
+ mapItem.iconColor = currWaypointData[2]
+ mapView.addMapItem(mapItem)
+ }
+ }
}
DefaultMapControls {
id: mapControls
@@ -58,6 +93,11 @@ Item {
}
}
Component {
+ id: waypoint
+ MapWaypoint {
+ }
+ }
+ Component {
id: setPointPage
SetPointPage {
}
diff --git a/src/MapWaypoint.qml b/src/MapWaypoint.qml
new file mode 100644
index 0000000..1300cb0
--- /dev/null
+++ b/src/MapWaypoint.qml
@@ -0,0 +1,20 @@
+import QtQuick 2.0
+import org.asteroid.controls 1.0 as Asteroid
+import QtPositioning 5.15
+import QtLocation 5.15
+
+MapQuickItem {
+ id: root
+ anchorPoint.x: width/2
+ anchorPoint.y: height
+ zoomLevel: 0
+ autoFadeIn: false
+ property string iconName
+ property color iconColor
+ sourceItem: Asteroid.Icon {
+ width: Asteroid.Dims.w(12)
+ height: width
+ name: root.iconName
+ color: root.iconColor
+ }
+}
diff --git a/src/SetPointMapControls.qml b/src/SetPointMapControls.qml
index 8423ea7..de0078e 100644
--- a/src/SetPointMapControls.qml
+++ b/src/SetPointMapControls.qml
@@ -1,5 +1,6 @@
import QtQuick 2.0
import org.asteroid.controls 1.0
+import org.asteroid.utils 1.0
Item {
PageHeader {
@@ -8,7 +9,8 @@ Item {
IconButton {
iconName: "ios-add-circle-outline"
anchors.right: parent.right
- anchors.bottom: parent.verticalCenter
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.verticalCenterOffset: - height/2 + DeviceInfo.flatTireHeight/2
height: parent.height*0.2
width: height
iconColor: "blue"
@@ -18,17 +20,39 @@ Item {
IconButton {
iconName: "ios-remove-circle-outline"
anchors.right: parent.right
- anchors.top: parent.verticalCenter
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.verticalCenterOffset: height/2 + DeviceInfo.flatTireHeight/2
height: parent.height*0.2
width: height
iconColor: "blue"
z: 2
onClicked: mapView.zoomLevel = mapView.zoomLevel - 0.3
}
+ MouseArea {
+ anchors.left: parent.left
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.verticalCenterOffset: - height/2 + DeviceInfo.flatTireHeight/2
+ height: parent.height*0.2
+ width: height
+ z: 2
+ rotation: compassMode.value == 1 ? 360 - compass.reading.azimuth : 45
+ onClicked: compassMode.value = enableCompass.value ? (compassMode.value+1)%3 : 0
+ onPressAndHold: {
+ if (compassMode.value == 2) {compassMode.value = 0}
+ mapView.bearing = 0
+ }
+ Icon {
+ anchors.fill: parent
+ name: compass.reading.calibrationLevel > 0 ? "ios-compass-outline" : "ios-infinite-outline"
+ rotation: -45
+ color: "blue"
+ }
+ }
IconButton {
iconName: "ios-locate-outline"
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
+ anchors.verticalCenterOffset: height/2 + DeviceInfo.flatTireHeight/2
height: parent.height*0.2
width: height
iconColor: "blue"
diff --git a/src/SetPointPage.qml b/src/SetPointPage.qml
index 50643b0..c2e8787 100644
--- a/src/SetPointPage.qml
+++ b/src/SetPointPage.qml
@@ -35,7 +35,7 @@ Item {
height: parent.width*0.2
//for the default text, we probably want a date/time
previewText: "Waypoint name"
- text: Date().toLocaleString(Locale.ShortFormat)
+ text: Date.toLocaleString(Locale.ShortFormat)
}
ListView {
id: iconSelectorView
@@ -89,8 +89,11 @@ Item {
}
function appendWayPoint() { //the colours.primary is currently a placeholder. it would be nice to let users select colours, but I CBA to write a colour picker right now.
- var newWayPointString = ">" + "selectedIcon" + ";" + coord + ";" + colours.primary + ";" + textBox.text + ";" + Date()
+ var newWayPointString = selectedIcon + ";" + coord.latitude + "," + coord.longitude + ";" + colours.primary + ";" + textBox.text + ";" + Date.now() + ">"
console.log(newWayPointString)
- pageStack.pop()
+ waypointList.value = waypointList.value + newWayPointString
+ setPointControls.visible = false
+ mapControls.visible = true
+ pageStack.pop(pageStack.currentLayer)
}
}
diff --git a/src/SettingsPage.qml b/src/SettingsPage.qml
index 6ff5da3..5c2e12f 100644
--- a/src/SettingsPage.qml
+++ b/src/SettingsPage.qml
@@ -5,11 +5,6 @@ import QtLocation 5.15
Item {
id: root
- // FlatMesh {
- // centerColor: "#003ee9"
- // outerColor: "#00bc1b"
- // anchors.fill: parent
- // }
PageHeader {
text: "Map settings"
}
@@ -35,6 +30,13 @@ Item {
height: width*0.2
text: "center on GPS"
}
+ LabeledSwitch {
+ width: parent.width
+ height: width*0.2
+ text: "enable compass"
+ Component.onCompleted: checked = enableCompass.value
+ onCheckedChanged: enableCompass.value = checked
+ }
Row {
width: parent.width
height: width*0.2
diff --git a/src/main.qml b/src/main.qml
index 49abcb6..acca47a 100644
--- a/src/main.qml
+++ b/src/main.qml
@@ -2,6 +2,8 @@ import QtQuick 2.0
import org.asteroid.controls 1.0
import QtPositioning 5.15
import QtLocation 5.15
+import Nemo.Configuration 1.0
+import QtSensors 5.3
Application {
centerColor: "#6e90e9"
@@ -20,11 +22,20 @@ Application {
PositionSource {
id: positionProvider
}
+ Compass {
+ id: compass
+ active: enableCompass.value
+ }
LayerStack {
id: pageStack
anchors.fill: parent
firstPage: mainMapView
}
+ ConfigurationValue {
+ id: enableCompass
+ key: "/map/enableCompass"
+ defaultValue: true
+ }
Component {
id: mainMapView
diff --git a/src/resources.qrc b/src/resources.qrc
index 0984a2c..4a8e297 100644
--- a/src/resources.qrc
+++ b/src/resources.qrc
@@ -6,5 +6,6 @@
<file>SetPointMapControls.qml</file>
<file>SetPointPage.qml</file>
<file>SettingsPage.qml</file>
+ <file>MapWaypoint.qml</file>
</qresource>
</RCC>