summaryrefslogtreecommitdiffstats
path: root/kicker/applets/clock
diff options
context:
space:
mode:
Diffstat (limited to 'kicker/applets/clock')
-rw-r--r--kicker/applets/clock/Makefile.am29
-rw-r--r--kicker/applets/clock/analog.ui344
-rw-r--r--kicker/applets/clock/clock.cpp1871
-rw-r--r--kicker/applets/clock/clock.h348
-rw-r--r--kicker/applets/clock/clockapplet.desktop151
-rw-r--r--kicker/applets/clock/clockapplet.kcfg191
-rw-r--r--kicker/applets/clock/datepicker.cpp87
-rw-r--r--kicker/applets/clock/datepicker.h49
-rw-r--r--kicker/applets/clock/digital.ui305
-rw-r--r--kicker/applets/clock/fuzzy.ui287
-rw-r--r--kicker/applets/clock/lcd.pngbin0 -> 237 bytes
-rw-r--r--kicker/applets/clock/prefs.kcfgc6
-rw-r--r--kicker/applets/clock/settings.ui515
-rw-r--r--kicker/applets/clock/zone.cpp180
-rw-r--r--kicker/applets/clock/zone.h62
15 files changed, 4425 insertions, 0 deletions
diff --git a/kicker/applets/clock/Makefile.am b/kicker/applets/clock/Makefile.am
new file mode 100644
index 000000000..b87e0d8e7
--- /dev/null
+++ b/kicker/applets/clock/Makefile.am
@@ -0,0 +1,29 @@
+pic_DATA = lcd.png
+picdir = $(kde_datadir)/clockapplet/pics
+
+INCLUDES = -I$(top_srcdir)/kicker/libkicker -I../../libkicker $(all_includes)
+
+kde_module_LTLIBRARIES = clock_panelapplet.la
+
+clock_panelapplet_la_SOURCES = clock.skel clock.cpp datepicker.cpp zone.cpp analog.ui digital.ui fuzzy.ui settings.ui prefs.kcfgc
+
+METASOURCES = AUTO
+noinst_HEADERS = clock.h datepicker.h zone.h
+
+lnkdir = $(kde_datadir)/kicker/applets
+lnk_DATA = clockapplet.desktop
+
+EXTRA_DIST = $(lnk_DATA) $(pic_DATA)
+
+clock_panelapplet_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
+clock_panelapplet_la_LIBADD = ../../libkicker/libkickermain.la $(LIB_KDEUI)
+
+srcdoc:
+ kdoc -a -p -H -d $$HOME/web/src/clockapplet clockapplet *.h -lqt -lkdecore -lkdeui -lkfile
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp *.h -o $(podir)/clockapplet.pot
+
+KDE_OPTIONS=nofinal
+
+clock_skel.lo: settings.h
diff --git a/kicker/applets/clock/analog.ui b/kicker/applets/clock/analog.ui
new file mode 100644
index 000000000..4a20312ec
--- /dev/null
+++ b/kicker/applets/clock/analog.ui
@@ -0,0 +1,344 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>AnalogWidget</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>AnalogWidget</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>524</width>
+ <height>307</height>
+ </rect>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QButtonGroup">
+ <property name="name">
+ <cstring>ButtonGroup2_3_2</cstring>
+ </property>
+ <property name="title">
+ <string>Display</string>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>kcfg_AnalogShowDate</cstring>
+ </property>
+ <property name="text">
+ <string>Dat&amp;e</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>kcfg_AnalogShowSeconds</cstring>
+ </property>
+ <property name="text">
+ <string>Seco&amp;nds</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>kcfg_AnalogShowDayOfWeek</cstring>
+ </property>
+ <property name="text">
+ <string>Da&amp;y of week</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>kcfg_AnalogShowFrame</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Frame</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer20</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox1</cstring>
+ </property>
+ <property name="title">
+ <string>Time</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="2" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>layout9</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KColorButton" row="2" column="1">
+ <property name="name">
+ <cstring>kcfg_AnalogBackgroundColor</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="KColorButton" row="1" column="1">
+ <property name="name">
+ <cstring>kcfg_AnalogShadowColor</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>foregroundAnalogLabel</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Foreground color:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>kcfg_AnalogForegroundColor</cstring>
+ </property>
+ </widget>
+ <spacer row="1" column="2">
+ <property name="name">
+ <cstring>spacer13</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>backgroundAnalogLabel</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Background color:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>kcfg_AnalogBackgroundColor</cstring>
+ </property>
+ </widget>
+ <widget class="KColorButton" row="0" column="1">
+ <property name="name">
+ <cstring>kcfg_AnalogForegroundColor</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>shadowAnalogLabel</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Shadow color:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>kcfg_AnalogShadowColor</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>TextLabel1_3</cstring>
+ </property>
+ <property name="text">
+ <string>Antialias:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>kcfg_AnalogAntialias</cstring>
+ </property>
+ </widget>
+ <widget class="QComboBox" row="0" column="1">
+ <item>
+ <property name="text">
+ <string>None</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Low Quality</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>High Quality</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>kcfg_AnalogAntialias</cstring>
+ </property>
+ <property name="currentItem">
+ <number>0</number>
+ </property>
+ </widget>
+ <spacer row="0" column="2">
+ <property name="name">
+ <cstring>Spacer18_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>310</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox" row="1" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>kcfg_AnalogLCDStyle</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;LCD look</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <spacer row="3" column="2">
+ <property name="name">
+ <cstring>spacer54</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>50</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ </vbox>
+</widget>
+<customwidgets>
+</customwidgets>
+<connections>
+ <connection>
+ <sender>kcfg_AnalogLCDStyle</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>foregroundAnalogLabel</receiver>
+ <slot>setDisabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>kcfg_AnalogLCDStyle</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>backgroundAnalogLabel</receiver>
+ <slot>setDisabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>kcfg_AnalogLCDStyle</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>shadowAnalogLabel</receiver>
+ <slot>setDisabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>kcfg_AnalogLCDStyle</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>kcfg_AnalogForegroundColor</receiver>
+ <slot>setDisabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>kcfg_AnalogLCDStyle</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>kcfg_AnalogShadowColor</receiver>
+ <slot>setDisabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>kcfg_AnalogLCDStyle</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>kcfg_AnalogBackgroundColor</receiver>
+ <slot>setDisabled(bool)</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>kcfg_AnalogShowDate</tabstop>
+ <tabstop>kcfg_AnalogShowSeconds</tabstop>
+ <tabstop>kcfg_AnalogShowFrame</tabstop>
+ <tabstop>kcfg_AnalogAntialias</tabstop>
+ <tabstop>kcfg_AnalogLCDStyle</tabstop>
+ <tabstop>kcfg_AnalogForegroundColor</tabstop>
+ <tabstop>kcfg_AnalogShadowColor</tabstop>
+ <tabstop>kcfg_AnalogBackgroundColor</tabstop>
+</tabstops>
+<includes>
+ <include location="local" impldecl="in implementation">kdialog.h</include>
+ <include location="local" impldecl="in implementation">kfontrequester.h</include>
+</includes>
+<layoutdefaults spacing="3" margin="6"/>
+<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
+<includehints>
+ <includehint>kcolorbutton.h</includehint>
+ <includehint>kcolorbutton.h</includehint>
+ <includehint>kcolorbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/kicker/applets/clock/clock.cpp b/kicker/applets/clock/clock.cpp
new file mode 100644
index 000000000..19e91be5c
--- /dev/null
+++ b/kicker/applets/clock/clock.cpp
@@ -0,0 +1,1871 @@
+/************************************************************
+
+Copyright (c) 1996-2002 the kicker authors. See file AUTHORS.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+******************************************************************/
+
+#include <cstdlib>
+#include <ctime>
+#include <time.h>
+
+#include <qcheckbox.h>
+#include <qcursor.h>
+#include <qgroupbox.h>
+#include <qimage.h>
+#include <qpainter.h>
+#include <qtimer.h>
+#include <qtooltip.h>
+#include <qclipboard.h>
+#include <qtabwidget.h>
+#include <qwidgetstack.h>
+#include <qcombobox.h>
+
+#include <kapplication.h>
+#include <kdebug.h>
+#include <kcolorbutton.h>
+#include <kiconloader.h>
+#include <kstandarddirs.h>
+#include <kapplication.h>
+#include <kprocess.h>
+#include <klocale.h>
+#include <kpopupmenu.h>
+#include <kstringhandler.h>
+#include <kfiledialog.h>
+#include <kfontrequester.h>
+#include <kglobalsettings.h>
+#include <kconfigdialogmanager.h>
+#include <kcalendarsystem.h>
+#include <kicontheme.h>
+#include <kiconloader.h>
+
+#include <global.h> // libkickermain
+
+#include "kickerSettings.h"
+#include "clock.h"
+#include "datepicker.h"
+#include "zone.h"
+#include "analog.h"
+#include "digital.h"
+#include "fuzzy.h"
+#include "prefs.h"
+
+extern "C"
+{
+ KDE_EXPORT KPanelApplet* init(QWidget *parent, const QString& configFile)
+ {
+ KGlobal::locale()->insertCatalogue("clockapplet");
+ KGlobal::locale()->insertCatalogue("timezones"); // For time zone translations
+ return new ClockApplet(configFile, KPanelApplet::Normal,
+ KPanelApplet::Preferences, parent, "clockapplet");
+ }
+}
+
+// Settings
+
+KConfigDialogSingle::KConfigDialogSingle(Zone *zone, QWidget *parent,
+ const char *name, Prefs * prefs,
+ KDialogBase::DialogType dialogType,
+ bool modal) :
+ KConfigDialog(parent, name, prefs, dialogType,
+ KDialogBase::Default | KDialogBase::Ok |
+ KDialogBase::Apply | KDialogBase::Cancel,
+ KDialogBase::Ok,
+ modal), _prefs(prefs)
+{
+ // As a temporary mesure until the kicker applet's app name is set to the
+ // applets name so KDialogBase gets the right info.
+ setPlainCaption(i18n("Configure - Clock"));
+ setIcon(SmallIcon("date"));
+
+ settings = new SettingsWidgetImp(prefs, zone, 0, "General");
+ connect(settings->kcfg_Type, SIGNAL(activated(int)), SLOT(selectPage(int)));
+
+ settings->kcfg_PlainBackgroundColor->setDefaultColor(KApplication::palette().active().background());
+ settings->kcfg_DateBackgroundColor->setDefaultColor(KApplication::palette().active().background());
+
+ // Digital
+ digitalPage = new DigitalWidget(0, "DigitalClock");
+ settings->widgetStack->addWidget(digitalPage, 1);
+ digitalPage->kcfg_DigitalBackgroundColor->setDefaultColor(KApplication::palette().active().background());
+
+ // Analog
+ analogPage = new AnalogWidget(0, "AnalogClock");
+ settings->widgetStack->addWidget(analogPage, 2);
+ analogPage->kcfg_AnalogBackgroundColor->setDefaultColor(KApplication::palette().active().background());
+
+ // Fuzzy
+ fuzzyPage = new FuzzyWidget(0, "FuzzyClock");
+ settings->widgetStack->addWidget(fuzzyPage, 3);
+ fuzzyPage->kcfg_FuzzyBackgroundColor->setDefaultColor(KApplication::palette().active().background());
+
+ connect(settings->kcfg_PlainShowDate, SIGNAL(toggled(bool)),
+ SLOT(dateToggled()));
+ connect(settings->kcfg_PlainShowDayOfWeek, SIGNAL(toggled(bool)),
+ SLOT(dateToggled()));
+ connect(digitalPage->kcfg_DigitalShowDate, SIGNAL(toggled(bool)),
+ SLOT(dateToggled()));
+ connect(digitalPage->kcfg_DigitalShowDayOfWeek, SIGNAL(toggled(bool)),
+ SLOT(dateToggled()));
+ connect(digitalPage->kcfg_DigitalShowDate, SIGNAL(toggled(bool)),
+ SLOT(dateToggled()));
+ connect(analogPage->kcfg_AnalogShowDate, SIGNAL(toggled(bool)),
+ SLOT(dateToggled()));
+ connect(analogPage->kcfg_AnalogShowDayOfWeek, SIGNAL(toggled(bool)),
+ SLOT(dateToggled()));
+ connect(fuzzyPage->kcfg_FuzzyShowDate, SIGNAL(toggled(bool)),
+ SLOT(dateToggled()));
+ connect(fuzzyPage->kcfg_FuzzyShowDayOfWeek, SIGNAL(toggled(bool)),
+ SLOT(dateToggled()));
+
+ addPage(settings, i18n("General"), QString::fromLatin1("package_settings"));
+}
+
+void KConfigDialogSingle::updateSettings()
+{
+ settings->OkApply();
+}
+
+void KConfigDialogSingle::updateWidgets()
+{
+ selectPage( _prefs->type() );
+}
+
+void KConfigDialogSingle::updateWidgetsDefault()
+{
+ KConfigSkeletonItem *item = _prefs->findItem("Type");
+ item->swapDefault();
+ selectPage( _prefs->type() );
+ item->swapDefault();
+ // This is ugly, but kcfg_Type does not have its correct setting
+ // at this point in time.
+ QTimer::singleShot(0, this, SLOT(dateToggled()));
+}
+
+void KConfigDialogSingle::selectPage(int p)
+{
+ settings->widgetStack->raiseWidget( p );
+ dateToggled();
+}
+
+void KConfigDialogSingle::dateToggled()
+{
+ bool showDate;
+ switch( settings->kcfg_Type->currentItem() )
+ {
+ case Prefs::EnumType::Plain:
+ showDate = settings->kcfg_PlainShowDate->isChecked() ||
+ settings->kcfg_PlainShowDayOfWeek->isChecked();
+ break;
+ case Prefs::EnumType::Digital:
+ showDate = digitalPage->kcfg_DigitalShowDate->isChecked() ||
+ digitalPage->kcfg_DigitalShowDayOfWeek->isChecked();
+ break;
+ case Prefs::EnumType::Analog:
+ showDate = analogPage->kcfg_AnalogShowDate->isChecked() ||
+ analogPage->kcfg_AnalogShowDayOfWeek->isChecked();
+ break;
+ case Prefs::EnumType::Fuzzy:
+ default:
+ showDate = fuzzyPage->kcfg_FuzzyShowDate->isChecked() ||
+ fuzzyPage->kcfg_FuzzyShowDayOfWeek->isChecked();
+ break;
+ }
+ settings->dateBox->setEnabled(showDate);
+}
+
+SettingsWidgetImp::SettingsWidgetImp(Prefs *p, Zone *z, QWidget* parent, const char* name, WFlags fl) :
+ SettingsWidget(parent, name, fl), prefs(p), zone(z)
+{
+ zone->readZoneList(tzListView);
+}
+
+void SettingsWidgetImp::OkApply()
+{
+ zone->getSelectedZonelist(tzListView);
+ zone->writeSettings();
+}
+
+//************************************************************
+
+
+ClockWidget::ClockWidget(ClockApplet *applet, Prefs* prefs)
+ : _applet(applet), _prefs(prefs), _force(false)
+{}
+
+
+ClockWidget::~ClockWidget()
+{}
+
+
+//************************************************************
+
+
+PlainClock::PlainClock(ClockApplet *applet, Prefs *prefs, QWidget *parent, const char *name)
+ : QLabel(parent, name), ClockWidget(applet, prefs)
+{
+ setWFlags(WNoAutoErase);
+ setBackgroundOrigin(AncestorOrigin);
+ loadSettings();
+ updateClock();
+}
+
+
+int PlainClock::preferedWidthForHeight(int ) const
+{
+ QString maxLengthTime = KGlobal::locale()->formatTime( QTime( 23, 59 ), _prefs->plainShowSeconds());
+ return fontMetrics().width( maxLengthTime ) + 8;
+}
+
+
+int PlainClock::preferedHeightForWidth(int /*w*/) const
+{
+ return fontMetrics().lineSpacing();
+}
+
+
+void PlainClock::updateClock()
+{
+ QString newStr = KGlobal::locale()->formatTime(_applet->clockGetTime(), _prefs->plainShowSeconds());
+
+ if (_force || newStr != _timeStr) {
+ _timeStr = newStr;
+ update();
+ }
+}
+
+void PlainClock::loadSettings()
+{
+ setFrameStyle(_prefs->plainShowFrame() ? Panel | Sunken : NoFrame);
+ setAlignment(AlignVCenter | AlignHCenter | SingleLine);
+
+ setFont(_prefs->plainFont());
+}
+
+bool PlainClock::showDate()
+{
+ return _prefs->plainShowDate();
+}
+
+bool PlainClock::showDayOfWeek()
+{
+ return _prefs->plainShowDayOfWeek();
+}
+
+void PlainClock::paintEvent(QPaintEvent *)
+{
+ QPainter p;
+ QPixmap buf(size());
+ buf.fill(this, 0, 0);
+ p.begin(&buf);
+ p.setFont(font());
+ p.setPen(paletteForegroundColor());
+ drawContents(&p);
+ drawFrame(&p);
+ p.end();
+ p.begin(this);
+ p.drawPixmap(0, 0, buf);
+ p.end();
+}
+
+void PlainClock::drawContents(QPainter *p)
+{
+ QRect tr(0, 0, width(), height());
+
+ if (!KickerSettings::transparent())
+ p->drawText(tr, AlignCenter, _timeStr);
+ else
+ _applet->shadowEngine()->drawText(*p, tr, AlignCenter, _timeStr, size());
+}
+
+//************************************************************
+
+
+DigitalClock::DigitalClock(ClockApplet *applet, Prefs *prefs, QWidget *parent, const char *name)
+ : QLCDNumber(parent, name), ClockWidget(applet, prefs)
+{
+ setWFlags(WNoAutoErase);
+ setBackgroundOrigin(AncestorOrigin);
+ loadSettings();
+ updateClock();
+}
+
+
+DigitalClock::~DigitalClock()
+{
+ delete _buffer;
+}
+
+
+int DigitalClock::preferedWidthForHeight(int h) const
+{
+ if (h > 29) h = 29;
+ if (h < 0) h = 0;
+ return (numDigits()*h*5/11)+2;
+}
+
+
+int DigitalClock::preferedHeightForWidth(int w) const
+{
+ if (w < 0) w = 0;
+ return((w / numDigits() * 2) + 6);
+}
+
+
+void DigitalClock::updateClock()
+{
+ static bool colon = true;
+ QString newStr;
+ QTime t(_applet->clockGetTime());
+
+ int h = t.hour();
+ int m = t.minute();
+ int s = t.second();
+
+ QString format("%02d");
+
+ QString sep(!colon && _prefs->digitalBlink() ? " " : ":");
+
+ if (_prefs->digitalShowSeconds())
+ format += sep + "%02d";
+
+ if (KGlobal::locale()->use12Clock()) {
+ if (h > 12)
+ h -= 12;
+ else if( h == 0)
+ h = 12;
+
+ format.prepend("%2d" + sep);
+ } else
+ format.prepend("%02d" + sep);
+
+
+ if (_prefs->digitalShowSeconds())
+ newStr.sprintf(format.latin1(), h, m, s);
+ else
+ newStr.sprintf(format.latin1(), h, m);
+
+ if (_force || newStr != _timeStr)
+ {
+ _timeStr = newStr;
+ setUpdatesEnabled( FALSE );
+ display(_timeStr);
+ setUpdatesEnabled( TRUE );
+ update();
+ }
+
+ if (_prefs->digitalBlink())
+ colon = !colon;
+}
+
+void DigitalClock::loadSettings()
+{
+ setFrameStyle(_prefs->digitalShowFrame() ? Panel | Sunken : NoFrame);
+ setMargin( 4 );
+ setSegmentStyle(QLCDNumber::Flat);
+
+ if (_prefs->digitalLCDStyle())
+ lcdPattern = KIconLoader("clockapplet").loadIcon("lcd", KIcon::User);
+
+ setNumDigits(_prefs->digitalShowSeconds() ? 8:5);
+
+ _buffer = new QPixmap(width(), height());
+}
+
+void DigitalClock::paintEvent(QPaintEvent*)
+{
+ QPainter p(_buffer);
+
+ if (_prefs->digitalLCDStyle())
+ {
+ p.drawTiledPixmap(0, 0, width(), height(), lcdPattern);
+ }
+ else if (_prefs->digitalBackgroundColor() !=
+ KApplication::palette().active().background())
+ {
+ p.fillRect(0, 0, width(), height(), _prefs->digitalBackgroundColor());
+ }
+ else if (paletteBackgroundPixmap())
+ {
+ QPoint offset = backgroundOffset();
+ p.drawTiledPixmap(0, 0, width(), height(), *paletteBackgroundPixmap(), offset.x(), offset.y());
+ }
+ else
+ {
+ p.fillRect(0, 0, width(), height(), _prefs->digitalBackgroundColor());
+ }
+
+ drawContents(&p);
+ if (_prefs->digitalShowFrame())
+ {
+ drawFrame(&p);
+ }
+
+ p.end();
+ bitBlt(this, 0, 0, _buffer, 0, 0);
+}
+
+
+// yes, the colors for the lcd-lock are hardcoded,
+// but other colors would break the lcd-lock anyway
+void DigitalClock::drawContents( QPainter * p)
+{
+ setUpdatesEnabled( FALSE );
+ QPalette pal = palette();
+ if (_prefs->digitalLCDStyle())
+ pal.setColor( QColorGroup::Foreground, QColor(128,128,128));
+ else
+ pal.setColor( QColorGroup::Foreground, _prefs->digitalShadowColor());
+ setPalette( pal );
+ p->translate( +1, +1 );
+ QLCDNumber::drawContents( p );
+ if (_prefs->digitalLCDStyle())
+ pal.setColor( QColorGroup::Foreground, Qt::black);
+ else
+ pal.setColor( QColorGroup::Foreground, _prefs->digitalForegroundColor());
+ setPalette( pal );
+ p->translate( -2, -2 );
+ setUpdatesEnabled( TRUE );
+ QLCDNumber::drawContents( p );
+ p->translate( +1, +1 );
+}
+
+
+// reallocate buffer pixmap
+void DigitalClock::resizeEvent ( QResizeEvent *)
+{
+ delete _buffer;
+ _buffer = new QPixmap( width(), height() );
+}
+
+
+bool DigitalClock::showDate()
+{
+ return _prefs->digitalShowDate();
+}
+
+bool DigitalClock::showDayOfWeek()
+{
+ return _prefs->digitalShowDayOfWeek();
+}
+
+
+//************************************************************
+
+
+AnalogClock::AnalogClock(ClockApplet *applet, Prefs *prefs, QWidget *parent, const char *name)
+ : QFrame(parent, name), ClockWidget(applet, prefs), _spPx(NULL)
+{
+ setWFlags(WNoAutoErase);
+ setBackgroundOrigin(AncestorOrigin);
+ loadSettings();
+}
+
+
+AnalogClock::~AnalogClock()
+{
+ delete _spPx;
+}
+
+void AnalogClock::initBackgroundPixmap()
+{
+ //if no antialiasing, use pixmap as-is
+ if (_prefs->analogAntialias() == 0)
+ {
+ lcdPattern = KIconLoader("clockapplet").loadIcon("lcd",KIcon::User);
+ _bgScale = 1;
+ }
+ else
+ {
+ //make a scaled pixmap -- so when image is reduced it'll look "OK".
+ _bgScale = _prefs->analogAntialias()+1;
+ QImage bgImage = KIconLoader("clockapplet").loadIcon("lcd", KIcon::User).convertToImage();
+ lcdPattern = QPixmap(bgImage.scale(bgImage.width() * _bgScale,
+ bgImage.height() * _bgScale));
+
+ }
+}
+
+void AnalogClock::updateClock()
+{
+ if (!_force)
+ {
+ if (!_prefs->analogShowSeconds() && (_time.minute() == _applet->clockGetTime().minute()))
+ return;
+ }
+
+ _time = _applet->clockGetTime();
+ update();
+}
+
+void AnalogClock::loadSettings()
+{
+ if (_prefs->analogLCDStyle())
+ {
+ initBackgroundPixmap();
+ }
+/* this may prevent flicker, but it also prevents transparency
+ else
+ {
+ setBackgroundMode(NoBackground);
+ }*/
+
+ setFrameStyle(_prefs->analogShowFrame() ? Panel | Sunken : NoFrame);
+ _time = _applet->clockGetTime();
+ _spPx = new QPixmap(size().width() * _prefs->analogAntialias()+1,
+ size().height() * _prefs->analogAntialias()+1);
+
+ update();
+}
+
+void AnalogClock::paintEvent( QPaintEvent * )
+{
+ if ( !isVisible() )
+ return;
+
+ int aaFactor = _prefs->analogAntialias()+1;
+ int spWidth = size().width() * aaFactor;
+ int spHeight = size().height() * aaFactor;
+
+ if ((spWidth != _spPx->size().width()) ||
+ (spHeight != _spPx->size().height()))
+ {
+ delete _spPx;
+ _spPx = new QPixmap(spWidth, spHeight);
+ }
+
+ QPainter paint;
+ paint.begin(_spPx);
+
+ if (_prefs->analogLCDStyle())
+ {
+ if (_bgScale != aaFactor)
+ {
+ //check to see if antialiasing has changed -- bg pixmap will need
+ //to be re-created
+ initBackgroundPixmap();
+ }
+
+ paint.drawTiledPixmap(0, 0, spWidth, spHeight, lcdPattern);
+ }
+ else if (_prefs->analogBackgroundColor() != KApplication::palette().active().background())
+ {
+ _spPx->fill(_prefs->analogBackgroundColor());
+ }
+ else if (paletteBackgroundPixmap())
+ {
+ QPixmap bg(width(), height());
+ QPainter p(&bg);
+ QPoint offset = backgroundOffset();
+ p.drawTiledPixmap(0, 0, width(), height(), *paletteBackgroundPixmap(), offset.x(), offset.y());
+ p.end();
+ QImage bgImage = bg.convertToImage().scale(spWidth, spHeight);
+ paint.drawImage(0, 0, bgImage);
+ }
+ else
+ {
+ _spPx->fill(_prefs->analogBackgroundColor());
+ }
+
+ QPointArray pts;
+ QPoint cp(spWidth / 2, spHeight / 2);
+
+ int d = KMIN(spWidth,spHeight) - (10 * aaFactor);
+
+ if (_prefs->analogLCDStyle())
+ {
+ paint.setPen( QPen(QColor(100,100,100), aaFactor) );
+ paint.setBrush( QColor(100,100,100) );
+ }
+ else
+ {
+ paint.setPen( QPen(_prefs->analogShadowColor(), aaFactor) );
+ paint.setBrush( _prefs->analogShadowColor() );
+ }
+
+ paint.setViewport(2,2,spWidth,spHeight);
+
+ for ( int c=0 ; c < 2 ; c++ ) {
+ QWMatrix matrix;
+ matrix.translate( cp.x(), cp.y());
+ matrix.scale( d/1000.0F, d/1000.0F );
+
+ // hour
+ float h_angle = 30*(_time.hour()%12-3) + _time.minute()/2;
+ matrix.rotate( h_angle );
+ paint.setWorldMatrix( matrix );
+ pts.setPoints( 4, -20,0, 0,-20, 300,0, 0,20 );
+ paint.drawPolygon( pts );
+ matrix.rotate( -h_angle );
+
+ // minute
+ float m_angle = (_time.minute()-15)*6;
+ matrix.rotate( m_angle );
+ paint.setWorldMatrix( matrix );
+ pts.setPoints( 4, -10,0, 0,-10, 400,0, 0,10 );
+ paint.drawPolygon( pts );
+ matrix.rotate( -m_angle );
+
+ if (_prefs->analogShowSeconds()) { // second
+ float s_angle = (_time.second()-15)*6;
+ matrix.rotate( s_angle );
+ paint.setWorldMatrix( matrix );
+ pts.setPoints(4,0,0,0,0,400,0,0,0);
+ paint.drawPolygon( pts );
+ matrix.rotate( -s_angle );
+ }
+
+ QWMatrix matrix2;
+ matrix2.translate( cp.x(), cp.y());
+ matrix2.scale( d/1000.0F, d/1000.0F );
+
+ // quadrante
+ for ( int i=0 ; i < 12 ; i++ ) {
+ paint.setWorldMatrix( matrix2 );
+ paint.drawLine( 460,0, 500,0 ); // draw hour lines
+ // paint.drawEllipse( 450, -15, 30, 30 );
+ matrix2.rotate( 30 );
+ }
+
+ if (_prefs->analogLCDStyle()) {
+ paint.setPen( QPen(Qt::black, aaFactor) );
+ paint.setBrush( Qt::black );
+ } else {
+ paint.setPen( QPen(_prefs->analogForegroundColor(), aaFactor) );
+ paint.setBrush( _prefs->analogForegroundColor() );
+ }
+
+ paint.setViewport(0,0,spWidth,spHeight);
+ }
+ paint.end();
+
+ QPainter paintFinal;
+ paintFinal.begin(this);
+
+ if (aaFactor != 1)
+ {
+ QImage spImage = _spPx->convertToImage();
+ QImage displayImage = spImage.smoothScale(size());
+
+ paintFinal.drawImage(0, 0, displayImage);
+ }
+ else
+ {
+ paintFinal.drawPixmap(0, 0, *_spPx);
+ }
+
+ if (_prefs->analogShowFrame())
+ {
+ drawFrame(&paintFinal);
+ }
+}
+
+
+// the background pixmap disappears during a style change
+void AnalogClock::styleChange(QStyle &)
+{
+ if (_prefs->analogLCDStyle())
+ {
+ initBackgroundPixmap();
+ }
+}
+
+bool AnalogClock::showDate()
+{
+ return _prefs->analogShowDate();
+}
+
+bool AnalogClock::showDayOfWeek()
+{
+ return _prefs->analogShowDayOfWeek();
+}
+
+
+//************************************************************
+
+
+FuzzyClock::FuzzyClock(ClockApplet *applet, Prefs *prefs, QWidget *parent, const char *name)
+ : QFrame(parent, name), ClockWidget(applet, prefs)
+{
+ setBackgroundOrigin(AncestorOrigin);
+ loadSettings();
+ hourNames << i18n("hour","one") << i18n("hour","two")
+ << i18n("hour","three") << i18n("hour","four") << i18n("hour","five")
+ << i18n("hour","six") << i18n("hour","seven") << i18n("hour","eight")
+ << i18n("hour","nine") << i18n("hour","ten") << i18n("hour","eleven")
+ << i18n("hour","twelve");
+
+ // xgettext:no-c-format
+ normalFuzzy << i18n("%0 o'clock") // xgettext:no-c-format
+ << i18n("five past %0") // xgettext:no-c-format
+ << i18n("ten past %0") // xgettext:no-c-format
+ << i18n("quarter past %0") // xgettext:no-c-format
+ << i18n("twenty past %0") // xgettext:no-c-format
+ << i18n("twenty five past %0") // xgettext:no-c-format
+ << i18n("half past %0") // xgettext:no-c-format
+ << i18n("twenty five to %1") // xgettext:no-c-format
+ << i18n("twenty to %1") // xgettext:no-c-format
+ << i18n("quarter to %1") // xgettext:no-c-format
+ << i18n("ten to %1") // xgettext:no-c-format
+ << i18n("five to %1") // xgettext:no-c-format
+ << i18n("%1 o'clock");
+
+ // xgettext:no-c-format
+ normalFuzzyOne << i18n("one","%0 o'clock") // xgettext:no-c-format
+ << i18n("one","five past %0") // xgettext:no-c-format
+ << i18n("one","ten past %0") // xgettext:no-c-format
+ << i18n("one","quarter past %0") // xgettext:no-c-format
+ << i18n("one","twenty past %0") // xgettext:no-c-format
+ << i18n("one","twenty five past %0") // xgettext:no-c-format
+ << i18n("one","half past %0") // xgettext:no-c-format
+ << i18n("one","twenty five to %1") // xgettext:no-c-format
+ << i18n("one","twenty to %1") // xgettext:no-c-format
+ << i18n("one","quarter to %1") // xgettext:no-c-format
+ << i18n("one","ten to %1") // xgettext:no-c-format
+ << i18n("one","five to %1") // xgettext:no-c-format
+ << i18n("one","%1 o'clock");
+
+ dayTime << i18n("Night")
+ << i18n("Early morning") << i18n("Morning") << i18n("Almost noon")
+ << i18n("Noon") << i18n("Afternoon") << i18n("Evening")
+ << i18n("Late evening");
+
+ _time = _applet->clockGetTime();
+ alreadyDrawing=false;
+ update();
+}
+
+void FuzzyClock::deleteMyself()
+{
+ if(alreadyDrawing) // try again later
+ QTimer::singleShot(1000, this, SLOT(deleteMyself()));
+ else
+ delete this;
+}
+
+
+int FuzzyClock::preferedWidthForHeight(int ) const
+{
+ QFontMetrics fm(_prefs->fuzzyFont());
+ return fm.width(_timeStr) + 8;
+}
+
+
+int FuzzyClock::preferedHeightForWidth(int ) const
+{
+ QFontMetrics fm(_prefs->fuzzyFont());
+ return fm.width(_timeStr) + 8;
+}
+
+
+void FuzzyClock::updateClock()
+{
+ if (!_force)
+ {
+ if (_time.hour() == _applet->clockGetTime().hour() &&
+ _time.minute() == _applet->clockGetTime().minute())
+ return;
+ }
+
+ _time = _applet->clockGetTime();
+ update();
+}
+
+void FuzzyClock::loadSettings()
+{
+ setFrameStyle(_prefs->fuzzyShowFrame() ? Panel | Sunken : 0);
+}
+
+void FuzzyClock::drawContents(QPainter *p)
+{
+ if (!isVisible())
+ return;
+
+ if(!_applet)
+ return;
+
+ alreadyDrawing = true;
+ QString newTimeStr;
+
+ if (_prefs->fuzzyness() == 1 || _prefs->fuzzyness() == 2) {
+ int minute = _time.minute();
+ int sector = 0;
+ int realHour = 0;
+
+ if (_prefs->fuzzyness() == 1) {
+ if (minute > 2)
+ sector = (minute - 3) / 5 + 1;
+ } else {
+ if (minute > 6)
+ sector = ((minute - 7) / 15 + 1) * 3;
+ }
+
+ newTimeStr = normalFuzzy[sector];
+ int phStart = newTimeStr.find("%");
+ if (phStart >= 0) { // protect yourself from translations
+ int phLength = newTimeStr.find(" ", phStart) - phStart;
+
+ // larrosa: we want the exact length, in case the translation needs it,
+ // in other case, we would cut off the end of the translation.
+ if (phLength < 0) phLength = newTimeStr.length() - phStart;
+ int deltaHour = newTimeStr.mid(phStart + 1, phLength - 1).toInt();
+
+ if ((_time.hour() + deltaHour) % 12 > 0)
+ realHour = (_time.hour() + deltaHour) % 12 - 1;
+ else
+ realHour = 12 - ((_time.hour() + deltaHour) % 12 + 1);
+ if (realHour==0) {
+ newTimeStr = normalFuzzyOne[sector];
+ phStart = newTimeStr.find("%");
+ // larrosa: Note that length is the same,
+ // so we only have to update phStart
+ }
+ if (phStart >= 0)
+ newTimeStr.replace(phStart, phLength, hourNames[realHour]);
+ newTimeStr.replace(0, 1, QString(newTimeStr.at(0).upper()));
+ }
+ } else if (_prefs->fuzzyness() == 3) {
+ newTimeStr = dayTime[_time.hour() / 3];
+ } else {
+ int dow = _applet->clockGetDate().dayOfWeek();
+
+ if (dow == 1)
+ newTimeStr = i18n("Start of week");
+ else if (dow >= 2 && dow <= 4)
+ newTimeStr = i18n("Middle of week");
+ else if (dow == 5)
+ newTimeStr = i18n("End of week");
+ else
+ newTimeStr = i18n("Weekend!");
+ }
+
+ if (_timeStr != newTimeStr) {
+ _timeStr = newTimeStr;
+ _applet->resizeRequest();
+ }
+
+ p->setFont(_prefs->fuzzyFont());
+ p->setPen(_prefs->fuzzyForegroundColor());
+
+ QRect tr;
+
+ if (_applet->getOrientation() == Vertical)
+ {
+ p->rotate(90);
+ tr = QRect(4, -2, height() - 8, -(width()) + 2);
+ }
+ else
+ tr = QRect(4, 2, width() - 8, height() - 4);
+
+ if (!KickerSettings::transparent())
+ p->drawText(tr, AlignCenter, _timeStr);
+ else
+ _applet->shadowEngine()->drawText(*p, tr, AlignCenter, _timeStr, size());
+
+ alreadyDrawing = false;
+}
+
+bool FuzzyClock::showDate()
+{
+ return _prefs->fuzzyShowDate();
+}
+
+bool FuzzyClock::showDayOfWeek()
+{
+ return _prefs->fuzzyShowDayOfWeek();
+}
+
+
+//************************************************************
+
+
+ClockApplet::ClockApplet(const QString& configFile, Type t, int actions,
+ QWidget *parent, const char *name)
+ : KPanelApplet(configFile, t, actions, parent, name),
+ _calendar(0),
+ _disableCalendar(false),
+ _clock(0),
+ _timer(new QTimer(this)),
+ m_layoutTimer(new QTimer(this)),
+ m_layoutDelay(0),
+ m_followBackgroundSetting(true),
+ m_dateFollowBackgroundSetting(true),
+ TZoffset(0),
+ _prefs(new Prefs(sharedConfig())),
+ zone(new Zone(config())),
+ menu(0),
+ m_tooltip(this),
+ m_shadowEngine(0)
+{
+ DCOPObject::setObjId("ClockApplet");
+ _prefs->readConfig();
+ configFileName = configFile.latin1();
+ setBackgroundOrigin(AncestorOrigin);
+
+ _dayOfWeek = new QLabel(this);
+ _dayOfWeek->setAlignment(AlignVCenter | AlignHCenter | WordBreak);
+ _dayOfWeek->setBackgroundOrigin(AncestorOrigin);
+ _dayOfWeek->installEventFilter(this); // catch mouse clicks
+
+ _date = new QLabel(this);
+ _date->setAlignment(AlignVCenter | AlignHCenter | WordBreak);
+ _date->setBackgroundOrigin(AncestorOrigin);
+ _date->installEventFilter(this); // catch mouse clicks
+
+ connect(m_layoutTimer, SIGNAL(timeout()), this, SLOT(fixupLayout()));
+ connect(_timer, SIGNAL(timeout()), SLOT(slotUpdate()));
+ connect(kapp, SIGNAL(kdisplayPaletteChanged()), SLOT(globalPaletteChange()));
+
+ reconfigure(); // initialize clock widget
+ slotUpdate();
+
+ if (kapp->authorizeKAction("kicker_rmb"))
+ {
+ menu = new KPopupMenu();
+ connect(menu, SIGNAL(aboutToShow()), SLOT(aboutToShowContextMenu()));
+ connect(menu, SIGNAL(activated(int)), SLOT(contextMenuActivated(int)));
+ setCustomMenu(menu);
+ }
+
+ installEventFilter(KickerTip::the());
+}
+
+
+ClockApplet::~ClockApplet()
+{
+ delete m_shadowEngine;
+ //reverse for the moment
+ KGlobal::locale()->removeCatalogue("clockapplet");
+ KGlobal::locale()->removeCatalogue("timezones"); // For time zone translations
+
+ if (_calendar)
+ {
+ // we have to take care of the calendar closing first before deleting
+ // the prefs
+ _calendar->close();
+ }
+
+ zone->writeSettings();
+
+ delete _prefs; _prefs = 0;
+ delete zone; zone = 0;
+ delete menu; menu = 0;
+ config()->sync();
+}
+
+
+KTextShadowEngine *ClockApplet::shadowEngine()
+{
+ if (!m_shadowEngine)
+ m_shadowEngine = new KTextShadowEngine();
+
+ return m_shadowEngine;
+}
+
+
+int ClockApplet::widthForHeight(int h) const
+{
+ if (orientation() == Qt::Vertical)
+ {
+ return width();
+ }
+
+ int shareDateHeight = 0, shareDayOfWeekHeight = 0;
+ bool dateToSide = (h < 32);
+ bool mustShowDate = showDate || (zone->zoneIndex() != 0);
+ if (mustShowDate)
+ {
+ _date->setAlignment(AlignVCenter | AlignHCenter);
+ if (!dateToSide)
+ {
+ shareDateHeight = _date->sizeHint().height();
+ }
+ }
+ if (showDayOfWeek)
+ {
+ _dayOfWeek->setAlignment(AlignVCenter | AlignHCenter);
+ if (!dateToSide)
+ {
+ shareDayOfWeekHeight = _dayOfWeek->sizeHint().height();
+ }
+ }
+
+ int clockWidth = _clock->preferedWidthForHeight(KMAX(0, h - shareDateHeight - shareDayOfWeekHeight));
+ int w = clockWidth;
+ if (!mustShowDate && !showDayOfWeek)
+ {
+ // resize the date widgets in case the are to the left of the clock
+ _clock->widget()->setFixedSize(w, h);
+ _clock->widget()->move(0,0);
+ _dayOfWeek->move(clockWidth + 4, 0);
+ _date->move(clockWidth + 4, 0);
+ }
+ else
+ {
+ int dateWidth = mustShowDate ? _date->sizeHint().width() + 4 : 0;
+ int dayOfWeekWidth = showDayOfWeek ? _dayOfWeek->sizeHint().width() + 4 : 0;
+
+ if (dateToSide)
+ {
+ w += dateWidth + dayOfWeekWidth;
+ bool dateFirst = false;
+
+ if (mustShowDate)
+ {
+ // if the date format STARTS with a year, assume it's in descending
+ // order and should therefore PRECEED the date.
+ QString dateFormat = KGlobal::locale()->dateFormatShort();
+ dateFirst = dateFormat.at(1) == 'y' || dateFormat.at(1) == 'Y';
+ }
+
+ if (dateFirst)
+ {
+ _date->setFixedSize(dateWidth, h);
+ _date->move(0, 0);
+
+ if (showDayOfWeek)
+ {
+ _dayOfWeek->setFixedSize(dayOfWeekWidth, h);
+ _dayOfWeek->move(dateWidth, 0);
+ }
+
+ _clock->widget()->setFixedSize(clockWidth, h);
+ _clock->widget()->move(dateWidth + dayOfWeekWidth, 0);
+ }
+ else
+ {
+ _clock->widget()->setFixedSize(clockWidth, h);
+ _clock->widget()->move(0,0);
+
+ if (showDayOfWeek)
+ {
+ _dayOfWeek->setFixedSize(dayOfWeekWidth, h);
+ _dayOfWeek->move(clockWidth, 0);
+ }
+
+ if (mustShowDate)
+ {
+ _date->setFixedSize(dateWidth, h);
+ _date->move(clockWidth + dayOfWeekWidth, 0);
+ }
+ }
+ }
+ else
+ {
+ w = KMAX(KMAX(w, dateWidth), dayOfWeekWidth);
+
+ _clock->widget()->setFixedSize(w, h - shareDateHeight - shareDayOfWeekHeight);
+ _clock->widget()->setMinimumSize(w, h - shareDateHeight - shareDayOfWeekHeight);
+ _clock->widget()->move(0, 0);
+ if (showDayOfWeek)
+ {
+ _dayOfWeek->setFixedSize(w, _dayOfWeek->sizeHint().height());
+ _dayOfWeek->move(0, _clock->widget()->height());
+ }
+
+ if (mustShowDate)
+ {
+ _date->setFixedSize(w, _date->sizeHint().height());
+ _date->move(0, _clock->widget()->height() + shareDayOfWeekHeight);
+ }
+ }
+ }
+
+ return w;
+}
+
+int ClockApplet::heightForWidth(int w) const
+{
+ if (orientation() == Qt::Horizontal)
+ {
+ return height();
+ }
+
+ int clockHeight = _clock->preferedHeightForWidth(w);
+ bool mustShowDate = showDate || (zone->zoneIndex() != 0);
+
+ _clock->widget()->setFixedSize(w, clockHeight);
+
+ // add 4 pixels in height for each of date+dayOfWeek, if visible
+ if (showDayOfWeek)
+ {
+ if (_dayOfWeek->minimumSizeHint().width() > w)
+ {
+ _dayOfWeek->setAlignment(AlignVCenter | WordBreak);
+ }
+ else
+ {
+ _dayOfWeek->setAlignment(AlignVCenter | AlignHCenter | WordBreak);
+ }
+
+ _dayOfWeek->setFixedSize(w, _dayOfWeek->minimumSizeHint().height());
+ _dayOfWeek->move(0, clockHeight);
+
+ clockHeight += _dayOfWeek->height();
+ }
+
+ if (mustShowDate)
+ {
+ // yes, the const_cast is ugly, but this is to ensure that we
+ // get a proper date label in the case that we munged it for
+ // display on panel that is too narrow and then they made it wider
+ const_cast<ClockApplet*>(this)->updateDateLabel(false);
+
+ if (_date->minimumSizeHint().width() > w)
+ {
+ QString dateStr = _date->text();
+ // if we're too wide to fit, replace the first non-digit from the end with a space
+ int p = dateStr.findRev(QRegExp("[^0-9]"));
+ if (p > 0)
+ {
+ _date->setText(dateStr.insert(p, '\n'));
+ }
+ }
+
+ if (_date->minimumSizeHint().width() > w)
+ {
+ _date->setAlignment(AlignVCenter | WordBreak);
+ }
+ else
+ {
+ _date->setAlignment(AlignVCenter | AlignHCenter | WordBreak);
+ }
+ _date->setFixedSize(w, _date->heightForWidth(w));
+ _date->move(0, clockHeight);
+
+ clockHeight += _date->height();
+ }
+
+ return clockHeight;
+}
+
+void ClockApplet::preferences()
+{
+ preferences(false);
+}
+
+void ClockApplet::preferences(bool timezone)
+{
+ KConfigDialogSingle *dialog = dynamic_cast<KConfigDialogSingle*>(KConfigDialog::exists(configFileName));
+
+ if (!dialog)
+ {
+ dialog = new KConfigDialogSingle(zone, this, configFileName, _prefs, KDialogBase::Swallow);
+ connect(dialog, SIGNAL(settingsChanged()), this, SLOT(slotReconfigure()));
+ }
+
+ if (timezone)
+ {
+ dialog->settings->tabs->setCurrentPage(1);
+ }
+
+ dialog->show();
+}
+
+void ClockApplet::updateFollowBackground()
+{
+ QColor globalBgroundColor = KApplication::palette().active().background();
+ QColor bgColor;
+
+ switch (_prefs->type())
+ {
+ case Prefs::EnumType::Plain:
+ bgColor = _prefs->plainBackgroundColor();
+ break;
+ case Prefs::EnumType::Analog:
+ bgColor = _prefs->analogBackgroundColor();
+ break;
+ case Prefs::EnumType::Fuzzy:
+ bgColor = _prefs->fuzzyBackgroundColor();
+ break;
+ case Prefs::EnumType::Digital:
+ default:
+ bgColor = _prefs->digitalBackgroundColor();
+ break;
+ }
+
+ m_followBackgroundSetting = (bgColor == globalBgroundColor);
+
+ bgColor = _prefs->dateBackgroundColor();
+ m_dateFollowBackgroundSetting = (bgColor == globalBgroundColor);
+}
+
+// DCOP interface
+void ClockApplet::reconfigure()
+{
+ _timer->stop();
+
+ // ugly workaround for FuzzyClock: sometimes FuzzyClock
+ // hasn't finished drawing when getting deleted, so we
+ // ask FuzzyClock to delete itself appropriately
+ if (_clock && _clock->widget()->inherits("FuzzyClock"))
+ {
+ FuzzyClock* f = static_cast<FuzzyClock*>(_clock);
+ f->deleteMyself();
+ }
+ else
+ {
+ delete _clock;
+ }
+
+ int shortInterval = 500;
+ int updateInterval = 0;
+
+ switch (_prefs->type())
+ {
+ case Prefs::EnumType::Plain:
+ _clock = new PlainClock(this, _prefs, this);
+ if (_prefs->plainShowSeconds())
+ updateInterval = shortInterval;
+ break;
+ case Prefs::EnumType::Analog:
+ _clock = new AnalogClock(this, _prefs, this);
+ if (_prefs->analogShowSeconds())
+ updateInterval = shortInterval;
+ break;
+ case Prefs::EnumType::Fuzzy:
+ _clock = new FuzzyClock(this, _prefs, this);
+ break;
+ case Prefs::EnumType::Digital:
+ default:
+ _clock = new DigitalClock(this, _prefs, this);
+ if (_prefs->digitalShowSeconds() || _prefs->digitalBlink())
+ updateInterval = shortInterval;
+ break;
+ }
+
+ m_updateOnTheMinute = updateInterval != shortInterval;
+ if (m_updateOnTheMinute)
+ {
+ connect(_timer, SIGNAL(timeout()), this, SLOT(setTimerTo60()));
+ updateInterval = ((60 - clockGetTime().second()) * 1000) + 500;
+ }
+ else
+ {
+ // in case we reconfigure to show seconds but setTimerTo60 is going to be called
+ // we need to make sure to disconnect this so we don't end up updating only once
+ // a minute ;)
+ disconnect(_timer, SIGNAL(timeout()), this, SLOT(setTimerTo60()));
+ }
+
+ _timer->start(updateInterval);
+
+ // See if the clock wants to show the date.
+ showDate = _clock->showDate();
+ if (showDate)
+ {
+ TZoffset = zone->calc_TZ_offset(zone->zone(), true);
+ updateDateLabel();
+ }
+
+ updateFollowBackground();
+ setBackground();
+
+ // FIXME: this means you can't have a transparent clock but a non-transparent
+ // date or day =/
+
+ _clock->widget()->installEventFilter(this); // catch mouse clicks
+ _clock->widget()->show();
+
+ _clock->forceUpdate(); /* force repaint */
+
+ if (showDayOfWeek)
+ {
+ _dayOfWeek->show();
+ }
+ else
+ {
+ _dayOfWeek->hide();
+ }
+
+ if (showDate || (zone->zoneIndex() != 0))
+ {
+ _date->show();
+ }
+ else
+ {
+ _date->hide();
+ }
+
+ emit(updateLayout());
+
+ showZone(zone->zoneIndex());
+}
+
+void ClockApplet::setTimerTo60()
+{
+// kdDebug() << "setTimerTo60" << endl;
+ disconnect(_timer, SIGNAL(timeout()), this, SLOT(setTimerTo60()));
+ _timer->changeInterval(60000);
+}
+
+void ClockApplet::setBackground()
+{
+ QColor globalBgroundColor = KApplication::palette().active().background();
+ QColor fgColor, bgColor;
+
+ if (!_clock)
+ return;
+
+ switch (_prefs->type())
+ {
+ case Prefs::EnumType::Plain:
+ bgColor = _prefs->plainBackgroundColor();
+ fgColor = _prefs->plainForegroundColor();
+ break;
+ case Prefs::EnumType::Analog:
+ bgColor = _prefs->analogBackgroundColor();
+ fgColor = _prefs->analogForegroundColor();
+ break;
+ case Prefs::EnumType::Fuzzy:
+ bgColor = _prefs->fuzzyBackgroundColor();
+ fgColor = _prefs->fuzzyForegroundColor();
+ break;
+ case Prefs::EnumType::Digital:
+ default:
+ bgColor = _prefs->digitalBackgroundColor();
+ fgColor = _prefs->digitalForegroundColor();
+ break;
+ }
+
+ if (!m_followBackgroundSetting)
+ _clock->widget()->setPaletteBackgroundColor(bgColor);
+ else
+ _clock->widget()->unsetPalette();
+ _clock->widget()->setPaletteForegroundColor(fgColor);
+
+ bgColor = _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->setFont(_prefs->dateFont());
+
+ if (!m_dateFollowBackgroundSetting)
+ _dayOfWeek->setBackgroundColor(bgColor);
+ else
+ _dayOfWeek->unsetPalette();
+ _dayOfWeek->setPaletteForegroundColor(_prefs->dateForegroundColor());
+ }
+
+ // See if the clock wants to show the date.
+ showDate = _clock->showDate();
+ _date->setFont(_prefs->dateFont());
+
+ if (!m_dateFollowBackgroundSetting)
+ _date->setPaletteBackgroundColor(bgColor);
+ else
+ _date->unsetPalette();
+ _date->setPaletteForegroundColor(_prefs->dateForegroundColor());
+}
+
+void ClockApplet::globalPaletteChange()
+{
+ if (!m_dateFollowBackgroundSetting && !m_followBackgroundSetting)
+ return;
+
+ QColor globalBgroundColor = KApplication::palette().active().background();
+
+ if (m_dateFollowBackgroundSetting)
+ _prefs->setDateBackgroundColor(globalBgroundColor);
+
+ if (m_followBackgroundSetting)
+ {
+ // we need to makes sure we have the background color synced!
+ // otherwise when we switch color schemes again or restart kicker
+ // it might come back non-transparent
+ switch (_prefs->type())
+ {
+ case Prefs::EnumType::Plain:
+ _prefs->setPlainBackgroundColor(globalBgroundColor);
+ break;
+ case Prefs::EnumType::Analog:
+ _prefs->setAnalogBackgroundColor(globalBgroundColor);
+ break;
+ case Prefs::EnumType::Fuzzy:
+ _prefs->setFuzzyBackgroundColor(globalBgroundColor);
+ break;
+ case Prefs::EnumType::Digital:
+ default:
+ _prefs->setDigitalBackgroundColor(globalBgroundColor);
+ break;
+ }
+ }
+
+ _prefs->writeConfig();
+}
+
+void ClockApplet::slotUpdate()
+{
+ if (_lastDate != clockGetDate())
+ {
+ updateDateLabel();
+ }
+
+ if (m_updateOnTheMinute)
+ {
+ // catch drift so we're never more than a few s out
+ int seconds = clockGetTime().second();
+// kdDebug() << "checking for drift: " << seconds << endl;
+
+ if (seconds > 2)
+ {
+ connect(_timer, SIGNAL(timeout()), this, SLOT(setTimerTo60()));
+ _timer->changeInterval(((60 - seconds) * 1000) + 500);
+ }
+ }
+ _clock->updateClock();
+ KickerTip::Client::updateKickerTip();
+}
+
+void ClockApplet::slotCalendarDeleted()
+{
+ _calendar = 0L;
+ // don't reopen the calendar immediately ...
+ _disableCalendar = true;
+ QTimer::singleShot(100, this, SLOT(slotEnableCalendar()));
+
+ // we are free to show a tip know :)
+ installEventFilter(KickerTip::the());
+}
+
+
+void ClockApplet::slotEnableCalendar()
+{
+ _disableCalendar = false;
+}
+
+void ClockApplet::toggleCalendar()
+{
+ if (_calendar && !_disableCalendar)
+ {
+ // calls slotCalendarDeleted which does the cleanup for us
+ _calendar->close();
+ return;
+ }
+
+ if (_calendar || _disableCalendar)
+ {
+ return;
+ }
+
+ KickerTip::the()->untipFor(this);
+ removeEventFilter(KickerTip::the());
+
+ _calendar = new DatePicker(this, _lastDate, _prefs);
+ connect(_calendar, SIGNAL(destroyed()), SLOT(slotCalendarDeleted()));
+
+ QSize size = _prefs->calendarSize();
+
+ if (size != QSize())
+ {
+ _calendar->resize(size);
+ }
+ else
+ {
+ _calendar->adjustSize();
+ }
+
+ // make calendar fully visible
+ QPoint popupAt = KickerLib::popupPosition(popupDirection(),
+ _calendar,
+ this);
+ _calendar->move(popupAt);
+ _calendar->show();
+ _calendar->setFocus();
+}
+
+
+void ClockApplet::openContextMenu()
+{
+ if (!menu || !kapp->authorizeKAction("kicker_rmb"))
+ return;
+
+ menu->exec( QCursor::pos() );
+}
+
+void ClockApplet::contextMenuActivated(int result)
+{
+ if ((result >= 0) && (result < 100))
+ {
+ _prefs->setType(result);
+ _prefs->writeConfig();
+ reconfigure();
+ return;
+ };
+
+ if ((result >= 500) && (result < 600))
+ {
+ showZone(result-500);
+ zone->writeSettings();
+ return;
+ };
+
+ KProcess proc;
+ switch (result)
+ {
+ case 102:
+ preferences();
+ break;
+ case 103:
+ proc << locate("exe", "kdesu");
+ proc << "--nonewdcop";
+ proc << QString("%1 kde-clock.desktop --lang %2")
+ .arg(locate("exe", "kcmshell"))
+ .arg(KGlobal::locale()->language());
+ proc.start(KProcess::DontCare);
+ break;
+ case 104:
+ proc << locate("exe", "kcmshell");
+ proc << "kde-language.desktop";
+ proc.start(KProcess::DontCare);
+ break;
+ case 110:
+ preferences(true);
+ break;
+ } /* switch() */
+}
+
+void ClockApplet::aboutToShowContextMenu()
+{
+ bool bImmutable = config()->isImmutable();
+
+ menu->clear();
+ menu->insertTitle( SmallIcon( "clock" ), i18n( "Clock" ) );
+
+ KLocale *loc = KGlobal::locale();
+ QDateTime dt = QDateTime::currentDateTime();
+ dt = dt.addSecs(TZoffset);
+
+ KPopupMenu *copyMenu = new KPopupMenu( menu );
+ copyMenu->insertItem(loc->formatDateTime(dt), 201);
+ copyMenu->insertItem(loc->formatDate(dt.date()), 202);
+ copyMenu->insertItem(loc->formatDate(dt.date(), true), 203);
+ copyMenu->insertItem(loc->formatTime(dt.time()), 204);
+ copyMenu->insertItem(loc->formatTime(dt.time(), true), 205);
+ copyMenu->insertItem(dt.date().toString(), 206);
+ copyMenu->insertItem(dt.time().toString(), 207);
+ copyMenu->insertItem(dt.toString(), 208);
+ copyMenu->insertItem(dt.toString("yyyy-MM-dd hh:mm:ss"), 209);
+ connect( copyMenu, SIGNAL( activated(int) ), this, SLOT( slotCopyMenuActivated(int) ) );
+
+ if (!bImmutable)
+ {
+ KPopupMenu *zoneMenu = new KPopupMenu( menu );
+ connect(zoneMenu, SIGNAL(activated(int)), SLOT(contextMenuActivated(int)));
+ for (int i = 0; i <= zone->remoteZoneCount(); i++)
+ {
+ if (i == 0)
+ {
+ zoneMenu->insertItem(i18n("Local Timezone"), 500 + i);
+ }
+ else
+ {
+ zoneMenu->insertItem(i18n(zone->zone(i).utf8()).replace("_", " "), 500 + i);
+ }
+ }
+ zoneMenu->setItemChecked(500 + zone->zoneIndex(),true);
+ zoneMenu->insertSeparator();
+ zoneMenu->insertItem(SmallIcon("configure"), i18n("&Configure Timezones..."), 110);
+
+ KPopupMenu *type_menu = new KPopupMenu(menu);
+ connect(type_menu, SIGNAL(activated(int)), SLOT(contextMenuActivated(int)));
+ type_menu->insertItem(i18n("&Plain"), Prefs::EnumType::Plain, 1);
+ type_menu->insertItem(i18n("&Digital"), Prefs::EnumType::Digital, 2);
+ type_menu->insertItem(i18n("&Analog"), Prefs::EnumType::Analog, 3);
+ type_menu->insertItem(i18n("&Fuzzy"), Prefs::EnumType::Fuzzy, 4);
+ type_menu->setItemChecked(_prefs->type(),true);
+
+ menu->insertItem(i18n("&Type"), type_menu, 101, 1);
+ menu->insertItem(i18n("Show Time&zone"), zoneMenu, 110, 2);
+ if (kapp->authorize("user/root"))
+ {
+ menu->insertItem(SmallIcon("date"), i18n("&Adjust Date && Time..."), 103, 4);
+ }
+ menu->insertItem(SmallIcon("kcontrol"), i18n("Date && Time &Format..."), 104, 5);
+ }
+
+ menu->insertItem(SmallIcon("editcopy"), i18n("C&opy to Clipboard"), copyMenu, 105, 6);
+ if (!bImmutable)
+ {
+ menu->insertSeparator(7);
+ menu->insertItem(SmallIcon("configure"), i18n("&Configure Clock..."), 102, 8);
+ }
+}
+
+
+void ClockApplet::slotCopyMenuActivated( int id )
+{
+ QPopupMenu *m = (QPopupMenu *) sender();
+ QString s = m->text(id);
+ QApplication::clipboard()->setText(s);
+}
+
+QTime ClockApplet::clockGetTime()
+{
+ return QTime::currentTime().addSecs(TZoffset);
+}
+
+QDate ClockApplet::clockGetDate()
+{
+ return QDateTime::currentDateTime().addSecs(TZoffset).date();
+}
+
+void ClockApplet::showZone(int z)
+{
+ zone->setZone(z);
+ TZoffset = zone->calc_TZ_offset( zone->zone() );
+ updateDateLabel();
+ _clock->forceUpdate(); /* force repaint */
+}
+
+void ClockApplet::nextZone()
+{
+ zone->nextZone();
+ showZone(zone->zoneIndex());
+}
+
+void ClockApplet::prevZone()
+{
+ zone->prevZone();
+ showZone(zone->zoneIndex());
+}
+
+void ClockApplet::mousePressEvent(QMouseEvent *ev)
+{
+ switch (ev->button())
+ {
+ case QMouseEvent::LeftButton:
+ toggleCalendar();
+ break;
+ case QMouseEvent::RightButton:
+ openContextMenu();
+ break;
+ case QMouseEvent::MidButton:
+ nextZone();
+ QToolTip::remove(_clock->widget());
+ break;
+ default:
+ break;
+ }
+}
+
+void ClockApplet::wheelEvent(QWheelEvent* e)
+{
+ if (e->delta() < 0)
+ {
+ prevZone();
+ }
+ else
+ {
+ nextZone();
+ }
+
+ QToolTip::remove(_clock->widget());
+ KickerTip::Client::updateKickerTip();
+}
+
+// catch the mouse clicks of our child widgets
+bool ClockApplet::eventFilter( QObject *o, QEvent *e )
+{
+ if (( o == _clock->widget() || o == _date || o == _dayOfWeek) &&
+ e->type() == QEvent::MouseButtonPress )
+ {
+ mousePressEvent(static_cast<QMouseEvent*>(e) );
+ return true;
+ }
+
+ return KPanelApplet::eventFilter(o, e);
+}
+
+void ClockApplet::positionChange(Position p)
+{
+ KPanelApplet::positionChange(p);
+ reconfigure();
+}
+
+void ClockApplet::updateDateLabel(bool reLayout)
+{
+ _lastDate = clockGetDate();
+ _dayOfWeek->setText(KGlobal::locale()->calendar()->weekDayName(_lastDate));
+
+ if (zone->zoneIndex() != 0)
+ {
+ QString zone_s = i18n(zone->zone().utf8());
+ _date->setText(zone_s.mid(zone_s.find('/') + 1).replace("_", " "));
+ _date->setShown(true);
+ }
+ else
+ {
+ QString dateStr = KGlobal::locale()->formatDate(_lastDate, true);
+ _date->setText(dateStr);
+ _date->setShown(showDate);
+ }
+
+ if (reLayout)
+ {
+ if (_calendar && _lastDate != _calendar->date())
+ {
+ _calendar->setDate(_lastDate);
+ }
+
+ m_layoutTimer->stop();
+ m_layoutTimer->start(m_layoutDelay, true);
+ }
+}
+
+void ClockApplet::updateKickerTip(KickerTip::Data& data)
+{
+ int zoneCount = zone->remoteZoneCount();
+
+ QString activeZone = zone->zone();
+ if (zoneCount == 0)
+ {
+ QString _time = KGlobal::locale()->formatTime(clockGetTime(),
+ _prefs->plainShowSeconds());
+ QString _date = KGlobal::locale()->formatDate(clockGetDate(), false);
+ data.message = _time;
+ data.subtext = _date;
+
+ if (!activeZone.isEmpty())
+ {
+ activeZone = i18n(activeZone.utf8());
+ data.subtext.append("<br>").append(activeZone.mid(activeZone.find('/') + 1).replace("_", " "));
+ }
+ }
+ else
+ {
+ int activeIndex = zone->zoneIndex();
+
+ for (int i = 0; i <= zone->remoteZoneCount(); i++)
+ {
+ QString m_zone = zone->zone(i);
+ TZoffset = zone->calc_TZ_offset(m_zone);
+
+ if (!m_zone.isEmpty())
+ {
+ m_zone = i18n(m_zone.utf8()); // ensure it gets translated
+ }
+
+ QString _time = KGlobal::locale()->formatTime(clockGetTime(),
+ _prefs->plainShowSeconds());
+ QString _date = KGlobal::locale()->formatDate(clockGetDate(), false);
+
+ if (activeIndex == i)
+ {
+ data.message = m_zone.mid(m_zone.find('/') + 1).replace("_", " ");
+ data.message += " " + _time + "<br>" + _date;
+ }
+ else
+ {
+ if (i == 0)
+ {
+ data.subtext += "<b>" + i18n("Local Timezone") + "</b>";
+ }
+ else
+ {
+ data.subtext += "<b>" + m_zone.mid(m_zone.find('/') + 1).replace("_", " ") + "</b>";
+ }
+ data.subtext += " " + _time + ", " + _date + "<br>";
+ }
+ }
+
+ TZoffset = zone->calc_TZ_offset(activeZone);
+ }
+
+ data.icon = DesktopIcon("date", KIcon::SizeMedium);
+ data.direction = popupDirection();
+ data.duration = 4000;
+}
+
+void ClockApplet::fixupLayout()
+{
+ m_layoutDelay = 0;
+
+ // ensure we have the right widget line up in horizontal mode
+ // when we are showing date beside the clock
+ // this fixes problems triggered by having the date first
+ // because of the date format (e.g. YY/MM/DD) and then hiding
+ // the date
+ if (orientation() == Qt::Horizontal && height() < 32)
+ {
+ bool mustShowDate = showDate || (zone->zoneIndex() != 0);
+
+ if (!mustShowDate && !showDayOfWeek)
+ {
+ _clock->widget()->move(0,0);
+ }
+
+ int dayWidth = 0;
+ if (!showDayOfWeek)
+ {
+ _dayOfWeek->move(_clock->widget()->width() + 4, 0);
+ }
+ else
+ {
+ dayWidth = _dayOfWeek->width();
+ }
+
+ if (!showDate)
+ {
+ _date->move(_clock->widget()->width() + dayWidth + 4, 0);
+ }
+ }
+
+ emit updateLayout();
+}
+
+int ClockApplet::type()
+{
+ return _prefs->type();
+}
+
+ClockAppletToolTip::ClockAppletToolTip( ClockApplet* clock )
+ : QToolTip( clock ),
+ m_clock( clock )
+{
+}
+
+void ClockAppletToolTip::maybeTip( const QPoint & /*point*/ )
+{
+ QString tipText;
+ if ( (m_clock->type() == Prefs::EnumType::Fuzzy) ||
+ (m_clock->type() == Prefs::EnumType::Analog) )
+ {
+ // show full time (incl. hour) as tooltip for Fuzzy clock
+ tipText = KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(m_clock->TZoffset));
+ }
+ else
+ {
+ tipText = KGlobal::locale()->formatDate(m_clock->clockGetDate());
+ }
+
+ if (m_clock->timezones() && m_clock->timezones()->zoneIndex() > 0)
+ {
+ tipText += "\n" + i18n("Showing time for %1").arg(i18n(m_clock->timezones()->zone().utf8()), false);
+ }
+
+ tip(m_clock->geometry(), tipText);
+}
+
+//************************************************************
+
+#include "clock.moc"
diff --git a/kicker/applets/clock/clock.h b/kicker/applets/clock/clock.h
new file mode 100644
index 000000000..efa67be46
--- /dev/null
+++ b/kicker/applets/clock/clock.h
@@ -0,0 +1,348 @@
+/*****************************************************************
+
+Copyright (c) 1996-2000 the kicker authors. See file AUTHORS.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+******************************************************************/
+
+#ifndef __CLOCK_H
+#define __CLOCK_H
+
+#include <qlcdnumber.h>
+#include <qlabel.h>
+#include <qtoolbutton.h>
+#include <qguardedptr.h>
+#include <qdatetime.h>
+#include <qvbox.h>
+#include <qstringlist.h>
+#include <qtooltip.h>
+#include <qevent.h>
+
+#include <dcopobject.h>
+#include <kpanelapplet.h>
+#include <kdirwatch.h>
+#include <kconfigdialog.h>
+
+#include <kickertip.h>
+#include "settings.h"
+#include "kshadowengine.h"
+
+class QTimer;
+class QBoxLayout;
+class DatePicker;
+class QPixmap;
+class Zone;
+class KPopupMenu;
+class Prefs;
+class ClockApplet;
+
+namespace KIO
+{
+ class Job;
+}
+
+class DigitalWidget;
+class AnalogWidget;
+class FuzzyWidget;
+class ClockApplet;
+class KConfigDialogManager;
+class SettingsWidgetImp;
+
+class SettingsWidgetImp : public SettingsWidget
+{
+ Q_OBJECT
+
+ public:
+ SettingsWidgetImp(Prefs *p=0,
+ Zone *z=0,
+ QWidget* parent=0,
+ const char* name=0,
+ WFlags fl=0);
+ public slots:
+ void OkApply();
+
+ private:
+ Prefs *prefs;
+ Zone *zone;
+};
+
+class KConfigDialogSingle : public KConfigDialog
+{
+ Q_OBJECT
+
+ public:
+ KConfigDialogSingle(Zone *zone,
+ QWidget *parent=0,
+ const char *name=0,
+ Prefs *prefs=0,
+ KDialogBase::DialogType dialogType = KDialogBase::IconList,
+ bool modal=false);
+
+ SettingsWidgetImp* settings;
+
+ void updateSettings();
+ void updateWidgets();
+ void updateWidgetsDefault();
+
+ protected slots:
+ void selectPage(int p);
+ void dateToggled();
+
+ private:
+ DigitalWidget *digitalPage;
+ AnalogWidget *analogPage;
+ FuzzyWidget *fuzzyPage;
+ Prefs *_prefs;
+};
+
+/**
+ * Base class for all clock types
+ */
+class ClockWidget
+{
+ public:
+ ClockWidget(ClockApplet *applet, Prefs *prefs);
+ virtual ~ClockWidget();
+
+ virtual QWidget* widget()=0;
+ virtual int preferedWidthForHeight(int h) const =0;
+ virtual int preferedHeightForWidth(int w) const =0;
+ virtual void updateClock()=0;
+ virtual void forceUpdate() { _force = true; updateClock(); }
+ virtual void loadSettings()=0;
+ virtual bool showDate()=0;
+ virtual bool showDayOfWeek()=0;
+
+ protected:
+ ClockApplet *_applet;
+ Prefs *_prefs;
+ QTime _time;
+ bool _force;
+};
+
+
+class PlainClock : public QLabel, public ClockWidget
+{
+ Q_OBJECT
+
+ public:
+ PlainClock(ClockApplet *applet, Prefs *prefs, QWidget *parent=0, const char *name=0);
+
+ QWidget* widget() { return this; }
+ int preferedWidthForHeight(int h) const;
+ int preferedHeightForWidth(int w) const;
+ void updateClock();
+ void loadSettings();
+ bool showDate();
+ bool showDayOfWeek();
+
+ protected:
+ void paintEvent(QPaintEvent *e);
+ void drawContents(QPainter *p);
+
+ QString _timeStr;
+};
+
+
+class DigitalClock : public QLCDNumber, public ClockWidget
+{
+ Q_OBJECT
+
+ public:
+ DigitalClock(ClockApplet *applet, Prefs *prefs, QWidget *parent=0, const char *name=0);
+ ~DigitalClock();
+
+ QWidget* widget() { return this; }
+ int preferedWidthForHeight(int h) const;
+ int preferedHeightForWidth(int w) const;
+ void updateClock();
+ void loadSettings();
+ bool showDate();
+ bool showDayOfWeek();
+
+ protected:
+ void paintEvent( QPaintEvent*);
+ void drawContents( QPainter * p);
+ void resizeEvent ( QResizeEvent *ev);
+
+ QPixmap *_buffer;
+ QString _timeStr;
+ QPixmap lcdPattern;
+};
+
+
+class AnalogClock : public QFrame, public ClockWidget
+{
+ Q_OBJECT
+
+ public:
+ AnalogClock(ClockApplet *applet, Prefs *prefs, QWidget *parent=0, const char *name=0);
+ ~AnalogClock();
+
+ QWidget* widget() { return this; }
+ int preferedWidthForHeight(int h) const { return h; }
+ int preferedHeightForWidth(int w) const { return w; }
+ void updateClock();
+ void loadSettings();
+ bool showDate();
+ bool showDayOfWeek();
+
+ protected:
+ virtual void paintEvent(QPaintEvent *);
+ void styleChange(QStyle&);
+ void initBackgroundPixmap();
+
+ QPixmap *_spPx;
+ QPixmap lcdPattern;
+ int _bgScale;
+};
+
+
+class FuzzyClock : public QFrame, public ClockWidget
+{
+ Q_OBJECT
+
+ public:
+ FuzzyClock(ClockApplet *applet, Prefs* prefs, QWidget *parent=0, const char *name=0);
+
+ QWidget* widget() { return this; }
+ int preferedWidthForHeight(int h) const;
+ int preferedHeightForWidth(int w) const;
+ void updateClock();
+ void loadSettings();
+ bool showDate();
+ bool showDayOfWeek();
+
+ public slots:
+ void deleteMyself();
+
+ protected:
+ virtual void drawContents(QPainter *p);
+
+ QStringList hourNames;
+ QStringList normalFuzzy;
+ QStringList normalFuzzyOne;
+ QStringList dayTime;
+
+ QString _timeStr;
+
+ private:
+ bool alreadyDrawing;
+};
+
+class ClockAppletToolTip : public QToolTip
+{
+ public:
+ ClockAppletToolTip( ClockApplet* clock );
+
+ protected:
+ virtual void maybeTip( const QPoint & );
+
+ private:
+ ClockApplet *m_clock;
+};
+
+class ClockApplet : public KPanelApplet, public KickerTip::Client, public DCOPObject
+{
+ Q_OBJECT
+ K_DCOP
+
+ friend class ClockAppletToolTip;
+
+ public:
+ ClockApplet(const QString& configFile, Type t = Normal, int actions = 0,
+ QWidget *parent = 0, const char *name = 0);
+ ~ClockApplet();
+
+ int widthForHeight(int h) const;
+ int heightForWidth(int w) const;
+ void preferences();
+ void preferences(bool timezone);
+ int type();
+ Orientation getOrientation() { return orientation(); }
+ void resizeRequest() { emit(updateLayout()); }
+ const Zone* timezones() { return zone; }
+
+ QTime clockGetTime();
+ QDate clockGetDate();
+
+ virtual void updateKickerTip(KickerTip::Data&);
+
+ KTextShadowEngine *shadowEngine();
+
+ k_dcop:
+ void reconfigure();
+
+ protected slots:
+ void slotReconfigure() { reconfigure(); }
+ void slotUpdate();
+ void slotCalendarDeleted();
+ void slotEnableCalendar();
+ void slotCopyMenuActivated( int id );
+ void contextMenuActivated(int result);
+ void aboutToShowContextMenu();
+ void fixupLayout();
+ void globalPaletteChange();
+ void setTimerTo60();
+
+ protected:
+ void toggleCalendar();
+ void openContextMenu();
+ void updateDateLabel(bool reLayout = true);
+ void showZone(int z);
+ void nextZone();
+ void prevZone();
+ void updateFollowBackground();
+
+ void paletteChange(const QPalette &) { setBackground(); }
+ void setBackground();
+ void mousePressEvent(QMouseEvent *ev);
+ void wheelEvent(QWheelEvent* e);
+ bool eventFilter(QObject *, QEvent *);
+
+ virtual void positionChange(Position p);
+
+ QCString configFileName;
+ DatePicker *_calendar;
+ bool _disableCalendar;
+ ClockWidget *_clock;
+ QLabel *_date;
+ QLabel *_dayOfWeek;
+ QDate _lastDate;
+ QTimer *_timer;
+ QTimer *m_layoutTimer;
+ int m_layoutDelay;
+ bool m_followBackgroundSetting;
+ bool m_dateFollowBackgroundSetting;
+ int TZoffset;
+
+ // settings
+ Prefs *_prefs;
+ Zone *zone;
+ bool showDate;
+ bool showDayOfWeek;
+ bool m_updateOnTheMinute;
+ QStringList _remotezonelist;
+ KPopupMenu* menu;
+ ClockAppletToolTip m_tooltip;
+ KTextShadowEngine *m_shadowEngine;
+};
+
+
+#endif
diff --git a/kicker/applets/clock/clockapplet.desktop b/kicker/applets/clock/clockapplet.desktop
new file mode 100644
index 000000000..6dda8818a
--- /dev/null
+++ b/kicker/applets/clock/clockapplet.desktop
@@ -0,0 +1,151 @@
+[Desktop Entry]
+Type=Plugin
+Icon=clock
+Name=Clock
+Name[af]=Horlosie
+Name[ar]=الساعة
+Name[az]=Saat
+Name[be]=Гадзіннік
+Name[bg]=Часовник
+Name[bn]=ঘড়ি
+Name[br]=Eurier
+Name[bs]=Sat
+Name[ca]=Rellotge
+Name[cs]=Hodiny
+Name[csb]=Zédżer
+Name[cy]=Cloc
+Name[da]=Ur
+Name[de]=Uhr
+Name[el]=Ρολόι
+Name[eo]=Horloĝo
+Name[es]=Reloj
+Name[et]=Kell
+Name[eu]=Erlojua
+Name[fa]=ساعت
+Name[fi]=Kello
+Name[fr]=Horloge
+Name[fy]=Klok
+Name[ga]=Clog
+Name[gl]=Reloxo
+Name[he]=שעון
+Name[hi]=घड़ी
+Name[hr]=Sat
+Name[hu]=Óra
+Name[id]=Jam
+Name[is]=Klukka
+Name[it]=Orologio
+Name[ja]=時計
+Name[ka]=საათი
+Name[kk]=Сағат
+Name[km]=នាឡិកា
+Name[ko]=시계
+Name[lo]=ໂມງ
+Name[lt]=Laikrodis
+Name[lv]=Pulkstenis
+Name[mk]=Часовник
+Name[mn]=Цаг
+Name[ms]=Jam
+Name[mt]=Arloġġ
+Name[nb]=Klokke
+Name[nds]=Klock
+Name[ne]=घडी
+Name[nl]=Klok
+Name[nn]=Klokke
+Name[nso]=Sesupanako
+Name[oc]=Rellotge
+Name[pa]=ਘੜੀ
+Name[pl]=Zegar
+Name[pt]=Relógio
+Name[pt_BR]=Relógio
+Name[ro]=Ceas
+Name[ru]=Часы
+Name[rw]=Isaha
+Name[se]=Diibmu
+Name[sk]=Hodiny
+Name[sl]=Ura
+Name[sr]=Часовник
+Name[sr@Latn]=Časovnik
+Name[ss]=Liwashi
+Name[sv]=Klocka
+Name[ta]=கடிகாரம்
+Name[te]=గడియారం
+Name[tg]=Соат
+Name[th]=นาฬิกา
+Name[tr]=Saat
+Name[tt]=Säğät
+Name[uk]=Годинник
+Name[uz]=Soat
+Name[uz@cyrillic]=Соат
+Name[ven]=Tshifhinga
+Name[vi]=Đồng hồ
+Name[wa]=Ôrlodje
+Name[xh]=Ikloko
+Name[zh_CN]=时钟
+Name[zh_TW]=時鐘
+Name[zu]=Iwashi
+
+Comment=An analog and digital clock
+Comment[af]='n Analoog en digitale horlosie
+Comment[ar]= ساعة رقمية و عادية
+Comment[be]=Аналагавы і лічбавы гадзіннік
+Comment[bg]=Системен аплет за показване на датата и часа
+Comment[bn]=একটি অ্যানালগ এবং ডিজিটাল ঘড়ি
+Comment[bs]=Analogni i digitalni sat
+Comment[ca]=Un rellotge digital i analògic
+Comment[cs]=Applet s analogovými a digitálními hodinami
+Comment[csb]=Analogòwi ë cyfrowi zédżer
+Comment[da]=Et analogt og digitalt ur
+Comment[de]=Eine analoge und digitale Uhr
+Comment[el]=Ένα αναλογικό και ψηφιακό ρολόι
+Comment[en_GB]=An analogue and digital clock
+Comment[eo]=Analoga kaj cifereca horloĝo
+Comment[es]=Reloj analógico/digital
+Comment[et]=Analoog- ja digitaalkell
+Comment[eu]=Erloju analogiko eta digitala
+Comment[fa]=ساعت قیاسی و رقمی
+Comment[fi]=Analoginen ja digitaalinen kello
+Comment[fr]=Une horloge numérique et analogique
+Comment[fy]=In analoge en digitale klok
+Comment[ga]=Clog analógach agus digiteach
+Comment[gl]=Unha applet cun reloxo analóxico e dixital.
+Comment[he]=שעון אנלוגי ודיגיטלי
+Comment[hr]=Analogni i digitalni sat
+Comment[hu]=Egy analóg/digitális óra kisalkalmazásként
+Comment[is]=Forrit sem birtir stafræna klukku eða skífuklukku
+Comment[it]=Un orologio digitale o analogico
+Comment[ja]=アナログ時計とデジタル時計
+Comment[ka]=ანალოგური და ციფრული საათი
+Comment[kk]=Тілді немесе цифрлық сағат
+Comment[km]=នាឡិកា​អាណាឡូក និង​ឌីជីថល
+Comment[lt]=Analoginis ir skaitmeninis laikrodis
+Comment[mk]=Аналоген и дигитален часовник
+Comment[nb]=En analog og digital klokke for panelet.
+Comment[nds]=En analoog oder digitaal Klock
+Comment[ne]=एनालग र डिजिटल घडी
+Comment[nl]=Een analoge en digitale klok
+Comment[nn]=Ei analog og digital klokke
+Comment[pa]=ਇੱਕ ਐਨਾਲਾਗ ਤੇ ਡਿਜ਼ੀਟਲ ਘੜੀ ਹੈ।
+Comment[pl]=Zegar analogowy i cyfrowy
+Comment[pt]=Um relógio analógico e digital
+Comment[pt_BR]=Um relógio analógico e digital
+Comment[ro]=Un ceas analogic și digital
+Comment[ru]=Аплет аналоговых и цифровых часов
+Comment[se]=Analogálaš ja digitalálaš diibmo
+Comment[sk]=Analógové a digitálne hodiny.
+Comment[sl]=Analogna in digitalna ura
+Comment[sr]=Аналогни и дигитални часовник
+Comment[sr@Latn]=Analogni i digitalni časovnik
+Comment[sv]=En analog och digital klocka
+Comment[te]=ఎనాలాగ్ మరయూ డిజిటల్ గడియారం
+Comment[th]=นาฬิกาแบบเข็มและแบบตัวเลข
+Comment[tr]=Bir sayısal ve analog saat programcığı
+Comment[uk]=Аналоговий або цифровий годинник
+Comment[uz]=Analog va raqamli soat
+Comment[uz@cyrillic]=Аналог ва рақамли соат
+Comment[vi]=Đồng hồ thường và đồng hồ điện tử
+Comment[wa]=Ene analodjike ou didjitåle ôrlodje.
+Comment[zh_CN]=模拟和数字时钟面板小程序
+Comment[zh_TW]=一個小的類比或數字時鐘
+
+X-KDE-Library=clock_panelapplet
+X-KDE-UniqueApplet=false
diff --git a/kicker/applets/clock/clockapplet.kcfg b/kicker/applets/clock/clockapplet.kcfg
new file mode 100644
index 000000000..9b1ab3031
--- /dev/null
+++ b/kicker/applets/clock/clockapplet.kcfg
@@ -0,0 +1,191 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+ <include>kapplication.h</include>
+ <kcfgfile arg="true"/>
+ <group name="General">
+ <entry name="Type" type="Enum">
+ <label>Clock type</label>
+ <choices>
+ <choice name="Plain"/>
+ <choice name="Digital"/>
+ <choice name="Analog"/>
+ <choice name="Fuzzy"/>
+ </choices>
+ <default>Digital</default>
+ </entry>
+ </group>
+ <group name="Date">
+ <entry name="DateForegroundColor" type="Color" key="Foreground_Color">
+ <label>Foreground color.</label>
+ <default code="true">KApplication::palette().active().text()</default>
+ </entry>
+ <entry name="DateBackgroundColor" type="Color" key="Background_Color">
+ <label>Foreground color.</label>
+ <default code="true">KApplication::palette().active().background()</default>
+ </entry>
+ <entry name="DateFont" type="Font" key="Font">
+ <label>Font for the clock.</label>
+ <code>
+QFont defFont=KGlobalSettings::generalFont();
+defFont.setPointSize(8);
+ </code>
+ <default code="true">defFont</default>
+ </entry>
+ </group>
+ <group name="Plain">
+ <entry name="PlainShowSeconds" type="Bool" key="Show_Seconds">
+ <label>Show seconds.</label>
+ <default>false</default>
+ </entry>
+ <entry name="PlainShowDate" type="Bool" key="Show_Date">
+ <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>
+ </entry>
+ <entry name="PlainFont" type="Font" key="Font">
+ <label>Font for the clock.</label>
+ <code>
+defFont=KGlobalSettings::generalFont();
+defFont.setPointSize(8);
+defFont.setBold(true);
+ </code>
+ <default code="true">defFont</default>
+ </entry>
+ <entry name="PlainForegroundColor" type="Color" key="Foreground_Color">
+ <label>Foreground color.</label>
+ <default code="true">KApplication::palette().active().text()</default>
+ </entry>
+ <entry name="PlainBackgroundColor" type="Color" key="Background_Color">
+ <label>Background color.</label>
+ <default code="true">KApplication::palette().active().background()</default>
+ </entry>
+ </group>
+ <group name="Digital">
+ <entry name="DigitalShowSeconds" type="Bool" key="Show_Seconds">
+ <label>Show seconds.</label>
+ <default>false</default>
+ </entry>
+ <entry name="DigitalShowDate" type="Bool" key="Show_Date">
+ <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>
+ </entry>
+ <entry name="DigitalForegroundColor" type="Color" key="Foreground_Color">
+ <label>Foreground color.</label>
+ <default code="true">KApplication::palette().active().text()</default>
+ </entry>
+ <entry name="DigitalBackgroundColor" type="Color" key="Background_Color">
+ <label>Background color.</label>
+ <default code="true">KApplication::palette().active().background()</default>
+ </entry>
+ <entry name="DigitalShadowColor" type="Color" key="Shadow_Color">
+ <label>Shadow color.</label>
+ <default code="true">KApplication::palette().active().mid()</default>
+ </entry>
+ <entry name="DigitalBlink" type="Bool" key="Blink">
+ <label>Blink</label>
+ <default>false</default>
+ </entry>
+ <entry name="DigitalLCDStyle" type="Bool" key="LCD_Style">
+ <label>LCD Style</label>
+ <default>false</default>
+ </entry>
+ </group>
+ <group name="Analog">
+ <entry name="AnalogShowSeconds" type="Bool" key="Show_Seconds">
+ <label>Show seconds.</label>
+ <default>true</default>
+ </entry>
+ <entry name="AnalogShowDate" type="Bool" key="Show_Date">
+ <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>
+ </entry>
+ <entry name="AnalogForegroundColor" type="Color" key="Foreground_Color">
+ <label>Foreground color.</label>
+ <default code="true">KApplication::palette().active().text()</default>
+ </entry>
+ <entry name="AnalogBackgroundColor" type="Color" key="Background_Color">
+ <label>Background color.</label>
+ <default code="true">KApplication::palette().active().background()</default>
+ </entry>
+ <entry name="AnalogShadowColor" type="Color" key="Shadow_Color">
+ <label>Shadow color.</label>
+ <default code="true">KApplication::palette().active().mid()</default>
+ </entry>
+ <entry name="AnalogLCDStyle" type="Bool" key="LCD_Style">
+ <label>LCD Style</label>
+ <default>true</default>
+ </entry>
+ <entry name="AnalogAntialias" type="Int" key="Antialias">
+ <label>Anti-Alias factor</label>
+ <default>0</default>
+ </entry>
+ </group>
+ <group name="Fuzzy">
+ <entry name="FuzzyShowDate" type="Bool" key="Show_Date">
+ <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>
+ </entry>
+ <entry name="FuzzyFont" type="Font" key="Font">
+ <label>Font for the clock.</label>
+ <code>
+defFont=KGlobalSettings::generalFont();
+ </code>
+ <default code="true">defFont</default>
+ </entry>
+ <entry name="FuzzyForegroundColor" type="Color" key="Foreground_Color">
+ <label>Foreground color.</label>
+ <default code="true">KApplication::palette().active().text()</default>
+ </entry>
+ <entry name="FuzzyBackgroundColor" type="Color" key="Background_Color">
+ <label>Background color.</label>
+ <default code="true">KApplication::palette().active().background()</default>
+ </entry>
+ <entry name="Fuzzyness" type="Int">
+ <label>Fuzzyness</label>
+ <default>1</default>
+ </entry>
+ </group>
+ <group name="Calendar">
+ <entry name="CalendarFullWindow" type="Bool" key="FullWindow">
+ <label>Show window frame</label>
+ <default>true</default>
+ </entry>
+ <entry name="CalendarSize" type="Size" key="Size">
+ <label>Default size of the calendar</label>
+ </entry>
+ </group>
+</kcfg>
diff --git a/kicker/applets/clock/datepicker.cpp b/kicker/applets/clock/datepicker.cpp
new file mode 100644
index 000000000..0ea677e8a
--- /dev/null
+++ b/kicker/applets/clock/datepicker.cpp
@@ -0,0 +1,87 @@
+/************************************************************
+
+Copyright (c) 1996-2002 the kicker authors. See file AUTHORS.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+******************************************************************/
+
+#include "datepicker.h"
+#include "prefs.h"
+
+#include <kdatepicker.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kwin.h>
+#include <netwm.h>
+
+DatePicker::DatePicker(QWidget *parent, const QDate& date, Prefs* _prefs)
+ : QVBox( parent, 0,
+ _prefs->calendarFullWindow()
+ ? (WType_TopLevel | WDestructiveClose |
+ WStyle_StaysOnTop)
+ : (WStyle_Customize | WStyle_NoBorder |
+ WType_TopLevel | WDestructiveClose |
+ WStyle_StaysOnTop) ),
+ prefs(_prefs)
+{
+ if (prefs->calendarFullWindow())
+ {
+ KWin::setType(winId(), NET::Utility);
+ setFrameStyle(QFrame::NoFrame);
+ }
+ else
+ {
+ setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
+ }
+
+ KWin::setOnAllDesktops(handle(), true);
+ picker = new KDatePicker(this, date);
+ picker->setCloseButton(!_prefs->calendarFullWindow());
+
+ /* name and icon for kicker's taskbar */
+ setCaption(i18n("Calendar"));
+ setIcon(SmallIcon("date"));
+}
+
+void DatePicker::closeEvent(QCloseEvent* e)
+{
+ prefs->setCalendarSize(size());
+ QVBox::closeEvent(e);
+}
+
+void DatePicker::keyPressEvent(QKeyEvent *e)
+{
+ QVBox::keyPressEvent(e);
+
+ if (e->key() == Qt::Key_Escape)
+ {
+ close();
+ }
+}
+
+bool DatePicker::setDate(const QDate& date)
+{
+ return picker->setDate(date);
+}
+
+QDate DatePicker::date()
+{
+ return picker->date();
+}
+
diff --git a/kicker/applets/clock/datepicker.h b/kicker/applets/clock/datepicker.h
new file mode 100644
index 000000000..ee39261e0
--- /dev/null
+++ b/kicker/applets/clock/datepicker.h
@@ -0,0 +1,49 @@
+/*****************************************************************
+
+Copyright (c) 1996-2000 the kicker authors. See file AUTHORS.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+******************************************************************/
+
+#ifndef __DATEPICKER_H
+#define __DATEPICKER_H
+
+#include <qvbox.h>
+#include <qdatetime.h>
+
+class KDatePicker;
+class Prefs;
+
+class DatePicker : public QVBox
+{
+ public:
+ DatePicker(QWidget*, const QDate&, Prefs* _prefs);
+ bool setDate(const QDate& date);
+ QDate date();
+
+ protected:
+ void closeEvent(QCloseEvent* e);
+ void keyPressEvent(QKeyEvent *e);
+
+ private:
+ KDatePicker *picker;
+ Prefs *prefs;
+};
+
+#endif
diff --git a/kicker/applets/clock/digital.ui b/kicker/applets/clock/digital.ui
new file mode 100644
index 000000000..256bca99b
--- /dev/null
+++ b/kicker/applets/clock/digital.ui
@@ -0,0 +1,305 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>DigitalWidget</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>DigitalWidget</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>553</width>
+ <height>251</height>
+ </rect>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QButtonGroup">
+ <property name="name">
+ <cstring>ButtonGroup2_3</cstring>
+ </property>
+ <property name="title">
+ <string>Display</string>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>kcfg_DigitalShowDate</cstring>
+ </property>
+ <property name="text">
+ <string>Dat&amp;e</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>kcfg_DigitalShowSeconds</cstring>
+ </property>
+ <property name="text">
+ <string>Seco&amp;nds</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>kcfg_DigitalShowDayOfWeek</cstring>
+ </property>
+ <property name="text">
+ <string>Da&amp;y of week</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>kcfg_DigitalBlink</cstring>
+ </property>
+ <property name="text">
+ <string>Blin&amp;king dots</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>kcfg_DigitalShowFrame</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Frame</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer21</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox1</cstring>
+ </property>
+ <property name="title">
+ <string>Time</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>kcfg_DigitalLCDStyle</cstring>
+ </property>
+ <property name="text">
+ <string>LCD look</string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout14</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>Foreground_ColorL</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Foreground color:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>kcfg_DigitalForegroundColor</cstring>
+ </property>
+ </widget>
+ <widget class="KColorButton" row="2" column="1">
+ <property name="name">
+ <cstring>kcfg_DigitalBackgroundColor</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>backgroundDigitalLabel</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Background color:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>kcfg_DigitalBackgroundColor</cstring>
+ </property>
+ </widget>
+ <widget class="KColorButton" row="0" column="1">
+ <property name="name">
+ <cstring>kcfg_DigitalForegroundColor</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="KColorButton" row="1" column="1">
+ <property name="name">
+ <cstring>kcfg_DigitalShadowColor</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <spacer row="1" column="2">
+ <property name="name">
+ <cstring>spacer9</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>110</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>Shadow_ColorL</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Shadow color:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>kcfg_DigitalShadowColor</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer75</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ </vbox>
+</widget>
+<customwidgets>
+</customwidgets>
+<connections>
+ <connection>
+ <sender>kcfg_DigitalLCDStyle</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>kcfg_DigitalBackgroundColor</receiver>
+ <slot>setDisabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>kcfg_DigitalLCDStyle</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>backgroundDigitalLabel</receiver>
+ <slot>setDisabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>kcfg_DigitalLCDStyle</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>kcfg_DigitalForegroundColor</receiver>
+ <slot>setDisabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>kcfg_DigitalLCDStyle</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>Foreground_ColorL</receiver>
+ <slot>setDisabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>kcfg_DigitalLCDStyle</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>kcfg_DigitalShadowColor</receiver>
+ <slot>setDisabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>kcfg_DigitalLCDStyle</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>Shadow_ColorL</receiver>
+ <slot>setDisabled(bool)</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>kcfg_DigitalShowDate</tabstop>
+ <tabstop>kcfg_DigitalShowSeconds</tabstop>
+ <tabstop>kcfg_DigitalBlink</tabstop>
+ <tabstop>kcfg_DigitalShowFrame</tabstop>
+ <tabstop>kcfg_DigitalLCDStyle</tabstop>
+ <tabstop>kcfg_DigitalForegroundColor</tabstop>
+ <tabstop>kcfg_DigitalShadowColor</tabstop>
+ <tabstop>kcfg_DigitalBackgroundColor</tabstop>
+</tabstops>
+<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>
+ <includehint>kcolorbutton.h</includehint>
+ <includehint>kcolorbutton.h</includehint>
+ <includehint>kcolorbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/kicker/applets/clock/fuzzy.ui b/kicker/applets/clock/fuzzy.ui
new file mode 100644
index 000000000..04e910340
--- /dev/null
+++ b/kicker/applets/clock/fuzzy.ui
@@ -0,0 +1,287 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>FuzzyWidget</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>FuzzyWidget</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>306</width>
+ <height>299</height>
+ </rect>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>GroupBox1</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="title">
+ <string>Display</string>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>kcfg_FuzzyShowDate</cstring>
+ </property>
+ <property name="text">
+ <string>Dat&amp;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>Da&amp;y of week</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>kcfg_FuzzyShowFrame</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Frame</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer13</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox2</cstring>
+ </property>
+ <property name="title">
+ <string>Time</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="3" column="2">
+ <property name="name">
+ <cstring>spacer46</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>30</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Font:</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="1" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>layout11</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>TextLabel1_2_3_4_3</cstring>
+ </property>
+ <property name="text">
+ <string>Background color:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>kcfg_FuzzyBackgroundColor</cstring>
+ </property>
+ </widget>
+ <spacer row="1" column="2">
+ <property name="name">
+ <cstring>spacer6</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>51</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>TextLabel1_4_3_2</cstring>
+ </property>
+ <property name="text">
+ <string>Foreground color:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>kcfg_FuzzyForegroundColor</cstring>
+ </property>
+ </widget>
+ <widget class="KColorButton" row="1" column="1">
+ <property name="name">
+ <cstring>kcfg_FuzzyBackgroundColor</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="KColorButton" row="0" column="1">
+ <property name="name">
+ <cstring>kcfg_FuzzyForegroundColor</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QLayoutWidget" row="0" column="2">
+ <property name="name">
+ <cstring>Layout7_3</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>TextLabel4_3</cstring>
+ </property>
+ <property name="text">
+ <string>Low</string>
+ </property>
+ </widget>
+ <widget class="QSlider">
+ <property name="name">
+ <cstring>kcfg_Fuzzyness</cstring>
+ </property>
+ <property name="minValue">
+ <number>1</number>
+ </property>
+ <property name="maxValue">
+ <number>4</number>
+ </property>
+ <property name="pageStep">
+ <number>1</number>
+ </property>
+ <property name="value">
+ <number>1</number>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="tickmarks">
+ <enum>Both</enum>
+ </property>
+ <property name="tickInterval">
+ <number>1</number>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>TextLabel5_3</cstring>
+ </property>
+ <property name="text">
+ <string>High</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>TextLabel3_3</cstring>
+ </property>
+ <property name="text">
+ <string>Fuzziness:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>kcfg_Fuzzyness</cstring>
+ </property>
+ </widget>
+ <widget class="KFontRequester" row="2" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>kcfg_FuzzyFont</cstring>
+ </property>
+ <property name="title">
+ <string>Date Font</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </vbox>
+</widget>
+<customwidgets>
+</customwidgets>
+<tabstops>
+ <tabstop>kcfg_FuzzyShowDate</tabstop>
+ <tabstop>kcfg_FuzzyShowFrame</tabstop>
+ <tabstop>kcfg_Fuzzyness</tabstop>
+ <tabstop>kcfg_FuzzyForegroundColor</tabstop>
+ <tabstop>kcfg_FuzzyBackgroundColor</tabstop>
+</tabstops>
+<includes>
+ <include location="local" impldecl="in implementation">kdialog.h</include>
+ <include location="local" impldecl="in implementation">kfontrequester.h</include>
+</includes>
+<layoutdefaults spacing="3" margin="6"/>
+<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
+<includehints>
+ <includehint>kcolorbutton.h</includehint>
+ <includehint>kcolorbutton.h</includehint>
+ <includehint>kfontrequester.h</includehint>
+</includehints>
+</UI>
diff --git a/kicker/applets/clock/lcd.png b/kicker/applets/clock/lcd.png
new file mode 100644
index 000000000..32e5e90d8
--- /dev/null
+++ b/kicker/applets/clock/lcd.png
Binary files differ
diff --git a/kicker/applets/clock/prefs.kcfgc b/kicker/applets/clock/prefs.kcfgc
new file mode 100644
index 000000000..890209526
--- /dev/null
+++ b/kicker/applets/clock/prefs.kcfgc
@@ -0,0 +1,6 @@
+# Code generation options for kconfig_compiler
+File=clockapplet.kcfg
+ClassName=Prefs
+Singleton=false
+Mutators=Type,CalendarSize,CalendarFullWindow,DateBackgroundColor,PlainBackgroundColor,AnalogBackgroundColor,FuzzyBackgroundColor,DigitalBackgroundColor
+# MemberVariables=public
diff --git a/kicker/applets/clock/settings.ui b/kicker/applets/clock/settings.ui
new file mode 100644
index 000000000..215aa5433
--- /dev/null
+++ b/kicker/applets/clock/settings.ui
@@ -0,0 +1,515 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SettingsWidget</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>SettingsWidget</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>605</width>
+ <height>639</height>
+ </rect>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QTabWidget">
+ <property name="name">
+ <cstring>tabs</cstring>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>&amp;Appearance</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout14</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <property name="text">
+ <string>Clock type:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>clockCombo</cstring>
+ </property>
+ </widget>
+ <widget class="QComboBox">
+ <item>
+ <property name="text">
+ <string>Plain Clock</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Digital Clock</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Analog Clock</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Fuzzy Clock</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>kcfg_Type</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QWidgetStack">
+ <property name="name">
+ <cstring>widgetStack</cstring>
+ </property>
+ <property name="lineWidth">
+ <number>0</number>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>page</cstring>
+ </property>
+ <attribute name="id">
+ <number>0</number>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QButtonGroup">
+ <property name="name">
+ <cstring>ButtonGroup2_3_2_2</cstring>
+ </property>
+ <property name="title">
+ <string>Display</string>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>kcfg_PlainShowDate</cstring>
+ </property>
+ <property name="text">
+ <string>Dat&amp;e</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>kcfg_PlainShowSeconds</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Seconds</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>kcfg_PlainShowDayOfWeek</cstring>
+ </property>
+ <property name="text">
+ <string>Da&amp;y of week</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>kcfg_PlainShowFrame</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Frame</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer14</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox2</cstring>
+ </property>
+ <property name="title">
+ <string>Time</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>TextLabel1_3_3_2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Font:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>TextLabel1_2_3_4_3_2</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Background color:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>kcfg_PlainBackgroundColor</cstring>
+ </property>
+ </widget>
+ <widget class="KColorButton" row="1" column="2">
+ <property name="name">
+ <cstring>kcfg_PlainBackgroundColor</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="KColorButton" row="0" column="2">
+ <property name="name">
+ <cstring>kcfg_PlainForegroundColor</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>TextLabel1_4_3_2_2</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Foreground color:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>kcfg_PlainForegroundColor</cstring>
+ </property>
+ </widget>
+ <spacer row="0" column="3">
+ <property name="name">
+ <cstring>spacer17</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>230</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KFontRequester" row="2" column="1" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>kcfg_PlainFont</cstring>
+ </property>
+ </widget>
+ <spacer row="3" column="3">
+ <property name="name">
+ <cstring>spacer6</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ </vbox>
+ </widget>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>dateBox</cstring>
+ </property>
+ <property name="title">
+ <string>Date</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KColorButton" row="1" column="1">
+ <property name="name">
+ <cstring>kcfg_DateBackgroundColor</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_3</cstring>
+ </property>
+ <property name="text">
+ <string>Foreground color:</string>
+ </property>
+ </widget>
+ <widget class="KColorButton" row="0" column="1">
+ <property name="name">
+ <cstring>kcfg_DateForegroundColor</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Background color:</string>
+ </property>
+ </widget>
+ <spacer row="0" column="2">
+ <property name="name">
+ <cstring>spacer15</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>343</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLayoutWidget" row="2" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel4</cstring>
+ </property>
+ <property name="text">
+ <string>Font:</string>
+ </property>
+ </widget>
+ <widget class="KFontRequester">
+ <property name="name">
+ <cstring>kcfg_DateFont</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer6_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>100</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>&amp;Timezones</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KListView">
+ <column>
+ <property name="text">
+ <string>City</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Comment</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>tzListView</cstring>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string></string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>A list of timezones known to your system. Press the middle mouse button on the clock in the taskbar and it shows you the time in the selected cities.</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </widget>
+ </vbox>
+</widget>
+<customwidgets>
+</customwidgets>
+<tabstops>
+ <tabstop>tabs</tabstop>
+ <tabstop>kcfg_Type</tabstop>
+ <tabstop>kcfg_PlainShowDate</tabstop>
+ <tabstop>kcfg_PlainShowSeconds</tabstop>
+ <tabstop>kcfg_PlainShowFrame</tabstop>
+ <tabstop>kcfg_PlainForegroundColor</tabstop>
+ <tabstop>kcfg_PlainBackgroundColor</tabstop>
+ <tabstop>kcfg_DateBackgroundColor</tabstop>
+ <tabstop>kcfg_DateForegroundColor</tabstop>
+ <tabstop>kcfg_DateFont</tabstop>
+ <tabstop>tzListView</tabstop>
+</tabstops>
+<includes>
+ <include location="local" impldecl="in implementation">kdialog.h</include>
+ <include location="local" impldecl="in implementation">kfontrequester.h</include>
+</includes>
+<slots>
+ <slot>configureType()</slot>
+</slots>
+<layoutdefaults spacing="3" margin="6"/>
+<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
+<includehints>
+ <includehint>kcolorbutton.h</includehint>
+ <includehint>kcolorbutton.h</includehint>
+ <includehint>kfontrequester.h</includehint>
+ <includehint>kcolorbutton.h</includehint>
+ <includehint>kcolorbutton.h</includehint>
+ <includehint>kfontrequester.h</includehint>
+ <includehint>klistview.h</includehint>
+</includehints>
+</UI>
diff --git a/kicker/applets/clock/zone.cpp b/kicker/applets/clock/zone.cpp
new file mode 100644
index 000000000..1d952a765
--- /dev/null
+++ b/kicker/applets/clock/zone.cpp
@@ -0,0 +1,180 @@
+/************************************************************
+
+Copyright (c) 1996-2002 the kicker authors. See file AUTHORS.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+******************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "zone.h"
+
+#include <kcolorbutton.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kstandarddirs.h>
+#include <kstringhandler.h>
+#include <klocale.h>
+
+#include <qfile.h>
+#include <qtooltip.h>
+#include <klistview.h>
+
+#include <time.h>
+#include <stdlib.h> // for getenv()
+
+Zone::Zone(KConfig* conf):
+ config(conf),
+ _zoneIndex(0)
+{
+ _defaultTZ = ::getenv("TZ");
+ tzset();
+
+ config->setGroup("General");
+
+ /* default displayable timezones */
+ QString tzList = config->readEntry("RemoteZones");
+ _remotezonelist = QStringList::split(",", tzList);
+ setZone(config->readNumEntry("Initial_TZ", 0));
+}
+
+Zone::~Zone()
+{
+ writeSettings();
+}
+
+void Zone::setZone(int z)
+{
+ if (_zoneIndex > _remotezonelist.count())
+ z = 0;
+
+ _zoneIndex = z;
+}
+
+QString Zone::zone(int z) const
+{
+ return (z == 0 ? _defaultTZ : _remotezonelist[z-1]);
+}
+
+int Zone::calc_TZ_offset(const QString& zone, bool /* reset */)
+{
+ const KTimezone *z = zone.isEmpty() ? m_zoneDb.local() : m_zoneDb.zone(zone);
+
+ if (!z)
+ {
+ z = m_zoneDb.local();
+ }
+
+ if (z)
+ {
+ return -z->offset(Qt::LocalTime);
+ }
+
+ return 0;
+}
+
+void Zone::readZoneList(KListView *listView )
+{
+ const KTimezones::ZoneMap zones = m_zoneDb.allZones();
+ QMap<QString, QListViewItem*> KontinentMap;
+
+ listView->setRootIsDecorated(true);
+ for (KTimezones::ZoneMap::ConstIterator it = zones.begin(); it != zones.end(); ++it)
+ {
+ const KTimezone *zone = it.data();
+ QString tzName = zone->name();
+ QString comment = zone->comment();
+ if (!comment.isEmpty())
+ comment = i18n(comment.utf8());
+
+ const QStringList KontCity = QStringList::split("/", i18n(tzName.utf8()).replace("_", " "));
+ QListViewItem* Kontinent = KontinentMap[KontCity[0]];
+ if (!Kontinent) {
+ KontinentMap[KontCity[0]] = new QListViewItem(listView, KontCity[0]);
+ Kontinent = KontinentMap[KontCity[0]];
+ Kontinent->setExpandable(true);
+ }
+
+ QCheckListItem *li = new QCheckListItem(Kontinent, KontCity[1], QCheckListItem::CheckBox);
+ li->setText(1, comment);
+ li->setText(2, tzName); /* store complete path in ListView */
+
+ if (_remotezonelist.findIndex(tzName) != -1)
+ li->setOn(true);
+
+ // locate the flag from /l10n/%1/flag.png
+ // if not available select default "C" flag
+ QString flag = locate( "locale", QString("l10n/%1/flag.png").arg(zone->countryCode().lower()) );
+ if (!QFile::exists(flag))
+ flag = locate( "locale", "l10n/C/flag.png" );
+ if (QFile::exists(flag))
+ li->setPixmap(0, QPixmap(flag));
+ }
+}
+
+void Zone::getSelectedZonelist(KListView *listView)
+{
+ _remotezonelist.clear();
+
+ /* loop through all entries */
+ QListViewItem *root = listView->firstChild();
+ while (root) {
+ if (root->firstChild()) {
+ root = root->firstChild();
+ continue;
+ }
+
+ QCheckListItem *cl = (QCheckListItem*) root;
+ if (cl->isOn()) {
+ _remotezonelist.append(cl->text(2));
+ }
+
+ if (root->nextSibling()) {
+ root = root->nextSibling();
+ continue;
+ }
+ root = root->parent();
+ if (root)
+ root = root->nextSibling();
+ }
+}
+
+void Zone::nextZone()
+{
+ if (++_zoneIndex > _remotezonelist.count())
+ _zoneIndex = 0;
+}
+
+void Zone::prevZone()
+{
+ if (_zoneIndex == 0)
+ _zoneIndex = _remotezonelist.count();
+ else
+ --_zoneIndex;
+}
+
+void Zone::writeSettings()
+{
+ config->setGroup("General");
+ config->writeEntry("RemoteZones", _remotezonelist.join(","));
+ config->writeEntry("Initial_TZ",_zoneIndex);
+ config->sync();
+}
diff --git a/kicker/applets/clock/zone.h b/kicker/applets/clock/zone.h
new file mode 100644
index 000000000..34371c6ae
--- /dev/null
+++ b/kicker/applets/clock/zone.h
@@ -0,0 +1,62 @@
+/*****************************************************************
+
+Copyright (c) 1996-2000 the kicker authors. See file AUTHORS.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+******************************************************************/
+
+#ifndef __ZONE_H
+#define __ZONE_H
+
+#include <ktimezones.h>
+#include <qstringlist.h>
+
+class KConfig;
+class KListView;
+
+class Zone {
+
+public:
+ Zone(KConfig* conf);
+ ~Zone();
+
+ void writeSettings();
+
+ QString zone() const { return zone(_zoneIndex); };
+ QString zone(int z) const;
+ QStringList remoteZoneList() const { return _remotezonelist; };
+ int remoteZoneCount() { return _remotezonelist.count(); };
+ unsigned int zoneIndex() const { return _zoneIndex; }
+ void setZone(int z = 0);
+
+ void nextZone();
+ void prevZone();
+ int calc_TZ_offset(const QString& zone, bool reset=false);
+ void readZoneList(KListView *listView);
+ void getSelectedZonelist(KListView *listView);
+
+protected:
+ KTimezones m_zoneDb;
+ QStringList _remotezonelist;
+ KConfig *config;
+ QString _defaultTZ;
+ unsigned int _zoneIndex;
+};
+
+#endif