matrixion/resources/qml/dialogs/RoomMembers.qml

258 lines
9.3 KiB
QML
Raw Normal View History

// SPDX-FileCopyrightText: 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
color: palette.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
}
2022-04-23 02:59:40 +03:00
MatrixTextField {
id: searchBar
Layout.fillWidth: true
placeholderText: qsTr("Search...")
onTextChanged: members.setFilterString(text)
Component.onCompleted: forceActiveFocus()
}
RowLayout {
spacing: Nheko.paddingMedium
Label {
text: qsTr("Sort by: ")
color: palette.text
2022-04-23 02:59:40 +03:00
}
ComboBox {
model: ListModel {
ListElement { data: MemberList.Mxid; text: qsTr("User ID") }
ListElement { data: MemberList.DisplayName; text: qsTr("Display name") }
ListElement { data: MemberList.Powerlevel; text: qsTr("Power level") }
}
textRole: "text"
valueRole: "data"
onCurrentValueChanged: members.sortBy(currentValue)
Layout.fillWidth: true
}
}
2021-05-30 04:09:21 +03:00
ScrollView {
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
delegate: ItemDelegate {
2021-08-14 00:58:26 +03:00
id: del
onClicked: room.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 {
color: del.hovered ? palette.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
Layout.fillWidth: true
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
Layout.fillWidth: true
}
ElidedLabel {
fullText: model.mxid
color: del.hovered ? palette.brightText : palette.buttonText
font.pixelSize: Math.ceil(fontMetrics.font.pixelSize * 0.9)
elideWidth: del.width - Nheko.paddingMedium * 2 - avatar.width - encryptInd.width
Layout.fillWidth: true
}
2021-11-19 00:33:45 +03:00
}
2022-05-07 03:30:16 +03:00
Image {
property bool isAdmin: room.permissions.changeLevel(MtxEvent.PowerLevels) <= model.powerlevel
property bool isModerator: room.permissions.redactLevel() <= model.powerlevel
//property bool isDefault: room.permissions.defaultLevel() <= model.powerlevel
property string sourceUrl: {
if (isAdmin)
return "image://colorimage/:/icons/icons/ui/ribbon_star.svg?";
else if (isModerator)
return "image://colorimage/:/icons/icons/ui/ribbon.svg?";
else
return "image://colorimage/:/icons/icons/ui/person.svg?";
}
2022-06-30 06:38:22 +03:00
Layout.preferredWidth: 16
Layout.preferredHeight: 16
sourceSize.width: width
sourceSize.height: height
source: sourceUrl + (ma.hovered ? palette.highlight : palette.buttonText)
2022-05-07 03:30:16 +03:00
ToolTip.visible: ma.hovered
ToolTip.text: {
if (isAdmin)
return qsTr("Administrator: %1").arg(model.powerlevel);
else if (isModerator)
return qsTr("Moderator: %1").arg(model.powerlevel);
else
return qsTr("User: %1").arg(model.powerlevel);
}
HoverHandler {
id: ma
}
}
EncryptionIndicator {
id: encryptInd
2022-06-30 06:38:22 +03:00
Layout.preferredWidth: 16
Layout.preferredHeight: 16
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
2022-04-23 02:59:40 +03:00
height: membersLoadingSpinner.implicitHeight
anchors.margins: Nheko.paddingMedium
Spinner {
id: membersLoadingSpinner
anchors.centerIn: parent
2022-04-23 02:59:40 +03:00
implicitHeight: parent.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
}