mirror of
https://github.com/danbulant/dots-hyprland
synced 2026-05-19 04:08:48 +00:00
124 lines
4.6 KiB
QML
124 lines
4.6 KiB
QML
import qs
|
|
import qs.services
|
|
import qs.modules.common
|
|
import qs.modules.common.widgets
|
|
import qs.modules.common.functions
|
|
import QtQuick
|
|
import QtQuick.Controls
|
|
import QtQuick.Layouts
|
|
import Qt5Compat.GraphicalEffects
|
|
import Quickshell
|
|
import Quickshell.Io
|
|
|
|
MouseArea {
|
|
id: root
|
|
required property var fileModelData
|
|
property bool isDirectory: fileModelData.fileIsDir
|
|
property bool useThumbnail: Images.isValidImageByName(fileModelData.fileName)
|
|
|
|
property alias colBackground: background.color
|
|
property alias colText: wallpaperItemName.color
|
|
property alias radius: background.radius
|
|
property alias margins: background.anchors.margins
|
|
property alias padding: wallpaperItemColumnLayout.anchors.margins
|
|
margins: Appearance.sizes.wallpaperSelectorItemMargins
|
|
padding: Appearance.sizes.wallpaperSelectorItemPadding
|
|
|
|
signal activated()
|
|
|
|
hoverEnabled: true
|
|
onClicked: root.activated()
|
|
|
|
Rectangle {
|
|
id: background
|
|
anchors.fill: parent
|
|
radius: Appearance.rounding.normal
|
|
Behavior on color {
|
|
animation: Appearance.animation.elementMoveFast.colorAnimation.createObject(this)
|
|
}
|
|
|
|
ColumnLayout {
|
|
id: wallpaperItemColumnLayout
|
|
anchors.fill: parent
|
|
spacing: 4
|
|
|
|
Item {
|
|
id: wallpaperItemImageContainer
|
|
Layout.fillHeight: true
|
|
Layout.fillWidth: true
|
|
|
|
Loader {
|
|
id: thumbnailShadowLoader
|
|
active: thumbnailImageLoader.active && thumbnailImageLoader.item.status === Image.Ready
|
|
anchors.fill: thumbnailImageLoader
|
|
sourceComponent: StyledRectangularShadow {
|
|
target: thumbnailImageLoader
|
|
anchors.fill: undefined
|
|
radius: Appearance.rounding.small
|
|
}
|
|
}
|
|
|
|
Loader {
|
|
id: thumbnailImageLoader
|
|
anchors.fill: parent
|
|
active: root.useThumbnail
|
|
sourceComponent: ThumbnailImage {
|
|
id: thumbnailImage
|
|
generateThumbnail: false
|
|
sourcePath: fileModelData.filePath
|
|
|
|
fillMode: Image.PreserveAspectCrop
|
|
clip: true
|
|
sourceSize.width: wallpaperItemColumnLayout.width
|
|
sourceSize.height: wallpaperItemColumnLayout.height - wallpaperItemColumnLayout.spacing - wallpaperItemName.height
|
|
|
|
Connections {
|
|
target: Wallpapers
|
|
function onThumbnailGenerated(directory) {
|
|
if (thumbnailImage.status !== Image.Error) return;
|
|
if (FileUtils.parentDirectory(thumbnailImage.sourcePath) !== directory) return;
|
|
thumbnailImage.source = "";
|
|
thumbnailImage.source = thumbnailImage.thumbnailPath;
|
|
}
|
|
}
|
|
|
|
layer.enabled: true
|
|
layer.effect: OpacityMask {
|
|
maskSource: Rectangle {
|
|
width: wallpaperItemImageContainer.width
|
|
height: wallpaperItemImageContainer.height
|
|
radius: Appearance.rounding.small
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Loader {
|
|
id: iconLoader
|
|
active: !root.useThumbnail
|
|
anchors.fill: parent
|
|
sourceComponent: DirectoryIcon {
|
|
fileModelData: root.fileModelData
|
|
sourceSize.width: wallpaperItemColumnLayout.width
|
|
sourceSize.height: wallpaperItemColumnLayout.height - wallpaperItemColumnLayout.spacing - wallpaperItemName.height
|
|
}
|
|
}
|
|
}
|
|
|
|
StyledText {
|
|
id: wallpaperItemName
|
|
Layout.fillWidth: true
|
|
Layout.leftMargin: 10
|
|
Layout.rightMargin: 10
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
elide: Text.ElideRight
|
|
font.pixelSize: Appearance.font.pixelSize.smaller
|
|
Behavior on color {
|
|
animation: Appearance.animation.elementMoveFast.colorAnimation.createObject(this)
|
|
}
|
|
text: fileModelData.fileName
|
|
}
|
|
}
|
|
}
|
|
}
|