[KCMs/Night Color] Add a valueForText handler for the new SpinBox
ClosedPublic

Authored by ngraham on Oct 21 2019, 4:54 PM.

Details

Summary

Now you can enter "1 minute" and it will be parsed correctly

Test Plan

Enter "1 minute" and tab away from the box

Diff Detail

Repository
R119 Plasma Desktop
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
ngraham created this revision.Oct 21 2019, 4:54 PM
Restricted Application added a project: Plasma. · View Herald TranscriptOct 21 2019, 4:54 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
ngraham requested review of this revision.Oct 21 2019, 4:54 PM
zzag removed a reviewer: zzag.Oct 21 2019, 6:48 PM
zzag added inline comments.
kcms/nightcolor/package/contents/ui/main.qml
319

Hmm, does parseInt take the user's locale into account?

Does it work in your locale?

zzag accepted this revision.Oct 21 2019, 7:56 PM
zzag added a subscriber: zzag.

Uh, I don't use Ukrainian locale. However, it doesn't matter that much. We format numbers practically the same way as in en_US.

Given the current implementation of textFromValue and the fact that the maximum value of transTimeField is capped, this change is good to go. However, it would be great to respect the user's locale.

This revision is now accepted and ready to land.Oct 21 2019, 7:56 PM
In D24838#551712, @zzag wrote:

Uh, I don't use Ukrainian locale. However, it doesn't matter that much. We format numbers practically the same way as in en_US.

Given the current implementation of textFromValue and the fact that the maximum value of transTimeField is capped, this change is good to go. However, it would be great to respect the user's locale.

I agree. Since there are other textFromValue implementations in plasma-desktop that don't do this, it would probably make sense to do them all at once. I'll see if I can figure out how.

This revision was automatically updated to reflect the committed changes.

Looks like parseInt() won't work for non-ASCII digits and for languages where the number of minutes does not come first in the phrase, see Sinhala language:

ro Romanian :	%1 minute
ru Russian :	%1 минуты
gd Scottish Gaelic :	%1 m(h)ionaid(ean)
sr Serbian :	%1 минута
si Sinhala :	මිනිත්තු %1

( found here: https://l10n.kde.org/dictionary/compare-translations.php?package=frameworks&filename=kdelibs4support.po&compare=%251+minutes )

Examples of non-ASCII digits:

Original Message: Every 30 Minutes

Farsi (Persian) :	هر ۳۰ دقیقه
Khmer :	រៀង​រាល់​ ៣០ ​នាទី​​
Nepali :	प्रत्येक ३० मिनेटमा

( found here: https://l10n.kde.org/dictionary/compare-translations.php?package=applications&filename=autorefresh.po&compare=Every+30+Minutes )