2019-07-13 19:39:01 +10:00
|
|
|
import QtQuick 2.12
|
2019-09-14 14:36:19 +10:00
|
|
|
import "../utils.js" as Utils
|
2019-04-27 11:16:45 +10:00
|
|
|
|
|
|
|
Image {
|
2019-08-18 03:01:43 +10:00
|
|
|
id: image
|
2019-09-03 17:04:57 +10:00
|
|
|
autoTransform: true
|
2019-04-27 11:16:45 +10:00
|
|
|
asynchronous: true
|
|
|
|
fillMode: Image.PreserveAspectFit
|
2019-08-18 03:01:43 +10:00
|
|
|
|
2019-09-13 06:23:30 +10:00
|
|
|
cache: ! (animate && animated) &&
|
2019-09-13 06:16:35 +10:00
|
|
|
(sourceSize.width + sourceSize.height) <= 512
|
|
|
|
|
|
|
|
|
2019-11-13 00:10:00 +11:00
|
|
|
property bool broken: false
|
2019-09-13 06:16:35 +10:00
|
|
|
property bool animate: true
|
2019-10-30 21:47:59 +11:00
|
|
|
property bool animated: Utils.urlExtension(image.source) === "gif"
|
2019-11-07 06:47:18 +11:00
|
|
|
property alias progressBar: progressBar
|
2019-09-13 06:23:30 +10:00
|
|
|
|
2019-09-13 06:16:35 +10:00
|
|
|
|
|
|
|
Component {
|
2019-09-13 07:27:26 +10:00
|
|
|
id: animatedImageComponent
|
2019-09-13 06:16:35 +10:00
|
|
|
|
|
|
|
AnimatedImage {
|
2019-09-13 07:27:26 +10:00
|
|
|
id: animatedImage
|
2019-09-13 06:16:35 +10:00
|
|
|
source: image.source
|
|
|
|
autoTransform: image.autoTransform
|
|
|
|
asynchronous: image.asynchronous
|
|
|
|
fillMode: image.fillMode
|
|
|
|
mirror: image.mirror
|
|
|
|
mipmap: image.mipmap
|
|
|
|
smooth: image.smooth
|
|
|
|
horizontalAlignment: image.horizontalAlignment
|
|
|
|
verticalAlignment: image.verticalAlignment
|
|
|
|
|
2019-11-05 01:53:13 +11:00
|
|
|
// Online GIFs won't be able to loop if cache is set to false,
|
|
|
|
// but caching GIFs is expansive.
|
|
|
|
cache: ! Qt.resolvedUrl(source).startsWith("file://")
|
2019-09-13 06:23:30 +10:00
|
|
|
paused: ! visible || window.hidden || userPaused
|
|
|
|
|
2019-09-18 06:30:04 +10:00
|
|
|
property bool userPaused: ! window.settings.media.autoPlayGIF
|
2019-09-13 06:23:30 +10:00
|
|
|
|
|
|
|
TapHandler {
|
|
|
|
onTapped: parent.userPaused = ! parent.userPaused
|
|
|
|
}
|
2019-09-13 07:27:26 +10:00
|
|
|
|
|
|
|
HIcon {
|
2019-09-13 07:32:48 +10:00
|
|
|
anchors.centerIn: parent
|
2019-09-18 06:30:04 +10:00
|
|
|
svgName: "play-overlay"
|
2019-09-13 07:27:26 +10:00
|
|
|
colorize: "transparent"
|
|
|
|
dimension: Math.min(
|
|
|
|
parent.width - theme.spacing * 2,
|
|
|
|
parent.height - theme.spacing * 2,
|
|
|
|
theme.controls.image.maxPauseIndicatorSize,
|
|
|
|
)
|
2019-09-13 07:32:48 +10:00
|
|
|
scale: parent.status == Image.Ready && parent.paused ? 1 : 0
|
2019-09-13 07:27:26 +10:00
|
|
|
visible: scale > 0
|
|
|
|
|
|
|
|
Behavior on scale { HNumberAnimation { overshoot: 4 } }
|
|
|
|
}
|
2019-09-13 06:16:35 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HLoader {
|
|
|
|
anchors.fill: parent
|
2019-09-13 07:27:26 +10:00
|
|
|
sourceComponent: animate && animated ? animatedImageComponent : null
|
2019-09-13 06:16:35 +10:00
|
|
|
}
|
2019-10-28 07:35:58 +11:00
|
|
|
|
2019-11-07 06:47:18 +11:00
|
|
|
HCircleProgressBar {
|
|
|
|
id: progressBar
|
2019-10-28 07:35:58 +11:00
|
|
|
anchors.centerIn: parent
|
2019-11-07 06:47:18 +11:00
|
|
|
width: Math.min(parent.width, parent.height) * 0.5
|
|
|
|
height: width
|
2019-10-28 07:35:58 +11:00
|
|
|
visible: image.status === Image.Loading
|
2019-11-07 06:47:18 +11:00
|
|
|
value: image.progress
|
|
|
|
text: Math.round(value * 100) + "%"
|
2019-10-28 07:35:58 +11:00
|
|
|
|
2019-11-07 06:47:18 +11:00
|
|
|
Behavior on value { HNumberAnimation { factor: 2 } }
|
2019-10-28 07:35:58 +11:00
|
|
|
}
|
2019-11-07 07:09:07 +11:00
|
|
|
|
|
|
|
HIcon {
|
|
|
|
anchors.centerIn: parent
|
2019-11-13 00:10:00 +11:00
|
|
|
visible: broken || image.status === Image.Error
|
2019-11-07 07:09:07 +11:00
|
|
|
svgName: "broken-image"
|
|
|
|
dimension: Math.max(16, Math.min(parent.width, parent.height) * 0.2)
|
|
|
|
colorize: theme.colors.negativeBackground
|
|
|
|
}
|
2019-04-27 11:16:45 +10:00
|
|
|
}
|