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

0001 // SPDX-FileCopyrightText: 2021 Tobias Fella <tobias.fella@kde.org>
0002 // SPDX-License-Identifier: GPL-3.0-only
0003 
0004 import QtQuick
0005 import QtQuick.Layouts
0006 
0007 import Qt.labs.qmlmodels
0008 
0009 import org.kde.neochat
0010 import org.kde.neochat.config
0011 
0012 /**
0013  * @brief A timeline delegate for a text message.
0014  *
0015  * @inherit MessageDelegate
0016  */
0017 MessageDelegate {
0018     id: root
0019 
0020     /**
0021      * @brief The link preview properties.
0022      *
0023      * This is a list or object containing the following:
0024      *  - url - The URL being previewed.
0025      *  - loaded - Whether the URL preview has been loaded.
0026      *  - title - the title of the URL preview.
0027      *  - description - the description of the URL preview.
0028      *  - imageSource - a source URL for the preview image.
0029      *
0030      * @note An empty link previewer should be passed if there are no links to
0031      *       preview.
0032      */
0033     required property var linkPreview
0034 
0035     /**
0036      * @brief Whether there are any links to preview.
0037      */
0038     required property bool showLinkPreview
0039 
0040     onOpenContextMenu: RoomManager.viewEventMenu(eventId, author, delegateType, plainText, display, label.selectedText)
0041 
0042     bubbleContent: ColumnLayout {
0043         RichLabel {
0044             id: label
0045             Layout.fillWidth: true
0046             visible: root.room.editCache.editId !== root.eventId
0047 
0048             isReply: root.isReply
0049 
0050             textMessage: root.display
0051 
0052             TapHandler {
0053                 enabled: !label.hoveredLink
0054                 acceptedButtons: Qt.LeftButton
0055                 onLongPressed: root.openContextMenu()
0056             }
0057         }
0058         Loader {
0059             Layout.fillWidth: true
0060             Layout.minimumHeight: item ? item.minimumHeight : -1
0061             Layout.preferredWidth: item ? item.preferredWidth : -1
0062             visible: root.room.editCache.editId === root.eventId
0063             active: visible
0064             sourceComponent: MessageEditComponent {
0065                 room: root.room
0066                 actionsHandler: root.ListView.view.actionsHandler
0067                 messageId: root.eventId
0068             }
0069         }
0070         LinkPreviewDelegate {
0071             Layout.fillWidth: true
0072             active: !root.room.usesEncryption && root.room.urlPreviewEnabled && Config.showLinkPreview && root.showLinkPreview && !root.linkPreview.empty
0073             linkPreviewer: root.linkPreview
0074             indicatorEnabled: root.isVisibleInTimeline()
0075         }
0076     }
0077 }