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

0001 // SPDX-FileCopyrightText: 2023 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.delegates as Delegates
0010 import org.kde.kirigamiaddons.labs.components as Components
0011 
0012 import org.kde.neochat
0013 
0014 Delegates.RoundedItemDelegate {
0015     id: root
0016 
0017     required property string roomId
0018     required property string displayName
0019     required property url avatarUrl
0020     required property string alias
0021     required property string topic
0022     required property int memberCount
0023     required property bool isJoined
0024     property bool justJoined: false
0025 
0026     /**
0027      * @brief Signal emitted when a room delegate is selected.
0028      *
0029      * The signal contains all the delegate's model info so that it can be acted
0030      * upon as required, e.g. joining or entering the room or adding the room as
0031      * the child of a space.
0032      */
0033     signal roomSelected(string roomId, string displayName, url avatarUrl, string alias, string topic, int memberCount, bool isJoined)
0034 
0035     onClicked: {
0036         if (!isJoined) {
0037             justJoined = true;
0038         }
0039         root.roomSelected(root.roomId, root.displayName, root.avatarUrl, root.alias, root.topic, root.memberCount, root.isJoined);
0040     }
0041 
0042     contentItem: RowLayout {
0043         spacing: Kirigami.Units.smallSpacing
0044 
0045         Components.Avatar {
0046             Layout.preferredWidth: Kirigami.Units.gridUnit * 2
0047             Layout.preferredHeight: Kirigami.Units.gridUnit * 2
0048             Layout.alignment: Qt.AlignTop
0049 
0050             source: root.avatarUrl
0051             name: root.displayName
0052         }
0053 
0054         ColumnLayout {
0055             Layout.fillWidth: true
0056             RowLayout {
0057                 Layout.fillWidth: true
0058                 Kirigami.Heading {
0059                     Layout.fillWidth: true
0060                     level: 4
0061                     text: root.displayName
0062                     font.bold: true
0063                     textFormat: Text.PlainText
0064                     elide: Text.ElideRight
0065                     wrapMode: Text.NoWrap
0066                 }
0067                 QQC2.Label {
0068                     visible: root.isJoined || root.justJoined
0069                     text: i18n("Joined")
0070                     color: Kirigami.Theme.linkColor
0071                 }
0072             }
0073             QQC2.Label {
0074                 Layout.fillWidth: true
0075                 visible: text
0076                 text: root.topic ? root.topic.replace(/(\r\n\t|\n|\r\t)/gm, " ") : ""
0077                 textFormat: Text.PlainText
0078                 elide: Text.ElideRight
0079                 wrapMode: Text.NoWrap
0080             }
0081             RowLayout {
0082                 Layout.fillWidth: true
0083                 Kirigami.Icon {
0084                     source: "user"
0085                     color: Kirigami.Theme.disabledTextColor
0086                     implicitHeight: Kirigami.Units.iconSizes.small
0087                     implicitWidth: Kirigami.Units.iconSizes.small
0088                 }
0089                 QQC2.Label {
0090                     text: root.memberCount + " " + (root.alias ?? root.roomId)
0091                     color: Kirigami.Theme.disabledTextColor
0092                     elide: Text.ElideRight
0093                     Layout.fillWidth: true
0094                 }
0095             }
0096         }
0097     }
0098 }