Spectral/qml/component/MessageDelegate.qml

46 lines
1.2 KiB
QML
Raw Normal View History

2018-07-09 14:00:27 +00:00
import QtQuick 2.11
import QtQuick.Controls 2.4
import QtQuick.Controls.Material 2.4
Item {
2018-07-10 04:18:21 +00:00
id: messageDelegate
2018-07-09 14:00:27 +00:00
readonly property bool sentByMe: author === currentRoom.localUser
2018-07-10 04:18:21 +00:00
width: delegateLoader.width
height: delegateLoader.height
2018-07-09 14:00:27 +00:00
anchors.right: (eventType === "message" || eventType === "image" || eventType === "file" || eventType === "video" || eventType === "audio") && sentByMe ? parent.right : undefined
2018-07-10 04:18:21 +00:00
anchors.horizontalCenter: (eventType === "state" || eventType === "emote") ? parent.horizontalCenter : undefined
2018-07-09 14:00:27 +00:00
MouseArea {
anchors.fill: parent
ToolTip.visible: pressed
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
ToolTip.text: time
}
2018-07-10 04:18:21 +00:00
Loader {
id: delegateLoader
source: {
switch (eventType) {
case "notice":
case "message":
return "MessageBubble.qml"
case "image":
return "ImageBubble.qml"
case "emote":
case "state":
return "StateBubble.qml"
case "video":
case "audio":
case "file":
return "FileBubble.qml"
2018-07-09 14:00:27 +00:00
}
return ""
2018-07-09 14:00:27 +00:00
}
}
}