background: fix desktop clock 12h format
This commit is contained in:
parent
a17fe72be5
commit
685ad569a3
4 changed files with 28 additions and 18 deletions
|
|
@ -79,7 +79,7 @@ Item {
|
||||||
spacing: Appearance.spacing.small
|
spacing: Appearance.spacing.small
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: Time.format(Config.services.useTwelveHourClock ? "hh" : "HH")
|
text: Time.hourStr
|
||||||
font.pointSize: Appearance.font.size.extraLarge * 3 * root.scale
|
font.pointSize: Appearance.font.size.extraLarge * 3 * root.scale
|
||||||
font.weight: Font.Bold
|
font.weight: Font.Bold
|
||||||
color: root.safePrimary
|
color: root.safePrimary
|
||||||
|
|
@ -94,19 +94,24 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: Time.format("mm")
|
text: Time.minuteStr
|
||||||
font.pointSize: Appearance.font.size.extraLarge * 3 * root.scale
|
font.pointSize: Appearance.font.size.extraLarge * 3 * root.scale
|
||||||
font.weight: Font.Bold
|
font.weight: Font.Bold
|
||||||
color: root.safeSecondary
|
color: root.safeSecondary
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
Loader {
|
||||||
visible: Config.services.useTwelveHourClock
|
|
||||||
text: Time.format("A")
|
|
||||||
font.pointSize: Appearance.font.size.large * root.scale
|
|
||||||
color: root.safeSecondary
|
|
||||||
Layout.alignment: Qt.AlignTop
|
Layout.alignment: Qt.AlignTop
|
||||||
Layout.topMargin: Appearance.padding.large * 1.4 * root.scale
|
Layout.topMargin: Appearance.padding.large * 1.4 * root.scale
|
||||||
|
|
||||||
|
active: Config.services.useTwelveHourClock
|
||||||
|
visible: active
|
||||||
|
|
||||||
|
sourceComponent: StyledText {
|
||||||
|
text: Time.amPmStr
|
||||||
|
font.pointSize: Appearance.font.size.large * root.scale
|
||||||
|
color: root.safeSecondary
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -155,10 +160,10 @@ Item {
|
||||||
easing.bezierCurve: Appearance.anim.curves.expressiveDefaultSpatial
|
easing.bezierCurve: Appearance.anim.curves.expressiveDefaultSpatial
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Behavior on implicitWidth {
|
Behavior on implicitWidth {
|
||||||
Anim {
|
Anim {
|
||||||
duration: Appearance.anim.durations.small
|
duration: Appearance.anim.durations.small
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,6 @@ import QtQuick.Layouts
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
readonly property list<string> timeComponents: Time.format(Config.services.useTwelveHourClock ? "hh:mm:A" : "hh:mm").split(":")
|
|
||||||
|
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
implicitWidth: Config.dashboard.sizes.dateTimeWidth
|
implicitWidth: Config.dashboard.sizes.dateTimeWidth
|
||||||
|
|
@ -24,7 +22,7 @@ Item {
|
||||||
StyledText {
|
StyledText {
|
||||||
Layout.bottomMargin: -(font.pointSize * 0.4)
|
Layout.bottomMargin: -(font.pointSize * 0.4)
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
text: root.timeComponents[0]
|
text: Time.hourStr
|
||||||
color: Colours.palette.m3secondary
|
color: Colours.palette.m3secondary
|
||||||
font.pointSize: Appearance.font.size.extraLarge
|
font.pointSize: Appearance.font.size.extraLarge
|
||||||
font.family: Appearance.font.family.clock
|
font.family: Appearance.font.family.clock
|
||||||
|
|
@ -42,7 +40,7 @@ Item {
|
||||||
StyledText {
|
StyledText {
|
||||||
Layout.topMargin: -(font.pointSize * 0.4)
|
Layout.topMargin: -(font.pointSize * 0.4)
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
text: root.timeComponents[1]
|
text: Time.minuteStr
|
||||||
color: Colours.palette.m3secondary
|
color: Colours.palette.m3secondary
|
||||||
font.pointSize: Appearance.font.size.extraLarge
|
font.pointSize: Appearance.font.size.extraLarge
|
||||||
font.family: Appearance.font.family.clock
|
font.family: Appearance.font.family.clock
|
||||||
|
|
@ -56,7 +54,7 @@ Item {
|
||||||
visible: active
|
visible: active
|
||||||
|
|
||||||
sourceComponent: StyledText {
|
sourceComponent: StyledText {
|
||||||
text: root.timeComponents[2] ?? ""
|
text: Time.amPmStr
|
||||||
color: Colours.palette.m3primary
|
color: Colours.palette.m3primary
|
||||||
font.pointSize: Appearance.font.size.large
|
font.pointSize: Appearance.font.size.large
|
||||||
font.family: Appearance.font.family.clock
|
font.family: Appearance.font.family.clock
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ ColumnLayout {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
required property var lock
|
required property var lock
|
||||||
readonly property list<string> timeComponents: Time.format(Config.services.useTwelveHourClock ? "hh:mm:A" : "hh:mm").split(":")
|
|
||||||
readonly property real centerScale: Math.min(1, (lock.screen?.height ?? 1440) / 1440)
|
readonly property real centerScale: Math.min(1, (lock.screen?.height ?? 1440) / 1440)
|
||||||
readonly property int centerWidth: Config.lock.sizes.centerWidth * centerScale
|
readonly property int centerWidth: Config.lock.sizes.centerWidth * centerScale
|
||||||
|
|
||||||
|
|
@ -29,7 +28,7 @@ ColumnLayout {
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
text: root.timeComponents[0]
|
text: Time.hourStr
|
||||||
color: Colours.palette.m3secondary
|
color: Colours.palette.m3secondary
|
||||||
font.pointSize: Math.floor(Appearance.font.size.extraLarge * 3 * root.centerScale)
|
font.pointSize: Math.floor(Appearance.font.size.extraLarge * 3 * root.centerScale)
|
||||||
font.family: Appearance.font.family.clock
|
font.family: Appearance.font.family.clock
|
||||||
|
|
@ -47,7 +46,7 @@ ColumnLayout {
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
text: root.timeComponents[1]
|
text: Time.minuteStr
|
||||||
color: Colours.palette.m3secondary
|
color: Colours.palette.m3secondary
|
||||||
font.pointSize: Math.floor(Appearance.font.size.extraLarge * 3 * root.centerScale)
|
font.pointSize: Math.floor(Appearance.font.size.extraLarge * 3 * root.centerScale)
|
||||||
font.family: Appearance.font.family.clock
|
font.family: Appearance.font.family.clock
|
||||||
|
|
@ -62,7 +61,7 @@ ColumnLayout {
|
||||||
visible: active
|
visible: active
|
||||||
|
|
||||||
sourceComponent: StyledText {
|
sourceComponent: StyledText {
|
||||||
text: root.timeComponents[2] ?? ""
|
text: Time.amPmStr
|
||||||
color: Colours.palette.m3primary
|
color: Colours.palette.m3primary
|
||||||
font.pointSize: Math.floor(Appearance.font.size.extraLarge * 2 * root.centerScale)
|
font.pointSize: Math.floor(Appearance.font.size.extraLarge * 2 * root.centerScale)
|
||||||
font.family: Appearance.font.family.clock
|
font.family: Appearance.font.family.clock
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
pragma Singleton
|
pragma Singleton
|
||||||
|
|
||||||
|
import qs.config
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
import QtQuick
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
property alias enabled: clock.enabled
|
property alias enabled: clock.enabled
|
||||||
|
|
@ -9,6 +11,12 @@ Singleton {
|
||||||
readonly property int minutes: clock.minutes
|
readonly property int minutes: clock.minutes
|
||||||
readonly property int seconds: clock.seconds
|
readonly property int seconds: clock.seconds
|
||||||
|
|
||||||
|
readonly property string timeStr: format(Config.services.useTwelveHourClock ? "hh:mm:A" : "hh:mm")
|
||||||
|
readonly property list<string> timeComponents: timeStr.split(":")
|
||||||
|
readonly property string hourStr: timeComponents[0] ?? ""
|
||||||
|
readonly property string minuteStr: timeComponents[1] ?? ""
|
||||||
|
readonly property string amPmStr: timeComponents[2] ?? ""
|
||||||
|
|
||||||
function format(fmt: string): string {
|
function format(fmt: string): string {
|
||||||
return Qt.formatDateTime(clock.date, fmt);
|
return Qt.formatDateTime(clock.date, fmt);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue