2020-07-23 18:20:57 +00:00
|
|
|
import QtQuick 2.3
|
2020-11-12 14:08:40 +00:00
|
|
|
import QtGraphicalEffects 1.13
|
2020-07-23 18:20:57 +00:00
|
|
|
import "../../../../../shared"
|
|
|
|
import "../../../../../imports"
|
|
|
|
|
|
|
|
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
|
2020-11-17 19:43:52 +00:00
|
|
|
property bool playing: true
|
feat: whitelist gifs (no url extension needed)
Fixes #1377.
Fixes #1479.
Two sites have been added to the whitelist: giphy.com and tenor.com.
`imageUrls` in its entirety has been removed and instead all links are being handle through the message `linkUrls`. This prevents double-handling of urls that may or may not be images.
The logic to automatically show links previews works like this:
1. If the setting "display chat images" is enabled, all links that *contain* ".png", ".jpg", ".jpeg", ".svg", ".gif" will be automatically shown. If the URL doesn't contain the extension, we are not downloading it. This was meant to be somewhat of a security compromise as we do not want to download each and every link posted in a message just to find out its true content type.
2. If the above setting is *disabled*, then we follow the whitelist settings for tenor and giphy. This allows us to preview gifs that do not have a file extension in their url.
feat: bump status-go to the commit that supports the new whitelist (https://github.com/status-im/status-go/pull/2094), and also lets us get link preview data from urls in the whitelist. NOTE: this commit was branched off status-go `develop`, so once it is merged, and we update this PR to the new commit, we will effectively be getting status-go develop changes. We *could* base that status-go PR off of master if it makes things easier.
fix: height on settings update issue
feat: move date/time of message below links
fix: layout issues when changing setting `neverAskAboutUnfurlingAgain`
feat: Add MessageBorder component to aid in showing rounded corners with different radius
2020-12-11 00:53:44 +00:00
|
|
|
property bool isAnimated: true
|
2020-11-17 19:43:52 +00:00
|
|
|
signal clicked(var image)
|
2020-12-07 23:38:53 +00:00
|
|
|
property var container
|
2020-07-23 18:20:57 +00:00
|
|
|
|
|
|
|
id: imageContainer
|
|
|
|
width: loadingImage.visible ? loadingImage.width : imageMessage.width
|
|
|
|
height: loadingImage.visible ? loadingImage.height : imageMessage.paintedHeight
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: loadingImage
|
|
|
|
property bool hasError: false
|
|
|
|
width: hasError ? 200 : imageContainer.imageWidth
|
|
|
|
height: hasError ? 75 : imageContainer.imageWidth
|
|
|
|
border.width: 1
|
|
|
|
border.color: Style.current.border
|
|
|
|
radius: Style.current.radius
|
|
|
|
|
|
|
|
StyledText {
|
2020-08-26 15:52:26 +00:00
|
|
|
//% "Error loading the image"
|
|
|
|
//% "Loading image..."
|
|
|
|
text: loadingImage.hasError ? qsTrId("error-loading-the-image") : qsTrId("loading-image---")
|
2020-07-23 18:20:57 +00:00
|
|
|
color: loadingImage.hasError ? Style.current.red : Style.current.textColor
|
|
|
|
font.pixelSize: 15
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-17 19:43:52 +00:00
|
|
|
Connections {
|
|
|
|
target: applicationWindow
|
|
|
|
onActiveChanged: {
|
|
|
|
if (applicationWindow.active === false) {
|
|
|
|
imageMessage.playing = false
|
|
|
|
} else {
|
|
|
|
imageMessage.playing = Qt.binding(function () {return imageContainer.playing})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimatedImage {
|
2020-07-23 18:20:57 +00:00
|
|
|
id: imageMessage
|
|
|
|
width: sourceSize.width > imageWidth ? imageWidth : sourceSize.width
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
source: imageContainer.source
|
2020-11-17 19:43:52 +00:00
|
|
|
playing: imageContainer.playing
|
2020-07-23 18:20:57 +00:00
|
|
|
onStatusChanged: {
|
|
|
|
if (imageMessage.status === Image.Error) {
|
|
|
|
loadingImage.hasError = true
|
|
|
|
imageMessage.height = 0
|
|
|
|
imageMessage.source = ""
|
|
|
|
imageMessage.visible = false
|
|
|
|
} else if (imageMessage.status === Image.Ready) {
|
|
|
|
loadingImage.visible = false
|
2020-12-16 20:50:54 +00:00
|
|
|
scrollToBottom(true, imageContainer.container)
|
2020-07-23 18:20:57 +00:00
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
visible: !imageContainer.isCurrentUser
|
|
|
|
}
|
|
|
|
Rectangle {
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.right: parent.right
|
|
|
|
width: 32
|
|
|
|
height: 32
|
|
|
|
radius: 4
|
|
|
|
visible: imageContainer.isCurrentUser
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-30 14:01:08 +00:00
|
|
|
MouseArea {
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
2020-11-17 19:43:52 +00:00
|
|
|
if (imageContainer.isAnimated) {
|
|
|
|
// FIXME the ListView completely removes Items that scroll out of view
|
|
|
|
// so when we scroll backto the image, it gets reloaded and playing is reset
|
|
|
|
imageContainer.playing = !imageContainer.playing
|
|
|
|
return
|
|
|
|
}
|
|
|
|
imageContainer.clicked(imageMessage)
|
2020-09-30 14:01:08 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-23 18:20:57 +00:00
|
|
|
}
|
|
|
|
}
|