2018-12-07 01:18:42 +00:00
|
|
|
import QtQuick 2.12
|
2018-12-22 14:25:03 +00:00
|
|
|
import QtQuick.Controls 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
import QtQuick.Controls.Material 2.12
|
2018-11-22 09:15:14 +00:00
|
|
|
import QtGraphicalEffects 1.0
|
2018-12-15 14:29:51 +00:00
|
|
|
import Qt.labs.platform 1.0 as Platform
|
2018-11-22 09:15:14 +00:00
|
|
|
|
|
|
|
import Spectral 0.1
|
|
|
|
import Spectral.Setting 0.1
|
|
|
|
|
|
|
|
import Spectral.Component 2.0
|
2019-04-26 11:59:01 +00:00
|
|
|
import Spectral.Dialog 2.0
|
2019-04-22 01:28:33 +00:00
|
|
|
import Spectral.Effect 2.0
|
2018-11-22 09:15:14 +00:00
|
|
|
import Spectral.Font 0.1
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
readonly property bool avatarVisible: !sentByMe && (aboveAuthor !== author || aboveSection !== section || aboveEventType === "state" || aboveEventType === "emote" || aboveEventType === "other")
|
|
|
|
readonly property bool sentByMe: author === currentRoom.localUser
|
|
|
|
|
2018-12-15 14:29:51 +00:00
|
|
|
property bool openOnFinished: false
|
|
|
|
readonly property bool downloaded: progressInfo && progressInfo.completed
|
2018-11-22 09:15:14 +00:00
|
|
|
|
|
|
|
id: root
|
|
|
|
|
|
|
|
spacing: 0
|
|
|
|
|
2018-12-15 14:29:51 +00:00
|
|
|
onDownloadedChanged: if (downloaded && openOnFinished) openSavedFile()
|
|
|
|
|
2018-11-22 09:15:14 +00:00
|
|
|
Label {
|
|
|
|
Layout.leftMargin: 48
|
|
|
|
|
|
|
|
text: author.displayName
|
|
|
|
|
|
|
|
visible: avatarVisible
|
|
|
|
|
|
|
|
font.pixelSize: 13
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
Layout.alignment: sentByMe ? Qt.AlignRight : Qt.AlignLeft
|
|
|
|
|
|
|
|
z: -5
|
|
|
|
|
|
|
|
id: messageRow
|
|
|
|
|
|
|
|
spacing: 4
|
|
|
|
|
2018-12-03 11:55:42 +00:00
|
|
|
Avatar {
|
2018-11-22 09:15:14 +00:00
|
|
|
Layout.preferredWidth: 32
|
|
|
|
Layout.preferredHeight: 32
|
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
|
|
|
|
visible: avatarVisible
|
|
|
|
hint: author.displayName
|
2019-01-04 12:17:26 +00:00
|
|
|
source: author.avatarMediaId
|
2019-04-26 12:18:08 +00:00
|
|
|
|
|
|
|
Component {
|
|
|
|
id: userDetailDialog
|
|
|
|
|
|
|
|
UserDetailDialog {}
|
|
|
|
}
|
|
|
|
|
|
|
|
RippleEffect {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
circular: true
|
|
|
|
|
|
|
|
onClicked: userDetailDialog.createObject(ApplicationWindow.overlay, {"room": currentRoom, "user": author}).open()
|
|
|
|
}
|
2018-11-22 09:15:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
Layout.preferredWidth: 32
|
|
|
|
Layout.preferredHeight: 32
|
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
|
|
|
|
visible: !(sentByMe || avatarVisible)
|
|
|
|
|
|
|
|
text: Qt.formatDateTime(time, "hh:mm")
|
|
|
|
color: "#5B7480"
|
|
|
|
|
|
|
|
font.pixelSize: 10
|
|
|
|
horizontalAlignment: Label.AlignHCenter
|
|
|
|
verticalAlignment: Label.AlignVCenter
|
|
|
|
}
|
|
|
|
|
2019-04-22 01:28:33 +00:00
|
|
|
BusyIndicator {
|
|
|
|
Layout.preferredWidth: 64
|
|
|
|
Layout.preferredHeight: 64
|
|
|
|
|
|
|
|
visible: img.status == Image.Loading
|
|
|
|
}
|
|
|
|
|
2018-11-22 09:15:14 +00:00
|
|
|
Image {
|
|
|
|
Layout.maximumWidth: messageListView.width - (!sentByMe ? 32 + messageRow.spacing : 0) - 48
|
|
|
|
|
|
|
|
id: img
|
|
|
|
|
2019-04-22 01:28:33 +00:00
|
|
|
source: "image://mxc/" +
|
2019-04-23 02:57:35 +00:00
|
|
|
(content.info && content.info.thumbnail_info ?
|
|
|
|
content.thumbnailMediaId : content.mediaId)
|
|
|
|
|
|
|
|
sourceSize.width: 720
|
|
|
|
sourceSize.height: 720
|
|
|
|
|
|
|
|
fillMode: Image.PreserveAspectCrop
|
2018-11-22 09:15:14 +00:00
|
|
|
|
|
|
|
layer.enabled: true
|
|
|
|
layer.effect: OpacityMask {
|
|
|
|
maskSource: Rectangle {
|
2019-01-04 12:17:26 +00:00
|
|
|
width: img.width
|
|
|
|
height: img.height
|
|
|
|
radius: 24
|
|
|
|
}
|
2018-11-22 09:15:14 +00:00
|
|
|
}
|
|
|
|
|
2019-04-23 02:57:35 +00:00
|
|
|
Component {
|
|
|
|
id: fullScreenImage
|
|
|
|
|
|
|
|
FullScreenImage {
|
|
|
|
imageUrl: "image://mxc/" + content.mediaId
|
|
|
|
sourceWidth: content.info.w
|
|
|
|
sourceHeight: content.info.h
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-03 11:35:50 +00:00
|
|
|
Rectangle {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
color: "transparent"
|
|
|
|
radius: 24
|
2019-04-22 01:28:33 +00:00
|
|
|
antialiasing: true
|
2019-03-03 11:35:50 +00:00
|
|
|
|
2019-04-22 01:28:33 +00:00
|
|
|
border.width: 4
|
2019-03-03 11:35:50 +00:00
|
|
|
border.color: MPalette.banner
|
|
|
|
}
|
|
|
|
|
2019-04-22 01:28:33 +00:00
|
|
|
RippleEffect {
|
2018-11-22 09:15:14 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
id: messageMouseArea
|
|
|
|
|
2019-04-23 02:57:35 +00:00
|
|
|
onPrimaryClicked: {
|
|
|
|
var window = fullScreenImage.createObject()
|
|
|
|
window.show()
|
|
|
|
}
|
|
|
|
|
2018-12-15 14:29:51 +00:00
|
|
|
onSecondaryClicked: messageContextMenu.popup()
|
|
|
|
|
2019-04-26 11:59:01 +00:00
|
|
|
Component {
|
|
|
|
id: messageSourceDialog
|
|
|
|
|
|
|
|
MessageSourceDialog {}
|
|
|
|
}
|
|
|
|
|
2018-12-15 14:29:51 +00:00
|
|
|
Menu {
|
|
|
|
id: messageContextMenu
|
|
|
|
|
|
|
|
MenuItem {
|
|
|
|
text: "View Source"
|
|
|
|
|
2019-04-26 11:59:01 +00:00
|
|
|
onTriggered: messageSourceDialog.createObject(ApplicationWindow.overlay, {"sourceText": toolTip}).open()
|
2018-12-15 14:29:51 +00:00
|
|
|
}
|
2019-04-23 02:57:35 +00:00
|
|
|
|
2018-12-15 14:29:51 +00:00
|
|
|
MenuItem {
|
|
|
|
text: "Open Externally"
|
|
|
|
|
|
|
|
onTriggered: downloadAndOpen()
|
|
|
|
}
|
2019-04-23 02:57:35 +00:00
|
|
|
|
2018-12-15 14:29:51 +00:00
|
|
|
MenuItem {
|
|
|
|
text: "Save As"
|
|
|
|
|
|
|
|
onTriggered: saveFileAs()
|
|
|
|
}
|
2019-04-23 02:57:35 +00:00
|
|
|
|
2018-12-15 14:29:51 +00:00
|
|
|
MenuItem {
|
|
|
|
text: "Reply"
|
|
|
|
|
|
|
|
onTriggered: {
|
|
|
|
roomPanelInput.replyUser = author
|
|
|
|
roomPanelInput.replyEventID = eventId
|
|
|
|
roomPanelInput.replyContent = message
|
|
|
|
roomPanelInput.isReply = true
|
|
|
|
roomPanelInput.focus()
|
|
|
|
}
|
|
|
|
}
|
2019-04-23 02:57:35 +00:00
|
|
|
|
2018-12-15 14:29:51 +00:00
|
|
|
MenuItem {
|
|
|
|
text: "Redact"
|
|
|
|
|
|
|
|
onTriggered: currentRoom.redactEvent(eventId)
|
|
|
|
}
|
2018-11-22 09:15:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-12-15 14:29:51 +00:00
|
|
|
|
|
|
|
function saveFileAs() { currentRoom.saveFileAs(eventId) }
|
|
|
|
|
|
|
|
function downloadAndOpen()
|
|
|
|
{
|
|
|
|
if (downloaded) openSavedFile()
|
|
|
|
else
|
|
|
|
{
|
|
|
|
openOnFinished = true
|
|
|
|
currentRoom.downloadFile(eventId, Platform.StandardPaths.writableLocation(Platform.StandardPaths.CacheLocation) + "/" + eventId.replace(":", "_") + (message || ".tmp"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function openSavedFile()
|
|
|
|
{
|
|
|
|
if (Qt.openUrlExternally(progressInfo.localPath)) return;
|
|
|
|
if (Qt.openUrlExternally(progressInfo.localDir)) return;
|
|
|
|
}
|
2018-11-22 09:15:14 +00:00
|
|
|
}
|