aboutsummaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qml
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2017-07-21 01:28:58 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-07-28 07:31:11 -0700
commit4d0d0e102b12d70e3944c7fdeae3b3a0270f6870 (patch)
tree8ce6b5906572eaf356ad9f7833e582f2802fb51a /mobile-widgets/qml
parent413e4712448a005c30c323d2da1e0e5ef3640004 (diff)
downloadsubsurface-4d0d0e102b12d70e3944c7fdeae3b3a0270f6870.tar.gz
mapwidgetcontextmenu: add the actionSelected() signal
The actionSelected() signal is now dispatched when the user selects an action from the menu (see the "actions" object). Then the declaration of the MapWidgetContextMenu object in mapwidget.qml can catch that signal in the onActionSelected() slot and obtain the action via switch() branching. The actions enumeration is kept in QML for now, with the idea that specific C++ methods from the mapwidgethelper class will be called directly (if marked as Q_INVOCABLE), instead of a generic onMapAction(action) C++ method in the helper. But if the actions are possible from QML (like copying to clipboard) and are also small and non-expensive, it might be better to keep them in mapwidget.qml. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'mobile-widgets/qml')
-rw-r--r--mobile-widgets/qml/MapWidget.qml14
-rw-r--r--mobile-widgets/qml/MapWidgetContextMenu.qml15
2 files changed, 24 insertions, 5 deletions
diff --git a/mobile-widgets/qml/MapWidget.qml b/mobile-widgets/qml/MapWidget.qml
index 684d76a03..13c095a5f 100644
--- a/mobile-widgets/qml/MapWidget.qml
+++ b/mobile-widgets/qml/MapWidget.qml
@@ -141,5 +141,19 @@ Item {
MapWidgetContextMenu {
id: contextMenu
y: 10; x: map.width - y
+ onActionSelected: {
+ // TODO: perform action actions
+ switch (action) {
+ case contextMenu.actions.OPEN_LOCATION_IN_GOOGLE_MAPS:
+ console.log("OPEN_LOCATION_IN_GOOGLE_MAPS");
+ break;
+ case contextMenu.actions.COPY_LOCATION_DECIMAL:
+ console.log("COPY_LOCATION_DECIMAL");
+ break;
+ case contextMenu.actions.COPY_LOCATION_SEXAGESIMAL:
+ console.log("COPY_LOCATION_SEXAGESIMAL");
+ break;
+ }
+ }
}
}
diff --git a/mobile-widgets/qml/MapWidgetContextMenu.qml b/mobile-widgets/qml/MapWidgetContextMenu.qml
index f2d224778..f6edc86ec 100644
--- a/mobile-widgets/qml/MapWidgetContextMenu.qml
+++ b/mobile-widgets/qml/MapWidgetContextMenu.qml
@@ -2,15 +2,18 @@
import QtQuick 2.7
Item {
- readonly property var menuItemIndex: {
+ id: container
+ signal actionSelected(int action)
+
+ readonly property var actions: {
"OPEN_LOCATION_IN_GOOGLE_MAPS": 0,
"COPY_LOCATION_DECIMAL": 1,
"COPY_LOCATION_SEXAGESIMAL": 2
}
readonly property var menuItemData: [
- { idx: menuItemIndex.OPEN_LOCATION_IN_GOOGLE_MAPS, itemText: qsTr("Open location in Google Maps") },
- { idx: menuItemIndex.COPY_LOCATION_DECIMAL, itemText: qsTr("Copy location to clipboard (decimal)") },
- { idx: menuItemIndex.COPY_LOCATION_SEXAGESIMAL, itemText: qsTr("Copy location to clipboard (sexagesimal)") }
+ { idx: actions.OPEN_LOCATION_IN_GOOGLE_MAPS, itemText: qsTr("Open location in Google Maps") },
+ { idx: actions.COPY_LOCATION_DECIMAL, itemText: qsTr("Copy location to clipboard (decimal)") },
+ { idx: actions.COPY_LOCATION_SEXAGESIMAL, itemText: qsTr("Copy location to clipboard (sexagesimal)") }
]
readonly property real itemTextPadding: 10.0
readonly property real itemHeight: 30.0
@@ -107,7 +110,9 @@ Item {
onClicked: {
if (opacity < 1.0)
return;
- listModel.selectedIdx = listView.indexAt(mouseX, mouseY)
+ var idx = listView.indexAt(mouseX, mouseY)
+ listModel.selectedIdx = idx
+ container.actionSelected(idx)
timerListViewVisible.restart()
}
}