status-desktop/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ImageMessage.qml

55 lines
1.4 KiB
QML
Raw Normal View History

import QtQuick 2.3
import "../../../../../imports"
Rectangle {
property int chatVerticalPadding: 12
property int chatHorizontalPadding: 12
signal clicked(string source)
id: imageChatBox
height: {
2020-09-30 18:45:45 +00:00
let h = appSettings.compactMode ? 0 : chatVerticalPadding
for (let i = 0; i < imageRepeater.count; i++) {
2020-07-23 16:23:20 +00:00
h += imageRepeater.itemAt(i).height
}
return h + chatVerticalPadding * imageRepeater.count
}
color: isCurrentUser ? Style.current.blue : Style.current.lightBlue
border.color: "transparent"
width: {
let w = 0
for (let i = 0; i < imageRepeater.count; i++) {
if (imageRepeater.itemAt(i).width > w) {
w = imageRepeater.itemAt(i).width
}
}
return w + 2 * chatHorizontalPadding
}
radius: 16
Repeater {
id: imageRepeater
2020-07-20 15:38:24 +00:00
model: {
if (!imageUrls) {
return []
}
return imageUrls.split(" ")
}
ImageLoader {
verticalPadding: imageChatBox.chatVerticalPadding
anchors.top: (index === 0) ? parent.top: parent.children[index-1].bottom
anchors.topMargin: verticalPadding
anchors.horizontalCenter: parent.horizontalCenter
source: modelData
onClicked: {
imageChatBox.clicked(source)
}
}
}
RectangleCorner {}
}