mapwidget.qml: add visual tracking of editMode from MapWidgetHelper

The MapWidgetHelper QML instance now has the slot onEditModeChanged()
which toggles the visiblity of a newly added message box that
notifies the user if editing mode is enabled.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
Lubomir I. Ivanov 2017-07-28 00:09:25 +03:00 committed by Dirk Hohndel
parent 4a004f37ea
commit 3589e2e952

View file

@ -15,10 +15,12 @@ Item {
MapWidgetHelper { MapWidgetHelper {
id: mapHelper id: mapHelper
map: map map: map
editMode: false
onSelectedDivesChanged: { onSelectedDivesChanged: {
// 'list' contains a list of dive list indexes // 'list' contains a list of dive list indexes
nSelectedDives = list.length nSelectedDives = list.length
} }
onEditModeChanged: editMessage.isVisible = editMode === true ? 1 : 0
} }
Map { Map {
@ -163,6 +165,37 @@ Item {
} }
} }
Rectangle {
id: editMessage
radius: padding
color: "#b08000"
border.color: "white"
x: (map.width - width) * 0.5; y: padding
width: editMessageText.width + padding * 2.0
height: editMessageText.height + padding * 2.0
visible: false
opacity: 0.0
property int isVisible: -1
property real padding: 10.0
onOpacityChanged: visible = opacity != 0.0
states: [
State { when: editMessage.isVisible === 1; PropertyChanges { target: editMessage; opacity: 1.0 }},
State { when: editMessage.isVisible === 0; PropertyChanges { target: editMessage; opacity: 0.0 }}
]
transitions: Transition {
NumberAnimation { properties: "opacity"; easing.type: Easing.InOutQuad }
}
Text {
id: editMessageText
y: editMessage.padding; x: editMessage.padding
verticalAlignment: Text.AlignVCenter
color: "white"
font.pointSize: 11.0
text: qsTr("Drag the selected dive location")
}
}
Image { Image {
id: toggleImage id: toggleImage
x: 10; y: x x: 10; y: x