matrixion/qml/TimelineView.qml

278 lines
8.3 KiB
QML
Raw Normal View History

2021-03-05 02:35:15 +03:00
// SPDX-FileCopyrightText: 2021 Nheko Contributors
// SPDX-FileCopyrightText: 2022 Nheko Contributors
2021-03-05 02:35:15 +03:00
// SPDX-License-Identifier: GPL-3.0-or-later
2022-04-16 03:13:01 +03:00
import "components"
import "delegates"
import "device-verification"
import "emoji"
import "ui"
import "voip"
2021-03-15 00:22:52 +03:00
import Qt.labs.platform 1.1 as Platform
import QtQuick 2.15
2021-06-13 02:48:11 +03:00
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.3
import QtQuick.Window 2.13
2022-04-14 16:28:17 +03:00
import im.nheko
import im.nheko
Item {
id: timelineView
2021-04-27 12:08:21 +03:00
property var room: null
property var roomPreview: null
2021-06-08 23:18:51 +03:00
property bool showBackButton: false
2022-04-16 03:13:01 +03:00
2022-03-27 22:23:40 +03:00
clip: true
2022-04-03 03:28:44 +03:00
Shortcut {
sequence: StandardKey.Close
2022-04-16 03:13:01 +03:00
2022-04-03 03:28:44 +03:00
onActivated: Rooms.resetCurrentRoom()
}
Label {
anchors.centerIn: parent
2022-04-11 05:18:16 +03:00
color: timelineRoot.palette.text
2022-04-16 03:13:01 +03:00
font.pointSize: 24
text: qsTr("No room open")
visible: !room && !TimelineManager.isInitialSync && (!roomPreview || !roomPreview.roomid)
2021-04-11 17:31:49 +03:00
}
2021-03-12 07:09:57 +03:00
Spinner {
anchors.centerIn: parent
2022-04-11 05:18:16 +03:00
foreground: timelineRoot.palette.mid
2021-03-12 07:09:57 +03:00
// height is somewhat arbitrary here... don't set width because width scales w/ height
height: parent.height / 16
2022-04-16 03:13:01 +03:00
running: TimelineManager.isInitialSync
visible: TimelineManager.isInitialSync
z: 3
}
ColumnLayout {
id: timelineLayout
2020-10-08 22:11:21 +03:00
anchors.fill: parent
2022-04-16 03:13:01 +03:00
enabled: visible
spacing: 0
2022-04-16 03:13:01 +03:00
visible: room != null && !room.isSpace
2021-01-12 22:22:52 +03:00
TopBar {
2021-06-08 23:18:51 +03:00
showBackButton: timelineView.showBackButton
2020-10-08 22:11:21 +03:00
}
Rectangle {
Layout.fillWidth: true
2022-04-16 03:13:01 +03:00
color: Nheko.theme.separator
height: 1
2020-10-08 22:11:21 +03:00
z: 3
}
Rectangle {
id: msgView
Layout.fillHeight: true
2022-04-16 03:13:01 +03:00
Layout.fillWidth: true
2022-04-11 05:18:16 +03:00
color: timelineRoot.palette.base
2020-10-08 22:11:21 +03:00
ColumnLayout {
anchors.fill: parent
spacing: 0
2020-11-15 06:52:49 +03:00
StackLayout {
id: stackLayout
currentIndex: 0
2020-11-15 06:52:49 +03:00
Connections {
function onRoomChanged() {
stackLayout.currentIndex = 0;
2020-10-08 22:11:21 +03:00
}
target: timelineView
}
2021-08-29 20:24:44 +03:00
MessageView {
Layout.fillWidth: true
2022-04-16 03:13:01 +03:00
implicitHeight: msgView.height - typingIndicator.height
2021-08-29 20:24:44 +03:00
}
Loader {
source: CallManager.isOnCall && CallManager.callType != Voip.VOICE ? "voip/VideoCall.qml" : ""
2022-04-16 03:13:01 +03:00
onLoaded: TimelineManager.setVideoCallItem()
2020-10-27 20:14:06 +03:00
}
2020-10-08 22:11:21 +03:00
}
TypingIndicator {
id: typingIndicator
}
2020-12-17 19:25:32 +03:00
}
}
CallInviteBar {
id: callInviteBar
Layout.fillWidth: true
z: 3
}
ActiveCallBar {
Layout.fillWidth: true
z: 3
}
Rectangle {
Layout.fillWidth: true
2021-05-15 00:35:34 +03:00
color: Nheko.theme.separator
2022-04-16 03:13:01 +03:00
height: 1
z: 3
}
UploadBox {
2022-03-21 00:49:33 +03:00
}
NotificationWarning {
}
ReplyPopup {
2021-02-03 03:30:03 +03:00
}
MessageInput {
2020-10-08 22:11:21 +03:00
}
}
2021-06-18 17:22:06 +03:00
ColumnLayout {
id: preview
2022-04-16 03:13:01 +03:00
property string avatarUrl: room ? room.roomAvatarUrl : (roomPreview ? roomPreview.roomAvatarUrl : "")
property string roomId: room ? room.roomId : (roomPreview ? roomPreview.roomid : "")
property string roomName: room ? room.roomName : (roomPreview ? roomPreview.roomName : "")
property string roomTopic: room ? room.roomTopic : (roomPreview ? roomPreview.roomTopic : "")
2021-06-18 17:22:06 +03:00
anchors.fill: parent
anchors.margins: Nheko.paddingLarge
2022-04-16 03:13:01 +03:00
enabled: visible
2021-06-18 17:22:06 +03:00
spacing: Nheko.paddingLarge
2022-04-16 03:13:01 +03:00
visible: room != null && room.isSpace || roomPreview != null
2021-06-18 17:22:06 +03:00
Item {
Layout.fillHeight: true
}
2021-06-18 17:22:06 +03:00
Avatar {
2022-04-16 03:13:01 +03:00
Layout.alignment: Qt.AlignHCenter
displayName: parent.roomName
2022-04-16 03:13:01 +03:00
enabled: false
2021-06-18 17:22:06 +03:00
height: 130
2022-04-16 03:13:01 +03:00
roomid: parent.roomId
url: parent.avatarUrl.replace("mxc://", "image://MxcImage/")
2021-06-18 17:22:06 +03:00
width: 130
}
RowLayout {
2021-06-18 17:22:06 +03:00
Layout.alignment: Qt.AlignHCenter
2022-04-16 03:13:01 +03:00
spacing: Nheko.paddingMedium
MatrixText {
font.pixelSize: 24
2022-04-16 03:13:01 +03:00
text: preview.roomName == "" ? qsTr("No preview available") : preview.roomName
}
ImageButton {
2022-04-16 03:13:01 +03:00
ToolTip.text: qsTr("Settings")
ToolTip.visible: hovered
hoverEnabled: true
image: ":/icons/icons/ui/settings.svg"
visible: !!room
2022-04-16 03:13:01 +03:00
onClicked: TimelineManager.openRoomSettings(room.roomId)
}
2021-06-18 17:22:06 +03:00
}
RowLayout {
2021-06-18 17:22:06 +03:00
Layout.alignment: Qt.AlignHCenter
2022-04-16 03:13:01 +03:00
spacing: Nheko.paddingMedium
visible: !!room
MatrixText {
cursorShape: Qt.PointingHandCursor
2022-04-16 03:13:01 +03:00
text: qsTr("%1 member(s)").arg(room ? room.roomMemberCount : 0)
}
ImageButton {
ToolTip.text: qsTr("View members of %1").arg(room.roomName)
2022-04-16 03:13:01 +03:00
ToolTip.visible: hovered
hoverEnabled: true
image: ":/icons/icons/ui/people.svg"
onClicked: TimelineManager.openRoomMembers(room)
}
2021-06-18 17:22:06 +03:00
}
ScrollView {
Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: true
Layout.leftMargin: Nheko.paddingLarge
Layout.rightMargin: Nheko.paddingLarge
2021-06-18 17:22:06 +03:00
TextArea {
background: null
2022-04-11 05:18:16 +03:00
color: timelineRoot.palette.text
2021-06-18 17:22:06 +03:00
horizontalAlignment: TextEdit.AlignHCenter
2022-04-16 03:13:01 +03:00
readOnly: true
selectByMouse: true
text: TimelineManager.escapeEmoji(preview.roomTopic)
textFormat: TextEdit.RichText
wrapMode: TextEdit.WordWrap
2021-06-18 17:22:06 +03:00
onLinkActivated: Nheko.openLink(link)
NhekoCursorShape {
2021-06-18 17:22:06 +03:00
anchors.fill: parent
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
}
}
}
FlatButton {
Layout.alignment: Qt.AlignHCenter
text: qsTr("join the conversation")
2022-04-16 03:13:01 +03:00
visible: roomPreview && !roomPreview.isInvite
onClicked: Rooms.joinPreview(roomPreview.roomid)
}
FlatButton {
Layout.alignment: Qt.AlignHCenter
text: qsTr("accept invite")
2022-04-16 03:13:01 +03:00
visible: roomPreview && roomPreview.isInvite
onClicked: Rooms.acceptInvite(roomPreview.roomid)
}
FlatButton {
Layout.alignment: Qt.AlignHCenter
text: qsTr("decline invite")
2022-04-16 03:13:01 +03:00
visible: roomPreview && roomPreview.isInvite
onClicked: Rooms.declineInvite(roomPreview.roomid)
}
Item {
Layout.preferredHeight: Math.ceil(fontMetrics.lineSpacing * 2)
2022-04-16 03:13:01 +03:00
visible: room != null
}
2021-06-18 17:22:06 +03:00
Item {
Layout.fillHeight: true
}
}
ImageButton {
id: backToRoomsButton
2022-04-16 03:13:01 +03:00
ToolTip.text: qsTr("Back to room list")
ToolTip.visible: hovered
anchors.left: parent.left
anchors.margins: Nheko.paddingMedium
2022-04-16 03:13:01 +03:00
anchors.top: parent.top
enabled: visible
2022-04-16 03:13:01 +03:00
height: Nheko.avatarSize
2021-11-14 04:23:10 +03:00
image: ":/icons/icons/ui/angle-arrow-left.svg"
2022-04-16 03:13:01 +03:00
visible: (room == null || room.isSpace) && showBackButton
width: Nheko.avatarSize
onClicked: Rooms.resetCurrentRoom()
}
NhekoDropArea {
anchors.fill: parent
2021-07-17 23:56:56 +03:00
roomid: room ? room.roomId : ""
}
Connections {
function onOpenReadReceiptsDialog(rr) {
var dialog = readReceiptsDialog.createObject(timelineRoot, {
2022-04-16 03:13:01 +03:00
"readReceipts": rr,
"room": room
});
dialog.show();
timelineRoot.destroyOnClose(dialog);
}
2021-07-31 05:13:58 +03:00
function onShowRawMessageDialog(rawMessage) {
var dialog = rawMessageDialog.createObject(timelineRoot, {
2022-04-16 03:13:01 +03:00
"rawMessage": rawMessage
});
2021-07-31 05:13:58 +03:00
dialog.show();
timelineRoot.destroyOnClose(dialog);
2021-07-31 05:13:58 +03:00
}
target: room
}
2019-08-30 20:29:25 +03:00
}