diff --git a/Modules/Bar/WiFiMenu.qml b/Modules/Bar/WiFiMenu.qml index 6775d18..34e463a 100644 --- a/Modules/Bar/WiFiMenu.qml +++ b/Modules/Bar/WiFiMenu.qml @@ -6,7 +6,7 @@ import Quickshell.Wayland import qs.Services import qs.Widgets -// LazyLoader for WiFi menu +// Loader for WiFi menu NLoader { id: root diff --git a/Modules/SidePanel/WeatherCard.qml b/Modules/SidePanel/WeatherCard.qml index fede32c..62f5120 100644 --- a/Modules/SidePanel/WeatherCard.qml +++ b/Modules/SidePanel/WeatherCard.qml @@ -1,5 +1,6 @@ import QtQuick import QtQuick.Layouts +import Quickshell import qs.Services import qs.Widgets @@ -8,6 +9,7 @@ NBox { id: root readonly property real scaling: Scaling.scale(screen) + readonly property bool weatherReady: (Location.data.weather !== null) Layout.fillWidth: true // Height driven by content @@ -24,11 +26,12 @@ NBox { RowLayout { spacing: Style.marginSmall * scaling NText { - text: Location.weatherSymbolFromCode(Location.data.weather.current_weather.weathercode) + text: weatherReady ? Location.weatherSymbolFromCode(Location.data.weather.current_weather.weathercode) : "" font.family: "Material Symbols Outlined" font.pointSize: Style.fontSizeXXL * 1.25 * scaling color: Colors.accentSecondary } + ColumnLayout { RowLayout { NText { @@ -37,14 +40,18 @@ NBox { font.pointSize: Style.fontSizeXL * scaling } NText { - text: `(${Location.data.weather.timezone_abbreviation})` + text: weatherReady ? `(${Location.data.weather.timezone_abbreviation})` : "" font.pointSize: Style.fontSizeSmall * scaling visible: Location.data.weather } } NText { + visible: weatherReady text: { + if (!weatherReady) { + return "" + } var temp = Location.data.weather.current_weather.temperature if (Settings.data.location.useFahrenheit) { temp = Location.celsiusToFahrenheit(temp) @@ -59,15 +66,17 @@ NBox { } NDivider { + visible: weatherReady Layout.fillWidth: true } RowLayout { + visible: weatherReady Layout.fillWidth: true Layout.alignment: Qt.AlignHCenter - spacing: Style.marginLarge* scaling + spacing: Style.marginLarge * scaling Repeater { - model: Location.data.weather.daily.time + model: weatherReady ? Location.data.weather.daily.time : [] delegate: ColumnLayout { Layout.alignment: Qt.AlignHCenter spacing: Style.spacingSmall * scaling @@ -99,5 +108,12 @@ NBox { } } } + + RowLayout { + visible: !weatherReady + Layout.fillWidth: true + Layout.alignment: Qt.AlignHCenter + NBusyIndicator {} + } } } diff --git a/Services/Location.qml b/Services/Location.qml index c33ca76..b5f91d2 100644 --- a/Services/Location.qml +++ b/Services/Location.qml @@ -41,9 +41,11 @@ Singleton { } } + // Every minute check if we need to fetch new weather Timer { id: updateTimer interval: 60 * 1000 + running: true repeat: true onTriggered: { updateWeather() @@ -51,7 +53,9 @@ Singleton { } // -------------------------------- - function init() {// does nothing but ensure the singleton is created + function init() { + // does nothing but ensure the singleton is created + // do not remove } // -------------------------------- @@ -60,11 +64,15 @@ Singleton { data.longitude = "" data.weatherLastFetch = 0 data.weather = null + + // Try to fetch immediately + updateWeather(); } // -------------------------------- function updateWeather() { if (isFetchingWeather) { + console.warn("Weather is still fetching") return }