forked from Shinonome/dots-hyprland
wallpaper selector: progress indicator for thumbnail generation
This commit is contained in:
@@ -23,9 +23,12 @@ Singleton {
|
||||
"jpg", "jpeg", "png", "webp", "avif", "bmp", "svg"
|
||||
]
|
||||
property list<string> wallpapers: [] // List of absolute file paths (without file://)
|
||||
readonly property bool thumbnailGenerationRunning: thumbgenProc.running
|
||||
property real thumbnailGenerationProgress: 0
|
||||
|
||||
signal changed()
|
||||
signal thumbnailGenerated(directory: string)
|
||||
signal thumbnailGeneratedFile(filePath: string)
|
||||
|
||||
// Executions
|
||||
Process {
|
||||
@@ -126,13 +129,30 @@ Singleton {
|
||||
thumbgenProc.running = false
|
||||
thumbgenProc.command = [
|
||||
"bash", "-c",
|
||||
`${thumbgenScriptPath} --size ${size} -d ${root.directory} || ${generateThumbnailsMagicScriptPath} --size ${size} -d ${root.directory}`,
|
||||
`${thumbgenScriptPath} --size ${size} --machine_progress -d ${root.directory} || ${generateThumbnailsMagicScriptPath} --size ${size} -d ${root.directory}`,
|
||||
]
|
||||
root.thumbnailGenerationProgress = 0
|
||||
thumbgenProc.running = true
|
||||
}
|
||||
Process {
|
||||
id: thumbgenProc
|
||||
property string directory
|
||||
stdout: SplitParser {
|
||||
onRead: data => {
|
||||
// print("thumb gen proc:", data)
|
||||
let match = data.match(/PROGRESS (\d+)\/(\d+)/)
|
||||
if (match) {
|
||||
const completed = parseInt(match[1])
|
||||
const total = parseInt(match[2])
|
||||
root.thumbnailGenerationProgress = completed / total
|
||||
}
|
||||
match = data.match(/FILE (.+)/)
|
||||
if (match) {
|
||||
const filePath = match[1]
|
||||
root.thumbnailGeneratedFile(filePath)
|
||||
}
|
||||
}
|
||||
}
|
||||
onExited: (exitCode, exitStatus) => {
|
||||
root.thumbnailGenerated(thumbgenProc.directory)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user