diff options
| author | AlexanderCurl <alexc@alexc.hu> | 2026-04-18 17:46:06 +0100 |
|---|---|---|
| committer | AlexanderCurl <alexc@alexc.hu> | 2026-04-18 17:46:06 +0100 |
| commit | 70ca3fef77ee8bdc6e3ac28589a6fa08c024cc69 (patch) | |
| tree | ab1123d4067c1b086dd6faa7ee4ea643236b565a /raveos-theme/hyprland/theme-data/DankMaterialShell/quickshell/Widgets/CachingImage.qml | |
| parent | 5d94c0a7d44a2255b81815a52a7056a94a39842d (diff) | |
| download | RaveOS-PKGBUILD-70ca3fef77ee8bdc6e3ac28589a6fa08c024cc69.tar.gz RaveOS-PKGBUILD-70ca3fef77ee8bdc6e3ac28589a6fa08c024cc69.zip | |
Replaced file structures for themes in the correct format
Diffstat (limited to 'raveos-theme/hyprland/theme-data/DankMaterialShell/quickshell/Widgets/CachingImage.qml')
| -rw-r--r-- | raveos-theme/hyprland/theme-data/DankMaterialShell/quickshell/Widgets/CachingImage.qml | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/raveos-theme/hyprland/theme-data/DankMaterialShell/quickshell/Widgets/CachingImage.qml b/raveos-theme/hyprland/theme-data/DankMaterialShell/quickshell/Widgets/CachingImage.qml deleted file mode 100644 index 5ffec09..0000000 --- a/raveos-theme/hyprland/theme-data/DankMaterialShell/quickshell/Widgets/CachingImage.qml +++ /dev/null @@ -1,102 +0,0 @@ -import QtQuick -import qs.Common - -Item { - id: root - - property string imagePath: "" - property int maxCacheSize: 512 - property int status: isAnimated ? animatedImg.status : staticImg.status - property int fillMode: Image.PreserveAspectCrop - - readonly property bool isRemoteUrl: imagePath.startsWith("http://") || imagePath.startsWith("https://") - readonly property bool isAnimated: { - if (!imagePath) - return false; - const lower = imagePath.toLowerCase(); - return lower.endsWith(".gif") || lower.endsWith(".webp"); - } - readonly property string normalizedPath: { - if (!imagePath) - return ""; - if (isRemoteUrl) - return imagePath; - if (imagePath.startsWith("file://")) - return imagePath.substring(7); - return imagePath; - } - - function djb2Hash(str) { - if (!str) - return ""; - let hash = 5381; - for (let i = 0; i < str.length; i++) { - hash = ((hash << 5) + hash) + str.charCodeAt(i); - hash = hash & 0x7FFFFFFF; - } - return hash.toString(16).padStart(8, '0'); - } - - readonly property string imageHash: normalizedPath ? djb2Hash(normalizedPath) : "" - readonly property string cachePath: imageHash && !isRemoteUrl && !isAnimated ? `${Paths.stringify(Paths.imagecache)}/${imageHash}@${maxCacheSize}x${maxCacheSize}.png` : "" - readonly property string encodedImagePath: { - if (!normalizedPath) - return ""; - if (isRemoteUrl) - return normalizedPath; - return "file://" + normalizedPath.split('/').map(s => encodeURIComponent(s)).join('/'); - } - - AnimatedImage { - id: animatedImg - anchors.fill: parent - visible: root.isAnimated - asynchronous: true - fillMode: root.fillMode - source: root.isAnimated ? root.imagePath : "" - playing: visible && status === AnimatedImage.Ready - } - - Image { - id: staticImg - anchors.fill: parent - visible: !root.isAnimated - asynchronous: true - fillMode: root.fillMode - sourceSize.width: root.maxCacheSize - sourceSize.height: root.maxCacheSize - smooth: true - - onStatusChanged: { - if (source == root.cachePath && status === Image.Error) { - source = root.encodedImagePath; - return; - } - if (root.isRemoteUrl || source != root.encodedImagePath || status !== Image.Ready || !root.cachePath) - return; - Paths.mkdir(Paths.imagecache); - const grabPath = root.cachePath; - if (visible && width > 0 && height > 0 && Window.window?.visible) { - grabToImage(res => res.saveToFile(grabPath)); - } - } - } - - onImagePathChanged: { - if (!imagePath) { - staticImg.source = ""; - return; - } - if (isAnimated) - return; - if (isRemoteUrl) { - staticImg.source = imagePath; - return; - } - Paths.mkdir(Paths.imagecache); - const hash = djb2Hash(normalizedPath); - const cPath = hash ? `${Paths.stringify(Paths.imagecache)}/${hash}@${maxCacheSize}x${maxCacheSize}.png` : ""; - const encoded = "file://" + normalizedPath.split('/').map(s => encodeURIComponent(s)).join('/'); - staticImg.source = cPath || encoded; - } -} |