Bug 443608 - Manual position entry disregards fractional part if the decimal separator is not a dot
Summary: Manual position entry disregards fractional part if the decimal separator is ...
Status: REPORTED
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_nighttime (other bugs)
Version First Reported In: 5.22.5
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-11 18:30 UTC by bugs.kde
Modified: 2025-08-01 22:44 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Input before pressing apply and switching module (79.47 KB, image/png)
2021-10-11 18:30 UTC, bugs.kde
Details
Settings after switching to another module and back. No changes done manually. (76.29 KB, image/png)
2021-10-11 18:31 UTC, bugs.kde
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bugs.kde 2021-10-11 18:30:31 UTC
Created attachment 142341 [details]
Input before pressing apply and switching module

When the Night Color activation time is set to “Sunset to sunrise at manual location”, I can enter the longitude and latitude including a fractional part but the fractional part is ignored and will be disregarded when switching to another settings module and back. This is because my locale use comma (“,”) as decimal separator.


STEPS TO REPRODUCE
1. Set numbers format to German (mine is Austrian German or “Österreichisches Deutsch”) and relogin to apply changes.
2. Set Night Color activation time to “Sunset to sunrise at manual location”
3. Enter latitude and longitude with comma as decimal separator. E.g. “47,5” / “11,5” and apply. Note that dots can not even be entered.
4. Switch to Compositor settings (or any other module) and switch back.

OBSERVED RESULT
Latitude is set to 47 and longitude to 11.
Also the calculated times correspond to these values.

EXPECTED RESULT
Latitude stays set to 47,5 and longitude to 11,5.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch Linux
KDE Plasma Version: 5.22.5
KDE Frameworks Version: 5.87.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
The bug happens due to the use of JavaScript’s parseFloat, which only parses floats with dot as a decimal separator, here: https://invent.kde.org/plasma/plasma-workspace/-/blob/master/kcms/nightcolor/package/contents/ui/NumberField.qml lines 25 and 33.

Replacing all commas with dots before calling parseFloat fixes the problem mostly. However this is only a dirty workaround.
Additionally the conversion from float to text on line 21 also has to be adjusted, otherwise the input behaves funnily in some cases.

In general, I am quite sure that the correct fix is to replace float-string conversions in both ways (lines 21, 25 and 33) with locale aware variants.

Note: While I am using the versions specified above obtained via Archlinux Packages the bug is obviously still present on master at the time of reporting.
Comment 1 bugs.kde 2021-10-11 18:31:47 UTC
Created attachment 142342 [details]
Settings after switching to another module and back. No changes done manually.
Comment 2 bugs.kde 2021-10-11 18:34:20 UTC
I have also attached before and after screenshots which show the exact situation.
After the before screenshot was taken I only pressed Apply and switched to compositor and back.
I did _not_ edit anything myself.