Click to play/pause animated image
This commit is contained in:
parent
125d1e24aa
commit
5192fe8b55
|
@ -7,13 +7,18 @@ Image {
|
|||
asynchronous: true
|
||||
fillMode: Image.PreserveAspectFit
|
||||
|
||||
cache: ! loader.sourceComponent &&
|
||||
cache: ! (animate && animated) &&
|
||||
(sourceSize.width + sourceSize.height) <= 512
|
||||
|
||||
|
||||
property bool animate: true
|
||||
property color colorize: "transparent"
|
||||
|
||||
readonly property bool animated:
|
||||
image.source.toString()
|
||||
.split("/").splice(-1)[0].split("?")[0].toLowerCase()
|
||||
.endsWith(".gif")
|
||||
|
||||
|
||||
layer.enabled: ! Qt.colorEqual(colorize, "transparent")
|
||||
layer.effect: ColorOverlay {
|
||||
|
@ -37,17 +42,19 @@ Image {
|
|||
verticalAlignment: image.verticalAlignment
|
||||
|
||||
cache: true // Needed to allow GIFs to loop
|
||||
paused: ! visible || window.hidden
|
||||
paused: ! visible || window.hidden || userPaused
|
||||
|
||||
property bool userPaused: false
|
||||
|
||||
TapHandler {
|
||||
onTapped: parent.userPaused = ! parent.userPaused
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HLoader {
|
||||
id: loader
|
||||
anchors.fill: parent
|
||||
sourceComponent:
|
||||
animate &&
|
||||
image.source.toString()
|
||||
.split("/").splice(-1)[0].split("?")[0].toLowerCase()
|
||||
.endsWith(".gif") ? animatedImage : null
|
||||
sourceComponent: animate && animated ? animatedImage : null
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,8 @@ HImage {
|
|||
)
|
||||
|
||||
TapHandler {
|
||||
onTapped: Qt.openUrlExternally(image.source)
|
||||
onTapped: if (! image.animated) Qt.openUrlExternally(image.source)
|
||||
onDoubleTapped: Qt.openUrlExternally(image.source)
|
||||
}
|
||||
|
||||
HoverHandler {
|
||||
|
|
|
@ -61,7 +61,6 @@ HGridLayout {
|
|||
avatarUrl: accountInfo.avatar_url
|
||||
imageUrl: fileDialog.selectedFile || fileDialog.file || defaultImageUrl
|
||||
toolTipImageUrl: ""
|
||||
animate: true // note: matrix doesn't actually support gif avatars
|
||||
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user