put wallpaper picker in loader and make it use real thumbnails

This commit is contained in:
end-4
2025-08-18 20:41:44 +07:00
parent 8feee4e61a
commit 445b10d6f0
2 changed files with 334 additions and 325 deletions
@@ -11,6 +11,7 @@ Singleton {
readonly property string config: StandardPaths.standardLocations(StandardPaths.ConfigLocation)[0] readonly property string config: StandardPaths.standardLocations(StandardPaths.ConfigLocation)[0]
readonly property string state: StandardPaths.standardLocations(StandardPaths.StateLocation)[0] readonly property string state: StandardPaths.standardLocations(StandardPaths.StateLocation)[0]
readonly property string cache: StandardPaths.standardLocations(StandardPaths.CacheLocation)[0] readonly property string cache: StandardPaths.standardLocations(StandardPaths.CacheLocation)[0]
readonly property string genericCache: StandardPaths.standardLocations(StandardPaths.GenericCacheLocation)[0]
readonly property string pictures: StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0] readonly property string pictures: StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0]
readonly property string downloads: StandardPaths.standardLocations(StandardPaths.DownloadLocation)[0] readonly property string downloads: StandardPaths.standardLocations(StandardPaths.DownloadLocation)[0]
@@ -14,11 +14,12 @@ import Quickshell.Hyprland
Scope { Scope {
id: scope id: scope
PanelWindow { Loader {
active: GlobalStates.wallpaperOverviewOpen
sourceComponent: PanelWindow {
id: root id: root
readonly property HyprlandMonitor monitor: Hyprland.monitorFor(root.screen) readonly property HyprlandMonitor monitor: Hyprland.monitorFor(root.screen)
property bool monitorIsFocused: (Hyprland.focusedMonitor?.id == monitor?.id) property bool monitorIsFocused: (Hyprland.focusedMonitor?.id == monitor?.id)
visible: GlobalStates.wallpaperOverviewOpen
property var filteredWallpapers: Wallpapers.wallpapers property var filteredWallpapers: Wallpapers.wallpapers
WlrLayershell.namespace: "quickshell:wallpaper-overview" WlrLayershell.namespace: "quickshell:wallpaper-overview"
@@ -194,10 +195,10 @@ Scope {
readonly property int rows: Math.max(1, Math.ceil(count / columns)) readonly property int rows: Math.max(1, Math.ceil(count / columns))
Layout.preferredWidth: columns * cellWidth Layout.preferredWidth: columns * cellWidth
Layout.alignment: Qt.AlignHcenter Layout.alignment: Qt.AlignHCenter
Layout.fillHeight: true Layout.fillHeight: true
cellWidth: 220 cellWidth: 128
cellHeight: 140 cellHeight: 72
clip: true clip: true
interactive: true interactive: true
keyNavigationWraps: true keyNavigationWraps: true
@@ -290,10 +291,16 @@ Scope {
Image { Image {
id: thumbnailImage id: thumbnailImage
anchors.fill: parent anchors.fill: parent
source: `file://${modelData}` source: {
const resolvedUrl = Qt.resolvedUrl(modelData);
const md5Hash = Qt.md5(resolvedUrl);
const cacheSize = "normal"
const thumbnailPath = `${Directories.genericCache}/thumbnails/${cacheSize}/${md5Hash}.png`;
return thumbnailPath
}
fillMode: Image.PreserveAspectCrop fillMode: Image.PreserveAspectCrop
asynchronous: true asynchronous: true
cache: false cache: true
smooth: true smooth: true
sourceSize.width: Math.min(128, grid.cellWidth - 16) sourceSize.width: Math.min(128, grid.cellWidth - 16)
@@ -392,6 +399,7 @@ Scope {
} }
} }
} }
}
GlobalShortcut { GlobalShortcut {
name: "wallpaperOverviewToggle" name: "wallpaperOverviewToggle"