Skip to content

Commit

Permalink
adding label support to MMCrosshair
Browse files Browse the repository at this point in the history
  • Loading branch information
VitorVieiraZ committed Aug 15, 2024
1 parent d289ffc commit dcd1892
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 15 deletions.
4 changes: 3 additions & 1 deletion app/qml/map/MMRecordingTools.qml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ Item {
accuracyRingSize: positionMarkerComponent.accuracyRingSize
}

MMDataCrosshair {
MMCrosshair { //labeled crosshair
id: crosshair

anchors.fill: parent
Expand All @@ -185,6 +185,8 @@ Item {
qgsProject: __activeProject.qgsProject
mapSettings: root.map.mapSettings
shouldUseSnapping: !mapTool.isUsingPosition
hasLabel: true
crosshairLabelText: "58.4 m"
}

MMToolbar {
Expand Down
25 changes: 25 additions & 0 deletions app/qml/map/components/MMCrosshair.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ Item {
/*required*/ property var mapSettings
property bool shouldUseSnapping: false

property bool hasLabel: false
property string crosshairLabelText: ""

property point center: Qt.point( root.width / 2, root.height / 2 )

property var recordPoint: snapUtils.recordPoint
Expand All @@ -39,6 +42,14 @@ Item {

}

Loader {
id: crosshairLabelLoader
active: root.hasLabel
sourceComponent: crosshairLabelComponent
anchors.top: crosshairForeground.bottom
anchors.horizontalCenter: crosshairForeground.horizontalCenter
}

Image {
id: crosshairBackground // white background of the crosshair

Expand Down Expand Up @@ -237,6 +248,20 @@ Item {
source: __style.crosshairCircleImage
}

Component {
id: crosshairLabelComponent

MMMapLabel {
bgColor: __style.forestColor
textColor: __style.polarColor
textBgColorInverted: false
hasIcon: false
text: root.crosshairLabelText

onClicked: console.log( "MapLabel" )
}
}

Connections {
target: __activeProject

Expand Down
13 changes: 1 addition & 12 deletions app/qml/map/components/MMDataCrosshair.qml
Original file line number Diff line number Diff line change
Expand Up @@ -273,21 +273,10 @@ Item {
}

MMMapLabel {
// Rectangle {
// anchors.fill: parent
// color: "lightgoldenrodyellow"
// }

//height:50
//width: 70
visible: true //root.state !== "inactive" && root.isStreaming
//iconSource: __style.streamingIcon

maxWidth: crosshairForeground.width + 6 * __dp
bgColor: __style.forestColor
textColor: __style.polarColor
textBgColorInverted: false

hasIcon: false
text: qsTr( "Test" )

anchors.top: crosshairForeground.bottom
Expand Down
4 changes: 2 additions & 2 deletions app/qml/map/components/MMMapLabel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Item {
property color bgColor: __style.positiveColor
property color textColor: __style.forestColor
property bool textBgColorInverted: false
property bool hasIcon: true

Rectangle {
width: row.width
Expand All @@ -52,8 +53,7 @@ Item {
anchors.verticalCenter: parent.verticalCenter
source: control.iconSource ? control.iconSource : ""
color: control.textColor
size: __style.icon24
visible: control.iconSource ? true : false
size: control.hasIcon ? __style.icon24 : 0
}

Rectangle {
Expand Down

0 comments on commit dcd1892

Please sign in to comment.