mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-09 15:05:39 -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: {
|
onStreamFinished: {
|
||||||
const out = matugenCollector.text
|
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.wallpaperErrorStatus = "error"
|
||||||
ToastService.showError("Wallpaper Processing Failed")
|
ToastService.showError("Wallpaper Processing Failed: Empty JSON extracted from matugen output.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
root.matugenJson = out
|
root.matugenJson = jsonStringOnly
|
||||||
root.matugenColors = JSON.parse(out)
|
root.matugenColors = JSON.parse(jsonStringOnly)
|
||||||
root.colorsUpdated()
|
root.colorsUpdated()
|
||||||
generateAppConfigs()
|
generateAppConfigs()
|
||||||
ToastService.clearWallpaperError()
|
ToastService.clearWallpaperError()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ToastService.wallpaperErrorStatus = "error"
|
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 {
|
stderr: StdioCollector {
|
||||||
id: matugenErr
|
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() {
|
function generateAppConfigs() {
|
||||||
|
|||||||
Reference in New Issue
Block a user