Wallpaper: fixed all edge cases when toggling on/off multi directories support and invalid directory names
This commit is contained in:
parent
9bbdf5f6f6
commit
5b8d7dbff5
2 changed files with 44 additions and 12 deletions
|
|
@ -85,6 +85,7 @@ ColumnLayout {
|
||||||
|
|
||||||
// Wallpaper grid container
|
// Wallpaper grid container
|
||||||
Item {
|
Item {
|
||||||
|
visible: !WallpaperService.scanning
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: {
|
Layout.preferredHeight: {
|
||||||
return Math.ceil(wallpapersList.length / wallpaperGridView.columns) * wallpaperGridView.cellHeight
|
return Math.ceil(wallpapersList.length / wallpaperGridView.columns) * wallpaperGridView.cellHeight
|
||||||
|
|
@ -197,14 +198,21 @@ ColumnLayout {
|
||||||
radius: Style.radiusM * scaling
|
radius: Style.radiusM * scaling
|
||||||
border.color: Color.mOutline
|
border.color: Color.mOutline
|
||||||
border.width: Math.max(1, Style.borderS * scaling)
|
border.width: Math.max(1, Style.borderS * scaling)
|
||||||
visible: wallpapersList.length === 0 && !WallpaperService.scanning
|
visible: wallpapersList.length === 0 || WallpaperService.scanning
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: 130 * scaling
|
Layout.preferredHeight: 130 * scaling
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: fallbackColumn
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
visible: WallpaperService.scanning
|
||||||
|
NBusyIndicator {
|
||||||
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
anchors.fill: parent
|
||||||
|
visible: wallpapersList.length === 0 && !WallpaperService.scanning
|
||||||
Item {
|
Item {
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,8 @@ Singleton {
|
||||||
}
|
}
|
||||||
|
|
||||||
property var wallpaperLists: ({})
|
property var wallpaperLists: ({})
|
||||||
property bool scanning: false
|
property int scanningCount: 0
|
||||||
|
readonly property bool scanning: (scanningCount > 0)
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: Settings.data.wallpaper
|
target: Settings.data.wallpaper
|
||||||
|
|
@ -57,6 +58,10 @@ Singleton {
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Get specific monitor directory
|
// Get specific monitor directory
|
||||||
function getMonitorDirectory(screenName) {
|
function getMonitorDirectory(screenName) {
|
||||||
|
if (!Settings.data.wallpaper.enableMultiMonitorDirectories) {
|
||||||
|
return Settings.data.wallpaper.directory
|
||||||
|
}
|
||||||
|
|
||||||
var monitor = getMonitorConfig(screenName)
|
var monitor = getMonitorConfig(screenName)
|
||||||
if (monitor !== undefined && monitor.directory !== undefined) {
|
if (monitor !== undefined && monitor.directory !== undefined) {
|
||||||
return monitor.directory
|
return monitor.directory
|
||||||
|
|
@ -186,13 +191,18 @@ Singleton {
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
function refreshWallpapersList() {
|
function refreshWallpapersList() {
|
||||||
if (!Settings.isLoaded) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
Logger.log("Wallpaper", "refreshWallpapersList")
|
Logger.log("Wallpaper", "refreshWallpapersList")
|
||||||
scanning = true
|
scanningCount = 0
|
||||||
|
|
||||||
|
// Force refresh by toggling the folder property on each FolderListModel
|
||||||
|
for (var i = 0; i < wallpaperScanners.count; i++) {
|
||||||
|
var scanner = wallpaperScanners.objectAt(i)
|
||||||
|
if (scanner) {
|
||||||
|
var currentFolder = scanner.folder
|
||||||
|
scanner.folder = ""
|
||||||
|
scanner.folder = currentFolder
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
@ -209,8 +219,8 @@ Singleton {
|
||||||
|
|
||||||
// Instantiator (not Repeater) to create FolderListModel for each monitor
|
// Instantiator (not Repeater) to create FolderListModel for each monitor
|
||||||
Instantiator {
|
Instantiator {
|
||||||
|
id: wallpaperScanners
|
||||||
model: Quickshell.screens
|
model: Quickshell.screens
|
||||||
|
|
||||||
delegate: FolderListModel {
|
delegate: FolderListModel {
|
||||||
property string screenName: modelData.name
|
property string screenName: modelData.name
|
||||||
|
|
||||||
|
|
@ -218,9 +228,22 @@ Singleton {
|
||||||
nameFilters: ["*.jpg", "*.jpeg", "*.png", "*.gif", "*.pnm", "*.bmp"]
|
nameFilters: ["*.jpg", "*.jpeg", "*.png", "*.gif", "*.pnm", "*.bmp"]
|
||||||
showDirs: false
|
showDirs: false
|
||||||
sortField: FolderListModel.Name
|
sortField: FolderListModel.Name
|
||||||
|
|
||||||
onStatusChanged: {
|
onStatusChanged: {
|
||||||
if (status === FolderListModel.Ready) {
|
if (status === FolderListModel.Null) {
|
||||||
|
// Flush the list
|
||||||
|
var lists = root.wallpaperLists
|
||||||
|
lists[screenName] = []
|
||||||
|
root.wallpaperLists = lists
|
||||||
|
}
|
||||||
|
else if (status === FolderListModel.Loading) {
|
||||||
|
// Flush the list
|
||||||
|
var lists = root.wallpaperLists
|
||||||
|
lists[screenName] = []
|
||||||
|
root.wallpaperLists = lists
|
||||||
|
|
||||||
|
scanningCount++
|
||||||
|
|
||||||
|
} else if (status === FolderListModel.Ready) {
|
||||||
var files = []
|
var files = []
|
||||||
for (var i = 0; i < count; i++) {
|
for (var i = 0; i < count; i++) {
|
||||||
var directory = root.getMonitorDirectory(screenName)
|
var directory = root.getMonitorDirectory(screenName)
|
||||||
|
|
@ -232,6 +255,7 @@ Singleton {
|
||||||
lists[screenName] = files
|
lists[screenName] = files
|
||||||
root.wallpaperLists = lists
|
root.wallpaperLists = lists
|
||||||
|
|
||||||
|
scanningCount--
|
||||||
Logger.log("Wallpaper", "List refreshed for", screenName, "count:", files.length)
|
Logger.log("Wallpaper", "List refreshed for", screenName, "count:", files.length)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue