not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / plasma / applets / digital-clock / clock.h
blob6639c80288d9ee6bde7d69535291062d734c7e6c
1 /***************************************************************************
2 * Copyright (C) 2007-2008 by Riccardo Iaconelli <riccardo@kde.org> *
3 * Copyright (C) 2007-2008 by Sebastian Kuegler <sebas@kde.org> *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
19 ***************************************************************************/
21 #ifndef CLOCK_H
22 #define CLOCK_H
24 #include <QtCore/QTime>
25 #include <QtCore/QDate>
27 #include <Plasma/Applet>
28 #include <Plasma/DataEngine>
29 #include <Plasma/Dialog>
31 #include "ui_clockConfig.h"
32 #include <plasmaclock/clockapplet.h>
34 class Clock : public ClockApplet
36 Q_OBJECT
37 public:
38 Clock(QObject *parent, const QVariantList &args);
39 ~Clock();
41 void init();
42 void paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option, const QRect &contentsRect);
44 public slots:
45 void dataUpdated(const QString &name, const Plasma::DataEngine::Data &data);
46 void updateColors();
48 protected slots:
49 void clockConfigAccepted();
50 void constraintsEvent(Plasma::Constraints constraints);
52 protected:
53 void createClockConfigurationInterface(KConfigDialog *parent);
54 void changeEngineTimezone(const QString &oldTimezone, const QString &newTimezone);
56 private:
57 void updateSize();
58 bool showTimezone() const;
59 QRect preparePainter(QPainter *p, const QRect &rect, const QFont &font, const QString &text, bool singleline = false);
60 QRectF normalLayout (int subtitleWidth, int subtitleHeight, const QRect &contentsRect);
61 QRectF sideBySideLayout (int subtitleWidth, int subtitleHeight, const QRect &contentsRect);
63 QFont m_plainClockFont;
64 bool m_useCustomColor;
65 QColor m_plainClockColor;
66 QRect m_timeRect;
67 QRect m_dateRect;
69 bool m_showDate;
70 bool m_showYear;
71 bool m_showDay;
72 bool m_showSeconds;
73 bool m_showTimezone;
74 bool m_dateTimezoneBesides;
76 int updateInterval() const;
77 Plasma::IntervalAlignment intervalAlignment() const;
79 QTime m_time;
80 QDate m_date;
81 QString m_dateString;
82 QVBoxLayout *m_layout;
83 QTime m_lastTimeSeen;
84 QPixmap m_toolTipIcon;
85 /// Designer Config files
86 Ui::clockConfig ui;
89 K_EXPORT_PLASMA_APPLET(dig_clock, Clock)
91 #endif