[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [plasma-workspace] applets/digital-clock/package/contents: Add option to the DigitalClock applet to
From: Dan_Vrátil <dvratil () redhat ! com>
Date: 2014-08-14 18:28:31
Message-ID: E1XHzlH-00070m-Fy () scm ! kde ! org
[Download RAW message or body]
Git commit e42e123948e8f44a5807873349764250b0d9cbec by Dan Vrátil.
Committed on 14/08/2014 at 18:28.
Pushed by dvratil into branch 'master'.
Add option to the DigitalClock applet to show date
This brings back the feature from KDE 4 when there was a checkbox in applet
configuration dialog to show date in the applet. Three formats of date are
now supported: long, short and narrow format.
REVIEW: 119758
BUG: 335006
FIXED-IN: 5.1.0
M +15 -9 applets/digital-clock/package/contents/config/main.xml
M +26 -1 applets/digital-clock/package/contents/ui/DigitalClock.qml
M +44 -0 applets/digital-clock/package/contents/ui/configAppearance.qml
http://commits.kde.org/plasma-workspace/e42e123948e8f44a5807873349764250b0d9cbec
diff --git a/applets/digital-clock/package/contents/config/main.xml \
b/applets/digital-clock/package/contents/config/main.xml index 74ac640..cbeb02f \
100644
--- a/applets/digital-clock/package/contents/config/main.xml
+++ b/applets/digital-clock/package/contents/config/main.xml
@@ -12,15 +12,21 @@
<entry name="showSeconds" type="Bool">
<default>false</default>
</entry>
- <entry name="boldText" type="Bool">
- <default>false</default>
- </entry>
- <entry name="italicText" type="Bool">
- <default>false</default>
- </entry>
- <entry name="timeFormat" type="string">
- <default>default</default>
- </entry>
+ <entry name="showDate" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="dateFormat" type="string">
+ <default>shortDate</default>
+ </entry>
+ <entry name="boldText" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="italicText" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="timeFormat" type="string">
+ <default>default</default>
+ </entry>
</group>
</kcfg>
\ No newline at end of file
diff --git a/applets/digital-clock/package/contents/ui/DigitalClock.qml \
b/applets/digital-clock/package/contents/ui/DigitalClock.qml index 20babc3..a67e2ef \
100644
--- a/applets/digital-clock/package/contents/ui/DigitalClock.qml
+++ b/applets/digital-clock/package/contents/ui/DigitalClock.qml
@@ -44,6 +44,11 @@ Item {
property bool showSeconds: plasmoid.configuration.showSeconds
property bool showTimezone: plasmoid.configuration.showTimezone
+ property bool showDate: plasmoid.configuration.showDate
+ property int dateFormat: plasmoid.configuration.dateFormat == "longDate" ? \
Locale.LongFormat : + plasmoid.configuration.dateFormat \
== "shortDate" ? Locale.ShortFormat : + \
Locale.NarrowFormat + property string lastDate: ""
property string timeFormat
onShowSecondsChanged: {
@@ -63,7 +68,8 @@ Item {
}
minimumPixelSize: theme.mSize(theme.smallestFont).height
fontSizeMode: Text.Fit
- text: Qt.formatTime(dataSource.data["Local"]["DateTime"], main.timeFormat);
+ text: Qt.formatTime(dataSource.data["Local"]["DateTime"], main.timeFormat)
+ + (showDate ? "<br/>" + \
Qt.formatDate(dataSource.data["Local"]["DateTime"], main.dateFormat) \
: "" )
wrapMode: plasmoid.formFactor != PlasmaCore.Types.Horizontal ? Text.WordWrap \
: Text.NoWrap
horizontalAlignment: vertical ? Text.AlignHCenter : Text.AlignLeft // we \
want left align when horizontal to avoid re-aligning when seconds are visible \
verticalAlignment: Text.AlignVCenter @@ -135,6 +141,9 @@ Item {
st += Qt.formatTime(dataSource.data["Local"]["DateTime"], " t");
}
+ if (main.showDate) {
+ st += "<br/>" + Qt.formatDate(dataSource.data["Local"]["DateTime"], \
main.dateFormat); + }
if (sizehelper.text != st) {
sizehelper.text = st;
@@ -151,7 +160,23 @@ Item {
main.timeFormat = timeFormatString;
}
+ function dateTimeChanged()
+ {
+ if (!main.showDate) {
+ return;
+ }
+
+ // If the date has changed, force size recalculation, because the day name
+ // or the month name can now be longer/shorter, so we need to adjust applet \
size + var currentDate = \
Qt.formatDateTime(dataSource.data["Local"]["DateTime"], "yyyy-mm-dd"); + if \
(main.lastDate != currentDate) { + timeFormatCorrection(main.timeFormat);
+ main.lastDate = currentDate
+ }
+ }
+
Component.onCompleted: {
timeFormatCorrection(Qt.locale().timeFormat(Locale.ShortFormat))
+ dataSource.onDataChanged.connect(dateTimeChanged);
}
}
diff --git a/applets/digital-clock/package/contents/ui/configAppearance.qml \
b/applets/digital-clock/package/contents/ui/configAppearance.qml index \
ab67e14..01f6878 100644
--- a/applets/digital-clock/package/contents/ui/configAppearance.qml
+++ b/applets/digital-clock/package/contents/ui/configAppearance.qml
@@ -35,6 +35,10 @@ Item {
property alias cfg_showTimezone: showTimezone.checked
property alias cfg_showSeconds: showSeconds.checked
+ property alias cfg_showDate: showDate.checked
+ property string cfg_dateFormat: "shortDate"
+
+
QtLayouts.ColumnLayout {
QtControls.GroupBox {
title: i18n("Appearance")
@@ -67,6 +71,46 @@ Item {
id: showTimezone
text: i18n("Show time zone")
}
+
+ QtControls.CheckBox {
+ id: showDate
+ text: i18n("Show date")
+ }
+
+ QtLayouts.RowLayout {
+ QtControls.Label {
+ text: i18n("Date format")
+ }
+
+ QtControls.ComboBox {
+ id: dateFormat
+ enabled: showDate.checked
+ textRole: "label"
+ model: [
+ {
+ 'label': i18n("Long date"),
+ 'name': "longDate"
+ },
+ {
+ 'label': i18n("Short date"),
+ 'name': "shortDate"
+ },
+ {
+ 'label': i18n("Narrow date"),
+ 'name': "narrowDate"
+ }
+ ]
+ onCurrentIndexChanged: cfg_dateFormat = \
model[currentIndex]["name"] +
+ Component.onCompleted: {
+ for (var i = 0; i < model.length; i++) {
+ if (model[i]["name"] == \
plasmoid.configuration.dateFormat) { + \
dateFormat.currentIndex = i; + }
+ }
+ }
+ }
+ }
}
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic