example 'meshtastic': fix manual position selection (map)

This commit is contained in:
pls.153 2024-03-14 16:38:24 +01:00
parent de786767ae
commit 4dab5efd7c
7 changed files with 33 additions and 20 deletions

View file

@ -19,7 +19,7 @@ Item {
zoomLevel: 14
property bool manualLocation: false
property var myMarker
property var myMarker: null
Ext.MapButton {
id: hand
@ -56,7 +56,7 @@ Item {
SequentialAnimation {
id: markerAnimation
loops: Animation.Infinite
running: manualLocation && !!myMarker
running: manualLocation && (myMarker !== null)
OpacityAnimator { target: myMarker; from: 1.0; to: 0.2; duration: 500; easing.type: Easing.InOutSine }
OpacityAnimator { target: myMarker; from: 0.2; to: 1.0; duration: 500; easing.type: Easing.InOutSine }
@ -64,12 +64,15 @@ Item {
MouseArea {
anchors.fill: parent
onClicked: {
manualLocation = false
var coord = map.toCoordinate(Qt.point(mouse.x, mouse.y))
myMarker.coordinate = coord
myMarker.opacity = 1
Lisp.call("loc:position-selected", coord.latitude, coord.longitude)
onClicked: (mouse) => {
if (manualLocation) {
manualLocation = false
var coord = map.toCoordinate(Qt.point(mouse.x, mouse.y))
myMarker.coordinate = coord
myMarker.opacity = 1
Lisp.call("loc:position-selected", coord.latitude, coord.longitude)
}
}
}

View file

@ -12,4 +12,5 @@ RoundButton {
height: width
radius: width / 2
palette.button: "#555"
focusPolicy: Qt.NoFocus
}

View file

@ -33,8 +33,10 @@ ScrollView {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: Lisp.call("app:emoji-clicked",
grid.itemAtIndex(grid.indexAt(mouse.x, mouse.y + grid.contentY)).text)
onClicked: (mouse) => {
Lisp.call("app:emoji-clicked",
grid.itemAtIndex(grid.indexAt(mouse.x, mouse.y + grid.contentY)).text)
}
}
}
}

View file

@ -75,6 +75,7 @@
(defun remove-marker () ; see QML
(setf *my-position* nil)
(remf *positions* (lora:my-num))
(app:change-setting :selected-position nil)
(values))

View file

@ -18,7 +18,7 @@ Item {
zoomLevel: 14
property bool manualLocation: false
property var myMarker
property var myMarker: null
Ext.MapButton {
id: hand
@ -55,7 +55,7 @@ Item {
SequentialAnimation {
id: markerAnimation
loops: Animation.Infinite
running: manualLocation && !!myMarker
running: manualLocation && (myMarker !== null)
OpacityAnimator { target: myMarker; from: 1.0; to: 0.2; duration: 500; easing.type: Easing.InOutSine }
OpacityAnimator { target: myMarker; from: 0.2; to: 1.0; duration: 500; easing.type: Easing.InOutSine }
@ -63,12 +63,15 @@ Item {
MouseArea {
anchors.fill: parent
onClicked: {
manualLocation = false
var coord = map.toCoordinate(Qt.point(mouse.x, mouse.y))
myMarker.coordinate = coord
myMarker.opacity = 1
Lisp.call("loc:position-selected", coord.latitude, coord.longitude)
onClicked: (mouse) => {
if (manualLocation) {
manualLocation = false
var coord = map.toCoordinate(Qt.point(mouse.x, mouse.y))
myMarker.coordinate = coord
myMarker.opacity = 1
Lisp.call("loc:position-selected", coord.latitude, coord.longitude)
}
}
}

View file

@ -11,4 +11,5 @@ RoundButton {
height: width
radius: width / 2
palette.button: "#555"
focusPolicy: Qt.NoFocus
}

View file

@ -32,8 +32,10 @@ ScrollView {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: Lisp.call("app:emoji-clicked",
grid.itemAtIndex(grid.indexAt(mouse.x, mouse.y + grid.contentY)).text)
onClicked: (mouse) => {
Lisp.call("app:emoji-clicked",
grid.itemAtIndex(grid.indexAt(mouse.x, mouse.y + grid.contentY)).text)
}
}
}
}