Switch member dialog to using ItemDelegate

This commit is contained in:
Loren Burkholder 2021-11-13 13:46:29 -05:00
parent cf43b7b9f0
commit 8ca1b93abb

View file

@ -85,67 +85,84 @@ ApplicationWindow {
enabled: !Settings.mobileMode enabled: !Settings.mobileMode
} }
delegate: RowLayout { delegate: ItemDelegate {
id: del id: del
onClicked: Rooms.currentRoom.openUserProfile(model.mxid)
padding: Nheko.paddingMedium
width: ListView.view.width width: ListView.view.width
spacing: Nheko.paddingMedium height: memberLayout.implicitHeight
background: Rectangle {
Avatar { color: roomMembersRoot.color
id: avatar
width: Nheko.avatarSize
height: Nheko.avatarSize
userid: model.mxid
url: model.avatarUrl.replace("mxc://", "image://MxcImage/")
displayName: model.displayName
onClicked: Rooms.currentRoom.openUserProfile(model.mxid)
} }
ColumnLayout { RowLayout {
spacing: Nheko.paddingSmall id: memberLayout
ElidedLabel { spacing: Nheko.paddingMedium
fullText: model.displayName
color: TimelineManager.userColor(model ? model.mxid : "", Nheko.colors.window) Avatar {
font.pixelSize: fontMetrics.font.pixelSize id: avatar
elideWidth: del.width - Nheko.paddingMedium * 2 - avatar.width - encryptInd.width
width: Nheko.avatarSize
height: Nheko.avatarSize
userid: model.mxid
url: model.avatarUrl.replace("mxc://", "image://MxcImage/")
displayName: model.displayName
enabled: false
} }
ElidedLabel { ColumnLayout {
fullText: model.mxid spacing: Nheko.paddingSmall
color: Nheko.colors.buttonText
font.pixelSize: Math.ceil(fontMetrics.font.pixelSize * 0.9) ElidedLabel {
elideWidth: del.width - Nheko.paddingMedium * 2 - avatar.width - encryptInd.width fullText: model.displayName
color: TimelineManager.userColor(model ? model.mxid : "", Nheko.colors.window)
font.pixelSize: fontMetrics.font.pixelSize
elideWidth: del.width - Nheko.paddingMedium * 2 - avatar.width - encryptInd.width
}
ElidedLabel {
fullText: model.mxid
color: Nheko.colors.buttonText
font.pixelSize: Math.ceil(fontMetrics.font.pixelSize * 0.9)
elideWidth: del.width - Nheko.paddingMedium * 2 - avatar.width - encryptInd.width
}
Item {
Layout.fillHeight: true
Layout.fillWidth: true
}
} }
Item { EncryptionIndicator {
Layout.fillHeight: true id: encryptInd
Layout.fillWidth: true
}
} 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!");
EncryptionIndicator { switch (trust) {
id: encryptInd case Crypto.Verified:
return qsTr("This user is verified.");
Layout.alignment: Qt.AlignRight case Crypto.TOFU:
visible: room.isEncrypted return qsTr("This user isn't verified, but is still using the same master key from the first time you met.");
encrypted: room.isEncrypted default:
trust: encrypted ? model.trustlevel : Crypto.Unverified return qsTr("This user has unverified devices!");
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!");
} }
} }
}
CursorShape {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
} }
} }