Members of the KDE Community are recommended to subscribe to the kde-community mailing list at to allow them to participate in important discussions and receive other important announcements

Commit 235fa810 authored by Zren (Chris Holland)'s avatar Zren (Chris Holland)

[Digital Clock] Add ability to set a custom date format string

Adds a new customDateFormat config key which is used when the dateFormat "StringEnum" is set to custom.
Shows a link to the Qt time formatting documentation next to the text field.
Qt doc link and text field are hidden when not set to custom date format.

CCBUG: 340982

Differential Revision:
parent 65e3cc3a
......@@ -19,9 +19,13 @@
<entry name="dateFormat" type="string">
<label>The date format to display. Options are: shortDate, longDate or isoDate.</label>
<label>The date format to display. Options are: shortDate, longDate, isoDate or custom.</label>
<entry name="customDateFormat" type="string">
<label>Custom date format string.</label>
<default>ddd d</default>
<entry name="fontFamily" type="string">
<label>Font family. e.g "arial". The system font is used if this is not set.</label>
......@@ -33,14 +33,16 @@ Item {
property bool showSeconds: plasmoid.configuration.showSeconds
property bool showLocalTimezone: plasmoid.configuration.showLocalTimezone
property bool showDate: plasmoid.configuration.showDate
property int dateFormat: {
if (plasmoid.configuration.dateFormat === "longDate") {
return Qt.SystemLocaleLongDate;
property var dateFormat: {
if (plasmoid.configuration.dateFormat === "custom") {
return plasmoid.configuration.customDateFormat; // str
} else if (plasmoid.configuration.dateFormat === "longDate") {
return Qt.SystemLocaleLongDate; // int
} else if (plasmoid.configuration.dateFormat === "isoDate") {
return Qt.ISODate;
return Qt.ISODate; // int
} else { // "shortDate"
return Qt.SystemLocaleShortDate; // int
return Qt.SystemLocaleShortDate;
property string lastSelectedTimezone: plasmoid.configuration.lastSelectedTimezone
......@@ -44,6 +44,7 @@ QtLayouts.ColumnLayout {
property alias cfg_showDate: showDate.checked
property string cfg_dateFormat: "shortDate"
property alias cfg_customDateFormat: customDateFormat.text
property alias cfg_use24hFormat: use24hFormat.checked
onCfg_fontFamilyChanged: {
......@@ -137,6 +138,10 @@ QtLayouts.ColumnLayout {
'label': i18n("ISO Date"),
'name': "isoDate"
'label': i18nc("custom date format", "Custom"),
'name': "custom"
onCurrentIndexChanged: cfg_dateFormat = model[currentIndex]["name"]
......@@ -150,6 +155,27 @@ QtLayouts.ColumnLayout {
QtControls.TextField {
id: customDateFormat
QtLayouts.Layout.fillWidth: true
visible: cfg_dateFormat == "custom"
QtControls.Label {
text: i18n("<a href=\"\">Time Format Documentation</a>")
visible: cfg_dateFormat == "custom"
wrapMode: Text.Wrap
QtLayouts.Layout.preferredWidth: QtLayouts.Layout.maximumWidth
QtLayouts.Layout.maximumWidth: units.gridUnit * 16
onLinkActivated: Qt.openUrlExternally(link)
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton // We don't want to eat clicks on the Label
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
Item {
Kirigami.FormData.isSection: true
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment