forked from Shinonome/dots-hyprland
wallpaper selector: progress indicator for thumbnail generation
This commit is contained in:
@@ -16,8 +16,9 @@ Image {
|
||||
property string thumbnailSizeName: Images.thumbnailSizeNameForDimensions(sourceSize.width, sourceSize.height)
|
||||
property string thumbnailPath: {
|
||||
if (sourcePath.length == 0) return;
|
||||
const resolvedUrl = Qt.resolvedUrl(sourcePath);
|
||||
const md5Hash = Qt.md5(resolvedUrl);
|
||||
const resolvedUrlWithoutFileProtocol = FileUtils.trimFileProtocol(`${Qt.resolvedUrl(sourcePath)}`);
|
||||
const encodedUrlWithoutFileProtocol = resolvedUrlWithoutFileProtocol.split("/").map(part => encodeURIComponent(part)).join("/");
|
||||
const md5Hash = Qt.md5(`file://${encodedUrlWithoutFileProtocol}`);
|
||||
return `${Directories.genericCache}/thumbnails/${thumbnailSizeName}/${md5Hash}.png`;
|
||||
}
|
||||
source: thumbnailPath
|
||||
|
||||
@@ -80,6 +80,12 @@ MouseArea {
|
||||
thumbnailImage.source = "";
|
||||
thumbnailImage.source = thumbnailImage.thumbnailPath;
|
||||
}
|
||||
function onThumbnailGeneratedFile(filePath) {
|
||||
if (thumbnailImage.status !== Image.Error) return;
|
||||
if (Qt.resolvedUrl(thumbnailImage.sourcePath) !== Qt.resolvedUrl(filePath)) return;
|
||||
thumbnailImage.source = "";
|
||||
thumbnailImage.source = thumbnailImage.thumbnailPath;
|
||||
}
|
||||
}
|
||||
|
||||
layer.enabled: true
|
||||
|
||||
@@ -205,7 +205,9 @@ Item {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
StyledProgressBar {
|
||||
StyledIndeterminateProgressBar {
|
||||
id: indeterminateProgressBar
|
||||
visible: Wallpapers.thumbnailGenerationRunning && value == 0
|
||||
anchors {
|
||||
bottom: parent.top
|
||||
left: parent.left
|
||||
@@ -213,7 +215,12 @@ Item {
|
||||
leftMargin: 4
|
||||
rightMargin: 4
|
||||
}
|
||||
indeterminate: true
|
||||
}
|
||||
|
||||
StyledProgressBar {
|
||||
visible: Wallpapers.thumbnailGenerationRunning && value > 0
|
||||
value: Wallpapers.thumbnailGenerationProgress
|
||||
anchors.fill: indeterminateProgressBar
|
||||
}
|
||||
|
||||
GridView {
|
||||
|
||||
Reference in New Issue
Block a user