2023-02-22 01:48:49 +03:00
|
|
|
// SPDX-FileCopyrightText: Nheko Contributors
|
2021-07-17 20:31:38 +03:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2021-09-25 06:27:57 +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
|
2021-08-04 03:27:50 +03:00
|
|
|
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
|
2021-07-20 17:10:43 +03:00
|
|
|
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
|
2021-09-01 04:53:12 +03:00
|
|
|
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/")
|
2021-07-22 01:56:20 +03:00
|
|
|
onClicked: TimelineManager.openRoomSettings(members.roomId)
|
2021-05-30 04:09:21 +03:00
|
|
|
}
|
|
|
|
|
2021-07-21 01:27:16 +03:00
|
|
|
ElidedLabel {
|
2021-07-20 19:53:16 +03:00
|
|
|
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")
|
2021-07-22 01:56:20 +03:00
|
|
|
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: Nheko.colors.text
|
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
2021-07-17 23:48:06 +03:00
|
|
|
palette: Nheko.colors
|
2021-07-20 17:10:43 +03:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2021-11-13 21:46:29 +03:00
|
|
|
delegate: ItemDelegate {
|
2021-08-14 00:58:26 +03:00
|
|
|
id: del
|
|
|
|
|
2022-07-30 17:47:46 +03:00
|
|
|
onClicked: room.openUserProfile(model.mxid)
|
2021-11-13 21:46:29 +03:00
|
|
|
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
|
2021-11-13 21:46:29 +03:00
|
|
|
background: Rectangle {
|
2021-11-13 22:05:27 +03:00
|
|
|
color: del.hovered ? Nheko.colors.dark : roomMembersRoot.color
|
2021-11-13 21:46:29 +03:00
|
|
|
}
|
2021-05-30 04:09:21 +03:00
|
|
|
|
2021-11-13 21:46:29 +03:00
|
|
|
RowLayout {
|
|
|
|
id: memberLayout
|
2021-08-14 00:58:26 +03:00
|
|
|
|
2021-11-13 21:46:29 +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
|
|
|
|
2021-11-13 21:46:29 +03:00
|
|
|
Avatar {
|
|
|
|
id: avatar
|
2021-05-30 04:09:21 +03:00
|
|
|
|
2021-11-13 21:46:29 +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
|
|
|
}
|
|
|
|
|
2021-11-13 21:46:29 +03:00
|
|
|
ColumnLayout {
|
|
|
|
spacing: Nheko.paddingSmall
|
2023-02-26 06:20:20 +03:00
|
|
|
Layout.fillWidth: true
|
2021-11-13 21:46:29 +03:00
|
|
|
|
|
|
|
ElidedLabel {
|
|
|
|
fullText: model.displayName
|
2021-11-19 00:33:45 +03:00
|
|
|
color: TimelineManager.userColor(model ? model.mxid : "", del.background.color)
|
2021-11-13 21:46:29 +03:00
|
|
|
font.pixelSize: fontMetrics.font.pixelSize
|
|
|
|
elideWidth: del.width - Nheko.paddingMedium * 2 - avatar.width - encryptInd.width
|
2023-02-26 06:20:20 +03:00
|
|
|
Layout.fillWidth: true
|
2021-11-13 21:46:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
ElidedLabel {
|
|
|
|
fullText: model.mxid
|
2021-11-19 00:33:45 +03:00
|
|
|
color: del.hovered ? Nheko.colors.brightText : Nheko.colors.buttonText
|
2021-11-13 21:46:29 +03:00
|
|
|
font.pixelSize: Math.ceil(fontMetrics.font.pixelSize * 0.9)
|
|
|
|
elideWidth: del.width - Nheko.paddingMedium * 2 - avatar.width - encryptInd.width
|
2023-02-26 06:20:20 +03:00
|
|
|
Layout.fillWidth: true
|
2021-11-13 21:46:29 +03:00
|
|
|
}
|
|
|
|
|
2021-11-19 00:33:45 +03:00
|
|
|
}
|
2021-11-13 21:46:29 +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
|
2022-05-07 03:30:16 +03:00
|
|
|
source: sourceUrl + (ma.hovered ? Nheko.colors.highlight : Nheko.colors.buttonText)
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-11-13 21:46:29 +03:00
|
|
|
EncryptionIndicator {
|
|
|
|
id: encryptInd
|
|
|
|
|
2022-06-30 06:38:22 +03:00
|
|
|
Layout.preferredWidth: 16
|
|
|
|
Layout.preferredHeight: 16
|
2021-11-13 21:46:29 +03:00
|
|
|
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
|
|
|
|
2021-11-13 21:46:29 +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
|
|
|
}
|
2021-06-12 01:53:32 +03:00
|
|
|
|
2021-07-21 02:57:36 +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
|
2021-07-21 02:57:36 +03:00
|
|
|
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-21 02:57:36 +03:00
|
|
|
}
|
|
|
|
|
2021-06-12 01:53:32 +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
|
|
|
}
|
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
|
|
|
}
|