2017-07-20 13:58:21 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
import QtQuick 2.7
|
|
|
|
|
|
|
|
Item {
|
2017-07-20 15:25:01 +00:00
|
|
|
Image {
|
|
|
|
id: contextMenuImage
|
2017-07-20 16:25:59 +00:00
|
|
|
x: -width
|
2017-07-20 15:25:01 +00:00
|
|
|
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()
|
2017-07-20 21:41:37 +00:00
|
|
|
listViewIsVisible = (listViewIsVisible !== 1) ? 1 : 0
|
2017-07-20 15:25:01 +00:00
|
|
|
}
|
|
|
|
}
|
2017-07-20 13:58:21 +00:00
|
|
|
}
|
2017-07-20 16:30:34 +00:00
|
|
|
|
|
|
|
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]);
|
|
|
|
}
|
|
|
|
}
|
2017-07-20 21:38:03 +00:00
|
|
|
|
|
|
|
property real maxItemWidth: 0.0
|
|
|
|
readonly property real itemTextPadding: 10.0
|
|
|
|
readonly property real itemHeight: 30.0
|
|
|
|
readonly property int itemAnimationDuration: 100
|
|
|
|
readonly property color colorItemBackground: "#dedede"
|
|
|
|
readonly property color colorItemBackgroundSelected: "grey"
|
|
|
|
readonly property color colorItemText: "black"
|
|
|
|
readonly property color colorItemTextSelected: "#dedede"
|
|
|
|
readonly property color colorItemBorder: "black"
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: listItemDelegate
|
|
|
|
Rectangle {
|
|
|
|
color: model.idx === listModel.selectedIdx ? colorItemBackgroundSelected : colorItemBackground
|
|
|
|
width: maxItemWidth
|
|
|
|
height: itemHeight
|
|
|
|
border.color: colorItemBorder
|
|
|
|
Text {
|
|
|
|
x: itemTextPadding
|
|
|
|
height: itemHeight
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
text: model.itemText
|
|
|
|
color: model.idx === listModel.selectedIdx ? colorItemTextSelected : colorItemText
|
|
|
|
onWidthChanged: {
|
|
|
|
if (width + itemTextPadding * 2.0 > maxItemWidth)
|
|
|
|
maxItemWidth = width + itemTextPadding * 2.0
|
|
|
|
}
|
|
|
|
Behavior on color { ColorAnimation { duration: itemAnimationDuration }}
|
|
|
|
}
|
|
|
|
Behavior on color { ColorAnimation { duration: itemAnimationDuration }}
|
|
|
|
}
|
|
|
|
}
|
2017-07-20 21:41:37 +00:00
|
|
|
|
|
|
|
property int listViewIsVisible: -1
|
2017-07-20 13:58:21 +00:00
|
|
|
}
|