Spectral/qml/component/MessageDelegate.qml

41 lines
1.1 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-07-09 14:00:27 +00:00
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-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-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-07-19 13:02:06 +00:00
anchors.right: !(eventType === "state" || eventType === "emote") && 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
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
}
}
}