[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: [patch] day of week option in clock-applet
From: Martin Koller <m.koller () surfeu ! at>
Date: 2004-09-24 22:06:01
Message-ID: 200409250006.07352.m.koller () surfeu ! at
[Download RAW message or body]
[Attachment #2 (multipart/mixed)]
Hi all,
attached is a patch which adds an option to all kicker clock-applets to allow
to show the day of the week.
Is this ok to commit ?
--
Best regards/Schöne Grüße
Martin () ascii ribbon campaign - against html mail
/\ - against microsoft attachments
Some operating systems are called 'user friendly',
Linux however is 'expert friendly'.
["dayOfWeek.patch" (text/x-diff)]
Index: analog.ui
===================================================================
RCS file: /home/kde/kdebase/kicker/applets/clock/analog.ui,v
retrieving revision 1.14
diff -u -3 -p -r1.14 analog.ui
--- analog.ui 13 Nov 2003 20:11:03 -0000 1.14
+++ analog.ui 24 Sep 2004 21:59:49 -0000
@@ -1,4 +1,4 @@
-<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>AnalogWidget</class>
<widget class="QWidget">
<property name="name">
@@ -8,10 +8,13 @@
<rect>
<x>0</x>
<y>0</y>
- <width>337</width>
+ <width>524</width>
<height>307</height>
</rect>
</property>
+ <property name="caption">
+ <string>AnalogWidget</string>
+ </property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
@@ -37,6 +40,9 @@
<property name="text">
<string>Dat&e</string>
</property>
+ <property name="accel">
+ <string>Alt+E</string>
+ </property>
</widget>
<widget class="QCheckBox">
<property name="name">
@@ -51,6 +57,14 @@
</widget>
<widget class="QCheckBox">
<property name="name">
+ <cstring>kcfg_AnalogShowDayOfWeek</cstring>
+ </property>
+ <property name="text">
+ <string>Day of Week</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
<cstring>kcfg_AnalogShowFrame</cstring>
</property>
<property name="text">
@@ -272,6 +286,8 @@
</widget>
</vbox>
</widget>
+<customwidgets>
+</customwidgets>
<connections>
<connection>
<sender>kcfg_AnalogLCDStyle</sender>
Index: clock.cpp
===================================================================
RCS file: /home/kde/kdebase/kicker/applets/clock/clock.cpp,v
retrieving revision 1.177
diff -u -3 -p -r1.177 clock.cpp
--- clock.cpp 1 Jul 2004 15:54:27 -0000 1.177
+++ clock.cpp 24 Sep 2004 21:59:50 -0000
@@ -50,6 +50,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE
#include <kfontrequester.h>
#include <kglobalsettings.h>
#include <kconfigdialogmanager.h>
+#include <kcalendarsystem.h>
#include "clock.h"
#include "datepicker.h"
@@ -212,8 +213,7 @@ int PlainClock::preferedHeightForWidth(i
void PlainClock::updateClock()
{
- QString newStr =
- KGlobal::locale()->formatTime(_applet->clockGetTime(), showSeconds);
+ QString newStr = KGlobal::locale()->formatTime(_applet->clockGetTime(), \
showSeconds);
if (newStr != _timeStr) {
_timeStr = newStr;
@@ -245,6 +245,11 @@ bool PlainClock::showDate()
return _prefs->plainShowDate();
}
+bool PlainClock::showDayOfWeek()
+{
+ return _prefs->plainShowDayOfWeek();
+}
+
//************************************************************
@@ -405,6 +410,11 @@ bool DigitalClock::showDate()
return _prefs->digitalShowDate();
}
+bool DigitalClock::showDayOfWeek()
+{
+ return _prefs->digitalShowDayOfWeek();
+}
+
//************************************************************
@@ -621,6 +631,11 @@ bool AnalogClock::showDate()
return _prefs->analogShowDate();
}
+bool AnalogClock::showDayOfWeek()
+{
+ return _prefs->analogShowDayOfWeek();
+}
+
//************************************************************
@@ -806,6 +821,11 @@ bool FuzzyClock::showDate()
return _prefs->fuzzyShowDate();
}
+bool FuzzyClock::showDayOfWeek()
+{
+ return _prefs->fuzzyShowDayOfWeek();
+}
+
//************************************************************
@@ -826,6 +846,11 @@ ClockApplet::ClockApplet(const QString&
TZoffset = zone->calc_TZ_offset( zone->zone() );
setBackgroundOrigin( QWidget::AncestorOrigin );
+ _dayOfWeek = new QLabel(this);
+ _dayOfWeek->setAlignment(AlignVCenter | AlignHCenter | WordBreak);
+ _dayOfWeek->setBackgroundOrigin( QWidget::AncestorOrigin );
+ _dayOfWeek->installEventFilter(this); // catch mouse clicks
+
_date = new QLabel(this);
_date->setAlignment(AlignVCenter | AlignHCenter | WordBreak);
_date->setBackgroundOrigin( QWidget::AncestorOrigin );
@@ -865,7 +890,7 @@ ClockApplet::~ClockApplet()
int ClockApplet::widthForHeight(int h) const
{
bool applyGeometry = (position() == pBottom) || (position() == pTop);
- int shareDateHeight = 0;
+ int shareDateHeight = 0, shareDayOfWeekHeight = 0;
bool dateToSide = false;
if (showDate) {
if (h < 32)
@@ -874,30 +899,45 @@ int ClockApplet::widthForHeight(int h) c
shareDateHeight = _date->sizeHint().height();
}
- int clockWidth = _clock->preferedWidthForHeight(h-shareDateHeight);
+ if (showDayOfWeek && (h >=32)) shareDayOfWeekHeight = \
_dayOfWeek->sizeHint().height(); +
+ int clockWidth = \
_clock->preferedWidthForHeight(h-shareDateHeight-shareDayOfWeekHeight);
int w;
- if (!showDate) {
+ if (!showDate && !showDayOfWeek) {
w = clockWidth;
if (applyGeometry) {
_clock->widget()->setFixedSize(w, h);
}
} else {
- int dateWidth = _date->sizeHint().width() + 4;
+ int dateWidth = showDate ? _date->sizeHint().width() + 4 : 0;
+ int dayOfWeekWidth = showDayOfWeek ? _dayOfWeek->sizeHint().width() + 4 : 0;
if (dateToSide) {
- w = clockWidth + dateWidth;
+ w = clockWidth + dateWidth + dayOfWeekWidth;
if (applyGeometry) {
_clock->widget()->setFixedSize(clockWidth, h);
- _date->setFixedSize(dateWidth, h);
- _date->move(clockWidth, 0);
+ if (showDayOfWeek) {
+ _dayOfWeek->setFixedSize(dayOfWeekWidth, h);
+ _dayOfWeek->move(clockWidth, 0);
+ }
+ if (showDate) {
+ _date->setFixedSize(dateWidth, h);
+ _date->move(clockWidth + dayOfWeekWidth, 0);
+ }
}
} else {
- w = (clockWidth > dateWidth ? clockWidth : dateWidth);
+ w = QMAX(QMAX(clockWidth, dateWidth), dayOfWeekWidth);
if (applyGeometry) {
- _clock->widget()->setFixedSize(w, h - shareDateHeight);
- _clock->widget()->setMinimumSize(w,h - shareDateHeight);
- _date->setFixedSize(w, shareDateHeight);
- _date->move(0, _clock->widget()->height());
+ _clock->widget()->setFixedSize(w, h - shareDateHeight - \
shareDayOfWeekHeight); + _clock->widget()->setMinimumSize(w, h - \
shareDateHeight - shareDayOfWeekHeight); + if (showDayOfWeek) {
+ _dayOfWeek->setFixedSize(w, _dayOfWeek->sizeHint().height());
+ _dayOfWeek->move(0, _clock->widget()->height());
+ }
+ if (showDate) {
+ _date->setFixedSize(w, _date->sizeHint().height());
+ _date->move(0, _clock->widget()->height() + shareDayOfWeekHeight);
+ }
}
}
}
@@ -915,14 +955,21 @@ int ClockApplet::heightForWidth(int w) c
_clock->widget()->setFixedSize(w, clockHeight);
}
- // add some (8) pixel in height for date, if visible
+ // add some (8) pixel in height for date+dayOfWeek, if visible
+ if (showDayOfWeek) {
+ if (applyGeometry) {
+ _dayOfWeek->setFixedSize(w, _dayOfWeek->minimumSizeHint().height() + 8);
+ _dayOfWeek->move(0, clockHeight);
+ }
+ clockHeight += _dayOfWeek->height();
+ }
+
if (showDate) {
if (applyGeometry) {
_date->setFixedSize(w, _date->minimumSizeHint().height() + 8);
_date->move(0, clockHeight);
}
clockHeight += _date->height();
-
}
return clockHeight;
@@ -979,16 +1026,29 @@ void ClockApplet::slotApplySettings()
break;
}
+ dateFont = _prefs->dateFont();
+ dateForeColor = _prefs->dateForegroundColor();
+ QColor dateBackColor = _prefs->dateBackgroundColor();
+
+ // See if the clock wants to show the day of week.
+ // use same font/color as for date
+ showDayOfWeek = _clock->showDayOfWeek();
+ if (showDayOfWeek){
+ _dayOfWeek->setBackgroundColor(dateBackColor);
+
+ _dayOfWeek->setFont(dateFont);
+ QPalette pal = _dayOfWeek->palette();
+ pal.setColor(QColorGroup::Foreground, dateForeColor);
+ pal.setColor(QColorGroup::Background, dateBackColor);
+ _dayOfWeek->setPalette(pal);
+ }
+
// See if the clock wants to show the date.
showDate = _clock->showDate();
- if(showDate){
- dateFont = _prefs->dateFont();
- dateForeColor = _prefs->dateForegroundColor();
- QColor dateBackColor = _prefs->dateBackgroundColor();
+ if (showDate) {
_date->setBackgroundColor(dateBackColor);
_date->setFont(dateFont);
- updateDateLabel();
QPalette pal = _date->palette();
pal.setColor(QColorGroup::Foreground, dateForeColor);
pal.setColor(QColorGroup::Background, dateBackColor);
@@ -997,8 +1057,8 @@ void ClockApplet::slotApplySettings()
else
{
zone->resetZone();
- updateDateLabel();
}
+ updateDateLabel();
TZoffset = zone->calc_TZ_offset( zone->zone() );
setBackground();
@@ -1009,6 +1069,12 @@ void ClockApplet::slotApplySettings()
_clock->forceUpdate(); /* force repaint */
_clock->updateClock();
+ if (showDayOfWeek) {
+ _dayOfWeek->show();
+ _dayOfWeek->repaint(true);
+ } else
+ _dayOfWeek->hide();
+
if (showDate) {
_date->show();
_date->repaint(true);
@@ -1041,12 +1107,19 @@ void ClockApplet::setBackground()
_date->setBackgroundOrigin(AncestorOrigin);
_date->setPaletteBackgroundPixmap(*brush);
}
+
+ if (_dayOfWeek && _dayOfWeek->palette().active().background() == \
palette().active().background()) + {
+ _dayOfWeek->setBackgroundOrigin(AncestorOrigin);
+ _dayOfWeek->setPaletteBackgroundPixmap(*brush);
+ }
}
}
if (toreset) {
_clock->widget()->setPaletteBackgroundPixmap(QPixmap());
_date->setPaletteBackgroundPixmap(QPixmap());
+ _dayOfWeek->setPaletteBackgroundPixmap(QPixmap());
}
}
@@ -1313,7 +1386,7 @@ void ClockApplet::wheelEvent(QWheelEvent
// catch the mouse clicks of our child widgets
bool ClockApplet::eventFilter( QObject *o, QEvent *e )
{
- if ( ( o == _clock->widget() || o == _date ) && e->type() == \
QEvent::MouseButtonPress ) { + if ( ( o == _clock->widget() || o == _date || o == \
_dayOfWeek) && e->type() == QEvent::MouseButtonPress ) { \
mousePressEvent(static_cast<QMouseEvent*>(e) ); return TRUE;
}
@@ -1325,6 +1398,8 @@ void ClockApplet::updateDateLabel()
{
_lastDate = clockGetDate();
+ _dayOfWeek->setText(KGlobal::locale()->calendar()->weekDayName(_lastDate));
+
if (zone->zoneIndex())
{
QString zone_s = i18n(zone->zone().utf8());
@@ -1348,7 +1423,8 @@ void ClockApplet::updateDateLabel()
void ClockApplet::fixupLayout() {
- _date->resize(_date->minimumSizeHint());
+ _date->adjustSize();
+ _dayOfWeek->adjustSize();
emit updateLayout();
}
Index: clock.h
===================================================================
RCS file: /home/kde/kdebase/kicker/applets/clock/clock.h,v
retrieving revision 1.46
diff -u -3 -p -r1.46 clock.h
--- clock.h 17 Feb 2004 23:44:57 -0000 1.46
+++ clock.h 24 Sep 2004 21:59:50 -0000
@@ -123,6 +123,7 @@ public:
virtual void forceUpdate()=0;
virtual void loadSettings()=0;
virtual bool showDate()=0;
+ virtual bool showDayOfWeek()=0;
protected:
ClockApplet *_applet;
@@ -145,6 +146,7 @@ public:
void forceUpdate();
void loadSettings();
bool showDate();
+ bool showDayOfWeek();
protected:
QString _timeStr;
@@ -167,6 +169,7 @@ public:
void forceUpdate();
void loadSettings();
bool showDate();
+ bool showDayOfWeek();
protected:
void paintEvent( QPaintEvent*);
@@ -202,6 +205,7 @@ public:
void forceUpdate();
void loadSettings();
bool showDate();
+ bool showDayOfWeek();
protected:
virtual void paintEvent(QPaintEvent *);
@@ -237,6 +241,7 @@ public:
void forceUpdate();
void loadSettings();
bool showDate();
+ bool showDayOfWeek();
public slots:
void deleteMyself();
@@ -322,6 +327,7 @@ protected:
bool _disableCalendar;
ClockWidget *_clock;
QLabel *_date;
+ QLabel *_dayOfWeek;
QDate _lastDate;
QTimer *_timer;
@@ -329,6 +335,7 @@ protected:
Prefs *_prefs;
Zone *zone;
bool showDate;
+ bool showDayOfWeek;
QFont dateFont;
QColor dateForeColor;
QStringList _remotezonelist;
Index: clockapplet.kcfg
===================================================================
RCS file: /home/kde/kdebase/kicker/applets/clock/clockapplet.kcfg,v
retrieving revision 1.4
diff -u -3 -p -r1.4 clockapplet.kcfg
--- clockapplet.kcfg 29 Mar 2004 20:58:56 -0000 1.4
+++ clockapplet.kcfg 24 Sep 2004 21:59:50 -0000
@@ -42,6 +42,10 @@ defFont.setPointSize(8);
<label>Show date.</label>
<default>true</default>
</entry>
+ <entry name="PlainShowDayOfWeek" type="Bool" key="Show_DayOfWeek">
+ <label>Show Day of Week.</label>
+ <default>false</default>
+ </entry>
<entry name="PlainShowFrame" type="Bool" key="Show_Frame">
<label>Show frame.</label>
<default>false</default>
@@ -73,6 +77,10 @@ defFont.setBold(true);
<label>Show date.</label>
<default>false</default>
</entry>
+ <entry name="DigitalShowDayOfWeek" type="Bool" key="Show_DayOfWeek">
+ <label>Show Day of Week.</label>
+ <default>false</default>
+ </entry>
<entry name="DigitalShowFrame" type="Bool" key="Show_Frame">
<label>Show frame.</label>
<default>false</default>
@@ -107,6 +115,10 @@ defFont.setBold(true);
<label>Show date.</label>
<default>false</default>
</entry>
+ <entry name="AnalogShowDayOfWeek" type="Bool" key="Show_DayOfWeek">
+ <label>Show Day of Week.</label>
+ <default>false</default>
+ </entry>
<entry name="AnalogShowFrame" type="Bool" key="Show_Frame">
<label>Show frame.</label>
<default>false</default>
@@ -137,6 +149,10 @@ defFont.setBold(true);
<label>Show date.</label>
<default>true</default>
</entry>
+ <entry name="FuzzyShowDayOfWeek" type="Bool" key="Show_DayOfWeek">
+ <label>Show Day of Week.</label>
+ <default>false</default>
+ </entry>
<entry name="FuzzyShowFrame" type="Bool" key="Show_Frame">
<label>Show frame.</label>
<default>false</default>
Index: digital.ui
===================================================================
RCS file: /home/kde/kdebase/kicker/applets/clock/digital.ui,v
retrieving revision 1.18
diff -u -3 -p -r1.18 digital.ui
--- digital.ui 13 Nov 2003 20:11:03 -0000 1.18
+++ digital.ui 24 Sep 2004 21:59:52 -0000
@@ -1,4 +1,4 @@
-<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>DigitalWidget</class>
<widget class="QWidget">
<property name="name">
@@ -8,10 +8,13 @@
<rect>
<x>0</x>
<y>0</y>
- <width>391</width>
+ <width>553</width>
<height>251</height>
</rect>
</property>
+ <property name="caption">
+ <string>DigitalWidget</string>
+ </property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
@@ -37,6 +40,9 @@
<property name="text">
<string>Dat&e</string>
</property>
+ <property name="accel">
+ <string>Alt+E</string>
+ </property>
<property name="checked">
<bool>true</bool>
</property>
@@ -48,6 +54,17 @@
<property name="text">
<string>Seco&nds</string>
</property>
+ <property name="accel">
+ <string>Alt+N</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>kcfg_DigitalShowDayOfWeek</cstring>
+ </property>
+ <property name="text">
+ <string>Day of Week</string>
+ </property>
</widget>
<widget class="QCheckBox">
<property name="name">
@@ -56,6 +73,9 @@
<property name="text">
<string>Blin&king dots</string>
</property>
+ <property name="accel">
+ <string>Alt+K</string>
+ </property>
</widget>
<widget class="QCheckBox">
<property name="name">
@@ -64,6 +84,9 @@
<property name="text">
<string>&Frame</string>
</property>
+ <property name="accel">
+ <string>Alt+F</string>
+ </property>
</widget>
<spacer>
<property name="name">
@@ -229,6 +252,8 @@
</widget>
</vbox>
</widget>
+<customwidgets>
+</customwidgets>
<connections>
<connection>
<sender>kcfg_DigitalLCDStyle</sender>
@@ -280,7 +305,11 @@
<includes>
<include location="local" impldecl="in implementation">kdialog.h</include>
<include location="local" impldecl="in \
implementation">kfontrequester.h</include> + <include location="local" \
impldecl="in implementation">digital.ui.h</include> </includes>
+<slots>
+ <slot>kcfg_DigitalLCDStyle_stateChanged( int )</slot>
+</slots>
<layoutdefaults spacing="3" margin="6"/>
<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
<includehints>
Index: fuzzy.ui
===================================================================
RCS file: /home/kde/kdebase/kicker/applets/clock/fuzzy.ui,v
retrieving revision 1.17
diff -u -3 -p -r1.17 fuzzy.ui
--- fuzzy.ui 3 Feb 2004 17:28:26 -0000 1.17
+++ fuzzy.ui 24 Sep 2004 21:59:52 -0000
@@ -1,4 +1,4 @@
-<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>FuzzyWidget</class>
<widget class="QWidget">
<property name="name">
@@ -12,6 +12,9 @@
<height>299</height>
</rect>
</property>
+ <property name="caption">
+ <string>FuzzyWidget</string>
+ </property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
@@ -49,12 +52,23 @@
<property name="text">
<string>Dat&e</string>
</property>
+ <property name="accel">
+ <string>Alt+E</string>
+ </property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
+ <cstring>kcfg_FuzzyShowDayOfWeek</cstring>
+ </property>
+ <property name="text">
+ <string>Day of Week</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
<cstring>kcfg_FuzzyShowFrame</cstring>
</property>
<property name="text">
@@ -256,6 +270,8 @@
</widget>
</vbox>
</widget>
+<customwidgets>
+</customwidgets>
<tabstops>
<tabstop>kcfg_FuzzyShowDate</tabstop>
<tabstop>kcfg_FuzzyShowFrame</tabstop>
Index: settings.ui
===================================================================
RCS file: /home/kde/kdebase/kicker/applets/clock/settings.ui,v
retrieving revision 1.18
diff -u -3 -p -r1.18 settings.ui
--- settings.ui 13 Nov 2003 20:11:04 -0000 1.18
+++ settings.ui 24 Sep 2004 21:59:52 -0000
@@ -1,4 +1,4 @@
-<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>SettingsWidget</class>
<widget class="QWidget">
<property name="name">
@@ -12,6 +12,9 @@
<height>639</height>
</rect>
</property>
+ <property name="caption">
+ <string>SettingsWidget</string>
+ </property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
@@ -150,6 +153,9 @@
<property name="text">
<string>Dat&e</string>
</property>
+ <property name="accel">
+ <string>Alt+E</string>
+ </property>
<property name="checked">
<bool>true</bool>
</property>
@@ -161,6 +167,17 @@
<property name="text">
<string>&Seconds</string>
</property>
+ <property name="accel">
+ <string>Alt+S</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ \
<cstring>kcfg_PlainShowDayOfWeek</cstring> + \
</property> + <property name="text">
+ <string>Day of Week</string>
+ </property>
</widget>
<widget class="QCheckBox">
<property name="name">
@@ -169,6 +186,9 @@
<property name="text">
<string>&Frame</string>
</property>
+ <property name="accel">
+ <string>Alt+F</string>
+ </property>
</widget>
<spacer>
<property name="name">
@@ -471,6 +491,8 @@
</widget>
</vbox>
</widget>
+<customwidgets>
+</customwidgets>
<tabstops>
<tabstop>tabs</tabstop>
<tabstop>kcfg_Type</tabstop>
[Attachment #6 (application/pgp-signature)]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic