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, {latitude: root.latitude, longitude: root.longitude, asset: root.asset, author: root.author});
0062                     map.open()
0063                 }
0064                 onLongPressed: openMessageContext("")
0065             }
0066             TapHandler {
0067                 acceptedButtons: Qt.RightButton
0068                 onTapped: openMessageContext("")
0069             }
0070             Connections {
0071                 target: mapView.map
0072                 function onCopyrightLinkActivated() {
0073                     Qt.openUrlExternally(link)
0074                 }
0075             }
0076         }
0077         Component {
0078             id: fullScreenMap
0079             FullScreenMap { }
0080         }
0081 
0082         RichLabel {
0083             textMessage: root.display
0084             visible: root.display !== ""
0085         }
0086     }
0087 }