2019-07-13 19:39:01 +10:00
|
|
|
import QtQuick 2.12
|
2019-08-18 03:01:43 +10:00
|
|
|
import QtGraphicalEffects 1.12
|
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:16:35 +10:00
|
|
|
cache: ! loader.sourceComponent &&
|
|
|
|
(sourceSize.width + sourceSize.height) <= 512
|
|
|
|
|
|
|
|
|
|
|
|
property bool animate: true
|
2019-08-18 03:01:43 +10:00
|
|
|
property color colorize: "transparent"
|
|
|
|
|
2019-09-13 06:16:35 +10:00
|
|
|
|
2019-08-18 05:28:20 +10:00
|
|
|
layer.enabled: ! Qt.colorEqual(colorize, "transparent")
|
|
|
|
layer.effect: ColorOverlay {
|
|
|
|
color: image.colorize
|
|
|
|
cached: image.cache
|
2019-08-18 03:01:43 +10:00
|
|
|
}
|
2019-09-13 06:16:35 +10:00
|
|
|
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: animatedImage
|
|
|
|
|
|
|
|
AnimatedImage {
|
|
|
|
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
|
|
|
|
|
|
|
|
cache: true // Needed to allow GIFs to loop
|
|
|
|
paused: ! visible || window.hidden
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HLoader {
|
|
|
|
id: loader
|
|
|
|
anchors.fill: parent
|
|
|
|
sourceComponent:
|
|
|
|
animate &&
|
|
|
|
image.source.toString()
|
|
|
|
.split("/").splice(-1)[0].split("?")[0].toLowerCase()
|
|
|
|
.endsWith(".gif") ? animatedImage : null
|
|
|
|
}
|
2019-04-27 11:16:45 +10:00
|
|
|
}
|