mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-02 09:46:38 +00:00
feat: enable animated gifs but stop them on click and out of focus
This commit is contained in:
parent
9148be5718
commit
1ec28bca01
@ -137,6 +137,9 @@ Item {
|
|||||||
ImageMessage {
|
ImageMessage {
|
||||||
color: Style.current.transparent
|
color: Style.current.transparent
|
||||||
chatHorizontalPadding: 0
|
chatHorizontalPadding: 0
|
||||||
|
onClicked: {
|
||||||
|
chatTextItem.clickMessage(false, false, true, image)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,9 @@ Item {
|
|||||||
property int imageWidth: 350
|
property int imageWidth: 350
|
||||||
property bool isCurrentUser: false
|
property bool isCurrentUser: false
|
||||||
property url source
|
property url source
|
||||||
signal clicked(string source)
|
property bool playing: true
|
||||||
|
property bool isAnimated: !!source && source.toString().endsWith('.gif')
|
||||||
|
signal clicked(var image)
|
||||||
|
|
||||||
id: imageContainer
|
id: imageContainer
|
||||||
width: loadingImage.visible ? loadingImage.width : imageMessage.width
|
width: loadingImage.visible ? loadingImage.width : imageMessage.width
|
||||||
@ -34,11 +36,23 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Image {
|
Connections {
|
||||||
|
target: applicationWindow
|
||||||
|
onActiveChanged: {
|
||||||
|
if (applicationWindow.active === false) {
|
||||||
|
imageMessage.playing = false
|
||||||
|
} else {
|
||||||
|
imageMessage.playing = Qt.binding(function () {return imageContainer.playing})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AnimatedImage {
|
||||||
id: imageMessage
|
id: imageMessage
|
||||||
width: sourceSize.width > imageWidth ? imageWidth : sourceSize.width
|
width: sourceSize.width > imageWidth ? imageWidth : sourceSize.width
|
||||||
fillMode: Image.PreserveAspectFit
|
fillMode: Image.PreserveAspectFit
|
||||||
source: imageContainer.source
|
source: imageContainer.source
|
||||||
|
playing: imageContainer.playing
|
||||||
onStatusChanged: {
|
onStatusChanged: {
|
||||||
if (imageMessage.status === Image.Error) {
|
if (imageMessage.status === Image.Error) {
|
||||||
loadingImage.hasError = true
|
loadingImage.hasError = true
|
||||||
@ -88,7 +102,13 @@ Item {
|
|||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
onClicked: {
|
||||||
imageContainer.clicked(imageContainer.source)
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ Rectangle {
|
|||||||
property int chatVerticalPadding: 12
|
property int chatVerticalPadding: 12
|
||||||
property int chatHorizontalPadding: 12
|
property int chatHorizontalPadding: 12
|
||||||
property bool isCurrentUser: bool
|
property bool isCurrentUser: bool
|
||||||
signal clicked(string source)
|
signal clicked(var image)
|
||||||
|
|
||||||
id: imageChatBox
|
id: imageChatBox
|
||||||
height: {
|
height: {
|
||||||
@ -47,7 +47,7 @@ Rectangle {
|
|||||||
source: modelData
|
source: modelData
|
||||||
isCurrentUser: imageChatBox.isCurrentUser
|
isCurrentUser: imageChatBox.isCurrentUser
|
||||||
onClicked: {
|
onClicked: {
|
||||||
imageChatBox.clicked(source)
|
imageChatBox.clicked(image)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,6 @@ MouseArea {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mouse.button & Qt.LeftButton) {
|
if (mouse.button & Qt.LeftButton) {
|
||||||
if (isImage && !isSticker)
|
|
||||||
clickMessage(false, false, isImage, image);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -221,7 +221,7 @@ Item {
|
|||||||
ImageMessage {
|
ImageMessage {
|
||||||
isCurrentUser: messageItem.isCurrentUser
|
isCurrentUser: messageItem.isCurrentUser
|
||||||
onClicked: {
|
onClicked: {
|
||||||
chatTextItem.clickMessage(false, false, true, source)
|
chatTextItem.clickMessage(false, false, true, image)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,17 +22,17 @@ Popup {
|
|||||||
padding: 0
|
padding: 0
|
||||||
|
|
||||||
function setPopupData(image) {
|
function setPopupData(image) {
|
||||||
messageImage.source = image;
|
messageImage.source = image.source;
|
||||||
|
const maxHeight = applicationWindow.height - 80
|
||||||
|
const maxWidth = applicationWindow.width - 80
|
||||||
|
|
||||||
let maxHeight = applicationWindow.height - 80
|
|
||||||
let maxWidth = applicationWindow.width - 80
|
|
||||||
|
|
||||||
if (messageImage.sourceSize.width >= maxWidth || messageImage.sourceSize.height >= maxHeight) {
|
if (image.sourceSize.width >= maxWidth || image.sourceSize.height >= maxHeight) {
|
||||||
this.width = maxWidth
|
this.width = maxWidth
|
||||||
this.height = maxHeight
|
this.height = maxHeight
|
||||||
} else {
|
} else {
|
||||||
this.width = messageImage.sourceSize.width
|
this.width = image.sourceSize.width
|
||||||
this.height = messageImage.sourceSize.height
|
this.height = image.sourceSize.height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user