diff --git a/src/qml/Component/LocationMapItem.qml b/src/qml/Component/LocationMapItem.qml new file mode 100644 index 000000000..be59d27d8 --- /dev/null +++ b/src/qml/Component/LocationMapItem.qml @@ -0,0 +1,58 @@ +// SPDX-FileCopyrightText: 2021 Tobias Fella +// SPDX-FileCopyrightText: 2023 Volker Krause +// SPDX-License-Identifier: GPL-2.0-or-later + +import QtQuick 2.15 +import QtQuick.Controls 2.15 +import QtQuick.Layouts 1.15 +import QtLocation 5.15 +import QtPositioning 5.15 + +import org.kde.kirigami 2.15 as Kirigami + +import org.kde.neochat 1.0 + +/** Location marker for any of the shared location maps. */ +MapQuickItem { + id: root + required property real latitude + required property real longitude + + required property string asset + required property var author + + required property bool isLive + + anchorPoint.x: sourceItem.width / 2 + anchorPoint.y: sourceItem.height + coordinate: QtPositioning.coordinate(root.latitude, root.longitude) + autoFadeIn: false + sourceItem: Kirigami.Icon { + width: height + height: Kirigami.Units.iconSizes.huge + source: "gps" + isMask: true + color: root.isLive ? Kirigami.Theme.highlightColor : Kirigami.Theme.disabledTextColor + + Kirigami.Icon { + anchors.centerIn: parent + anchors.verticalCenterOffset: -parent.height / 8 + visible: root.asset === "m.pin" + width: height + height: parent.height / 3 + 1 + source: "pin" + isMask: true + color: parent.color + } + Kirigami.Avatar { + anchors.centerIn: parent + anchors.verticalCenterOffset: -parent.height / 8 + visible: root.asset === "m.self" + width: height + height: parent.height / 3 + 1 + name: root.author.displayName + source: root.author.avatarSource + color: root.author.color + } + } +} diff --git a/src/qml/Component/Timeline/LiveLocationDelegate.qml b/src/qml/Component/Timeline/LiveLocationDelegate.qml index b69741865..e3831d7a0 100644 --- a/src/qml/Component/Timeline/LiveLocationDelegate.qml +++ b/src/qml/Component/Timeline/LiveLocationDelegate.qml @@ -42,40 +42,7 @@ TimelineContainer { MapItemView { model: liveLocationModel - delegate: MapQuickItem { - anchorPoint.x: sourceItem.width / 2 - anchorPoint.y: sourceItem.height - coordinate: QtPositioning.coordinate(model.latitude, model.longitude) - autoFadeIn: false - sourceItem: Kirigami.Icon { - width: height - height: Kirigami.Units.iconSizes.huge - source: "gps" - isMask: true - color: model.isLive ? Kirigami.Theme.highlightColor : Kirigami.Theme.disabledTextColor - - Kirigami.Icon { - anchors.centerIn: parent - anchors.verticalCenterOffset: -parent.height / 8 - visible: model.asset === "m.pin" - width: height - height: parent.height / 3 + 1 - source: "pin" - isMask: true - color: parent.color - } - Kirigami.Avatar { - anchors.centerIn: parent - anchors.verticalCenterOffset: -parent.height / 8 - visible: model.asset === "m.self" - width: height - height: parent.height / 3 + 1 - name: model.author.displayName - source: model.author.avatarSource - color: model.author.color - } - } - } + delegate: LocationMapItem {} } TapHandler { diff --git a/src/qml/Component/Timeline/LocationDelegate.qml b/src/qml/Component/Timeline/LocationDelegate.qml index d559139cb..d908a51c4 100644 --- a/src/qml/Component/Timeline/LocationDelegate.qml +++ b/src/qml/Component/Timeline/LocationDelegate.qml @@ -52,43 +52,12 @@ TimelineContainer { plugin: OsmLocationPlugin.plugin onCopyrightLinkActivated: Qt.openUrlExternally(link) - - MapQuickItem { - id: point - - anchorPoint.x: sourceItem.width / 2 - anchorPoint.y: sourceItem.height - coordinate: QtPositioning.coordinate(root.latitude, root.longitude) - autoFadeIn: false - - sourceItem: Kirigami.Icon { - width: height - height: Kirigami.Units.iconSizes.huge - source: "gps" - isMask: true - color: Kirigami.Theme.highlightColor - - Kirigami.Icon { - anchors.centerIn: parent - anchors.verticalCenterOffset: -parent.height / 8 - visible: root.asset === "m.pin" - width: height - height: parent.height / 3 + 1 - source: "pin" - isMask: true - color: Kirigami.Theme.highlightColor - } - Kirigami.Avatar { - anchors.centerIn: parent - anchors.verticalCenterOffset: -parent.height / 8 - visible: root.asset === "m.self" - width: height - height: parent.height / 3 + 1 - name: root.author.displayName - source: root.author.avatarSource - color: root.author.color - } - } + LocationMapItem { + latitude: root.latitude + longitude: root.longitude + asset: root.asset + author: root.author + isLive: true } TapHandler { diff --git a/src/res.qrc b/src/res.qrc index 24c1e41d8..eb64713d0 100644 --- a/src/res.qrc +++ b/src/res.qrc @@ -130,5 +130,6 @@ qml/Component/Timeline/LiveLocationDelegate.qml qml/Component/FullScreenMap.qml qml/Component/LocationPage.qml + qml/Component/LocationMapItem.qml