matrixion/qml/dialogs/RoomMembers.qml

209 lines
7.7 KiB
QML
Raw Permalink 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
2022-04-16 03:13:01 +03:00
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
import im.nheko
2021-05-30 04:09:21 +03:00
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
2022-04-16 03:13:01 +03:00
color: timelineRoot.palette.window
flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
2021-05-30 04:09:21 +03:00
height: 650
minimumHeight: 420
2022-04-11 05:18:16 +03:00
palette: timelineRoot.palette
2022-04-16 03:13:01 +03:00
title: qsTr("Members of %1").arg(members.roomName)
width: 420
footer: DialogButtonBox {
standardButtons: DialogButtonBox.Ok
onAccepted: roomMembersRoot.close()
}
2021-05-30 04:09:21 +03:00
Shortcut {
sequence: StandardKey.Cancel
2022-04-16 03:13:01 +03:00
2021-05-30 04:09:21 +03:00
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
2022-04-16 03:13:01 +03:00
Layout.alignment: Qt.AlignHCenter
displayName: members.roomName
2021-05-30 04:09:21 +03:00
height: width
roomid: members.roomId
2021-05-30 04:09:21 +03:00
url: members.avatarUrl.replace("mxc://", "image://MxcImage/")
2022-04-16 03:13:01 +03:00
width: 130
onClicked: TimelineManager.openRoomSettings(members.roomId)
2021-05-30 04:09:21 +03:00
}
2021-07-21 01:27:16 +03:00
ElidedLabel {
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
2022-04-16 03:13:01 +03:00
font.pixelSize: fontMetrics.font.pixelSize * 2
fullText: qsTr("%n people in %1", "Summary above list of members", members.memberCount).arg(members.roomName)
2021-05-30 04:09:21 +03:00
}
2021-06-11 03:13:12 +03:00
ImageButton {
Layout.alignment: Qt.AlignHCenter
ToolTip.text: qsTr("Invite more people")
2022-04-16 03:13:01 +03:00
ToolTip.visible: hovered
hoverEnabled: true
image: ":/icons/icons/ui/add-square-button.svg"
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...")
Component.onCompleted: forceActiveFocus()
2022-04-16 03:13:01 +03:00
onTextChanged: members.setFilterString(text)
2022-04-23 02:59:40 +03:00
}
RowLayout {
spacing: Nheko.paddingMedium
Label {
color: Nheko.colors.text
2022-04-16 03:13:01 +03:00
text: qsTr("Sort by: ")
2022-04-23 02:59:40 +03:00
}
ComboBox {
2022-04-16 03:13:01 +03:00
Layout.fillWidth: true
2022-04-23 02:59:40 +03:00
textRole: "text"
valueRole: "data"
2022-04-16 03:13:01 +03:00
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")
}
}
2022-04-23 02:59:40 +03:00
onCurrentValueChanged: members.sortBy(currentValue)
}
}
2021-05-30 04:09:21 +03:00
ScrollView {
Layout.fillHeight: true
Layout.fillWidth: true
2022-04-16 03:13:01 +03:00
Layout.minimumHeight: 200
ScrollBar.horizontal.visible: false
padding: Nheko.paddingMedium
palette: timelineRoot.palette
2021-05-30 04:09:21 +03:00
ListView {
id: memberList
boundsBehavior: Flickable.StopAtBounds
2022-04-16 03:13:01 +03:00
clip: true
2021-05-30 04:09:21 +03:00
model: members
delegate: ItemDelegate {
2021-08-14 00:58:26 +03:00
id: del
2021-11-13 22:38:22 +03:00
height: memberLayout.implicitHeight + Nheko.paddingSmall * 2
2021-11-13 22:05:27 +03:00
hoverEnabled: true
2022-04-16 03:13:01 +03:00
padding: Nheko.paddingMedium
width: ListView.view.width
background: Rectangle {
2022-04-11 05:18:16 +03:00
color: del.hovered ? timelineRoot.palette.dark : roomMembersRoot.color
}
2021-05-30 04:09:21 +03:00
2022-04-16 03:13:01 +03:00
onClicked: Rooms.currentRoom.openUserProfile(model.mxid)
RowLayout {
id: memberLayout
2021-11-19 00:33:45 +03:00
anchors.centerIn: parent
2022-04-16 03:13:01 +03:00
spacing: Nheko.paddingMedium
2021-11-19 00:33:45 +03:00
width: parent.width - Nheko.paddingSmall * 2
2021-05-30 04:09:21 +03:00
Avatar {
id: avatar
displayName: model.displayName
enabled: false
2022-04-16 03:13:01 +03:00
height: Nheko.avatarSize
url: model.avatarUrl.replace("mxc://", "image://MxcImage/")
userid: model.mxid
width: Nheko.avatarSize
2021-05-30 04:09:21 +03:00
}
ColumnLayout {
spacing: Nheko.paddingSmall
ElidedLabel {
2021-11-19 00:33:45 +03:00
color: TimelineManager.userColor(model ? model.mxid : "", del.background.color)
elideWidth: del.width - Nheko.paddingMedium * 2 - avatar.width - encryptInd.width
2022-04-16 03:13:01 +03:00
font.pixelSize: fontMetrics.font.pixelSize
fullText: model.displayName
}
ElidedLabel {
2022-04-15 06:53:41 +03:00
color: del.hovered ? timelineRoot.palette.brightText : timelineRoot.palette.placeholderText
elideWidth: del.width - Nheko.paddingMedium * 2 - avatar.width - encryptInd.width
2022-04-16 03:13:01 +03:00
font.pixelSize: Math.ceil(fontMetrics.font.pixelSize * 0.9)
fullText: model.mxid
}
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
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!");
}
}
2022-04-16 03:13:01 +03:00
encrypted: room.isEncrypted
trust: encrypted ? model.trustlevel : Crypto.Unverified
visible: room.isEncrypted
2021-05-30 04:09:21 +03:00
}
}
NhekoCursorShape {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
2021-08-14 00:58:26 +03:00
}
2021-05-30 04:09:21 +03:00
}
footer: Item {
2022-04-16 03:13:01 +03:00
anchors.margins: Nheko.paddingMedium
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
2022-04-16 03:13:01 +03:00
visible: (members.numUsersLoaded < members.memberCount) && members.loadingMoreMembers
width: parent.width
Spinner {
id: membersLoadingSpinner
anchors.centerIn: parent
2022-04-23 02:59:40 +03:00
implicitHeight: parent.visible ? 35 : 0
}
}
2021-05-30 04:09:21 +03:00
}
}
}
}