Warning, /network/neochat/src/qml/LocationDelegate.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2021 Tobias Fella <fella@posteo.de>
0002 // SPDX-License-Identifier: GPL-2.0-or-later
0003 
0004 import QtQuick
0005 import QtQuick.Controls
0006 import QtQuick.Layouts
0007 import QtLocation
0008 import QtPositioning
0009 
0010 import org.kde.neochat
0011 
0012 /**
0013  * @brief A timeline delegate for a location message.
0014  *
0015  * @inherit MessageDelegate
0016  */
0017 MessageDelegate {
0018     id: root
0019 
0020     /**
0021      * @brief The latitude of the location marker in the message.
0022      */
0023     required property real latitude
0024 
0025     /**
0026      * @brief The longitude of the location marker in the message.
0027      */
0028     required property real longitude
0029 
0030     /**
0031      * @brief What type of marker the location message is.
0032      *
0033      * The main options are m.pin for a general location or m.self for a pin to show
0034      * a user's location.
0035      */
0036     required property string asset
0037 
0038     bubbleContent: ColumnLayout {
0039         MapView {
0040             id: mapView
0041             Layout.fillWidth: true
0042             Layout.preferredHeight: root.contentMaxWidth / 16 * 9
0043 
0044             map.center: QtPositioning.coordinate(root.latitude, root.longitude)
0045             map.zoomLevel: 15
0046 
0047             map.plugin: OsmLocationPlugin.plugin
0048 
0049             LocationMapItem {
0050                 latitude: root.latitude
0051                 longitude: root.longitude
0052                 asset: root.asset
0053                 author: root.author
0054                 isLive: true
0055                 heading: NaN
0056             }
0057 
0058             TapHandler {
0059                 acceptedButtons: Qt.LeftButton
0060                 onTapped: {
0061                     let map = fullScreenMap.createObject(parent, {
0062                         latitude: root.latitude,
0063                         longitude: root.longitude,
0064                         asset: root.asset,
0065                         author: root.author
0066                     });
0067                     map.open();
0068                 }
0069                 onLongPressed: openMessageContext("")
0070             }
0071             TapHandler {
0072                 acceptedButtons: Qt.RightButton
0073                 onTapped: openMessageContext("")
0074             }
0075             Connections {
0076                 target: mapView.map
0077                 function onCopyrightLinkActivated() {
0078                     Qt.openUrlExternally(link);
0079                 }
0080             }
0081         }
0082         Component {
0083             id: fullScreenMap
0084             FullScreenMap {}
0085         }
0086 
0087         RichLabel {
0088             textMessage: root.display
0089             visible: root.display !== ""
0090         }
0091     }
0092 }