Warning, /network/neochat/src/qml/StateComponent.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2022 James Graham <james.h.graham@protonmail.com> 0002 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0003 0004 import QtQuick 0005 import QtQuick.Controls as QQC2 0006 import QtQuick.Layouts 0007 0008 import org.kde.kirigami as Kirigami 0009 import org.kde.kirigamiaddons.labs.components as KirigamiComponents 0010 0011 import org.kde.neochat 0012 0013 /** 0014 * @brief A component for visualising a single state event 0015 */ 0016 RowLayout { 0017 id: root 0018 0019 /** 0020 * @brief All model roles as a map with the property names as the keys. 0021 */ 0022 required property var modelData 0023 0024 /** 0025 * @brief The message author. 0026 * 0027 * This should consist of the following: 0028 * - id - The matrix ID of the author. 0029 * - isLocalUser - Whether the author is the local user. 0030 * - avatarSource - The mxc URL for the author's avatar in the current room. 0031 * - avatarMediaId - The media ID of the author's avatar. 0032 * - avatarUrl - The mxc URL for the author's avatar. 0033 * - displayName - The display name of the author. 0034 * - display - The name of the author. 0035 * - color - The color for the author. 0036 * - object - The Quotient::User object for the author. 0037 * 0038 * @sa Quotient::User 0039 */ 0040 property var author: modelData.author 0041 0042 /** 0043 * @brief The displayname for the event's sender; for name change events, the old displayname. 0044 */ 0045 property string authorDisplayName: modelData.authorDisplayName 0046 0047 /** 0048 * @brief The display text for the state event. 0049 */ 0050 property string text: modelData.text 0051 0052 KirigamiComponents.Avatar { 0053 id: stateAvatar 0054 0055 Layout.preferredWidth: Kirigami.Units.iconSizes.small 0056 Layout.preferredHeight: Kirigami.Units.iconSizes.small 0057 0058 source: root.author?.avatarSource ?? "" 0059 name: root.author?.displayName ?? "" 0060 color: root.author?.color ?? undefined 0061 0062 MouseArea { 0063 anchors.fill: parent 0064 cursorShape: Qt.PointingHandCursor 0065 onClicked: RoomManager.resolveResource("https://matrix.to/#/" + root.author.id) 0066 } 0067 } 0068 0069 QQC2.Label { 0070 id: label 0071 Layout.alignment: Qt.AlignVCenter 0072 Layout.fillWidth: true 0073 text: `<style>a {text-decoration: none; color: ${Kirigami.Theme.textColor};}</style><a href="https://matrix.to/#/${root.author.id}">${root.authorDisplayName}</a> ${root.text}` 0074 wrapMode: Text.WordWrap 0075 textFormat: Text.RichText 0076 onLinkActivated: link => RoomManager.resolveResource(link) 0077 HoverHandler { 0078 cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.IBeamCursor 0079 } 0080 } 0081 }