Skip to content
This repository has been archived by the owner on Oct 23, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dekisugi committed Feb 15, 2020
1 parent ffa846a commit 7617983
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
6 changes: 5 additions & 1 deletion applets/digital-clock/package/contents/config/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@
<default>false</default>
</entry>
<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>
<default>shortDate</default>
</entry>
<entry name="customDateFormat" type="string">
<label>Custom date format string.</label>
<default>yyyy/MM/dd(ddd)</default>
</entry>
<entry name="fontFamily" type="string">
<label>Font family. e.g "arial". The system font is used if this is not set.</label>
<default></default>
Expand Down
14 changes: 8 additions & 6 deletions applets/digital-clock/package/contents/ui/DigitalClock.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 31 additions & 0 deletions applets/digital-clock/package/contents/ui/configAppearance.qml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Item {

property alias cfg_showDate: showDate.checked
property string cfg_dateFormat: "shortDate"
property alias cfg_customDateFormat: customDateFormat.text
property alias cfg_use24hFormat: use24hFormat.checkedState

onCfg_fontFamilyChanged: {
Expand Down Expand Up @@ -147,6 +148,10 @@ Item {
{
'label': i18n("ISO Date"),
'name': "isoDate"
},
{
'label': i18nc("custom date format", "Custom"),
'name': "custom"
}
]
onCurrentIndexChanged: cfg_dateFormat = model[currentIndex]["name"]
Expand All @@ -160,6 +165,32 @@ Item {
}
}
}

QtLayouts.ColumnLayout {
QtLayouts.Layout.fillWidth: true
enabled: showDate.checked
visible: cfg_dateFormat == "custom"

QtControls.TextField {
id: customDateFormat
QtLayouts.Layout.fillWidth: true
placeholderText: i18n("e.g. 'yyyy/MM/dd(ddd)'")
}

QtControls.Label {
text: i18n("<a href=\"http://doc.qt.io/qt-5/qml-qtqml-qt.html#formatDateTime-method\">Time Format Documentation</a>")
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
}
}
}
}
}

Expand Down

0 comments on commit 7617983

Please sign in to comment.