Apply settings 12/24 hour time format to lockscreen and panel time

This commit is contained in:
Devin Lin 2020-09-17 12:04:49 -04:00
parent a857dbc299
commit cd4bf8d7c3
4 changed files with 7 additions and 3 deletions

View file

@ -217,8 +217,10 @@ Item {
PlasmaComponents.Label {
id: clock
property bool is24HourTime: Qt.locale().timeFormat(Locale.ShortFormat).toLowerCase().indexOf("ap") === -1
anchors.fill: parent
text: Qt.formatTime(timeSource.data.Local.DateTime, "hh:mm")
text: Qt.formatTime(timeSource.data.Local.DateTime, is24HourTime ? "h:mm" : "h:mm ap")
color: PlasmaCore.ColorScope.textColor
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter

View file

@ -29,7 +29,7 @@ ColumnLayout {
spacing: units.gridUnit
Label {
text: Qt.formatTime(timeSource.data["Local"]["DateTime"], "h:mm ap")
text: Qt.formatTime(timeSource.data["Local"]["DateTime"], root.is24HourTime ? "h:mm" : "h:mm ap")
color: ColorScope.textColor
style: softwareRendering ? Text.Outline : Text.Normal
styleColor: softwareRendering ? ColorScope.backgroundColor : "transparent" // no outline, doesn't matter

View file

@ -33,6 +33,8 @@ PlasmaCore.ColorScope {
property bool isWidescreen: root.height < root.width * 0.75
property bool notificationsShown: phoneNotificationsList.count !== 0
property bool is24HourTime: Qt.locale().timeFormat(Locale.ShortFormat).toLowerCase().indexOf("ap") === -1
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
anchors.fill: parent

View file

@ -76,7 +76,7 @@ PlasmaCore.ColorScope {
PlasmaComponents.Label {
id: clock
anchors.fill: parent
text: Qt.formatTime(timeSource.data.Local.DateTime, "hh:mm")
text: Qt.formatTime(timeSource.data.Local.DateTime, root.is24HourTime ? "h:mm" : "h:mm ap")
color: PlasmaCore.ColorScope.textColor
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter