2020-07-08 11:33:05 -04:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
import "../../../.."
|
|
|
|
import "../../../../Base"
|
|
|
|
|
|
|
|
HListView {
|
|
|
|
id: profile
|
|
|
|
|
|
|
|
|
|
|
|
property string userId
|
|
|
|
property string roomId
|
|
|
|
property QtObject member // RoomMember model item
|
|
|
|
property HStackView stackView
|
|
|
|
|
|
|
|
|
|
|
|
function loadDevices() {
|
|
|
|
py.callClientCoro(userId, "member_devices", [member.id], devices => {
|
|
|
|
profile.model.clear()
|
|
|
|
|
|
|
|
for (const device of devices)
|
|
|
|
profile.model.append(device)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
clip: true
|
|
|
|
bottomMargin: theme.spacing
|
|
|
|
model: ListModel {}
|
|
|
|
delegate: MemberDeviceDelegate {
|
|
|
|
width: profile.width
|
|
|
|
userId: profile.userId
|
|
|
|
deviceOwner: member.id
|
|
|
|
deviceOwnerDisplayName: member.display_name
|
|
|
|
stackView: profile.stackView
|
2020-07-08 17:33:02 -04:00
|
|
|
|
|
|
|
onTrustSet: trust => profile.loadDevices()
|
2020-07-08 11:33:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
section.property: "type"
|
2020-07-08 11:36:57 -04:00
|
|
|
section.delegate: MemberDeviceSection {
|
2020-07-08 11:33:05 -04:00
|
|
|
width: profile.width
|
|
|
|
}
|
|
|
|
|
|
|
|
header: HColumnLayout {
|
|
|
|
x: theme.spacing
|
|
|
|
width: profile.width - x * 2
|
|
|
|
spacing: theme.spacing * 1.5
|
|
|
|
|
|
|
|
HUserAvatar {
|
|
|
|
userId: member.id
|
|
|
|
displayName: member.display_name
|
|
|
|
mxc: member.avatar_url
|
|
|
|
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
Layout.fillWidth: true
|
2020-07-10 16:45:31 -04:00
|
|
|
Layout.maximumWidth: 256 * theme.uiScale
|
2020-07-08 11:33:05 -04:00
|
|
|
Layout.preferredHeight: width
|
|
|
|
Layout.topMargin: theme.spacing
|
|
|
|
|
|
|
|
HButton {
|
|
|
|
x: -theme.spacing * 0.75
|
|
|
|
y: x
|
|
|
|
z: 999
|
|
|
|
circle: true
|
|
|
|
icon.name: "close-view"
|
|
|
|
iconItem.small: true
|
|
|
|
onClicked: profile.stackView.pop()
|
|
|
|
}
|
2020-07-10 16:44:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
HColumnLayout { // no spacing between these children
|
|
|
|
HLabel {
|
|
|
|
wrapMode: HLabel.Wrap
|
|
|
|
horizontalAlignment: Qt.AlignHCenter
|
|
|
|
color: utils.nameColor(member.display_name || member.id)
|
|
|
|
text: member.display_name.trim() || member.id
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
|
|
|
HLabel {
|
|
|
|
wrapMode: HLabel.Wrap
|
|
|
|
horizontalAlignment: Qt.AlignHCenter
|
|
|
|
color: theme.colors.dimText
|
|
|
|
text: member.id
|
|
|
|
visible: member.display_name.trim() !== ""
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
}
|
2020-07-08 11:33:05 -04:00
|
|
|
|
2020-07-10 16:44:08 -04:00
|
|
|
HColumnLayout {
|
|
|
|
HLabel {
|
|
|
|
wrapMode: HLabel.Wrap
|
|
|
|
horizontalAlignment: Qt.AlignHCenter
|
|
|
|
|
|
|
|
text:
|
|
|
|
member.presence === "online" ? qsTr("Online") :
|
|
|
|
member.presence === "unavailable" ? qsTr("Unavailable") :
|
|
|
|
member.presence === "invisible" ? qsTr("Invisible") :
|
|
|
|
qsTr("Offline / Unknown")
|
|
|
|
|
|
|
|
color:
|
|
|
|
member.presence === "online" ?
|
|
|
|
theme.colors.positiveText :
|
|
|
|
|
|
|
|
member.presence === "unavailable" ?
|
|
|
|
theme.colors.warningText :
|
|
|
|
|
|
|
|
theme.colors.halfDimText
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
|
|
|
HLabel {
|
|
|
|
wrapMode: HLabel.Wrap
|
|
|
|
horizontalAlignment: Qt.AlignHCenter
|
|
|
|
visible: ! member.currently_active && text !== ""
|
|
|
|
color: theme.colors.dimText
|
|
|
|
|
|
|
|
Timer {
|
|
|
|
repeat: true
|
|
|
|
triggeredOnStart: true
|
|
|
|
|
|
|
|
running:
|
|
|
|
! member.currently_active &&
|
|
|
|
member.last_active_at > new Date(1)
|
|
|
|
|
|
|
|
interval:
|
|
|
|
new Date() - member.last_active_at < 60000 ?
|
|
|
|
1000 :
|
|
|
|
60000
|
|
|
|
|
|
|
|
onTriggered: parent.text = Qt.binding(() =>
|
|
|
|
qsTr("Last seen %1 ago").arg(utils.formatRelativeTime(
|
|
|
|
new Date() - member.last_active_at, false,
|
|
|
|
))
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2020-07-08 11:33:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
HLabel {
|
|
|
|
wrapMode: HLabel.Wrap
|
2020-07-10 16:44:08 -04:00
|
|
|
text: member.status_msg.trim()
|
|
|
|
visible: text !== ""
|
2020-07-08 11:33:05 -04:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.bottomMargin: theme.spacing
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
// HColumnLayout {
|
|
|
|
// spacing: theme.spacing / 2
|
|
|
|
|
|
|
|
// HLabel {
|
|
|
|
// text: qsTr("Power level:")
|
|
|
|
// wrapMode: HLabel.Wrap
|
|
|
|
// horizontalAlignment: Qt.AlignHCenter
|
|
|
|
|
|
|
|
// Layout.fillWidth: true
|
|
|
|
// }
|
|
|
|
|
|
|
|
// HRowLayout {
|
|
|
|
// spacing: theme.spacing
|
|
|
|
|
|
|
|
// HSpacer {}
|
|
|
|
|
|
|
|
// Row {
|
|
|
|
// HButton {
|
|
|
|
// text: qsTr("Default")
|
|
|
|
// checked: levelBox.value >= 0 && levelBox.value < 50
|
|
|
|
// onClicked: levelBox.value = 0
|
|
|
|
// }
|
|
|
|
// HButton {
|
|
|
|
// text: qsTr("Moderator")
|
|
|
|
// checked: levelBox.value >= 50 && levelBox.value < 100
|
|
|
|
// onClicked: levelBox.value = 50
|
|
|
|
// }
|
|
|
|
// HButton {
|
|
|
|
// text: qsTr("Admin")
|
|
|
|
// checked: levelBox.value === 100
|
|
|
|
// onClicked: levelBox.value = 100
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// HSpinBox {
|
|
|
|
// id: levelBox
|
|
|
|
// from: -999
|
|
|
|
// to: 100
|
|
|
|
// defaultValue: member.power_level
|
|
|
|
// }
|
|
|
|
|
|
|
|
// HSpacer {}
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: loadDevices()
|
|
|
|
|
2020-07-09 14:53:01 -04:00
|
|
|
Keys.onEnterPressed: Keys.onReturnPressed(event)
|
|
|
|
Keys.onReturnPressed: {
|
|
|
|
currentItem.leftClicked()
|
|
|
|
currentItem.clicked()
|
|
|
|
}
|
2020-07-08 11:33:05 -04:00
|
|
|
Keys.onEscapePressed: stackView.pop()
|
2020-07-08 17:26:52 -04:00
|
|
|
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: py.eventHandlers
|
|
|
|
|
|
|
|
function onDeviceUpdateSignal(forAccount) {
|
|
|
|
if (forAccount === profile.userId) profile.loadDevices()
|
|
|
|
}
|
|
|
|
}
|
2020-07-08 11:33:05 -04:00
|
|
|
}
|