subsurface/mobile-widgets/qml/MapWidgetContextMenu.qml
Lubomir I. Ivanov eeb53e965e mapwidgetcontextmenu: create a ListModel for the context menu
Menu item indexes are enumerated in the object menuItemIndex, while
menuItemData, holds an array of objects which will define the number
of items, with indexes (idx) and text (itemText).

When the ListModel is created, it's dynamically populated from
from menuItemData.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00

48 lines
1.2 KiB
QML

// SPDX-License-Identifier: GPL-2.0
import QtQuick 2.7
Item {
Image {
id: contextMenuImage
x: -width
source: "qrc:///mapwidget-context-menu"
SequentialAnimation {
id:contextMenuImageAnimation
PropertyAnimation {
target: contextMenuImage; property: "scale"; from: 1.0; to: 0.8; duration: 80;
}
PropertyAnimation {
target: contextMenuImage; property: "scale"; from: 0.8; to: 1.0; duration: 60;
}
}
MouseArea {
anchors.fill: parent
onClicked: {
contextMenuImageAnimation.restart()
}
}
}
readonly property var menuItemIndex: {
"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)") }
]
ListModel {
id: listModel
property int selectedIdx: -1
Component.onCompleted: {
for (var i = 0; i < menuItemData.length; i++)
append(menuItemData[i]);
}
}
}