Merge branch 'qewer33:main' into main

This commit is contained in:
A Ghulam Zakiy 2022-02-05 21:36:31 +08:00 committed by GitHub
commit 48d0e1ba05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 6 deletions

Binary file not shown.

View file

@ -9,9 +9,13 @@
<!-- Clock Display Settings --> <!-- Clock Display Settings -->
<entry name="clockUse24hFormat" type="Bool"> <entry name="clockUse24hFormat" type="Bool">
<label>Force the clock to use 12/24 hour time, instead of following the user locale.</label> <label>Forces the clock to use 12/24 hour time, instead of following the user locale.</label>
<default>true</default> <default>true</default>
</entry> </entry>
<entry name="clockShowSeconds" type="Bool">
<label>Makes the clock show seconds after minutes.</label>
<default>false</default>
</entry>
<entry name="clockSeparator" type="string"> <entry name="clockSeparator" type="string">
<label>Sets the clock separator.</label> <label>Sets the clock separator.</label>
<default>.</default> <default>.</default>

View file

@ -20,6 +20,7 @@ Item {
signal configurationChanged signal configurationChanged
property alias cfg_clockUse24hFormat: use24hFormat.checkState property alias cfg_clockUse24hFormat: use24hFormat.checkState
property alias cfg_clockShowSeconds: showSeconds.checkState
property alias cfg_clockSeparator: clockSeparatorTextField.text property alias cfg_clockSeparator: clockSeparatorTextField.text
property string cfg_clockFontColor property string cfg_clockFontColor
property string cfg_clockFontFamily property string cfg_clockFontFamily
@ -128,6 +129,13 @@ Item {
checked: cfg_clockUse24hFormat checked: cfg_clockUse24hFormat
} }
QtControls.CheckBox {
id: showSeconds
text: i18n("Show seconds")
tristate: false
checked: cfg_clockShowSeconds
}
QtLayouts.RowLayout { QtLayouts.RowLayout {
QtControls.Label { QtControls.Label {
text: i18n("Separator:") text: i18n("Separator:")

View file

@ -24,8 +24,8 @@ Item {
id: dataSource id: dataSource
engine: "time" engine: "time"
connectedSources: ["Local"] connectedSources: ["Local"]
interval: 60000 interval: plasmoid.configuration.clockShowSeconds ? 1000 : 60000
intervalAlignment: PlasmaCore.Types.AlignToMinute intervalAlignment: plasmoid.configuration.clockShowSeconds ? PlasmaCore.Types.NoAlignment : PlasmaCore.Types.AlignToMinute
} }
FontLoader { FontLoader {
@ -52,7 +52,8 @@ Item {
font.family: clockLabel.font.family font.family: clockLabel.font.family
font.pixelSize: clockLabel.font.pixelSize font.pixelSize: clockLabel.font.pixelSize
font.bold: clockLabel.font.bold font.bold: clockLabel.font.bold
text: " 99:99 " text: if (!plasmoid.configuration.clockShowSeconds) " 99:99 "
else " 99:99:99 "
} }
TextMetrics { TextMetrics {
@ -72,8 +73,15 @@ Item {
id: clockLabel id: clockLabel
anchors.centerIn: parent anchors.centerIn: parent
text: if (plasmoid.configuration.clockUse24hFormat) Qt.formatTime(currentDateTime, "hh.mm").replace(".", plasmoid.configuration.clockSeparator) property var textFormat: {
else Qt.formatTime(currentDateTime, "hh.mm AP").replace(".", plasmoid.configuration.clockSeparator) var AMPM = plasmoid.configuration.clockUse24hFormat ? "" : " AP"
if (plasmoid.configuration.clockShowSeconds)
return Qt.formatTime(currentDateTime, "hh.mm.ss" + AMPM).replace(".", plasmoid.configuration.clockSeparator)
else
return Qt.formatTime(currentDateTime, "hh.mm" + AMPM).replace(".", plasmoid.configuration.clockSeparator)
}
text: textFormat
color: plasmoid.configuration.clockFontColor color: plasmoid.configuration.clockFontColor
font.family: if (plasmoid.configuration.clockFontFamily === "ccdefault") fontOutfitBold.name font.family: if (plasmoid.configuration.clockFontFamily === "ccdefault") fontOutfitBold.name