From 3108b5b1a42d20ba6be646a776d043608ab04d39 Mon Sep 17 00:00:00 2001 From: quadbyte Date: Thu, 14 Aug 2025 23:38:07 -0400 Subject: [PATCH] Wallpapers + Selector: Fixed the refresh button and removed duplicate logic that was already present in the wallpaper service --- Modules/Settings/Tabs/WallpaperSelector.qml | 16 ++++------------ Services/Settings.qml | 6 +----- Services/Wallpapers.qml | 21 ++++++++++----------- 3 files changed, 15 insertions(+), 28 deletions(-) diff --git a/Modules/Settings/Tabs/WallpaperSelector.qml b/Modules/Settings/Tabs/WallpaperSelector.qml index 46e1e40..5100b9a 100644 --- a/Modules/Settings/Tabs/WallpaperSelector.qml +++ b/Modules/Settings/Tabs/WallpaperSelector.qml @@ -106,22 +106,14 @@ Item { Item { Layout.fillWidth: true Layout.preferredHeight: { - return Math.ceil(folderModel.count / wallpaperGridView.columns) * wallpaperGridView.cellHeight - } - - FolderListModel { - id: folderModel - folder: "file://" + (Settings.data.wallpaper.directory !== undefined ? Settings.data.wallpaper.directory : "") - nameFilters: ["*.jpg", "*.jpeg", "*.png", "*.gif", "*.pnm", "*.bmp"] - showDirs: false - sortField: FolderListModel.Name + return Math.ceil(Wallpapers.wallpaperList.length / wallpaperGridView.columns) * wallpaperGridView.cellHeight } GridView { id: wallpaperGridView anchors.fill: parent clip: true - model: folderModel + model: Wallpapers.wallpaperList boundsBehavior: Flickable.StopAtBounds flickableDirection: Flickable.AutoFlickDirection @@ -141,7 +133,7 @@ Item { delegate: Rectangle { id: wallpaperItem - property string wallpaperPath: Settings.data.wallpaper.directory + "/" + fileName + property string wallpaperPath: modelData property bool isSelected: wallpaperPath === Wallpapers.currentWallpaper width: wallpaperGridView.itemSize @@ -217,7 +209,7 @@ Item { radius: Style.radiusMedium * scaling border.color: Colors.mOutline border.width: Math.max(1, Style.borderThin * scaling) - visible: folderModel.count === 0 && !Wallpapers.scanning + visible: Wallpapers.wallpaperList.length === 0 && !Wallpapers.scanning ColumnLayout { anchors.centerIn: parent diff --git a/Services/Settings.qml b/Services/Settings.qml index a395808..2e219c6 100644 --- a/Services/Settings.qml +++ b/Services/Settings.qml @@ -37,11 +37,6 @@ Singleton { } FileView { - - // TBC ? needed for SWWW only ? - // Qt.callLater(function () { - // WallpaperManager.setCurrentWallpaper(settings.currentWallpaper, true); - // }) path: settingsFile watchChanges: true onFileChanged: reload() @@ -50,6 +45,7 @@ Singleton { reload() } onLoaded: function () { + console.log("[Settings] loaded") Qt.callLater(function () { if (adapter.wallpaper.current !== "") { console.log("[Settings] Set current wallpaper") diff --git a/Services/Wallpapers.qml b/Services/Wallpapers.qml index 8cfa789..e5197b8 100644 --- a/Services/Wallpapers.qml +++ b/Services/Wallpapers.qml @@ -8,17 +8,12 @@ import Quickshell.Io Singleton { id: root - Item { - Component.onCompleted: { - loadWallpapers() - // Only set initial wallpaper if it's not empty - if (currentWallpaper !== "") { - console.log("[WP] initializing with:", currentWallpaper) - setCurrentWallpaper(currentWallpaper, true) - } - // Don't start random wallpaper during initialization - // toggleRandomWallpaper() - } + Component.onCompleted: { + console.log("[WP] Service initialized") + loadWallpapers() + + // Wallpaper is set when the settings are loaded. + // Don't start random wallpaper during initialization } property var wallpaperList: [] @@ -28,8 +23,11 @@ Singleton { property var randomChoices: ["simple", "fade", "left", "right", "top", "bottom", "wipe", "wave", "grow", "center", "any", "outer"] function loadWallpapers() { + console.log("[WP] Load Wallpapers") scanning = true wallpaperList = [] + // Unsetting, then setting the folder will re-trigger the parsing! + folderModel.folder = ""; folderModel.folder = "file://" + (Settings.data.wallpaper.directory !== undefined ? Settings.data.wallpaper.directory : "") } @@ -128,6 +126,7 @@ Singleton { } wallpaperList = files scanning = false + console.log("[WP] List refreshed, count:", wallpaperList.length) } } }