mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-09 06:55:37 -05:00
Update Colors.qml
Made some modifications on parsing the json from matugen output, making shure only json stuff get parsed
This commit is contained in:
committed by
GitHub
parent
5c3d79eef7
commit
0eddbad0ce
@@ -148,20 +148,29 @@ Singleton {
|
||||
|
||||
onStreamFinished: {
|
||||
const out = matugenCollector.text
|
||||
if (!out.length) {
|
||||
const startIndex = out.indexOf('{')
|
||||
const endIndex = out.lastIndexOf('}')
|
||||
let jsonStringOnly = ""
|
||||
if (startIndex !== -1 && endIndex !== -1 && endIndex > startIndex) {
|
||||
jsonStringOnly = out.substring(startIndex, endIndex + 1)
|
||||
}
|
||||
if (!jsonStringOnly.length) {
|
||||
ToastService.wallpaperErrorStatus = "error"
|
||||
ToastService.showError("Wallpaper Processing Failed")
|
||||
ToastService.showError("Wallpaper Processing Failed: Empty JSON extracted from matugen output.")
|
||||
return
|
||||
}
|
||||
try {
|
||||
root.matugenJson = out
|
||||
root.matugenColors = JSON.parse(out)
|
||||
root.matugenJson = jsonStringOnly
|
||||
root.matugenColors = JSON.parse(jsonStringOnly)
|
||||
root.colorsUpdated()
|
||||
generateAppConfigs()
|
||||
ToastService.clearWallpaperError()
|
||||
} catch (e) {
|
||||
ToastService.wallpaperErrorStatus = "error"
|
||||
ToastService.showError("Wallpaper Processing Failed")
|
||||
const stderr = matugenErr.text
|
||||
const msg = "Wallpaper processing failed (JSON parse error after extraction)"
|
||||
+ (stderr ? `: ${stderr}` : ` with output: ${jsonStringOnly}`)
|
||||
ToastService.showError(msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -169,6 +178,16 @@ Singleton {
|
||||
stderr: StdioCollector {
|
||||
id: matugenErr
|
||||
}
|
||||
|
||||
onExited: code => {
|
||||
if (code !== 0) {
|
||||
ToastService.wallpaperErrorStatus = "error"
|
||||
const stderr = matugenErr.text
|
||||
const msg = "Matugen command failed with exit code " + code
|
||||
+ (stderr ? `: ${stderr}` : ". No stderr output.")
|
||||
ToastService.showError(msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function generateAppConfigs() {
|
||||
|
||||
Reference in New Issue
Block a user