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, 0034 string displayName, 0035 url avatarUrl, 0036 string alias, 0037 string topic, 0038 int memberCount, 0039 bool isJoined) 0040 0041 onClicked: { 0042 if (!isJoined) { 0043 justJoined = true; 0044 } 0045 root.roomSelected(root.roomId, 0046 root.displayName, 0047 root.avatarUrl, 0048 root.alias, 0049 root.topic, 0050 root.memberCount, 0051 root.isJoined) 0052 } 0053 0054 contentItem: RowLayout { 0055 spacing: Kirigami.Units.smallSpacing 0056 0057 Components.Avatar { 0058 Layout.preferredWidth: Kirigami.Units.gridUnit * 2 0059 Layout.preferredHeight: Kirigami.Units.gridUnit * 2 0060 Layout.alignment: Qt.AlignTop 0061 0062 source: root.avatarUrl 0063 name: root.displayName 0064 } 0065 0066 ColumnLayout { 0067 Layout.fillWidth: true 0068 RowLayout { 0069 Layout.fillWidth: true 0070 Kirigami.Heading { 0071 Layout.fillWidth: true 0072 level: 4 0073 text: root.displayName 0074 font.bold: true 0075 textFormat: Text.PlainText 0076 elide: Text.ElideRight 0077 wrapMode: Text.NoWrap 0078 } 0079 QQC2.Label { 0080 visible: root.isJoined || root.justJoined 0081 text: i18n("Joined") 0082 color: Kirigami.Theme.linkColor 0083 } 0084 } 0085 QQC2.Label { 0086 Layout.fillWidth: true 0087 visible: text 0088 text: root.topic ? root.topic.replace(/(\r\n\t|\n|\r\t)/gm," ") : "" 0089 textFormat: Text.PlainText 0090 elide: Text.ElideRight 0091 wrapMode: Text.NoWrap 0092 } 0093 RowLayout { 0094 Layout.fillWidth: true 0095 Kirigami.Icon { 0096 source: "user" 0097 color: Kirigami.Theme.disabledTextColor 0098 implicitHeight: Kirigami.Units.iconSizes.small 0099 implicitWidth: Kirigami.Units.iconSizes.small 0100 } 0101 QQC2.Label { 0102 text: root.memberCount + " " + (root.alias ?? root.roomId) 0103 color: Kirigami.Theme.disabledTextColor 0104 elide: Text.ElideRight 0105 Layout.fillWidth: true 0106 } 0107 } 0108 } 0109 } 0110 }