matrixion/resources/qml/dialogs/RoomMembers.qml

199 lines
6.7 KiB
QML
Raw Normal View History

2021-07-17 20:31:38 +03:00
// SPDX-FileCopyrightText: 2021 Nheko Contributors
// SPDX-FileCopyrightText: 2022 Nheko Contributors
2021-07-17 20:31:38 +03:00
//
// SPDX-License-Identifier: GPL-3.0-or-later
import ".."
import "../ui"
2021-05-30 04:09:21 +03:00
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import QtQuick.Window 2.13
2021-05-30 04:09:21 +03:00
import im.nheko 1.0
ApplicationWindow {
id: roomMembersRoot
property MemberList members
2021-08-14 00:58:26 +03:00
property Room room
2021-05-30 04:09:21 +03:00
2021-07-21 20:13:34 +03:00
title: qsTr("Members of %1").arg(members.roomName)
2021-05-30 04:09:21 +03:00
height: 650
width: 420
minimumHeight: 420
2021-07-21 01:04:19 +03:00
palette: Nheko.colors
color: Nheko.colors.window
2021-08-19 17:55:54 +03:00
flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
2021-05-30 04:09:21 +03:00
Shortcut {
sequence: StandardKey.Cancel
onActivated: roomMembersRoot.close()
}
ColumnLayout {
anchors.fill: parent
anchors.margins: Nheko.paddingMedium
2021-07-19 17:07:54 +03:00
spacing: Nheko.paddingMedium
2021-05-30 04:09:21 +03:00
Avatar {
id: roomAvatar
width: 130
height: width
roomid: members.roomId
2021-05-30 04:09:21 +03:00
displayName: members.roomName
Layout.alignment: Qt.AlignHCenter
url: members.avatarUrl.replace("mxc://", "image://MxcImage/")
onClicked: TimelineManager.openRoomSettings(members.roomId)
2021-05-30 04:09:21 +03:00
}
2021-07-21 01:27:16 +03:00
ElidedLabel {
font.pixelSize: fontMetrics.font.pixelSize * 2
2021-07-21 20:13:34 +03:00
fullText: qsTr("%n people in %1", "Summary above list of members", members.memberCount).arg(members.roomName)
2021-05-30 04:09:21 +03:00
Layout.alignment: Qt.AlignHCenter
2021-07-21 02:45:28 +03:00
elideWidth: parent.width - Nheko.paddingMedium
2021-05-30 04:09:21 +03:00
}
2021-06-11 03:13:12 +03:00
ImageButton {
Layout.alignment: Qt.AlignHCenter
2021-11-14 04:23:10 +03:00
image: ":/icons/icons/ui/add-square-button.svg"
2021-06-11 03:13:12 +03:00
hoverEnabled: true
ToolTip.visible: hovered
ToolTip.text: qsTr("Invite more people")
onClicked: TimelineManager.openInviteUsers(members.roomId)
2021-06-11 03:13:12 +03:00
}
2021-05-30 04:09:21 +03:00
ScrollView {
2021-07-17 23:48:06 +03:00
palette: Nheko.colors
padding: Nheko.paddingMedium
2021-05-30 04:09:21 +03:00
ScrollBar.horizontal.visible: false
Layout.fillHeight: true
Layout.minimumHeight: 200
Layout.fillWidth: true
ListView {
id: memberList
clip: true
boundsBehavior: Flickable.StopAtBounds
model: members
ScrollHelper {
flickable: parent
anchors.fill: parent
enabled: !Settings.mobileMode
}
delegate: ItemDelegate {
2021-08-14 00:58:26 +03:00
id: del
onClicked: Rooms.currentRoom.openUserProfile(model.mxid)
padding: Nheko.paddingMedium
2021-08-14 00:58:26 +03:00
width: ListView.view.width
2021-11-13 22:38:22 +03:00
height: memberLayout.implicitHeight + Nheko.paddingSmall * 2
2021-11-13 22:05:27 +03:00
hoverEnabled: true
background: Rectangle {
2021-11-13 22:05:27 +03:00
color: del.hovered ? Nheko.colors.dark : roomMembersRoot.color
}
2021-05-30 04:09:21 +03:00
RowLayout {
id: memberLayout
2021-08-14 00:58:26 +03:00
spacing: Nheko.paddingMedium
2021-11-19 00:33:45 +03:00
anchors.centerIn: parent
width: parent.width - Nheko.paddingSmall * 2
2021-05-30 04:09:21 +03:00
Avatar {
id: avatar
2021-05-30 04:09:21 +03:00
width: Nheko.avatarSize
height: Nheko.avatarSize
userid: model.mxid
url: model.avatarUrl.replace("mxc://", "image://MxcImage/")
displayName: model.displayName
enabled: false
2021-05-30 04:09:21 +03:00
}
ColumnLayout {
spacing: Nheko.paddingSmall
ElidedLabel {
fullText: model.displayName
2021-11-19 00:33:45 +03:00
color: TimelineManager.userColor(model ? model.mxid : "", del.background.color)
font.pixelSize: fontMetrics.font.pixelSize
elideWidth: del.width - Nheko.paddingMedium * 2 - avatar.width - encryptInd.width
}
ElidedLabel {
fullText: model.mxid
2021-11-19 00:33:45 +03:00
color: del.hovered ? Nheko.colors.brightText : Nheko.colors.buttonText
font.pixelSize: Math.ceil(fontMetrics.font.pixelSize * 0.9)
elideWidth: del.width - Nheko.paddingMedium * 2 - avatar.width - encryptInd.width
}
2021-11-19 00:33:45 +03:00
}
2021-11-19 00:33:45 +03:00
Item {
Layout.fillWidth: true
2021-05-30 04:09:21 +03:00
}
EncryptionIndicator {
id: encryptInd
Layout.alignment: Qt.AlignRight
visible: room.isEncrypted
encrypted: room.isEncrypted
trust: encrypted ? model.trustlevel : Crypto.Unverified
ToolTip.text: {
if (!encrypted)
return qsTr("This room is not encrypted!");
switch (trust) {
case Crypto.Verified:
return qsTr("This user is verified.");
case Crypto.TOFU:
return qsTr("This user isn't verified, but is still using the same master key from the first time you met.");
default:
return qsTr("This user has unverified devices!");
}
}
2021-05-30 04:09:21 +03:00
}
2021-07-19 21:31:08 +03:00
2021-05-30 04:09:21 +03:00
}
2021-07-19 21:31:08 +03:00
CursorShape {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
2021-08-14 00:58:26 +03:00
}
2021-05-30 04:09:21 +03:00
}
footer: Item {
width: parent.width
visible: (members.numUsersLoaded < members.memberCount) && members.loadingMoreMembers
2021-07-19 19:32:09 +03:00
// use the default height if it's visible, otherwise no height at all
height: membersLoadingSpinner.height
anchors.margins: Nheko.paddingMedium
Spinner {
id: membersLoadingSpinner
anchors.centerIn: parent
height: visible ? 35 : 0
}
}
2021-07-19 21:31:08 +03:00
2021-05-30 04:09:21 +03:00
}
2021-07-19 21:31:08 +03:00
2021-05-30 04:09:21 +03:00
}
2021-07-19 21:31:08 +03:00
2021-05-30 04:09:21 +03:00
}
footer: DialogButtonBox {
standardButtons: DialogButtonBox.Ok
onAccepted: roomMembersRoot.close()
}
2021-07-19 21:31:08 +03:00
2021-05-30 04:09:21 +03:00
}