From 4aed2c8219774f5d797760606b8489a92ddc5163 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kicker/applets/clock/Makefile.am | 29 + kicker/applets/clock/analog.ui | 344 ++++++ kicker/applets/clock/clock.cpp | 1871 ++++++++++++++++++++++++++++++ kicker/applets/clock/clock.h | 348 ++++++ kicker/applets/clock/clockapplet.desktop | 151 +++ kicker/applets/clock/clockapplet.kcfg | 191 +++ kicker/applets/clock/datepicker.cpp | 87 ++ kicker/applets/clock/datepicker.h | 49 + kicker/applets/clock/digital.ui | 305 +++++ kicker/applets/clock/fuzzy.ui | 287 +++++ kicker/applets/clock/lcd.png | Bin 0 -> 237 bytes kicker/applets/clock/prefs.kcfgc | 6 + kicker/applets/clock/settings.ui | 515 ++++++++ kicker/applets/clock/zone.cpp | 180 +++ kicker/applets/clock/zone.h | 62 + 15 files changed, 4425 insertions(+) create mode 100644 kicker/applets/clock/Makefile.am create mode 100644 kicker/applets/clock/analog.ui create mode 100644 kicker/applets/clock/clock.cpp create mode 100644 kicker/applets/clock/clock.h create mode 100644 kicker/applets/clock/clockapplet.desktop create mode 100644 kicker/applets/clock/clockapplet.kcfg create mode 100644 kicker/applets/clock/datepicker.cpp create mode 100644 kicker/applets/clock/datepicker.h create mode 100644 kicker/applets/clock/digital.ui create mode 100644 kicker/applets/clock/fuzzy.ui create mode 100644 kicker/applets/clock/lcd.png create mode 100644 kicker/applets/clock/prefs.kcfgc create mode 100644 kicker/applets/clock/settings.ui create mode 100644 kicker/applets/clock/zone.cpp create mode 100644 kicker/applets/clock/zone.h (limited to 'kicker/applets/clock') 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 @@ + +AnalogWidget + + + AnalogWidget + + + + 0 + 0 + 524 + 307 + + + + + unnamed + + + 0 + + + + ButtonGroup2_3_2 + + + Display + + + + unnamed + + + + kcfg_AnalogShowDate + + + Dat&e + + + + + kcfg_AnalogShowSeconds + + + Seco&nds + + + true + + + + + kcfg_AnalogShowDayOfWeek + + + Da&y of week + + + + + kcfg_AnalogShowFrame + + + &Frame + + + + + spacer20 + + + Horizontal + + + Expanding + + + + 40 + 20 + + + + + + + + groupBox1 + + + Time + + + + unnamed + + + + layout9 + + + + unnamed + + + + kcfg_AnalogBackgroundColor + + + false + + + + + + + + kcfg_AnalogShadowColor + + + false + + + + + + + + foregroundAnalogLabel + + + false + + + Foreground color: + + + kcfg_AnalogForegroundColor + + + + + spacer13 + + + Horizontal + + + Expanding + + + + 16 + 20 + + + + + + backgroundAnalogLabel + + + false + + + Background color: + + + kcfg_AnalogBackgroundColor + + + + + kcfg_AnalogForegroundColor + + + false + + + + + + + + shadowAnalogLabel + + + false + + + Shadow color: + + + kcfg_AnalogShadowColor + + + + + + + TextLabel1_3 + + + Antialias: + + + kcfg_AnalogAntialias + + + + + + None + + + + + Low Quality + + + + + High Quality + + + + kcfg_AnalogAntialias + + + 0 + + + + + Spacer18_2 + + + Horizontal + + + Expanding + + + + 310 + 20 + + + + + + kcfg_AnalogLCDStyle + + + &LCD look + + + true + + + + + spacer54 + + + Vertical + + + Expanding + + + + 20 + 50 + + + + + + + + + + + + kcfg_AnalogLCDStyle + toggled(bool) + foregroundAnalogLabel + setDisabled(bool) + + + kcfg_AnalogLCDStyle + toggled(bool) + backgroundAnalogLabel + setDisabled(bool) + + + kcfg_AnalogLCDStyle + toggled(bool) + shadowAnalogLabel + setDisabled(bool) + + + kcfg_AnalogLCDStyle + toggled(bool) + kcfg_AnalogForegroundColor + setDisabled(bool) + + + kcfg_AnalogLCDStyle + toggled(bool) + kcfg_AnalogShadowColor + setDisabled(bool) + + + kcfg_AnalogLCDStyle + toggled(bool) + kcfg_AnalogBackgroundColor + setDisabled(bool) + + + + kcfg_AnalogShowDate + kcfg_AnalogShowSeconds + kcfg_AnalogShowFrame + kcfg_AnalogAntialias + kcfg_AnalogLCDStyle + kcfg_AnalogForegroundColor + kcfg_AnalogShadowColor + kcfg_AnalogBackgroundColor + + + kdialog.h + kfontrequester.h + + + + + kcolorbutton.h + kcolorbutton.h + kcolorbutton.h + + 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 +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include // 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(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(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(_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(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("
").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 + "
" + _date; + } + else + { + if (i == 0) + { + data.subtext += "" + i18n("Local Timezone") + ""; + } + else + { + data.subtext += "" + m_zone.mid(m_zone.find('/') + 1).replace("_", " ") + ""; + } + data.subtext += " " + _time + ", " + _date + "
"; + } + } + + 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 +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#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 @@ + + + kapplication.h + + + + + + + + + + + Digital + + + + + + KApplication::palette().active().text() + + + + KApplication::palette().active().background() + + + + +QFont defFont=KGlobalSettings::generalFont(); +defFont.setPointSize(8); + + defFont + + + + + + false + + + + true + + + + false + + + + false + + + + +defFont=KGlobalSettings::generalFont(); +defFont.setPointSize(8); +defFont.setBold(true); + + defFont + + + + KApplication::palette().active().text() + + + + KApplication::palette().active().background() + + + + + + false + + + + false + + + + false + + + + false + + + + KApplication::palette().active().text() + + + + KApplication::palette().active().background() + + + + KApplication::palette().active().mid() + + + + false + + + + false + + + + + + true + + + + false + + + + false + + + + false + + + + KApplication::palette().active().text() + + + + KApplication::palette().active().background() + + + + KApplication::palette().active().mid() + + + + true + + + + 0 + + + + + + true + + + + false + + + + false + + + + +defFont=KGlobalSettings::generalFont(); + + defFont + + + + KApplication::palette().active().text() + + + + KApplication::palette().active().background() + + + + 1 + + + + + + true + + + + + + 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 +#include +#include +#include +#include + +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 +#include + +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 @@ + +DigitalWidget + + + DigitalWidget + + + + 0 + 0 + 553 + 251 + + + + + unnamed + + + 0 + + + + ButtonGroup2_3 + + + Display + + + + unnamed + + + + kcfg_DigitalShowDate + + + Dat&e + + + true + + + + + kcfg_DigitalShowSeconds + + + Seco&nds + + + + + kcfg_DigitalShowDayOfWeek + + + Da&y of week + + + + + kcfg_DigitalBlink + + + Blin&king dots + + + + + kcfg_DigitalShowFrame + + + &Frame + + + + + spacer21 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + + + groupBox1 + + + Time + + + + unnamed + + + + kcfg_DigitalLCDStyle + + + LCD look + + + false + + + + + layout14 + + + + unnamed + + + + Foreground_ColorL + + + true + + + Foreground color: + + + kcfg_DigitalForegroundColor + + + + + kcfg_DigitalBackgroundColor + + + true + + + + + + + + backgroundDigitalLabel + + + true + + + Background color: + + + kcfg_DigitalBackgroundColor + + + + + kcfg_DigitalForegroundColor + + + true + + + + + + + + kcfg_DigitalShadowColor + + + true + + + + + + + + spacer9 + + + Horizontal + + + Expanding + + + + 110 + 20 + + + + + + Shadow_ColorL + + + true + + + Shadow color: + + + kcfg_DigitalShadowColor + + + + + + + spacer75 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + + + + + + + kcfg_DigitalLCDStyle + toggled(bool) + kcfg_DigitalBackgroundColor + setDisabled(bool) + + + kcfg_DigitalLCDStyle + toggled(bool) + backgroundDigitalLabel + setDisabled(bool) + + + kcfg_DigitalLCDStyle + toggled(bool) + kcfg_DigitalForegroundColor + setDisabled(bool) + + + kcfg_DigitalLCDStyle + toggled(bool) + Foreground_ColorL + setDisabled(bool) + + + kcfg_DigitalLCDStyle + toggled(bool) + kcfg_DigitalShadowColor + setDisabled(bool) + + + kcfg_DigitalLCDStyle + toggled(bool) + Shadow_ColorL + setDisabled(bool) + + + + kcfg_DigitalShowDate + kcfg_DigitalShowSeconds + kcfg_DigitalBlink + kcfg_DigitalShowFrame + kcfg_DigitalLCDStyle + kcfg_DigitalForegroundColor + kcfg_DigitalShadowColor + kcfg_DigitalBackgroundColor + + + kdialog.h + kfontrequester.h + digital.ui.h + + + kcfg_DigitalLCDStyle_stateChanged( int ) + + + + + kcolorbutton.h + kcolorbutton.h + kcolorbutton.h + + 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 @@ + +FuzzyWidget + + + FuzzyWidget + + + + 0 + 0 + 306 + 299 + + + + + unnamed + + + 0 + + + + GroupBox1 + + + GroupBoxPanel + + + Sunken + + + Display + + + + unnamed + + + 11 + + + 6 + + + + kcfg_FuzzyShowDate + + + Dat&e + + + true + + + + + kcfg_FuzzyShowDayOfWeek + + + Da&y of week + + + + + kcfg_FuzzyShowFrame + + + &Frame + + + + + spacer13 + + + Horizontal + + + Expanding + + + + 40 + 20 + + + + + + + + groupBox2 + + + Time + + + + unnamed + + + + spacer46 + + + Vertical + + + Expanding + + + + 20 + 30 + + + + + + textLabel1 + + + Font: + + + + + layout11 + + + + unnamed + + + + TextLabel1_2_3_4_3 + + + Background color: + + + kcfg_FuzzyBackgroundColor + + + + + spacer6 + + + Horizontal + + + Expanding + + + + 51 + 20 + + + + + + TextLabel1_4_3_2 + + + Foreground color: + + + kcfg_FuzzyForegroundColor + + + + + kcfg_FuzzyBackgroundColor + + + + + + + + kcfg_FuzzyForegroundColor + + + + + + + + + + Layout7_3 + + + + unnamed + + + + TextLabel4_3 + + + Low + + + + + kcfg_Fuzzyness + + + 1 + + + 4 + + + 1 + + + 1 + + + Horizontal + + + Both + + + 1 + + + + + TextLabel5_3 + + + High + + + + + + + TextLabel3_3 + + + Fuzziness: + + + kcfg_Fuzzyness + + + + + kcfg_FuzzyFont + + + Date Font + + + + + + + + + + kcfg_FuzzyShowDate + kcfg_FuzzyShowFrame + kcfg_Fuzzyness + kcfg_FuzzyForegroundColor + kcfg_FuzzyBackgroundColor + + + kdialog.h + kfontrequester.h + + + + + kcolorbutton.h + kcolorbutton.h + kfontrequester.h + + diff --git a/kicker/applets/clock/lcd.png b/kicker/applets/clock/lcd.png new file mode 100644 index 000000000..32e5e90d8 Binary files /dev/null and b/kicker/applets/clock/lcd.png 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 @@ + +SettingsWidget + + + SettingsWidget + + + + 0 + 0 + 605 + 639 + + + + + unnamed + + + 0 + + + + tabs + + + + tab + + + &Appearance + + + + unnamed + + + + layout14 + + + + unnamed + + + + TextLabel1 + + + NoFrame + + + Plain + + + Clock type: + + + clockCombo + + + + + + Plain Clock + + + + + Digital Clock + + + + + Analog Clock + + + + + Fuzzy Clock + + + + kcfg_Type + + + + 5 + 0 + 0 + 0 + + + + + + Spacer2 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + + + widgetStack + + + 0 + + + + page + + + 0 + + + + unnamed + + + 0 + + + + ButtonGroup2_3_2_2 + + + Display + + + + unnamed + + + + kcfg_PlainShowDate + + + Dat&e + + + true + + + + + kcfg_PlainShowSeconds + + + &Seconds + + + + + kcfg_PlainShowDayOfWeek + + + Da&y of week + + + + + kcfg_PlainShowFrame + + + &Frame + + + + + spacer14 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + + + groupBox2 + + + Time + + + + unnamed + + + + TextLabel1_3_3_2 + + + + 4 + 1 + 0 + 0 + + + + Font: + + + + + TextLabel1_2_3_4_3_2 + + + true + + + Background color: + + + kcfg_PlainBackgroundColor + + + + + kcfg_PlainBackgroundColor + + + true + + + + + + + + kcfg_PlainForegroundColor + + + true + + + + + + + + TextLabel1_4_3_2_2 + + + true + + + Foreground color: + + + kcfg_PlainForegroundColor + + + + + spacer17 + + + Horizontal + + + Expanding + + + + 230 + 20 + + + + + + kcfg_PlainFont + + + + + spacer6 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + + + + + + dateBox + + + Date + + + + unnamed + + + + kcfg_DateBackgroundColor + + + + + + + + textLabel1_3 + + + Foreground color: + + + + + kcfg_DateForegroundColor + + + + + + + + textLabel2 + + + Background color: + + + + + spacer15 + + + Horizontal + + + Expanding + + + + 343 + 20 + + + + + + layout2 + + + + unnamed + + + + textLabel4 + + + Font: + + + + + kcfg_DateFont + + + + 7 + 5 + 0 + 0 + + + + + + + + + + spacer6_2 + + + Vertical + + + Expanding + + + + 20 + 100 + + + + + + + + tab + + + &Timezones + + + + unnamed + + + + + City + + + true + + + true + + + + + Comment + + + true + + + true + + + + tzListView + + + + + + 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. + + + + + + + + + + + tabs + kcfg_Type + kcfg_PlainShowDate + kcfg_PlainShowSeconds + kcfg_PlainShowFrame + kcfg_PlainForegroundColor + kcfg_PlainBackgroundColor + kcfg_DateBackgroundColor + kcfg_DateForegroundColor + kcfg_DateFont + tzListView + + + kdialog.h + kfontrequester.h + + + configureType() + + + + + kcolorbutton.h + kcolorbutton.h + kfontrequester.h + kcolorbutton.h + kcolorbutton.h + kfontrequester.h + klistview.h + + 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 +#endif + +#include "zone.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include // 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 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 +#include + +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 -- cgit v1.2.1