Spectral/qml/component/MessageDelegate.qml

54 lines
1.5 KiB
QML
Raw Normal View History

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
import Matrique.Settings 0.1
2018-07-09 14:00:27 +00:00
Item {
readonly property bool hidden: marks === EventStatus.Redacted || marks === EventStatus.Hidden
readonly property color background: MSettings.darkTheme ? "#242424" : "lightgrey"
readonly property bool sentByMe: author === currentRoom.localUser
readonly property bool isState: eventType === "state" || eventType === "emote"
id: messageDelegate
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
anchors.right: !isState && sentByMe ? parent.right : undefined
anchors.horizontalCenter: isState ? parent.horizontalCenter : undefined
2018-07-09 14:00:27 +00:00
AutoMouseArea {
anchors.fill: parent
onSecondaryClicked: Qt.createComponent("qrc:/qml/menu/MessageContextMenu.qml").createObject(this)
}
2018-07-10 04:18:21 +00:00
Loader {
id: delegateLoader
asynchronous: MSettings.asyncMessageDelegate
source: {
if (eventType == "redaction" || hidden) return ""
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":
case "file":
return "FileBubble.qml"
}
return ""
}
2018-07-09 14:00:27 +00:00
}
}