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