Bug 404292 - Digital clock settings option for toggling between 12 and 24 hour clock format is broken
Summary: Digital clock settings option for toggling between 12 and 24 hour clock forma...
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Digital Clock (show other bugs)
Version: 5.15.0
Platform: Other Linux
: NOR normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords:
: 404413 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-02-13 14:21 UTC by Martin
Modified: 2019-02-15 21:32 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.15.1


Attachments
screenshot of the issue (94.23 KB, image/png)
2019-02-13 14:21 UTC, Martin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin 2019-02-13 14:21:45 UTC
Created attachment 118042 [details]
screenshot of the issue

Version 5.15, released yesterday, not present in the bug tracker.

This issue is with digital clock, not fuzzy clock, but I also could not find the former on the bug tracker.

SUMMARY
Enabling 24-hour clock does nothing and it remains showing 12-hour clock in tray.



STEPS TO REPRODUCE
1. Set clock to Digital clock
2. Right click on it > Configure Digital Clocl
3. Toggling the "24 Hour format" with en_US locale makes the time remain on 12-hour clock.

OBSERVED RESULT
Clock to change to 24-hour format when the option is checked


EXPECTED RESULT
Clock remains in 12-hour format



SOFTWARE/OS VERSIONS
Linux: Arch Linux
KDE Plasma Version: 5.15.0
KDE Frameworks Version: 5.55.0
Qt Version: 5.12.1

ADDITIONAL INFORMATION
Comment 1 Chris Holland 2019-02-14 20:13:57 UTC
Why the heck is this config property an unsigned int instead of a bool? Oooooh right. It's a tri-state button that defaults to whatever the system locale chooses.

    // config/main.xml
    <entry name="use24hFormat" type="UInt">
      <label>Force the clock to use 12/24 hour time, instead of following the user locale.</label>
      <default>1</default>
    </entry>


    // ui/configAppearance.qml
    QtControls.CheckBox {
        id: use24hFormat
        text: i18nc("Checkbox label; means 24h clock format, without am/pm", "Use 24-hour Clock")
    }

    // ui/DigitalClock.qml
    property int use24hFormat: plasmoid.configuration.use24hFormat


* https://github.com/KDE/plasma-workspace/blame/master/applets/digital-clock/package/contents/ui/configAppearance.qml


It looks like during the QQC2/Kirigami migration, the tri-state button property `checkedState` was changed to `checked`.

https://github.com/KDE/plasma-workspace/commit/39e812d57fd6a52e6c8596f823564a241d9ae696#diff-26b9a772d0004bc6a0622b47b3cbfd09L46

Since `bool checked` when cast to an integer is 0=off, and 1=on, it's basically changing between Qt::Unchecked=0 and Qt::PartiallyChecked=1. So when the 24h button is "checked=true", it's cast as Qt::PartiallyChecked=1 and ends up using the system locale. Since in en_US defaults to 12h clock, it has no visible effect.

If the dev who wrote the code migration developed in a 24h system locale, it'd "work" during testing.

* https://doc.qt.io/qt-5/qml-qtquick-controls-checkbox.html#checkedState-prop
* https://doc.qt.io/archives/qt-5.10/qt.html#CheckState-enum

It's a bit odd that Qt::PartiallyChecked is 1, instead of 2. But I guess that was intentional by the Qt devs.
Comment 2 Chris Holland 2019-02-14 20:41:27 UTC
Ah, seems like the QQC1.CheckBox.checkedState property was renamed QQC2.CheckBox.checkState

* https://doc.qt.io/qt-5.11/qml-qtquick-controls2-checkbox.html#checkState-prop

In any case, here's a patch: https://phabricator.kde.org/D19021

Martin, you can either wait a few days for Plasma 5.15.1, or you can manually edit the file with the fix:
/usr/share/plasma/plasmoids/org.kde.plasma.digitalclock/contents/ui/configAppearance.qml

Then relog to reload the widget.
Comment 3 Chris Holland 2019-02-15 00:12:39 UTC
Git commit 006c4f5f9ee8dfb3d95604a706d01b968c1e1c8a by Chris Holland.
Committed on 14/02/2019 at 23:48.
Pushed by cholland into branch 'Plasma/5.15'.

[Digital Clock] Fix 24h tri-state button broken in port to QQC2

In 12h system locales (eg: en_US), checked=1 is cast as
Qt::PartiallyChecked=1 which defaults to the system locale (12h).
Since it's no longer a tri-state button, the user can't select
Qt::Checked=2 which forces the 24h state.

FIXED-IN: 5.15.1

M  +2    -1    applets/digital-clock/package/contents/ui/configAppearance.qml

https://commits.kde.org/plasma-workspace/006c4f5f9ee8dfb3d95604a706d01b968c1e1c8a
Comment 4 Alexander Kowalski 2019-02-15 21:32:33 UTC
*** Bug 404413 has been marked as a duplicate of this bug. ***