forked from Shinonome/dots-hyprland
wallpaper service: simplify dir setting
This commit is contained in:
@@ -9,30 +9,23 @@ pragma ComponentBehavior: Bound
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a list of wallpapers and an "apply" action that calls the existing
|
* Provides a list of wallpapers and an "apply" action that calls the existing
|
||||||
* switchwall.sh script. Uses QML's built-in image scaling for thumbnails.
|
* switchwall.sh script. Pretty much a limited file browsing service.
|
||||||
*/
|
*/
|
||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
// Directory to search for wallpapers (new location)
|
property string searchDir: FileUtils.trimFileProtocol(`${Directories.pictures}/Wallpapers`)
|
||||||
// Resolves to: ~/Pictures/Wallpapers
|
readonly property list<string> extensions: [ // TODO: add videos
|
||||||
property list<string> searchDirs: [ FileUtils.trimFileProtocol(`${Directories.pictures}/Wallpapers`) ]
|
|
||||||
|
|
||||||
// Supported image extensions. Videos are intentionally excluded for now
|
|
||||||
// to keep the overview lightweight.
|
|
||||||
readonly property list<string> extensions: [
|
|
||||||
"jpg", "jpeg", "png", "webp", "avif", "bmp", "svg"
|
"jpg", "jpeg", "png", "webp", "avif", "bmp", "svg"
|
||||||
]
|
]
|
||||||
|
property alias filesModel: files // Expose for direct binding when needed
|
||||||
|
property list<string> wallpapers: [] // List of absolute file paths (without file://)
|
||||||
|
|
||||||
// Resulting list of absolute file paths (without file:// prefix)
|
// Executions
|
||||||
property list<string> wallpapers: []
|
Process {
|
||||||
|
id: applyProc
|
||||||
// Public API (FolderListModel driven)
|
|
||||||
function reload() {
|
|
||||||
files.folder = Qt.resolvedUrl(root.searchDirs[0])
|
|
||||||
}
|
}
|
||||||
onSearchDirsChanged: reload()
|
|
||||||
|
|
||||||
function openFallbackPicker() {
|
function openFallbackPicker() {
|
||||||
applyProc.exec([Directories.wallpaperSwitchScriptPath])
|
applyProc.exec([Directories.wallpaperSwitchScriptPath])
|
||||||
}
|
}
|
||||||
@@ -49,14 +42,14 @@ Singleton {
|
|||||||
// Folder model
|
// Folder model
|
||||||
FolderListModel {
|
FolderListModel {
|
||||||
id: files
|
id: files
|
||||||
nameFilters: extensions.map(ext => `*.${ext}`)
|
folder: Qt.resolvedUrl(root.searchDir)
|
||||||
|
nameFilters: root.extensions.map(ext => `*.${ext}`)
|
||||||
showDirs: false
|
showDirs: false
|
||||||
showDotAndDotDot: false
|
showDotAndDotDot: false
|
||||||
showOnlyReadable: true
|
showOnlyReadable: true
|
||||||
sortField: FolderListModel.Time
|
sortField: FolderListModel.Time
|
||||||
sortReversed: false
|
sortReversed: false
|
||||||
onCountChanged: {
|
onCountChanged: {
|
||||||
console.log(`[Wallpapers] FolderListModel count=${files.count} folder=${files.folder}`)
|
|
||||||
root.wallpapers = []
|
root.wallpapers = []
|
||||||
for (let i = 0; i < files.count; i++) {
|
for (let i = 0; i < files.count; i++) {
|
||||||
const path = files.get(i, "filePath") || FileUtils.trimFileProtocol(files.get(i, "fileURL"))
|
const path = files.get(i, "filePath") || FileUtils.trimFileProtocol(files.get(i, "fileURL"))
|
||||||
@@ -64,16 +57,4 @@ Singleton {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expose the model for direct binding when needed
|
|
||||||
property alias filesModel: files
|
|
||||||
|
|
||||||
// Internal: applying a wallpaper
|
|
||||||
Process {
|
|
||||||
id: applyProc
|
|
||||||
}
|
|
||||||
|
|
||||||
Component.onCompleted: reload()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user