matrixion/resources/qml/TimelineView.qml

252 lines
6.3 KiB
QML
Raw Normal View History

2020-10-08 22:11:21 +03:00
import "./delegates"
import "./device-verification"
import "./emoji"
import QtGraphicalEffects 1.0
import QtQuick 2.9
import QtQuick.Controls 2.3
2020-10-27 20:14:06 +03:00
import QtQuick.Layouts 1.3
2019-09-18 21:34:30 +03:00
import QtQuick.Window 2.2
import im.nheko 1.0
2020-05-14 03:19:15 +03:00
import im.nheko.EmojiModel 1.0
Page {
2020-10-08 22:11:21 +03:00
id: timelineRoot
property var colors: currentActivePalette
property var systemInactive
property var inactiveColors: currentInactivePalette ? currentInactivePalette : systemInactive
property int avatarSize: 40
property real highlightHue: colors.highlight.hslHue
property real highlightSat: colors.highlight.hslSaturation
property real highlightLight: colors.highlight.hslLightness
palette: colors
FontMetrics {
id: fontMetrics
}
EmojiPicker {
id: emojiPopup
width: 7 * 52 + 20
height: 6 * 52
colors: palette
model: EmojiProxyModel {
category: EmojiCategory.People
sourceModel: EmojiModel {
}
}
}
Component {
id: userProfileComponent
UserProfile {
}
}
2020-10-08 22:11:21 +03:00
Menu {
id: messageContextMenu
property string eventId
property int eventType
property bool isEncrypted
function show(eventId_, eventType_, isEncrypted_, showAt_, position) {
eventId = eventId_;
eventType = eventType_;
isEncrypted = isEncrypted_;
if (position)
popup(position, showAt_);
else
popup(showAt_);
}
modal: true
MenuItem {
text: qsTr("React")
2020-11-16 20:41:29 +03:00
onClicked: emojiPopup.show(messageContextMenu.parent, function(emoji) {
TimelineManager.queueReactionMessage(messageContextMenu.eventId, emoji);
})
2020-10-08 22:11:21 +03:00
}
MenuItem {
text: qsTr("Reply")
2020-10-26 23:44:31 +03:00
onClicked: TimelineManager.timeline.replyAction(messageContextMenu.eventId)
2020-10-08 22:11:21 +03:00
}
MenuItem {
text: qsTr("Read receipts")
2020-10-26 23:44:31 +03:00
onTriggered: TimelineManager.timeline.readReceiptsAction(messageContextMenu.eventId)
2020-10-08 22:11:21 +03:00
}
MenuItem {
text: qsTr("Mark as read")
}
MenuItem {
text: qsTr("View raw message")
2020-10-26 23:44:31 +03:00
onTriggered: TimelineManager.timeline.viewRawMessage(messageContextMenu.eventId)
2020-10-08 22:11:21 +03:00
}
MenuItem {
visible: messageContextMenu.isEncrypted
height: visible ? implicitHeight : 0
text: qsTr("View decrypted raw message")
2020-10-26 23:44:31 +03:00
onTriggered: TimelineManager.timeline.viewDecryptedRawMessage(messageContextMenu.eventId)
2020-10-08 22:11:21 +03:00
}
MenuItem {
text: qsTr("Redact message")
2020-10-26 23:44:31 +03:00
onTriggered: TimelineManager.timeline.redactEvent(messageContextMenu.eventId)
2020-10-08 22:11:21 +03:00
}
MenuItem {
visible: messageContextMenu.eventType == MtxEvent.ImageMessage || messageContextMenu.eventType == MtxEvent.VideoMessage || messageContextMenu.eventType == MtxEvent.AudioMessage || messageContextMenu.eventType == MtxEvent.FileMessage || messageContextMenu.eventType == MtxEvent.Sticker
height: visible ? implicitHeight : 0
text: qsTr("Save as")
onTriggered: TimelineManager.timeline.saveMedia(messageContextMenu.eventId)
}
}
Rectangle {
anchors.fill: parent
color: colors.window
Component {
id: deviceVerificationDialog
DeviceVerification {
}
}
Connections {
2020-11-15 00:38:17 +03:00
target: TimelineManager
onNewDeviceVerificationRequest: {
2020-10-08 22:11:21 +03:00
var dialog = deviceVerificationDialog.createObject(timelineRoot, {
"flow": flow
});
dialog.show();
}
}
Connections {
2020-11-15 00:38:17 +03:00
target: TimelineManager.timeline
onOpenProfile: {
2020-10-08 22:11:21 +03:00
var userProfile = userProfileComponent.createObject(timelineRoot, {
"profile": profile
});
userProfile.show();
}
}
Label {
visible: !TimelineManager.timeline && !TimelineManager.isInitialSync
anchors.centerIn: parent
text: qsTr("No room open")
font.pointSize: 24
color: colors.text
}
BusyIndicator {
visible: running
anchors.centerIn: parent
running: TimelineManager.isInitialSync
height: 200
width: 200
z: 3
}
ColumnLayout {
2020-10-18 23:30:42 +03:00
visible: TimelineManager.timeline != null
2020-10-08 22:11:21 +03:00
anchors.fill: parent
2020-10-26 15:50:44 +03:00
spacing: 0
2020-10-08 22:11:21 +03:00
TopBar {
2020-10-08 22:11:21 +03:00
}
2020-10-26 15:50:44 +03:00
Rectangle {
2020-10-08 22:11:21 +03:00
Layout.fillWidth: true
2020-10-26 15:50:44 +03:00
height: 1
2020-10-08 22:11:21 +03:00
z: 3
2020-10-26 15:50:44 +03:00
color: colors.mid
2020-10-08 22:11:21 +03:00
}
2020-10-26 15:50:44 +03:00
Rectangle {
2020-10-08 22:11:21 +03:00
Layout.fillWidth: true
Layout.fillHeight: true
2020-10-26 15:50:44 +03:00
color: colors.base
2020-10-27 20:14:06 +03:00
ColumnLayout {
2020-10-26 15:50:44 +03:00
anchors.fill: parent
spacing: 0
2020-10-27 20:14:06 +03:00
StackLayout {
id: stackLayout
2020-11-15 06:52:49 +03:00
currentIndex: 0
2020-10-08 22:11:21 +03:00
Connections {
function onActiveTimelineChanged() {
stackLayout.currentIndex = 0;
2020-10-08 22:11:21 +03:00
}
2020-11-15 06:52:49 +03:00
target: TimelineManager
2020-10-08 22:11:21 +03:00
}
MessageView {
Layout.fillWidth: true
Layout.fillHeight: true
2020-10-08 22:11:21 +03:00
}
Loader {
source: TimelineManager.onVideoCall ? "VideoCall.qml" : ""
onLoaded: TimelineManager.setVideoCallItem()
2020-10-27 20:14:06 +03:00
}
2020-11-15 06:52:49 +03:00
2020-10-08 22:11:21 +03:00
}
TypingIndicator {
2020-10-27 20:14:06 +03:00
}
2020-10-08 22:11:21 +03:00
}
}
ActiveCallBar {
Layout.fillWidth: true
z: 3
}
2020-10-26 15:50:44 +03:00
Rectangle {
2020-10-08 22:11:21 +03:00
Layout.fillWidth: true
z: 3
2020-10-26 15:50:44 +03:00
height: 1
color: colors.mid
2020-10-08 22:11:21 +03:00
}
ReplyPopup {
}
2020-10-26 15:50:44 +03:00
2020-11-01 01:24:07 +03:00
MessageInput {
}
2020-10-26 15:50:44 +03:00
2020-10-08 22:11:21 +03:00
}
}
systemInactive: SystemPalette {
colorGroup: SystemPalette.Disabled
}
2019-08-30 20:29:25 +03:00
}