From 73e6127d4eb36fa9a09500616a9df4233ea55d9a Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 20 May 2026 20:27:59 +0200 Subject: [PATCH] Lift setting() onto the Panel base too Matches the BarWidget extraction in the previous commit. The weather panel was the only panel reimplementing the helper inline; future panels with inline settings get it for free. --- shell/Ui/Panel.qml | 7 +++++++ shell/plugins/panels/weather.qml | 5 ----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/shell/Ui/Panel.qml b/shell/Ui/Panel.qml index 3bc776df..be51587c 100644 --- a/shell/Ui/Panel.qml +++ b/shell/Ui/Panel.qml @@ -21,6 +21,13 @@ Item { function close() { panelController.hide() } function toggle() { opened ? close() : open() } + // Read a single value from this panel's inline shell.json entry, with a + // fallback for missing/null values. Matches BarWidget.setting(). + function setting(name, fallback) { + var value = settings ? settings[name] : undefined + return value === undefined || value === null ? fallback : value + } + PanelController { id: panelController } diff --git a/shell/plugins/panels/weather.qml b/shell/plugins/panels/weather.qml index efd3b2b3..496684ad 100644 --- a/shell/plugins/panels/weather.qml +++ b/shell/plugins/panels/weather.qml @@ -65,11 +65,6 @@ Panel { readonly property string reportWind: current ? (useImperial ? (current.windspeedMiles + " mph") : (current.windspeedKmph + " km/h")) : "" readonly property string reportHumidity: current ? (current.humidity + "%") : "" - function setting(name, fallback) { - var v = settings ? settings[name] : undefined - return v === undefined || v === null ? fallback : v - } - function refresh() { if (!forecastProc.running) forecastProc.running = true if (!locationProc.running) locationProc.running = true