Fix URLs on QT 6 map.

This commit is contained in:
srcejon 2024-02-28 12:34:03 +00:00
parent 3522feb355
commit 0d333a910e
2 changed files with 11 additions and 8 deletions

View File

@ -307,14 +307,12 @@ Item {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.RightButton acceptedButtons: Qt.LeftButton | Qt.RightButton
//propagateComposedEvents: true // so links in Text work
onClicked: { onClicked: {
if (mouse.button === Qt.LeftButton) { if (mouse.button === Qt.LeftButton) {
selected = !selected selected = !selected
if (selected) { if (selected) {
mapModel.moveToFront(mapModelFiltered.mapRowToSource(index)) mapModel.moveToFront(mapModelFiltered.mapRowToSource(index))
} }
//mouse.accepted = false // propagate to text
} else if (mouse.button === Qt.RightButton) { } else if (mouse.button === Qt.RightButton) {
menuItems.clear() menuItems.clear()
menus.clear() menus.clear()

View File

@ -316,12 +316,6 @@ Item {
height: text.height + 5 height: text.height + 5
radius: 5 radius: 5
visible: mapTextVisible visible: mapTextVisible
Text {
id: text
anchors.centerIn: parent
text: mapText
textFormat: TextEdit.RichText
}
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
@ -417,6 +411,17 @@ Item {
object.menu.removeItem(object) object.menu.removeItem(object)
} }
} }
}
}
// Have Text after MouseArea, so links can be clicked
Text {
id: text
anchors.centerIn: parent
text: mapText
textFormat: TextEdit.RichText
onLinkActivated: {
console.log("Link", link);
mapModel.link(link);
} }
} }
} }