Wallpapers + Selector: Fixed the refresh button and removed duplicate logic that was already present in the wallpaper service

This commit is contained in:
quadbyte 2025-08-14 23:38:07 -04:00
parent 1763fdcd97
commit 3108b5b1a4
3 changed files with 15 additions and 28 deletions

View file

@ -106,22 +106,14 @@ Item {
Item { Item {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: { Layout.preferredHeight: {
return Math.ceil(folderModel.count / wallpaperGridView.columns) * wallpaperGridView.cellHeight return Math.ceil(Wallpapers.wallpaperList.length / 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
} }
GridView { GridView {
id: wallpaperGridView id: wallpaperGridView
anchors.fill: parent anchors.fill: parent
clip: true clip: true
model: folderModel model: Wallpapers.wallpaperList
boundsBehavior: Flickable.StopAtBounds boundsBehavior: Flickable.StopAtBounds
flickableDirection: Flickable.AutoFlickDirection flickableDirection: Flickable.AutoFlickDirection
@ -141,7 +133,7 @@ Item {
delegate: Rectangle { delegate: Rectangle {
id: wallpaperItem id: wallpaperItem
property string wallpaperPath: Settings.data.wallpaper.directory + "/" + fileName property string wallpaperPath: modelData
property bool isSelected: wallpaperPath === Wallpapers.currentWallpaper property bool isSelected: wallpaperPath === Wallpapers.currentWallpaper
width: wallpaperGridView.itemSize width: wallpaperGridView.itemSize
@ -217,7 +209,7 @@ Item {
radius: Style.radiusMedium * scaling radius: Style.radiusMedium * scaling
border.color: Colors.mOutline border.color: Colors.mOutline
border.width: Math.max(1, Style.borderThin * scaling) border.width: Math.max(1, Style.borderThin * scaling)
visible: folderModel.count === 0 && !Wallpapers.scanning visible: Wallpapers.wallpaperList.length === 0 && !Wallpapers.scanning
ColumnLayout { ColumnLayout {
anchors.centerIn: parent anchors.centerIn: parent

View file

@ -37,11 +37,6 @@ Singleton {
} }
FileView { FileView {
// TBC ? needed for SWWW only ?
// Qt.callLater(function () {
// WallpaperManager.setCurrentWallpaper(settings.currentWallpaper, true);
// })
path: settingsFile path: settingsFile
watchChanges: true watchChanges: true
onFileChanged: reload() onFileChanged: reload()
@ -50,6 +45,7 @@ Singleton {
reload() reload()
} }
onLoaded: function () { onLoaded: function () {
console.log("[Settings] loaded")
Qt.callLater(function () { Qt.callLater(function () {
if (adapter.wallpaper.current !== "") { if (adapter.wallpaper.current !== "") {
console.log("[Settings] Set current wallpaper") console.log("[Settings] Set current wallpaper")

View file

@ -8,17 +8,12 @@ import Quickshell.Io
Singleton { Singleton {
id: root id: root
Item {
Component.onCompleted: { Component.onCompleted: {
console.log("[WP] Service initialized")
loadWallpapers() loadWallpapers()
// Only set initial wallpaper if it's not empty
if (currentWallpaper !== "") { // Wallpaper is set when the settings are loaded.
console.log("[WP] initializing with:", currentWallpaper)
setCurrentWallpaper(currentWallpaper, true)
}
// Don't start random wallpaper during initialization // Don't start random wallpaper during initialization
// toggleRandomWallpaper()
}
} }
property var wallpaperList: [] property var wallpaperList: []
@ -28,8 +23,11 @@ Singleton {
property var randomChoices: ["simple", "fade", "left", "right", "top", "bottom", "wipe", "wave", "grow", "center", "any", "outer"] property var randomChoices: ["simple", "fade", "left", "right", "top", "bottom", "wipe", "wave", "grow", "center", "any", "outer"]
function loadWallpapers() { function loadWallpapers() {
console.log("[WP] Load Wallpapers")
scanning = true scanning = true
wallpaperList = [] 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 : "") folderModel.folder = "file://" + (Settings.data.wallpaper.directory !== undefined ? Settings.data.wallpaper.directory : "")
} }
@ -128,6 +126,7 @@ Singleton {
} }
wallpaperList = files wallpaperList = files
scanning = false scanning = false
console.log("[WP] List refreshed, count:", wallpaperList.length)
} }
} }
} }