settings: bar/controlcenter/desktop widgets - debounce save

This commit is contained in:
Lemmy
2026-01-29 09:16:46 -05:00
parent 41ec8c4ee6
commit ae56470c4f
3 changed files with 43 additions and 10 deletions
@@ -15,11 +15,12 @@ Popup {
property string widgetId: ""
property string sectionId: ""
property var screen: null
signal updateWidgetSettings(string section, int index, var settings)
property var settingsCache: ({})
readonly property real maxHeight: screen ? screen.height * 0.9 : 800
signal updateWidgetSettings(string section, int index, var settings)
width: Math.max(content.implicitWidth + padding * 2, 640)
height: Math.min(content.implicitHeight + padding * 2, maxHeight)
padding: Style.marginXL
@@ -141,14 +142,24 @@ Popup {
}
}
Timer {
id: saveTimer
running: false
interval: 150
onTriggered: {
root.updateWidgetSettings(root.sectionId, root.widgetIndex, root.settingsCache);
}
}
Connections {
target: settingsLoader.item
ignoreUnknownSignals: true
function onSettingsChanged(newSettings) {
if (newSettings) {
root.updateWidgetSettings(root.sectionId, root.widgetIndex, newSettings);
root.settingsCache = newSettings;
saveTimer.start();
}
}
ignoreUnknownSignals: true
}
function saveAndClose() {
@@ -14,6 +14,7 @@ Popup {
property string widgetId: ""
property string sectionId: ""
property var screen: null
property var settingsCache: ({})
signal updateWidgetSettings(string section, int index, var settings)
@@ -113,14 +114,24 @@ Popup {
}
}
Timer {
id: saveTimer
running: false
interval: 150
onTriggered: {
root.updateWidgetSettings(root.sectionId, root.widgetIndex, root.settingsCache);
}
}
Connections {
target: settingsLoader.item
ignoreUnknownSignals: true
function onSettingsChanged(newSettings) {
if (newSettings) {
root.updateWidgetSettings(root.sectionId, root.widgetIndex, newSettings);
root.settingsCache = newSettings;
saveTimer.start();
}
}
ignoreUnknownSignals: true
}
function saveAndClose() {
@@ -16,11 +16,12 @@ Popup {
property string widgetId: ""
property string sectionId: "" // Not used for desktop widgets, but required by NSectionEditor
property var screen: null
signal updateWidgetSettings(string section, int index, var settings)
property var settingsCache: ({})
readonly property real maxHeight: screen ? screen.height * 0.9 : 800
signal updateWidgetSettings(string section, int index, var settings)
width: Math.max(content.implicitWidth + padding * 2, 500)
height: Math.min(content.implicitHeight + padding * 2, maxHeight)
padding: Style.marginXL
@@ -135,14 +136,24 @@ Popup {
}
}
Timer {
id: saveTimer
running: false
interval: 150
onTriggered: {
root.updateWidgetSettings(root.sectionId, root.widgetIndex, root.settingsCache);
}
}
Connections {
target: settingsLoader.item
ignoreUnknownSignals: true
function onSettingsChanged(newSettings) {
if (newSettings) {
root.updateWidgetSettings(root.sectionId, root.widgetIndex, newSettings);
root.settingsCache = newSettings;
saveTimer.start();
}
}
ignoreUnknownSignals: true
}
function saveAndClose() {