115 lines
2.4 KiB
QML
115 lines
2.4 KiB
QML
pragma ComponentBehavior: Bound
|
|
|
|
import QtQuick
|
|
import QtQuick.Layouts
|
|
import ZShell.Components
|
|
import Quickshell
|
|
import qs.Components
|
|
import ZShell.Config
|
|
import qs.Services
|
|
|
|
Item {
|
|
id: root
|
|
|
|
property alias imgHeight: imgWrapper.implicitHeight
|
|
property alias radius: imgWrapper.radius
|
|
property alias source: img.source
|
|
|
|
signal clicked
|
|
|
|
Layout.fillWidth: true
|
|
implicitHeight: layout.implicitHeight
|
|
|
|
SnapLayout {
|
|
orientation: Qt.Vertical
|
|
id: layout
|
|
|
|
anchors.fill: parent
|
|
spacing: Tokens.spacing.small
|
|
|
|
ClipRect {
|
|
id: imgWrapper
|
|
|
|
Layout.fillWidth: true
|
|
color: Colors.tPalette.m3surfaceContainer
|
|
implicitHeight: width
|
|
radius: Tokens.rounding.largeIncreased
|
|
|
|
Loader {
|
|
active: opacity > 0
|
|
anchors.centerIn: parent
|
|
opacity: img.status === Image.Ready ? 0 : 1
|
|
|
|
Behavior on opacity {
|
|
Anim {}
|
|
}
|
|
sourceComponent: CustomRect {
|
|
color: Colors.palette.m3primaryContainer
|
|
implicitHeight: loadingIndicator.implicitSize + Tokens.padding.large * 2
|
|
implicitWidth: loadingIndicator.implicitSize + Tokens.padding.large * 2
|
|
radius: Tokens.rounding.full
|
|
|
|
LoadingIndicator {
|
|
id: loadingIndicator
|
|
|
|
anchors.centerIn: parent
|
|
containsIcon: true
|
|
implicitSize: Math.min(imgWrapper.width, imgWrapper.height) * 0.3
|
|
}
|
|
}
|
|
}
|
|
|
|
Image {
|
|
id: img
|
|
|
|
anchors.fill: parent
|
|
asynchronous: true
|
|
fillMode: Image.PreserveAspectCrop
|
|
retainWhileLoading: true
|
|
sourceSize: {
|
|
const dpr = (QsWindow.window as QsWindow)?.devicePixelRatio ?? 1;
|
|
return Qt.size(width * dpr, height * dpr);
|
|
}
|
|
|
|
opacity: status === Image.Ready ? 1 : 0
|
|
Behavior on opacity {
|
|
Anim {
|
|
type: Anim.SlowEffects
|
|
}
|
|
}
|
|
|
|
Loader {
|
|
opacity: root.modelData.isVideo && img.status === Image.Ready ? 1 : 0
|
|
active: opacity > 0
|
|
anchors.centerIn: parent
|
|
Behavior on opacity {
|
|
Anim {
|
|
type: Anim.SlowEffects
|
|
}
|
|
}
|
|
|
|
sourceComponent: CustomRect {
|
|
implicitWidth: videoIcon.implicitWidth + Tokens.padding.extraLarge * 2
|
|
implicitHeight: implicitWidth
|
|
radius: Tokens.rounding.full
|
|
color: Colors.tPalette.m3surface
|
|
|
|
MaterialIcon {
|
|
id: videoIcon
|
|
anchors.centerIn: parent
|
|
text: "video_library"
|
|
fontStyle: Tokens.font.icon.extraLarge
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
StateLayer {
|
|
anchors.bottomMargin: layout.implicitHeight - imgWrapper.implicitHeight
|
|
|
|
onClicked: root.clicked()
|
|
}
|
|
}
|