Fix first start noctalia settings & color creation
This commit is contained in:
parent
849f3c52d7
commit
38928abab7
2 changed files with 25 additions and 12 deletions
|
|
@ -102,7 +102,7 @@ Singleton {
|
||||||
// FileView to load custom colors data from colors.json
|
// FileView to load custom colors data from colors.json
|
||||||
FileView {
|
FileView {
|
||||||
id: customColorsFile
|
id: customColorsFile
|
||||||
path: Settings.configDir + "colors.json"
|
path: Settings.directoriesCreated ? (Settings.configDir + "colors.json") : ""
|
||||||
watchChanges: true
|
watchChanges: true
|
||||||
onFileChanged: {
|
onFileChanged: {
|
||||||
Logger.log("Color", "Reloading colors from disk")
|
Logger.log("Color", "Reloading colors from disk")
|
||||||
|
|
@ -112,6 +112,13 @@ Singleton {
|
||||||
Logger.log("Color", "Writing colors to disk")
|
Logger.log("Color", "Writing colors to disk")
|
||||||
writeAdapter()
|
writeAdapter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Trigger initial load when path changes from empty to actual path
|
||||||
|
onPathChanged: {
|
||||||
|
if (path === Settings.configDir + "colors.json") {
|
||||||
|
reload()
|
||||||
|
}
|
||||||
|
}
|
||||||
onLoadFailed: function (error) {
|
onLoadFailed: function (error) {
|
||||||
if (error.toString().includes("No such file") || error === 2) {
|
if (error.toString().includes("No such file") || error === 2) {
|
||||||
// File doesn't exist, create it with default values
|
// File doesn't exist, create it with default values
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ Singleton {
|
||||||
readonly property alias data: adapter
|
readonly property alias data: adapter
|
||||||
|
|
||||||
property bool isLoaded: false
|
property bool isLoaded: false
|
||||||
|
property bool directoriesCreated: false
|
||||||
|
|
||||||
// Signal emitted when settings are loaded after startupcale changes
|
// Signal emitted when settings are loaded after startupcale changes
|
||||||
signal settingsLoaded
|
signal settingsLoaded
|
||||||
|
|
@ -176,14 +177,15 @@ Singleton {
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
Item {
|
// Ensure directories exist before FileView tries to read files
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
// ensure settings dir exists
|
||||||
// ensure settings dir exists
|
Quickshell.execDetached(["mkdir", "-p", configDir])
|
||||||
Quickshell.execDetached(["mkdir", "-p", configDir])
|
Quickshell.execDetached(["mkdir", "-p", cacheDir])
|
||||||
Quickshell.execDetached(["mkdir", "-p", cacheDir])
|
Quickshell.execDetached(["mkdir", "-p", cacheDirImages])
|
||||||
Quickshell.execDetached(["mkdir", "-p", cacheDirImages])
|
|
||||||
}
|
// Mark directories as created and trigger file loading
|
||||||
|
directoriesCreated = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't write settings to disk immediately
|
// Don't write settings to disk immediately
|
||||||
|
|
@ -197,12 +199,16 @@ Singleton {
|
||||||
|
|
||||||
FileView {
|
FileView {
|
||||||
id: settingsFileView
|
id: settingsFileView
|
||||||
path: settingsFile
|
path: directoriesCreated ? settingsFile : ""
|
||||||
watchChanges: true
|
watchChanges: true
|
||||||
onFileChanged: reload()
|
onFileChanged: reload()
|
||||||
onAdapterUpdated: saveTimer.start()
|
onAdapterUpdated: saveTimer.start()
|
||||||
Component.onCompleted: function () {
|
|
||||||
reload()
|
// Trigger initial load when path changes from empty to actual path
|
||||||
|
onPathChanged: {
|
||||||
|
if (path === settingsFile) {
|
||||||
|
reload()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
onLoaded: function () {
|
onLoaded: function () {
|
||||||
if (!isLoaded) {
|
if (!isLoaded) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue