Warning, /network/neochat/src/qml/UserDetailDialog.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2019 Black Hat <bhat@encom.eu.org> 0002 // SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu> 0003 // SPDX-License-Identifier: GPL-3.0-only 0004 0005 import QtQuick 0006 import QtQuick.Controls as QQC2 0007 import QtQuick.Layouts 0008 0009 import org.kde.kirigami as Kirigami 0010 import org.kde.kirigamiaddons.components as KirigamiComponents 0011 import org.kde.kirigamiaddons.formcard as FormCard 0012 import org.kde.prison 0013 0014 import org.kde.neochat 0015 0016 Kirigami.Dialog { 0017 id: root 0018 0019 property NeoChatRoom room 0020 property var user 0021 0022 parent: applicationWindow().overlay 0023 0024 leftPadding: 0 0025 rightPadding: 0 0026 topPadding: 0 0027 bottomPadding: 0 0028 0029 standardButtons: Kirigami.Dialog.NoButton 0030 0031 width: Math.min(applicationWindow().width, Kirigami.Units.gridUnit * 24) 0032 title: i18nc("@title:menu Account details dialog", "Account Details") 0033 0034 contentItem: ColumnLayout { 0035 spacing: 0 0036 RowLayout { 0037 Layout.fillWidth: true 0038 Layout.leftMargin: Kirigami.Units.largeSpacing 0039 Layout.rightMargin: Kirigami.Units.largeSpacing 0040 Layout.topMargin: Kirigami.Units.largeSpacing 0041 Layout.bottomMargin: Kirigami.Units.largeSpacing 0042 spacing: Kirigami.Units.largeSpacing 0043 0044 KirigamiComponents.Avatar { 0045 id: avatar 0046 Layout.preferredWidth: Kirigami.Units.iconSizes.huge 0047 Layout.preferredHeight: Kirigami.Units.iconSizes.huge 0048 0049 name: root.user.displayName 0050 source: root.user.avatarSource 0051 color: root.user.color 0052 } 0053 0054 ColumnLayout { 0055 Layout.fillWidth: true 0056 0057 Kirigami.Heading { 0058 level: 1 0059 Layout.fillWidth: true 0060 font.bold: true 0061 0062 elide: Text.ElideRight 0063 wrapMode: Text.NoWrap 0064 text: user.displayName 0065 textFormat: Text.PlainText 0066 } 0067 0068 Kirigami.SelectableLabel { 0069 textFormat: TextEdit.PlainText 0070 text: root.user.id 0071 } 0072 } 0073 QQC2.AbstractButton { 0074 Layout.minimumHeight: avatar.height * 0.75 0075 Layout.maximumHeight: avatar.height * 1.5 0076 contentItem: Barcode { 0077 id: barcode 0078 barcodeType: Barcode.QRCode 0079 content: "https://matrix.to/#/" + root.user.id 0080 } 0081 0082 onClicked: { 0083 let map = qrMaximizeComponent.createObject(parent, { 0084 text: barcode.content, 0085 title: root.user.displayName, 0086 subtitle: root.user.id, 0087 avatarColor: root.user.color, 0088 avatarSource: root.user.avatarSource 0089 }); 0090 root.close(); 0091 map.open(); 0092 } 0093 0094 QQC2.ToolTip.visible: hovered 0095 QQC2.ToolTip.text: barcode.content 0096 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay 0097 } 0098 } 0099 0100 Kirigami.Separator { 0101 Layout.fillWidth: true 0102 } 0103 0104 FormCard.FormButtonDelegate { 0105 visible: !root.user.isLocalUser 0106 action: Kirigami.Action { 0107 text: room.connection.isIgnored(root.user.object) ? i18n("Unignore this user") : i18n("Ignore this user") 0108 icon.name: "im-invisible-user" 0109 onTriggered: { 0110 root.close(); 0111 room.connection.isIgnored(root.user.object) ? room.connection.removeFromIgnoredUsers(root.user.object) : room.connection.addToIgnoredUsers(root.user.object); 0112 } 0113 } 0114 } 0115 0116 FormCard.FormButtonDelegate { 0117 visible: !root.user.isLocalUser && room.canSendState("kick") && room.containsUser(root.user.id) && room.getUserPowerLevel(root.user.id) < room.getUserPowerLevel(root.room.connection.localUser.id) 0118 0119 action: Kirigami.Action { 0120 text: i18n("Kick this user") 0121 icon.name: "im-kick-user" 0122 onTriggered: { 0123 room.kickMember(root.user.id); 0124 root.close(); 0125 } 0126 } 0127 } 0128 0129 FormCard.FormButtonDelegate { 0130 visible: !root.user.isLocalUser && room.canSendState("invite") && !room.containsUser(root.user.id) 0131 0132 action: Kirigami.Action { 0133 enabled: !room.isUserBanned(root.user.id) 0134 text: i18n("Invite this user") 0135 icon.name: "list-add-user" 0136 onTriggered: { 0137 room.inviteToRoom(root.user.id); 0138 root.close(); 0139 } 0140 } 0141 } 0142 0143 FormCard.FormButtonDelegate { 0144 visible: !root.user.isLocalUser && room.canSendState("ban") && !room.isUserBanned(root.user.id) && room.getUserPowerLevel(root.user.id) < room.getUserPowerLevel(root.room.connection.localUser.id) 0145 0146 action: Kirigami.Action { 0147 text: i18n("Ban this user") 0148 icon.name: "im-ban-user" 0149 icon.color: Kirigami.Theme.negativeTextColor 0150 onTriggered: { 0151 applicationWindow().pageStack.pushDialogLayer("qrc:/org/kde/neochat/qml/BanSheet.qml", { 0152 room: root.room, 0153 userId: root.user.id 0154 }, { 0155 title: i18nc("@title", "Ban User"), 0156 width: Kirigami.Units.gridUnit * 25 0157 }); 0158 root.close(); 0159 } 0160 } 0161 } 0162 0163 FormCard.FormButtonDelegate { 0164 visible: !root.user.isLocalUser && room.canSendState("ban") && room.isUserBanned(root.user.id) 0165 0166 action: Kirigami.Action { 0167 text: i18n("Unban this user") 0168 icon.name: "im-irc" 0169 icon.color: Kirigami.Theme.negativeTextColor 0170 onTriggered: { 0171 room.unban(root.user.id); 0172 root.close(); 0173 } 0174 } 0175 } 0176 0177 FormCard.FormButtonDelegate { 0178 visible: room.canSendState("m.room.power_levels") 0179 action: Kirigami.Action { 0180 text: i18n("Set user power level") 0181 icon.name: "visibility" 0182 onTriggered: { 0183 let dialog = powerLevelDialog.createObject(applicationWindow().overlay, { 0184 room: root.room, 0185 userId: root.user.id, 0186 powerLevel: root.room.getUserPowerLevel(root.user.id) 0187 }); 0188 dialog.open(); 0189 root.close(); 0190 } 0191 } 0192 0193 Component { 0194 id: powerLevelDialog 0195 PowerLevelDialog { 0196 id: powerLevelDialog 0197 } 0198 } 0199 } 0200 0201 FormCard.FormButtonDelegate { 0202 visible: root.user.isLocalUser || room.canSendState("redact") 0203 0204 action: Kirigami.Action { 0205 text: i18n("Remove recent messages by this user") 0206 icon.name: "delete" 0207 icon.color: Kirigami.Theme.negativeTextColor 0208 onTriggered: { 0209 applicationWindow().pageStack.pushDialogLayer("qrc:/org/kde/neochat/qml/RemoveSheet.qml", { 0210 room: root.room, 0211 userId: root.user.id 0212 }, { 0213 title: i18nc("@title", "Remove Messages"), 0214 width: Kirigami.Units.gridUnit * 25 0215 }); 0216 root.close(); 0217 } 0218 } 0219 } 0220 0221 FormCard.FormButtonDelegate { 0222 visible: !root.user.isLocalUser 0223 action: Kirigami.Action { 0224 text: root.room.connection.directChatExists(root.user.object) ? i18nc("%1 is the name of the user.", "Chat with %1", root.user.displayName) : i18n("Invite to private chat") 0225 icon.name: "document-send" 0226 onTriggered: { 0227 root.room.connection.openOrCreateDirectChat(root.user.object); 0228 root.close(); 0229 } 0230 } 0231 } 0232 0233 FormCard.FormButtonDelegate { 0234 action: Kirigami.Action { 0235 text: i18n("Copy link") 0236 icon.name: "username-copy" 0237 onTriggered: { 0238 Clipboard.saveText("https://matrix.to/#/" + root.user.id); 0239 } 0240 } 0241 } 0242 } 0243 Component { 0244 id: qrMaximizeComponent 0245 QrCodeMaximizeComponent {} 0246 } 0247 }