mirror of https://github.com/Nheko-Reborn/nheko
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
318 lines
8.4 KiB
318 lines
8.4 KiB
4 years ago
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||
3 years ago
|
// SPDX-FileCopyrightText: 2022 Nheko Contributors
|
||
4 years ago
|
//
|
||
4 years ago
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||
|
|
||
3 years ago
|
import "./components"
|
||
4 years ago
|
import "./delegates"
|
||
|
import "./device-verification"
|
||
|
import "./emoji"
|
||
4 years ago
|
import "./ui"
|
||
3 years ago
|
import "./voip"
|
||
4 years ago
|
import Qt.labs.platform 1.1 as Platform
|
||
3 years ago
|
import QtQuick 2.15
|
||
3 years ago
|
import QtQuick.Controls 2.5
|
||
4 years ago
|
import QtQuick.Layouts 1.3
|
||
3 years ago
|
import QtQuick.Window 2.13
|
||
3 years ago
|
import im.nheko
|
||
|
import im.nheko2
|
||
5 years ago
|
import im.nheko.EmojiModel 1.0
|
||
5 years ago
|
|
||
4 years ago
|
Item {
|
||
|
id: timelineView
|
||
4 years ago
|
|
||
4 years ago
|
property var room: null
|
||
3 years ago
|
property var roomPreview: null
|
||
4 years ago
|
property bool showBackButton: false
|
||
3 years ago
|
clip: true
|
||
4 years ago
|
|
||
3 years ago
|
Shortcut {
|
||
|
sequence: StandardKey.Close
|
||
|
onActivated: Rooms.resetCurrentRoom()
|
||
|
}
|
||
|
|
||
4 years ago
|
Label {
|
||
3 years ago
|
visible: !room && !TimelineManager.isInitialSync && (!roomPreview || !roomPreview.roomid)
|
||
4 years ago
|
anchors.centerIn: parent
|
||
|
text: qsTr("No room open")
|
||
|
font.pointSize: 24
|
||
3 years ago
|
color: timelineRoot.palette.text
|
||
4 years ago
|
}
|
||
|
|
||
4 years ago
|
Spinner {
|
||
4 years ago
|
visible: TimelineManager.isInitialSync
|
||
4 years ago
|
anchors.centerIn: parent
|
||
3 years ago
|
foreground: timelineRoot.palette.mid
|
||
4 years ago
|
running: TimelineManager.isInitialSync
|
||
4 years ago
|
// height is somewhat arbitrary here... don't set width because width scales w/ height
|
||
|
height: parent.height / 16
|
||
4 years ago
|
z: 3
|
||
4 years ago
|
}
|
||
|
|
||
4 years ago
|
ColumnLayout {
|
||
|
id: timelineLayout
|
||
4 years ago
|
|
||
3 years ago
|
visible: room != null && !room.isSpace
|
||
|
enabled: visible
|
||
4 years ago
|
anchors.fill: parent
|
||
4 years ago
|
spacing: 0
|
||
4 years ago
|
|
||
4 years ago
|
TopBar {
|
||
4 years ago
|
showBackButton: timelineView.showBackButton
|
||
4 years ago
|
}
|
||
|
|
||
4 years ago
|
Rectangle {
|
||
|
Layout.fillWidth: true
|
||
|
height: 1
|
||
4 years ago
|
z: 3
|
||
4 years ago
|
color: Nheko.theme.separator
|
||
4 years ago
|
}
|
||
|
|
||
4 years ago
|
Rectangle {
|
||
|
id: msgView
|
||
4 years ago
|
|
||
4 years ago
|
Layout.fillWidth: true
|
||
|
Layout.fillHeight: true
|
||
3 years ago
|
color: timelineRoot.palette.base
|
||
4 years ago
|
|
||
4 years ago
|
ColumnLayout {
|
||
|
anchors.fill: parent
|
||
|
spacing: 0
|
||
4 years ago
|
|
||
4 years ago
|
StackLayout {
|
||
|
id: stackLayout
|
||
4 years ago
|
|
||
4 years ago
|
currentIndex: 0
|
||
4 years ago
|
|
||
4 years ago
|
Connections {
|
||
4 years ago
|
function onRoomChanged() {
|
||
4 years ago
|
stackLayout.currentIndex = 0;
|
||
4 years ago
|
}
|
||
|
|
||
4 years ago
|
target: timelineView
|
||
4 years ago
|
}
|
||
4 years ago
|
|
||
3 years ago
|
MessageView {
|
||
|
implicitHeight: msgView.height - typingIndicator.height
|
||
|
Layout.fillWidth: true
|
||
|
}
|
||
3 years ago
|
|
||
4 years ago
|
Loader {
|
||
|
source: CallManager.isOnCall && CallManager.callType != CallType.VOICE ? "voip/VideoCall.qml" : ""
|
||
|
onLoaded: TimelineManager.setVideoCallItem()
|
||
4 years ago
|
}
|
||
4 years ago
|
|
||
|
}
|
||
|
|
||
4 years ago
|
TypingIndicator {
|
||
|
id: typingIndicator
|
||
|
}
|
||
4 years ago
|
|
||
4 years ago
|
}
|
||
|
|
||
4 years ago
|
}
|
||
4 years ago
|
|
||
4 years ago
|
CallInviteBar {
|
||
|
id: callInviteBar
|
||
4 years ago
|
|
||
4 years ago
|
Layout.fillWidth: true
|
||
|
z: 3
|
||
|
}
|
||
4 years ago
|
|
||
4 years ago
|
ActiveCallBar {
|
||
|
Layout.fillWidth: true
|
||
|
z: 3
|
||
|
}
|
||
|
|
||
|
Rectangle {
|
||
|
Layout.fillWidth: true
|
||
|
z: 3
|
||
|
height: 1
|
||
4 years ago
|
color: Nheko.theme.separator
|
||
4 years ago
|
}
|
||
4 years ago
|
|
||
3 years ago
|
|
||
3 years ago
|
UploadBox {
|
||
3 years ago
|
}
|
||
|
|
||
3 years ago
|
NotificationWarning {
|
||
|
}
|
||
|
|
||
4 years ago
|
ReplyPopup {
|
||
4 years ago
|
}
|
||
4 years ago
|
|
||
4 years ago
|
MessageInput {
|
||
4 years ago
|
}
|
||
|
|
||
4 years ago
|
}
|
||
4 years ago
|
|
||
3 years ago
|
ColumnLayout {
|
||
3 years ago
|
id: preview
|
||
|
|
||
3 years ago
|
property string roomId: room ? room.roomId : (roomPreview ? roomPreview.roomid : "")
|
||
3 years ago
|
property string roomName: room ? room.roomName : (roomPreview ? roomPreview.roomName : "")
|
||
|
property string roomTopic: room ? room.roomTopic : (roomPreview ? roomPreview.roomTopic : "")
|
||
|
property string avatarUrl: room ? room.roomAvatarUrl : (roomPreview ? roomPreview.roomAvatarUrl : "")
|
||
|
|
||
|
visible: room != null && room.isSpace || roomPreview != null
|
||
3 years ago
|
enabled: visible
|
||
|
anchors.fill: parent
|
||
|
anchors.margins: Nheko.paddingLarge
|
||
|
spacing: Nheko.paddingLarge
|
||
|
|
||
3 years ago
|
Item {
|
||
|
Layout.fillHeight: true
|
||
|
}
|
||
|
|
||
3 years ago
|
Avatar {
|
||
3 years ago
|
url: parent.avatarUrl.replace("mxc://", "image://MxcImage/")
|
||
3 years ago
|
roomid: parent.roomId
|
||
3 years ago
|
displayName: parent.roomName
|
||
3 years ago
|
height: 130
|
||
|
width: 130
|
||
|
Layout.alignment: Qt.AlignHCenter
|
||
|
enabled: false
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
RowLayout {
|
||
|
spacing: Nheko.paddingMedium
|
||
3 years ago
|
Layout.alignment: Qt.AlignHCenter
|
||
3 years ago
|
|
||
|
MatrixText {
|
||
|
text: preview.roomName == "" ? qsTr("No preview available") : preview.roomName
|
||
|
font.pixelSize: 24
|
||
|
}
|
||
|
|
||
|
ImageButton {
|
||
|
image: ":/icons/icons/ui/settings.svg"
|
||
|
visible: !!room
|
||
|
hoverEnabled: true
|
||
|
ToolTip.visible: hovered
|
||
|
ToolTip.text: qsTr("Settings")
|
||
|
onClicked: TimelineManager.openRoomSettings(room.roomId)
|
||
|
}
|
||
|
|
||
3 years ago
|
}
|
||
|
|
||
3 years ago
|
RowLayout {
|
||
3 years ago
|
visible: !!room
|
||
3 years ago
|
spacing: Nheko.paddingMedium
|
||
3 years ago
|
Layout.alignment: Qt.AlignHCenter
|
||
3 years ago
|
|
||
|
MatrixText {
|
||
|
text: qsTr("%1 member(s)").arg(room ? room.roomMemberCount : 0)
|
||
|
cursorShape: Qt.PointingHandCursor
|
||
|
}
|
||
|
|
||
|
ImageButton {
|
||
|
image: ":/icons/icons/ui/people.svg"
|
||
|
hoverEnabled: true
|
||
|
ToolTip.visible: hovered
|
||
|
ToolTip.text: qsTr("View members of %1").arg(room.roomName)
|
||
|
onClicked: TimelineManager.openRoomMembers(room)
|
||
|
}
|
||
|
|
||
3 years ago
|
}
|
||
|
|
||
|
ScrollView {
|
||
|
Layout.alignment: Qt.AlignHCenter
|
||
3 years ago
|
Layout.fillWidth: true
|
||
|
Layout.leftMargin: Nheko.paddingLarge
|
||
|
Layout.rightMargin: Nheko.paddingLarge
|
||
3 years ago
|
|
||
|
TextArea {
|
||
3 years ago
|
text: TimelineManager.escapeEmoji(preview.roomTopic)
|
||
3 years ago
|
wrapMode: TextEdit.WordWrap
|
||
|
textFormat: TextEdit.RichText
|
||
|
readOnly: true
|
||
|
background: null
|
||
|
selectByMouse: true
|
||
3 years ago
|
color: timelineRoot.palette.text
|
||
3 years ago
|
horizontalAlignment: TextEdit.AlignHCenter
|
||
|
onLinkActivated: Nheko.openLink(link)
|
||
|
|
||
|
CursorShape {
|
||
|
anchors.fill: parent
|
||
|
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
3 years ago
|
FlatButton {
|
||
|
visible: roomPreview && !roomPreview.isInvite
|
||
|
Layout.alignment: Qt.AlignHCenter
|
||
|
text: qsTr("join the conversation")
|
||
|
onClicked: Rooms.joinPreview(roomPreview.roomid)
|
||
|
}
|
||
|
|
||
|
FlatButton {
|
||
|
visible: roomPreview && roomPreview.isInvite
|
||
|
Layout.alignment: Qt.AlignHCenter
|
||
|
text: qsTr("accept invite")
|
||
|
onClicked: Rooms.acceptInvite(roomPreview.roomid)
|
||
|
}
|
||
|
|
||
|
FlatButton {
|
||
|
visible: roomPreview && roomPreview.isInvite
|
||
|
Layout.alignment: Qt.AlignHCenter
|
||
|
text: qsTr("decline invite")
|
||
|
onClicked: Rooms.declineInvite(roomPreview.roomid)
|
||
|
}
|
||
|
|
||
|
Item {
|
||
|
visible: room != null
|
||
|
Layout.preferredHeight: Math.ceil(fontMetrics.lineSpacing * 2)
|
||
|
}
|
||
|
|
||
3 years ago
|
Item {
|
||
|
Layout.fillHeight: true
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
3 years ago
|
ImageButton {
|
||
|
id: backToRoomsButton
|
||
|
|
||
|
anchors.top: parent.top
|
||
|
anchors.left: parent.left
|
||
|
anchors.margins: Nheko.paddingMedium
|
||
|
width: Nheko.avatarSize
|
||
|
height: Nheko.avatarSize
|
||
3 years ago
|
visible: (room == null || room.isSpace) && showBackButton
|
||
3 years ago
|
enabled: visible
|
||
3 years ago
|
image: ":/icons/icons/ui/angle-arrow-left.svg"
|
||
3 years ago
|
ToolTip.visible: hovered
|
||
|
ToolTip.text: qsTr("Back to room list")
|
||
|
onClicked: Rooms.resetCurrentRoom()
|
||
|
}
|
||
|
|
||
4 years ago
|
NhekoDropArea {
|
||
4 years ago
|
anchors.fill: parent
|
||
3 years ago
|
roomid: room ? room.roomId : ""
|
||
4 years ago
|
}
|
||
|
|
||
3 years ago
|
Connections {
|
||
|
function onOpenReadReceiptsDialog(rr) {
|
||
|
var dialog = readReceiptsDialog.createObject(timelineRoot, {
|
||
|
"readReceipts": rr,
|
||
|
"room": room
|
||
|
});
|
||
|
dialog.show();
|
||
3 years ago
|
timelineRoot.destroyOnClose(dialog);
|
||
3 years ago
|
}
|
||
|
|
||
3 years ago
|
function onShowRawMessageDialog(rawMessage) {
|
||
|
var dialog = rawMessageDialog.createObject(timelineRoot, {
|
||
|
"rawMessage": rawMessage
|
||
|
});
|
||
|
dialog.show();
|
||
3 years ago
|
timelineRoot.destroyOnClose(dialog);
|
||
3 years ago
|
}
|
||
|
|
||
3 years ago
|
target: room
|
||
|
}
|
||
|
|
||
5 years ago
|
}
|