2021-03-05 00:35:15 +01:00
|
|
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
2021-03-07 05:57:56 +01:00
|
|
|
//
|
2021-03-05 00:35:15 +01:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2021-03-14 22:22:52 +01:00
|
|
|
import Qt.labs.platform 1.1 as Platform
|
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.12
|
2021-01-12 15:03:39 +01:00
|
|
|
import QtQuick.Layouts 1.2
|
2020-10-26 14:57:54 +01:00
|
|
|
import im.nheko 1.0
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: topBar
|
|
|
|
|
2021-06-08 22:18:51 +02:00
|
|
|
property bool showBackButton: false
|
2021-07-09 09:36:33 +02:00
|
|
|
property string roomName: room ? room.roomName : qsTr("No room selected")
|
|
|
|
property string avatarUrl: room ? room.roomAvatarUrl : ""
|
|
|
|
property string roomTopic: room ? room.roomTopic : ""
|
2021-08-13 23:13:09 +02:00
|
|
|
property bool isEncrypted: room ? room.isEncrypted : false
|
|
|
|
property int trustlevel: room ? room.trustlevel : Crypto.Unverified
|
2021-06-08 22:18:51 +02:00
|
|
|
|
2020-10-26 14:57:54 +01:00
|
|
|
Layout.fillWidth: true
|
2021-05-14 23:35:34 +02:00
|
|
|
implicitHeight: topLayout.height + Nheko.paddingMedium * 2
|
2020-10-26 14:57:54 +01:00
|
|
|
z: 3
|
2021-05-13 08:23:56 +02:00
|
|
|
color: Nheko.colors.window
|
2020-10-26 14:57:54 +01:00
|
|
|
|
2021-03-14 22:22:52 +01:00
|
|
|
TapHandler {
|
2021-04-11 22:24:39 +02:00
|
|
|
onSingleTapped: {
|
2021-07-09 09:36:33 +02:00
|
|
|
if (room)
|
2021-07-22 00:56:20 +02:00
|
|
|
TimelineManager.openRoomSettings(room.roomId);
|
2021-07-09 09:36:33 +02:00
|
|
|
|
2021-04-11 22:24:39 +02:00
|
|
|
eventPoint.accepted = true;
|
|
|
|
}
|
|
|
|
gesturePolicy: TapHandler.ReleaseWithinBounds
|
2020-10-26 14:57:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
GridLayout {
|
|
|
|
id: topLayout
|
|
|
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2021-05-14 23:35:34 +02:00
|
|
|
anchors.margins: Nheko.paddingMedium
|
2020-10-26 14:57:54 +01:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
|
|
|
ImageButton {
|
|
|
|
id: backToRoomsButton
|
|
|
|
|
|
|
|
Layout.column: 0
|
|
|
|
Layout.row: 0
|
|
|
|
Layout.rowSpan: 2
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2021-05-13 11:32:20 +02:00
|
|
|
width: Nheko.avatarSize
|
|
|
|
height: Nheko.avatarSize
|
2021-06-08 22:18:51 +02:00
|
|
|
visible: showBackButton
|
2020-10-26 14:57:54 +01:00
|
|
|
image: ":/icons/icons/ui/angle-pointing-to-left.png"
|
|
|
|
ToolTip.visible: hovered
|
|
|
|
ToolTip.text: qsTr("Back to room list")
|
2021-06-08 22:18:51 +02:00
|
|
|
onClicked: Rooms.resetCurrentRoom()
|
2020-10-26 14:57:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Avatar {
|
|
|
|
Layout.column: 1
|
|
|
|
Layout.row: 0
|
|
|
|
Layout.rowSpan: 2
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2021-05-13 11:32:20 +02:00
|
|
|
width: Nheko.avatarSize
|
|
|
|
height: Nheko.avatarSize
|
2021-07-09 09:36:33 +02:00
|
|
|
url: avatarUrl.replace("mxc://", "image://MxcImage/")
|
|
|
|
displayName: roomName
|
|
|
|
onClicked: {
|
2021-07-10 17:21:15 +02:00
|
|
|
if (room)
|
2021-07-22 00:56:20 +02:00
|
|
|
TimelineManager.openRoomSettings(room.roomId);
|
2021-07-10 17:21:15 +02:00
|
|
|
|
2021-07-09 09:36:33 +02:00
|
|
|
}
|
2020-10-26 14:57:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.column: 2
|
|
|
|
Layout.row: 0
|
2021-05-13 08:23:56 +02:00
|
|
|
color: Nheko.colors.text
|
2020-10-26 14:57:54 +01:00
|
|
|
font.pointSize: fontMetrics.font.pointSize * 1.1
|
2021-07-09 09:36:33 +02:00
|
|
|
text: roomName
|
2020-12-13 16:05:48 +01:00
|
|
|
maximumLineCount: 1
|
2021-04-27 11:08:21 +02:00
|
|
|
elide: Text.ElideRight
|
|
|
|
textFormat: Text.RichText
|
2020-10-26 14:57:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
MatrixText {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.column: 2
|
|
|
|
Layout.row: 1
|
|
|
|
Layout.maximumHeight: fontMetrics.lineSpacing * 2 // show 2 lines
|
|
|
|
clip: true
|
2021-07-09 09:36:33 +02:00
|
|
|
text: roomTopic
|
2020-10-26 14:57:54 +01:00
|
|
|
}
|
|
|
|
|
2021-08-13 23:13:09 +02:00
|
|
|
EncryptionIndicator {
|
|
|
|
Layout.column: 3
|
|
|
|
Layout.row: 0
|
|
|
|
Layout.rowSpan: 2
|
|
|
|
visible: isEncrypted
|
|
|
|
encrypted: isEncrypted
|
|
|
|
trust: trustlevel
|
|
|
|
ToolTip.text: {
|
|
|
|
if (!encrypted)
|
|
|
|
return qsTr("This room is not encrypted!");
|
|
|
|
|
|
|
|
switch (trust) {
|
|
|
|
case Crypto.Verified:
|
|
|
|
return qsTr("This room contains only verified devices.");
|
|
|
|
case Crypto.TOFU:
|
|
|
|
return qsTr("This rooms contain verified devices and devices which have never changed their master key.");
|
|
|
|
default:
|
|
|
|
return qsTr("This room contains unverified devices!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-26 14:57:54 +01:00
|
|
|
ImageButton {
|
|
|
|
id: roomOptionsButton
|
|
|
|
|
2021-07-09 09:36:33 +02:00
|
|
|
visible: !!room
|
2021-08-13 23:13:09 +02:00
|
|
|
Layout.column: 4
|
2020-10-26 14:57:54 +01:00
|
|
|
Layout.row: 0
|
|
|
|
Layout.rowSpan: 2
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
image: ":/icons/icons/ui/vertical-ellipsis.png"
|
|
|
|
ToolTip.visible: hovered
|
|
|
|
ToolTip.text: qsTr("Room options")
|
2021-03-14 22:22:52 +01:00
|
|
|
onClicked: roomOptionsMenu.open(roomOptionsButton)
|
2020-10-26 14:57:54 +01:00
|
|
|
|
2021-03-14 22:22:52 +01:00
|
|
|
Platform.Menu {
|
2020-10-26 14:57:54 +01:00
|
|
|
id: roomOptionsMenu
|
|
|
|
|
2021-03-14 22:22:52 +01:00
|
|
|
Platform.MenuItem {
|
2021-05-28 22:14:59 +02:00
|
|
|
visible: room ? room.permissions.canInvite() : false
|
2020-10-26 14:57:54 +01:00
|
|
|
text: qsTr("Invite users")
|
2021-07-22 00:56:20 +02:00
|
|
|
onTriggered: TimelineManager.openInviteUsers(room.roomId)
|
2020-10-26 14:57:54 +01:00
|
|
|
}
|
|
|
|
|
2021-03-14 22:22:52 +01:00
|
|
|
Platform.MenuItem {
|
2020-10-26 14:57:54 +01:00
|
|
|
text: qsTr("Members")
|
2021-08-13 23:58:26 +02:00
|
|
|
onTriggered: TimelineManager.openRoomMembers(room)
|
2020-10-26 14:57:54 +01:00
|
|
|
}
|
|
|
|
|
2021-03-14 22:22:52 +01:00
|
|
|
Platform.MenuItem {
|
2020-10-26 14:57:54 +01:00
|
|
|
text: qsTr("Leave room")
|
2021-07-17 22:56:56 +02:00
|
|
|
onTriggered: TimelineManager.openLeaveRoomDialog(room.roomId)
|
2020-10-26 14:57:54 +01:00
|
|
|
}
|
|
|
|
|
2021-03-14 22:22:52 +01:00
|
|
|
Platform.MenuItem {
|
2020-10-26 14:57:54 +01:00
|
|
|
text: qsTr("Settings")
|
2021-07-22 00:56:20 +02:00
|
|
|
onTriggered: TimelineManager.openRoomSettings(room.roomId)
|
2020-10-26 14:57:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|