mapwidgetcontextmenu: rearrange some of the QML declarations

- move the readonly properties near the top of the root Item
- move the rest of the properties bellow the readonly properties
- make the ListView Timer as a child of the ListView
- slight rename of the timer ID

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
Lubomir I. Ivanov 2017-07-21 00:55:13 +03:00 committed by Dirk Hohndel
parent 18d910f6a7
commit 413e471244

View file

@ -2,6 +2,27 @@
import QtQuick 2.7
Item {
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)") }
]
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"
property int listViewIsVisible: -1
property real maxItemWidth: 0.0
Image {
id: contextMenuImage
x: -width
@ -26,18 +47,6 @@ Item {
}
}
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
@ -47,16 +56,6 @@ Item {
}
}
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 {
@ -80,8 +79,6 @@ Item {
}
}
property int listViewIsVisible: -1
ListView {
id: listView
y: contextMenuImage.y + contextMenuImage.height + 10;
@ -97,13 +94,21 @@ Item {
onVisibleChanged: listModel.selectedIdx = -1
onOpacityChanged: visible = opacity != 0.0
Timer {
id: timerListViewVisible
running: false
repeat: false
interval: itemAnimationDuration + 50
onTriggered: listViewIsVisible = 0
}
MouseArea {
anchors.fill: parent
onClicked: {
if (opacity < 1.0)
return;
listModel.selectedIdx = listView.indexAt(mouseX, mouseY)
listViewVisibleTimer.restart()
timerListViewVisible.restart()
}
}
states: [
@ -114,12 +119,4 @@ Item {
NumberAnimation { properties: "opacity"; easing.type: Easing.InOutQuad }
}
}
Timer {
id: listViewVisibleTimer
running: false
repeat: false
interval: itemAnimationDuration + 50
onTriggered: listViewIsVisible = 0
}
}