config: don't serialise sizes
We do not want to serialise sizes cause people aren't meant to change them
This commit is contained in:
parent
e304846421
commit
d2e35a071b
1 changed files with 51 additions and 113 deletions
|
|
@ -27,6 +27,8 @@ Singleton {
|
||||||
property alias services: adapter.services
|
property alias services: adapter.services
|
||||||
property alias paths: adapter.paths
|
property alias paths: adapter.paths
|
||||||
|
|
||||||
|
property bool recentlySaved: false
|
||||||
|
|
||||||
// Public save function - call this to persist config changes
|
// Public save function - call this to persist config changes
|
||||||
function save(): void {
|
function save(): void {
|
||||||
saveTimer.restart();
|
saveTimer.restart();
|
||||||
|
|
@ -34,48 +36,6 @@ Singleton {
|
||||||
recentSaveCooldown.restart();
|
recentSaveCooldown.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
property bool recentlySaved: false
|
|
||||||
|
|
||||||
ElapsedTimer {
|
|
||||||
id: timer
|
|
||||||
}
|
|
||||||
|
|
||||||
Timer {
|
|
||||||
id: saveTimer
|
|
||||||
|
|
||||||
interval: 500
|
|
||||||
onTriggered: {
|
|
||||||
timer.restart();
|
|
||||||
try {
|
|
||||||
// Parse current config to preserve structure and comments if possible
|
|
||||||
let config = {};
|
|
||||||
try {
|
|
||||||
config = JSON.parse(fileView.text());
|
|
||||||
} catch (e) {
|
|
||||||
// If parsing fails, start with empty object
|
|
||||||
config = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update config with current values
|
|
||||||
config = serializeConfig();
|
|
||||||
|
|
||||||
// Save to file with pretty printing
|
|
||||||
fileView.setText(JSON.stringify(config, null, 2));
|
|
||||||
} catch (e) {
|
|
||||||
Toaster.toast(qsTr("Failed to serialize config"), e.message, "settings_alert", Toast.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Timer {
|
|
||||||
id: recentSaveCooldown
|
|
||||||
|
|
||||||
interval: 2000
|
|
||||||
onTriggered: {
|
|
||||||
recentlySaved = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper function to serialize the config object
|
// Helper function to serialize the config object
|
||||||
function serializeConfig(): var {
|
function serializeConfig(): var {
|
||||||
return {
|
return {
|
||||||
|
|
@ -238,13 +198,6 @@ Singleton {
|
||||||
clock: {
|
clock: {
|
||||||
showIcon: bar.clock.showIcon
|
showIcon: bar.clock.showIcon
|
||||||
},
|
},
|
||||||
sizes: {
|
|
||||||
innerWidth: bar.sizes.innerWidth,
|
|
||||||
windowPreviewSize: bar.sizes.windowPreviewSize,
|
|
||||||
trayMenuWidth: bar.sizes.trayMenuWidth,
|
|
||||||
batteryWidth: bar.sizes.batteryWidth,
|
|
||||||
networkWidth: bar.sizes.networkWidth
|
|
||||||
},
|
|
||||||
entries: bar.entries,
|
entries: bar.entries,
|
||||||
excludedScreens: bar.excludedScreens
|
excludedScreens: bar.excludedScreens
|
||||||
};
|
};
|
||||||
|
|
@ -271,32 +224,12 @@ Singleton {
|
||||||
showMemory: dashboard.performance.showMemory,
|
showMemory: dashboard.performance.showMemory,
|
||||||
showStorage: dashboard.performance.showStorage,
|
showStorage: dashboard.performance.showStorage,
|
||||||
showNetwork: dashboard.performance.showNetwork
|
showNetwork: dashboard.performance.showNetwork
|
||||||
},
|
|
||||||
sizes: {
|
|
||||||
tabIndicatorHeight: dashboard.sizes.tabIndicatorHeight,
|
|
||||||
tabIndicatorSpacing: dashboard.sizes.tabIndicatorSpacing,
|
|
||||||
infoWidth: dashboard.sizes.infoWidth,
|
|
||||||
infoIconSize: dashboard.sizes.infoIconSize,
|
|
||||||
dateTimeWidth: dashboard.sizes.dateTimeWidth,
|
|
||||||
mediaWidth: dashboard.sizes.mediaWidth,
|
|
||||||
mediaProgressSweep: dashboard.sizes.mediaProgressSweep,
|
|
||||||
mediaProgressThickness: dashboard.sizes.mediaProgressThickness,
|
|
||||||
resourceProgessThickness: dashboard.sizes.resourceProgessThickness,
|
|
||||||
weatherWidth: dashboard.sizes.weatherWidth,
|
|
||||||
mediaCoverArtSize: dashboard.sizes.mediaCoverArtSize,
|
|
||||||
mediaVisualiserSize: dashboard.sizes.mediaVisualiserSize,
|
|
||||||
resourceSize: dashboard.sizes.resourceSize
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function serializeControlCenter(): var {
|
function serializeControlCenter(): var {
|
||||||
return {
|
return {};
|
||||||
sizes: {
|
|
||||||
heightMult: controlCenter.sizes.heightMult,
|
|
||||||
ratio: controlCenter.sizes.ratio
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function serializeLauncher(): var {
|
function serializeLauncher(): var {
|
||||||
|
|
@ -319,12 +252,6 @@ Singleton {
|
||||||
variants: launcher.useFuzzy.variants,
|
variants: launcher.useFuzzy.variants,
|
||||||
wallpapers: launcher.useFuzzy.wallpapers
|
wallpapers: launcher.useFuzzy.wallpapers
|
||||||
},
|
},
|
||||||
sizes: {
|
|
||||||
itemWidth: launcher.sizes.itemWidth,
|
|
||||||
itemHeight: launcher.sizes.itemHeight,
|
|
||||||
wallpaperWidth: launcher.sizes.wallpaperWidth,
|
|
||||||
wallpaperHeight: launcher.sizes.wallpaperHeight
|
|
||||||
},
|
|
||||||
actions: launcher.actions
|
actions: launcher.actions
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -336,12 +263,7 @@ Singleton {
|
||||||
clearThreshold: notifs.clearThreshold,
|
clearThreshold: notifs.clearThreshold,
|
||||||
expandThreshold: notifs.expandThreshold,
|
expandThreshold: notifs.expandThreshold,
|
||||||
actionOnClick: notifs.actionOnClick,
|
actionOnClick: notifs.actionOnClick,
|
||||||
groupPreviewNum: notifs.groupPreviewNum,
|
groupPreviewNum: notifs.groupPreviewNum
|
||||||
sizes: {
|
|
||||||
width: notifs.sizes.width,
|
|
||||||
image: notifs.sizes.image,
|
|
||||||
badge: notifs.sizes.badge
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -350,11 +272,7 @@ Singleton {
|
||||||
enabled: osd.enabled,
|
enabled: osd.enabled,
|
||||||
hideDelay: osd.hideDelay,
|
hideDelay: osd.hideDelay,
|
||||||
enableBrightness: osd.enableBrightness,
|
enableBrightness: osd.enableBrightness,
|
||||||
enableMicrophone: osd.enableMicrophone,
|
enableMicrophone: osd.enableMicrophone
|
||||||
sizes: {
|
|
||||||
sliderWidth: osd.sizes.sliderWidth,
|
|
||||||
sliderHeight: osd.sizes.sliderHeight
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -374,20 +292,12 @@ Singleton {
|
||||||
shutdown: session.commands.shutdown,
|
shutdown: session.commands.shutdown,
|
||||||
hibernate: session.commands.hibernate,
|
hibernate: session.commands.hibernate,
|
||||||
reboot: session.commands.reboot
|
reboot: session.commands.reboot
|
||||||
},
|
|
||||||
sizes: {
|
|
||||||
button: session.sizes.button
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function serializeWinfo(): var {
|
function serializeWinfo(): var {
|
||||||
return {
|
return {};
|
||||||
sizes: {
|
|
||||||
heightMult: winfo.sizes.heightMult,
|
|
||||||
detailsWidth: winfo.sizes.detailsWidth
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function serializeLock(): var {
|
function serializeLock(): var {
|
||||||
|
|
@ -395,12 +305,7 @@ Singleton {
|
||||||
recolourLogo: lock.recolourLogo,
|
recolourLogo: lock.recolourLogo,
|
||||||
enableFprint: lock.enableFprint,
|
enableFprint: lock.enableFprint,
|
||||||
maxFprintTries: lock.maxFprintTries,
|
maxFprintTries: lock.maxFprintTries,
|
||||||
hideNotifs: lock.hideNotifs,
|
hideNotifs: lock.hideNotifs
|
||||||
sizes: {
|
|
||||||
heightMult: lock.sizes.heightMult,
|
|
||||||
ratio: lock.sizes.ratio,
|
|
||||||
centerWidth: lock.sizes.centerWidth
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -408,10 +313,6 @@ Singleton {
|
||||||
return {
|
return {
|
||||||
enabled: utilities.enabled,
|
enabled: utilities.enabled,
|
||||||
maxToasts: utilities.maxToasts,
|
maxToasts: utilities.maxToasts,
|
||||||
sizes: {
|
|
||||||
width: utilities.sizes.width,
|
|
||||||
toastWidth: utilities.sizes.toastWidth
|
|
||||||
},
|
|
||||||
toasts: {
|
toasts: {
|
||||||
configLoaded: utilities.toasts.configLoaded,
|
configLoaded: utilities.toasts.configLoaded,
|
||||||
chargingChanged: utilities.toasts.chargingChanged,
|
chargingChanged: utilities.toasts.chargingChanged,
|
||||||
|
|
@ -435,10 +336,7 @@ Singleton {
|
||||||
function serializeSidebar(): var {
|
function serializeSidebar(): var {
|
||||||
return {
|
return {
|
||||||
enabled: sidebar.enabled,
|
enabled: sidebar.enabled,
|
||||||
dragThreshold: sidebar.dragThreshold,
|
dragThreshold: sidebar.dragThreshold
|
||||||
sizes: {
|
|
||||||
width: sidebar.sizes.width
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -467,6 +365,46 @@ Singleton {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ElapsedTimer {
|
||||||
|
id: timer
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: saveTimer
|
||||||
|
|
||||||
|
interval: 500
|
||||||
|
onTriggered: {
|
||||||
|
timer.restart();
|
||||||
|
try {
|
||||||
|
// Parse current config to preserve structure and comments if possible
|
||||||
|
let config = {};
|
||||||
|
try {
|
||||||
|
config = JSON.parse(fileView.text());
|
||||||
|
} catch (e) {
|
||||||
|
// If parsing fails, start with empty object
|
||||||
|
config = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update config with current values
|
||||||
|
config = root.serializeConfig();
|
||||||
|
|
||||||
|
// Save to file with pretty printing
|
||||||
|
fileView.setText(JSON.stringify(config, null, 2));
|
||||||
|
} catch (e) {
|
||||||
|
Toaster.toast(qsTr("Failed to serialize config"), e.message, "settings_alert", Toast.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: recentSaveCooldown
|
||||||
|
|
||||||
|
interval: 2000
|
||||||
|
onTriggered: {
|
||||||
|
root.recentlySaved = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FileView {
|
FileView {
|
||||||
id: fileView
|
id: fileView
|
||||||
|
|
||||||
|
|
@ -474,7 +412,7 @@ Singleton {
|
||||||
watchChanges: true
|
watchChanges: true
|
||||||
onFileChanged: {
|
onFileChanged: {
|
||||||
// Prevent reload loop - don't reload if we just saved
|
// Prevent reload loop - don't reload if we just saved
|
||||||
if (!recentlySaved) {
|
if (!root.recentlySaved) {
|
||||||
timer.restart();
|
timer.restart();
|
||||||
reload();
|
reload();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -487,9 +425,9 @@ Singleton {
|
||||||
JSON.parse(text());
|
JSON.parse(text());
|
||||||
const elapsed = timer.elapsedMs();
|
const elapsed = timer.elapsedMs();
|
||||||
// Only show toast for external changes (not our own saves) and when elapsed time is meaningful
|
// Only show toast for external changes (not our own saves) and when elapsed time is meaningful
|
||||||
if (adapter.utilities.toasts.configLoaded && !recentlySaved && elapsed > 0) {
|
if (adapter.utilities.toasts.configLoaded && !root.recentlySaved && elapsed > 0) {
|
||||||
Toaster.toast(qsTr("Config loaded"), qsTr("Config loaded in %1ms").arg(elapsed), "rule_settings");
|
Toaster.toast(qsTr("Config loaded"), qsTr("Config loaded in %1ms").arg(elapsed), "rule_settings");
|
||||||
} else if (adapter.utilities.toasts.configLoaded && recentlySaved && elapsed > 0) {
|
} else if (adapter.utilities.toasts.configLoaded && root.recentlySaved && elapsed > 0) {
|
||||||
Toaster.toast(qsTr("Config saved"), qsTr("Config reloaded in %1ms").arg(elapsed), "rule_settings");
|
Toaster.toast(qsTr("Config saved"), qsTr("Config reloaded in %1ms").arg(elapsed), "rule_settings");
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue