2020-07-23 18:20:57 +00:00
|
|
|
import QtQuick 2.3
|
2020-11-12 14:08:40 +00:00
|
|
|
import QtGraphicalEffects 1.13
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared 1.0
|
|
|
|
import shared.panels 1.0
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2020-07-23 18:20:57 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
property int verticalPadding: 0
|
|
|
|
property int imageWidth: 350
|
2020-11-12 14:08:40 +00:00
|
|
|
property bool isCurrentUser: false
|
2020-07-23 18:20:57 +00:00
|
|
|
property url source
|
2022-06-29 16:50:10 +00:00
|
|
|
property bool isActiveChannel: false
|
|
|
|
property bool playing: Global.applicationWindow.active && isChatActive
|
2021-01-13 20:27:56 +00:00
|
|
|
property bool isAnimated: !!source && source.toString().endsWith('.gif')
|
2021-08-25 20:31:00 +00:00
|
|
|
signal clicked(var image, var mouse)
|
2020-12-07 23:38:53 +00:00
|
|
|
property var container
|
2021-01-13 20:27:56 +00:00
|
|
|
property alias imageAlias: imageMessage
|
2021-04-23 15:49:05 +00:00
|
|
|
property bool allCornersRounded: false
|
2020-07-23 18:20:57 +00:00
|
|
|
|
|
|
|
id: imageContainer
|
2022-02-10 20:02:02 +00:00
|
|
|
width: loadingImageLoader.active ? loadingImageLoader.width : imageMessage.width
|
|
|
|
height: loadingImageLoader.active ? loadingImageLoader.height : imageMessage.paintedHeight
|
2020-07-23 18:20:57 +00:00
|
|
|
|
2020-11-17 19:43:52 +00:00
|
|
|
AnimatedImage {
|
2020-07-23 18:20:57 +00:00
|
|
|
id: imageMessage
|
|
|
|
width: sourceSize.width > imageWidth ? imageWidth : sourceSize.width
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
source: imageContainer.source
|
2022-02-22 20:48:57 +00:00
|
|
|
playing: imageContainer.isAnimated && imageContainer.playing
|
2020-09-30 14:01:08 +00:00
|
|
|
|
2020-11-12 14:08:40 +00:00
|
|
|
layer.enabled: true
|
|
|
|
layer.effect: OpacityMask {
|
|
|
|
maskSource: Item {
|
|
|
|
width: imageMessage.width
|
|
|
|
height: imageMessage.height
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.left
|
|
|
|
width: imageMessage.width
|
|
|
|
height: imageMessage.height
|
|
|
|
radius: 16
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.left: parent.left
|
|
|
|
width: 32
|
|
|
|
height: 32
|
|
|
|
radius: 4
|
2021-04-23 15:49:05 +00:00
|
|
|
visible: !imageContainer.isCurrentUser && !allCornersRounded
|
2020-11-12 14:08:40 +00:00
|
|
|
}
|
|
|
|
Rectangle {
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.right: parent.right
|
|
|
|
width: 32
|
|
|
|
height: 32
|
|
|
|
radius: 4
|
2021-04-23 15:49:05 +00:00
|
|
|
visible: imageContainer.isCurrentUser && !allCornersRounded
|
2020-11-12 14:08:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-30 14:01:08 +00:00
|
|
|
MouseArea {
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
2021-08-16 09:11:43 +00:00
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
2020-09-30 14:01:08 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
2021-08-25 20:31:00 +00:00
|
|
|
imageContainer.clicked(imageMessage, mouse)
|
2020-09-30 14:01:08 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-23 18:20:57 +00:00
|
|
|
}
|
2021-09-23 12:27:05 +00:00
|
|
|
|
2022-02-10 20:02:02 +00:00
|
|
|
Loader {
|
|
|
|
id: loadingImageLoader
|
|
|
|
active: imageMessage.status === Image.Loading
|
|
|
|
|| imageMessage.status === Image.Error
|
|
|
|
width: 300
|
2021-09-23 12:27:05 +00:00
|
|
|
height: width
|
2022-02-10 20:02:02 +00:00
|
|
|
sourceComponent: Rectangle {
|
|
|
|
anchors.fill: parent
|
|
|
|
border.width: 1
|
|
|
|
border.color: Style.current.border
|
|
|
|
radius: Style.current.radius
|
2021-09-23 12:27:05 +00:00
|
|
|
|
2022-02-10 20:02:02 +00:00
|
|
|
StyledText {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
text: imageMessage.status === Image.Error?
|
2022-04-04 11:26:30 +00:00
|
|
|
qsTr("Error loading the image") :
|
|
|
|
qsTr("Loading image...")
|
2022-02-10 20:02:02 +00:00
|
|
|
color: imageMessage.status === Image.Error?
|
|
|
|
Style.current.red :
|
|
|
|
Style.current.textColor
|
|
|
|
font.pixelSize: 15
|
|
|
|
}
|
2021-09-23 12:27:05 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-23 18:20:57 +00:00
|
|
|
}
|