mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-01 05:33:23 +00:00
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:
parent
18d910f6a7
commit
413e471244
1 changed files with 30 additions and 33 deletions
|
@ -2,6 +2,27 @@
|
||||||
import QtQuick 2.7
|
import QtQuick 2.7
|
||||||
|
|
||||||
Item {
|
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 {
|
Image {
|
||||||
id: contextMenuImage
|
id: contextMenuImage
|
||||||
x: -width
|
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 {
|
ListModel {
|
||||||
id: listModel
|
id: listModel
|
||||||
property int selectedIdx: -1
|
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 {
|
Component {
|
||||||
id: listItemDelegate
|
id: listItemDelegate
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
@ -80,8 +79,6 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
property int listViewIsVisible: -1
|
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
id: listView
|
id: listView
|
||||||
y: contextMenuImage.y + contextMenuImage.height + 10;
|
y: contextMenuImage.y + contextMenuImage.height + 10;
|
||||||
|
@ -97,13 +94,21 @@ Item {
|
||||||
onVisibleChanged: listModel.selectedIdx = -1
|
onVisibleChanged: listModel.selectedIdx = -1
|
||||||
onOpacityChanged: visible = opacity != 0.0
|
onOpacityChanged: visible = opacity != 0.0
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: timerListViewVisible
|
||||||
|
running: false
|
||||||
|
repeat: false
|
||||||
|
interval: itemAnimationDuration + 50
|
||||||
|
onTriggered: listViewIsVisible = 0
|
||||||
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (opacity < 1.0)
|
if (opacity < 1.0)
|
||||||
return;
|
return;
|
||||||
listModel.selectedIdx = listView.indexAt(mouseX, mouseY)
|
listModel.selectedIdx = listView.indexAt(mouseX, mouseY)
|
||||||
listViewVisibleTimer.restart()
|
timerListViewVisible.restart()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
states: [
|
states: [
|
||||||
|
@ -114,12 +119,4 @@ Item {
|
||||||
NumberAnimation { properties: "opacity"; easing.type: Easing.InOutQuad }
|
NumberAnimation { properties: "opacity"; easing.type: Easing.InOutQuad }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
|
||||||
id: listViewVisibleTimer
|
|
||||||
running: false
|
|
||||||
repeat: false
|
|
||||||
interval: itemAnimationDuration + 50
|
|
||||||
onTriggered: listViewIsVisible = 0
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue