diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-08-10 23:15:32 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-08-10 23:15:32 +1000 |
| commit | 87b491d8e794995950c6667e1d831061e36aa186 (patch) | |
| tree | f17fc2be88041dda842d2e3d7db05b09768d3c0d /services | |
| parent | lock: better lock anim (diff) | |
| download | caelestia-shell-87b491d8e794995950c6667e1d831061e36aa186.tar.gz caelestia-shell-87b491d8e794995950c6667e1d831061e36aa186.tar.bz2 caelestia-shell-87b491d8e794995950c6667e1d831061e36aa186.zip | |
lock: add weather
Also refactor weather service
Diffstat (limited to 'services')
| -rw-r--r-- | services/Weather.qml | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/services/Weather.qml b/services/Weather.qml index 38750ae..02458c2 100644 --- a/services/Weather.qml +++ b/services/Weather.qml @@ -9,10 +9,13 @@ Singleton { id: root property string loc - property string icon - property string description - property string tempC: "0°C" - property string tempF: "0°F" + property var cc + property var forecast + readonly property string icon: cc ? Icons.getWeatherIcon(cc.weatherCode) : "cloud_alert" + readonly property string description: cc?.weatherDesc[0].value ?? qsTr("No weather") + readonly property string temp: Config.services.useFahrenheit ? `${cc?.temp_F ?? 0}°F` : `${cc?.temp_C ?? 0}°C` + readonly property string feelsLike: Config.services.useFahrenheit ? `${cc?.FeelsLikeF ?? 0}°F` : `${cc?.FeelsLikeC ?? 0}°C` + readonly property int humidity: cc?.humidity ?? 0 function reload(): void { if (Config.services.weatherLocation) @@ -25,11 +28,9 @@ Singleton { } onLocChanged: Requests.get(`https://wttr.in/${loc}?format=j1`, text => { - const json = JSON.parse(text).current_condition[0]; - icon = Icons.getWeatherIcon(json.weatherCode); - description = json.weatherDesc[0].value; - tempC = `${parseFloat(json.temp_C)}°C`; - tempF = `${parseFloat(json.temp_F)}°F`; + const json = JSON.parse(text); + cc = json.current_condition[0]; + forecast = json.weather; }) Component.onCompleted: reload() |