From d2e35a071b36a797a2cb3aebc8a643edde31fa41 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sun, 15 Mar 2026 18:40:12 +1100 Subject: config: don't serialise sizes We do not want to serialise sizes cause people aren't meant to change them --- config/Config.qml | 164 +++++++++++++++++------------------------------------- 1 file changed, 51 insertions(+), 113 deletions(-) (limited to 'config') diff --git a/config/Config.qml b/config/Config.qml index c5cc109..07530fc 100644 --- a/config/Config.qml +++ b/config/Config.qml @@ -27,6 +27,8 @@ Singleton { property alias services: adapter.services property alias paths: adapter.paths + property bool recentlySaved: false + // Public save function - call this to persist config changes function save(): void { saveTimer.restart(); @@ -34,48 +36,6 @@ Singleton { 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 function serializeConfig(): var { return { @@ -238,13 +198,6 @@ Singleton { clock: { 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, excludedScreens: bar.excludedScreens }; @@ -271,32 +224,12 @@ Singleton { showMemory: dashboard.performance.showMemory, showStorage: dashboard.performance.showStorage, 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 { - return { - sizes: { - heightMult: controlCenter.sizes.heightMult, - ratio: controlCenter.sizes.ratio - } - }; + return {}; } function serializeLauncher(): var { @@ -319,12 +252,6 @@ Singleton { variants: launcher.useFuzzy.variants, wallpapers: launcher.useFuzzy.wallpapers }, - sizes: { - itemWidth: launcher.sizes.itemWidth, - itemHeight: launcher.sizes.itemHeight, - wallpaperWidth: launcher.sizes.wallpaperWidth, - wallpaperHeight: launcher.sizes.wallpaperHeight - }, actions: launcher.actions }; } @@ -336,12 +263,7 @@ Singleton { clearThreshold: notifs.clearThreshold, expandThreshold: notifs.expandThreshold, actionOnClick: notifs.actionOnClick, - groupPreviewNum: notifs.groupPreviewNum, - sizes: { - width: notifs.sizes.width, - image: notifs.sizes.image, - badge: notifs.sizes.badge - } + groupPreviewNum: notifs.groupPreviewNum }; } @@ -350,11 +272,7 @@ Singleton { enabled: osd.enabled, hideDelay: osd.hideDelay, enableBrightness: osd.enableBrightness, - enableMicrophone: osd.enableMicrophone, - sizes: { - sliderWidth: osd.sizes.sliderWidth, - sliderHeight: osd.sizes.sliderHeight - } + enableMicrophone: osd.enableMicrophone }; } @@ -374,20 +292,12 @@ Singleton { shutdown: session.commands.shutdown, hibernate: session.commands.hibernate, reboot: session.commands.reboot - }, - sizes: { - button: session.sizes.button } }; } function serializeWinfo(): var { - return { - sizes: { - heightMult: winfo.sizes.heightMult, - detailsWidth: winfo.sizes.detailsWidth - } - }; + return {}; } function serializeLock(): var { @@ -395,12 +305,7 @@ Singleton { recolourLogo: lock.recolourLogo, enableFprint: lock.enableFprint, maxFprintTries: lock.maxFprintTries, - hideNotifs: lock.hideNotifs, - sizes: { - heightMult: lock.sizes.heightMult, - ratio: lock.sizes.ratio, - centerWidth: lock.sizes.centerWidth - } + hideNotifs: lock.hideNotifs }; } @@ -408,10 +313,6 @@ Singleton { return { enabled: utilities.enabled, maxToasts: utilities.maxToasts, - sizes: { - width: utilities.sizes.width, - toastWidth: utilities.sizes.toastWidth - }, toasts: { configLoaded: utilities.toasts.configLoaded, chargingChanged: utilities.toasts.chargingChanged, @@ -435,10 +336,7 @@ Singleton { function serializeSidebar(): var { return { enabled: sidebar.enabled, - dragThreshold: sidebar.dragThreshold, - sizes: { - width: sidebar.sizes.width - } + dragThreshold: sidebar.dragThreshold }; } @@ -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 { id: fileView @@ -474,7 +412,7 @@ Singleton { watchChanges: true onFileChanged: { // Prevent reload loop - don't reload if we just saved - if (!recentlySaved) { + if (!root.recentlySaved) { timer.restart(); reload(); } else { @@ -487,9 +425,9 @@ Singleton { JSON.parse(text()); const elapsed = timer.elapsedMs(); // 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"); - } 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"); } } catch (e) { -- cgit v1.2.3-freya