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
|
||||
|
||||
StyledText {
|
||||
text: Time.format(Config.services.useTwelveHourClock ? "hh" : "HH")
|
||||
text: Time.hourStr
|
||||
font.pointSize: Appearance.font.size.extraLarge * 3 * root.scale
|
||||
font.weight: Font.Bold
|
||||
color: root.safePrimary
|
||||
|
|
@ -94,19 +94,24 @@ Item {
|
|||
}
|
||||
|
||||
StyledText {
|
||||
text: Time.format("mm")
|
||||
text: Time.minuteStr
|
||||
font.pointSize: Appearance.font.size.extraLarge * 3 * root.scale
|
||||
font.weight: Font.Bold
|
||||
color: root.safeSecondary
|
||||
}
|
||||
|
||||
StyledText {
|
||||
visible: Config.services.useTwelveHourClock
|
||||
text: Time.format("A")
|
||||
font.pointSize: Appearance.font.size.large * root.scale
|
||||
color: root.safeSecondary
|
||||
Loader {
|
||||
Layout.alignment: Qt.AlignTop
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Behavior on implicitWidth {
|
||||
Anim {
|
||||
duration: Appearance.anim.durations.small
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@ import QtQuick.Layouts
|
|||
Item {
|
||||
id: root
|
||||
|
||||
readonly property list<string> timeComponents: Time.format(Config.services.useTwelveHourClock ? "hh:mm:A" : "hh:mm").split(":")
|
||||
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
implicitWidth: Config.dashboard.sizes.dateTimeWidth
|
||||
|
|
@ -24,7 +22,7 @@ Item {
|
|||
StyledText {
|
||||
Layout.bottomMargin: -(font.pointSize * 0.4)
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
text: root.timeComponents[0]
|
||||
text: Time.hourStr
|
||||
color: Colours.palette.m3secondary
|
||||
font.pointSize: Appearance.font.size.extraLarge
|
||||
font.family: Appearance.font.family.clock
|
||||
|
|
@ -42,7 +40,7 @@ Item {
|
|||
StyledText {
|
||||
Layout.topMargin: -(font.pointSize * 0.4)
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
text: root.timeComponents[1]
|
||||
text: Time.minuteStr
|
||||
color: Colours.palette.m3secondary
|
||||
font.pointSize: Appearance.font.size.extraLarge
|
||||
font.family: Appearance.font.family.clock
|
||||
|
|
@ -56,7 +54,7 @@ Item {
|
|||
visible: active
|
||||
|
||||
sourceComponent: StyledText {
|
||||
text: root.timeComponents[2] ?? ""
|
||||
text: Time.amPmStr
|
||||
color: Colours.palette.m3primary
|
||||
font.pointSize: Appearance.font.size.large
|
||||
font.family: Appearance.font.family.clock
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ ColumnLayout {
|
|||
id: root
|
||||
|
||||
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 int centerWidth: Config.lock.sizes.centerWidth * centerScale
|
||||
|
||||
|
|
@ -29,7 +28,7 @@ ColumnLayout {
|
|||
|
||||
StyledText {
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
text: root.timeComponents[0]
|
||||
text: Time.hourStr
|
||||
color: Colours.palette.m3secondary
|
||||
font.pointSize: Math.floor(Appearance.font.size.extraLarge * 3 * root.centerScale)
|
||||
font.family: Appearance.font.family.clock
|
||||
|
|
@ -47,7 +46,7 @@ ColumnLayout {
|
|||
|
||||
StyledText {
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
text: root.timeComponents[1]
|
||||
text: Time.minuteStr
|
||||
color: Colours.palette.m3secondary
|
||||
font.pointSize: Math.floor(Appearance.font.size.extraLarge * 3 * root.centerScale)
|
||||
font.family: Appearance.font.family.clock
|
||||
|
|
@ -62,7 +61,7 @@ ColumnLayout {
|
|||
visible: active
|
||||
|
||||
sourceComponent: StyledText {
|
||||
text: root.timeComponents[2] ?? ""
|
||||
text: Time.amPmStr
|
||||
color: Colours.palette.m3primary
|
||||
font.pointSize: Math.floor(Appearance.font.size.extraLarge * 2 * root.centerScale)
|
||||
font.family: Appearance.font.family.clock
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
pragma Singleton
|
||||
|
||||
import qs.config
|
||||
import Quickshell
|
||||
import QtQuick
|
||||
|
||||
Singleton {
|
||||
property alias enabled: clock.enabled
|
||||
|
|
@ -9,6 +11,12 @@ Singleton {
|
|||
readonly property int minutes: clock.minutes
|
||||
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 {
|
||||
return Qt.formatDateTime(clock.date, fmt);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue