mirror of
https://github.com/danbulant/dots-hyprland
synced 2026-05-19 04:08:48 +00:00
31 lines
1 KiB
QML
31 lines
1 KiB
QML
pragma Singleton
|
|
|
|
import Quickshell
|
|
|
|
Singleton {
|
|
// Formats
|
|
readonly property list<string> validImageTypes: ["jpeg", "png", "webp", "tiff", "svg"]
|
|
readonly property list<string> validImageExtensions: ["jpg", "jpeg", "png", "webp", "tif", "tiff", "svg"]
|
|
|
|
function isValidImageByName(name: string): bool {
|
|
return validImageExtensions.some(t => name.endsWith(`.${t}`));
|
|
}
|
|
|
|
// Thumbnails
|
|
// https://specifications.freedesktop.org/thumbnail-spec/latest/directory.html
|
|
readonly property var thumbnailSizes: ({
|
|
"normal": 128,
|
|
"large": 256,
|
|
"x-large": 512,
|
|
"xx-large": 1024
|
|
})
|
|
function thumbnailSizeNameForDimensions(width: int, height: int): string {
|
|
const sizeNames = Object.keys(thumbnailSizes);
|
|
for(let i = 0; i < sizeNames.length; i++) {
|
|
const sizeName = sizeNames[i];
|
|
const maxSize = thumbnailSizes[sizeName];
|
|
if (width <= maxSize && height <= maxSize) return sizeName;
|
|
}
|
|
return "xx-large";
|
|
}
|
|
}
|