Show a map for location events
This commit is contained in:
committed by
Volker Krause
parent
d14db326bb
commit
5b4ae764cf
68
src/qml/Component/FullScreenMap.qml
Normal file
68
src/qml/Component/FullScreenMap.qml
Normal file
@@ -0,0 +1,68 @@
|
||||
// SPDX-FileCopyrightText: 2021 Tobias Fella <fella@posteo.de>
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import QtLocation 5.15
|
||||
import QtPositioning 5.15
|
||||
|
||||
import org.kde.kirigami 2.15 as Kirigami
|
||||
|
||||
ApplicationWindow {
|
||||
id: root
|
||||
|
||||
required property var content
|
||||
|
||||
flags: Qt.FramelessWindowHint | Qt.WA_TranslucentBackground
|
||||
visibility: Qt.WindowFullScreen
|
||||
|
||||
title: i18n("View Location")
|
||||
|
||||
Shortcut {
|
||||
sequence: "Escape"
|
||||
onActivated: root.destroy()
|
||||
}
|
||||
|
||||
color: Kirigami.Theme.backgroundColor
|
||||
|
||||
background: AbstractButton {
|
||||
onClicked: root.destroy()
|
||||
}
|
||||
|
||||
Map {
|
||||
id: map
|
||||
anchors.fill: parent
|
||||
property string latlong: root.content.geo_uri.split(':')[1]
|
||||
property string latitude: latlong.split(',')[0]
|
||||
property string longitude: latlong.split(',')[1]
|
||||
center: QtPositioning.coordinate(latitude, longitude)
|
||||
zoomLevel: 15
|
||||
plugin: OsmLocationPlugin.plugin
|
||||
MapCircle {
|
||||
radius: 1500 / map.zoomLevel
|
||||
color: Kirigami.Theme.highlightColor
|
||||
border.color: Kirigami.Theme.linkColor
|
||||
border.width: Kirigami.Units.devicePixelRatio * 2
|
||||
smooth: true
|
||||
opacity: 0.25
|
||||
center: QtPositioning.coordinate(map.latitude, map.longitude)
|
||||
}
|
||||
onCopyrightLinkActivated: {
|
||||
Qt.openUrlExternally(link)
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
|
||||
text: i18n("Close")
|
||||
icon.name: "dialog-close"
|
||||
display: AbstractButton.IconOnly
|
||||
|
||||
width: Kirigami.Units.gridUnit * 2
|
||||
height: Kirigami.Units.gridUnit * 2
|
||||
|
||||
onClicked: root.destroy()
|
||||
}
|
||||
}
|
||||
49
src/qml/Component/LocationPage.qml
Normal file
49
src/qml/Component/LocationPage.qml
Normal file
@@ -0,0 +1,49 @@
|
||||
// SPDX-FileCopyrightText: 2023 Tobias Fella <tobias.fella@kde.org>
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15 as QQC2
|
||||
import QtLocation 5.15
|
||||
import QtPositioning 5.15
|
||||
|
||||
import org.kde.kirigami 2.20 as Kirigami
|
||||
import org.kde.neochat 1.0
|
||||
|
||||
Kirigami.Page {
|
||||
id: locationsPage
|
||||
|
||||
required property var room
|
||||
|
||||
title: i18nc("Locations on a map", "Locations")
|
||||
|
||||
padding: 0
|
||||
|
||||
Map {
|
||||
id: map
|
||||
anchors.fill: parent
|
||||
plugin: OsmLocationPlugin.plugin
|
||||
|
||||
MapItemView {
|
||||
model: LocationsModel {
|
||||
room: locationsPage.room
|
||||
}
|
||||
delegate: MapQuickItem {
|
||||
id: point
|
||||
|
||||
required property var longitude
|
||||
required property var latitude
|
||||
required property string text
|
||||
anchorPoint.x: icon.width / 2
|
||||
anchorPoint.y: icon.height / 2
|
||||
coordinate: QtPositioning.coordinate(point.latitude, point.longitude)
|
||||
autoFadeIn: false
|
||||
sourceItem: Kirigami.Icon {
|
||||
id: icon
|
||||
width: height
|
||||
height: Kirigami.Units.iconSizes.medium
|
||||
source: "flag-blue"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,7 @@ TimelineContainer {
|
||||
* a user's location.
|
||||
*/
|
||||
required property string asset
|
||||
required property var content
|
||||
|
||||
ColumnLayout {
|
||||
Layout.maximumWidth: root.contentMaxWidth
|
||||
@@ -92,6 +93,10 @@ TimelineContainer {
|
||||
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.LeftButton
|
||||
onTapped: {
|
||||
let map = fullScreenMap.createObject(parent, {content: root.content});
|
||||
map.open()
|
||||
}
|
||||
onLongPressed: openMessageContext("")
|
||||
}
|
||||
TapHandler {
|
||||
@@ -99,5 +104,9 @@ TimelineContainer {
|
||||
onTapped: openMessageContext("")
|
||||
}
|
||||
}
|
||||
Component {
|
||||
id: fullScreenMap
|
||||
FullScreenMap { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user