2018-07-12 01:44:41 +00:00
|
|
|
import QtQuick 2.9
|
|
|
|
import QtQuick.Controls 2.2
|
|
|
|
import QtQuick.Controls.Material 2.2
|
2018-08-05 16:53:22 +00:00
|
|
|
import Matrique 0.1
|
2018-08-21 14:57:15 +00:00
|
|
|
import MatriqueSettings 0.1
|
2018-07-09 14:00:27 +00:00
|
|
|
|
|
|
|
Item {
|
2018-08-14 06:05:41 +00:00
|
|
|
readonly property bool hidden: marks === EventStatus.Redacted || marks === EventStatus.Hidden
|
2018-07-10 04:18:21 +00:00
|
|
|
|
2018-07-20 04:14:02 +00:00
|
|
|
readonly property bool darkTheme: Material.theme == Material.Dark
|
|
|
|
readonly property color background: darkTheme ? "#242424" : "lightgrey"
|
2018-07-09 14:00:27 +00:00
|
|
|
|
2018-08-01 12:26:29 +00:00
|
|
|
readonly property bool sentByMe: author === currentRoom.localUser
|
|
|
|
readonly property bool isState: eventType === "state" || eventType === "emote"
|
|
|
|
|
2018-08-14 06:05:41 +00:00
|
|
|
id: messageDelegate
|
2018-08-03 12:58:12 +00:00
|
|
|
|
2018-07-20 04:14:02 +00:00
|
|
|
z: -5
|
2018-07-10 04:18:21 +00:00
|
|
|
width: delegateLoader.width
|
|
|
|
height: delegateLoader.height
|
2018-07-09 14:00:27 +00:00
|
|
|
|
2018-08-01 12:26:29 +00:00
|
|
|
anchors.right: !isState && sentByMe ? parent.right : undefined
|
|
|
|
anchors.horizontalCenter: isState ? parent.horizontalCenter : undefined
|
2018-07-09 14:00:27 +00:00
|
|
|
|
2018-08-21 14:57:15 +00:00
|
|
|
AutoMouseArea {
|
2018-08-04 12:40:23 +00:00
|
|
|
anchors.fill: parent
|
2018-08-21 14:57:15 +00:00
|
|
|
onSecondaryClicked: Qt.createComponent("MessageContextMenu.qml").createObject(this)
|
2018-08-04 12:40:23 +00:00
|
|
|
}
|
|
|
|
|
2018-07-10 04:18:21 +00:00
|
|
|
Loader {
|
|
|
|
id: delegateLoader
|
|
|
|
|
2018-08-21 14:57:15 +00:00
|
|
|
asynchronous: MatriqueSettings.asyncMessageDelegate
|
2018-08-14 06:05:41 +00:00
|
|
|
|
2018-08-13 14:44:32 +00:00
|
|
|
source: {
|
2018-08-14 06:05:41 +00:00
|
|
|
if (eventType == "redaction" || hidden) return ""
|
2018-08-13 14:44:32 +00:00
|
|
|
switch (eventType) {
|
|
|
|
case "state":
|
|
|
|
case "emote":
|
|
|
|
return "StateBubble.qml"
|
|
|
|
case "message":
|
|
|
|
case "notice":
|
|
|
|
return "MessageBubble.qml"
|
|
|
|
case "image":
|
|
|
|
return "ImageBubble.qml"
|
|
|
|
case "audio":
|
2018-08-17 07:58:08 +00:00
|
|
|
return "AudioBubble.qml"
|
|
|
|
case "video":
|
2018-08-13 14:44:32 +00:00
|
|
|
case "file":
|
|
|
|
return "FileBubble.qml"
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
2018-07-09 14:00:27 +00:00
|
|
|
}
|
|
|
|
}
|