Bug 503138 - Default unit values missing
Summary: Default unit values missing
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Weather widget (other bugs)
Version First Reported In: 6.3.4
Platform: Other Linux
: NOR normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords: usability
Depends on:
Blocks:
 
Reported: 2025-04-21 19:56 UTC by postix
Modified: 2025-04-23 13:46 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.3.5
Sentry Crash Report:


Attachments
Screenshot (309.55 KB, image/png)
2025-04-21 19:56 UTC, postix
Details

Note You need to log in before you can comment on or make changes to this bug.
Description postix 2025-04-21 19:56:00 UTC
Created attachment 180496 [details]
Screenshot

STEPS TO REPRODUCE
1. Add the weather widge to your panel
2. Choose a location
3. Open the widget

OBSERVED RESULT
The weather report contains columns with two rows of zeros.
Its settings shows that no units are pre-selected.

EXPECTED RESULT
The weather widget chooses meaningful units depending on the region of the user.
eg. °F in the US, °C everywhere else


SOFTWARE/OS VERSIONS
Operating System: Fedora Linux 42
KDE Plasma Version: 6.3.4
KDE Frameworks Version: 6.13.0
Qt Version: 6.9.0
Kernel Version: 6.14.2-300.fc42.x86_64 (64-bit)
Graphics Platform: Wayland
Comment 1 Ismael Asensio 2025-04-22 08:57:05 UTC
I can reproduce it on a newly installed weather applet

Can you check if the state with no-units persists if you close the session and log-in back again? (keeping the weather widget in the panel)

Thanks!
Comment 2 postix 2025-04-22 09:07:02 UTC
(In reply to Ismael Asensio from comment #1)
> Can you check if the state with no-units persists if you close the session
> and log-in back again? (keeping the weather widget in the panel)
When logging back in, units are set automatically. :)

> Thanks!
You are welcome!
Comment 3 Ismael Asensio 2025-04-22 15:55:59 UTC
(In reply to postix from comment #2)
> When logging back in, units are set automatically. :)

Nice, thanks for confirming this! 
It matches what I've been able to debug: for a fresh installed weather applet, the default units are set to the config file at `init()`, but by then the applet is already loaded, and the property object in QML (a KConfigPropertyMap) is not updated to reflect this. 

Looking for a way to make this update happen, or either, a different way to use the default units without involving the user config
Comment 4 Bug Janitor Service 2025-04-22 21:30:58 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kdeplasma-addons/-/merge_requests/749
Comment 5 Ismael Asensio 2025-04-23 10:39:11 UTC
Git commit 923d22128332a019bfa2893e36c31181bec61a10 by Ismael Asensio.
Committed on 22/04/2025 at 21:40.
Pushed by iasensio into branch 'master'.

applets/weather: Expose and use default units directly

In the weather applet we want to have locale-aware default units
(ex ºF vs ºC) instead of hardcoded defaults in the config.xml.

This was done by writing these defaults into the config if empty.
This worked while doing so from the applet constructor, which was
wrong and caused other bugs. Setting them in the `init()` method
doesn't work either as the applet QML configuration is not correctly
updated from config at this point.

Instead, let's expose these defaults in the units model and use them
as actual fallback values in QML, which should be more robust that
messing with the plasma configuration, while also reducing the custom
WeatherApplet code.
FIXED-IN: 6.3.5

M  +4    -4    applets/weather/package/contents/ui/main.qml
M  +8    -2    applets/weather/plugin/abstractunitlistmodel.cpp
M  +4    -1    applets/weather/plugin/abstractunitlistmodel.h
M  +24   -6    applets/weather/plugin/plugin.cpp
M  +0    -24   applets/weather/weatherapplet.cpp
M  +0    -4    applets/weather/weatherapplet.h

https://invent.kde.org/plasma/kdeplasma-addons/-/commit/923d22128332a019bfa2893e36c31181bec61a10
Comment 6 Ismael Asensio 2025-04-23 13:46:15 UTC
Git commit b658c27508117bccb1ba0637a79f5c328b6ec7f6 by Ismael Asensio.
Committed on 23/04/2025 at 10:39.
Pushed by iasensio into branch 'Plasma/6.3'.

applets/weather: Expose and use default units directly

In the weather applet we want to have locale-aware default units
(ex ºF vs ºC) instead of hardcoded defaults in the config.xml.

This was done by writing these defaults into the config if empty.
This worked while doing so from the applet constructor, which was
wrong and caused other bugs. Setting them in the `init()` method
doesn't work either as the applet QML configuration is not correctly
updated from config at this point.

Instead, let's expose these defaults in the units model and use them
as actual fallback values in QML, which should be more robust that
messing with the plasma configuration, while also reducing the custom
WeatherApplet code.
FIXED-IN: 6.3.5


(cherry picked from commit 923d22128332a019bfa2893e36c31181bec61a10)

Co-authored-by: Ismael Asensio <isma.af@gmail.com>

M  +4    -4    applets/weather/package/contents/ui/main.qml
M  +8    -2    applets/weather/plugin/abstractunitlistmodel.cpp
M  +4    -1    applets/weather/plugin/abstractunitlistmodel.h
M  +24   -6    applets/weather/plugin/plugin.cpp
M  +0    -24   applets/weather/weatherapplet.cpp
M  +0    -4    applets/weather/weatherapplet.h

https://invent.kde.org/plasma/kdeplasma-addons/-/commit/b658c27508117bccb1ba0637a79f5c328b6ec7f6