Files
noctalia-shell/Widgets/NImageCached.qml
T
2025-12-25 17:56:33 -05:00

40 lines
782 B
QML

import QtQuick
import qs.Commons
import qs.Services.UI
Image {
id: root
property string imagePath: ""
property int maxCacheDimension: 256
asynchronous: true
fillMode: Image.PreserveAspectCrop
sourceSize.width: maxCacheDimension
sourceSize.height: maxCacheDimension
smooth: true
onImagePathChanged: {
if (!imagePath) {
source = "";
return;
}
if (!ImageCacheService.initialized) {
// Service not ready yet, use original
source = imagePath;
return;
}
ImageCacheService.getThumbnail(imagePath, function (cachedPath, success) {
if (!root)
return; // Component was destroyed
if (success) {
root.source = cachedPath;
} else {
root.source = imagePath;
}
});
}
}