add more spacing
[personal-kdebase.git] / workspace / plasma / applets / analog-clock / clock.h
blob308793447c70b1feb006d9382666b0456700b849
1 /***************************************************************************
2 * Copyright 2007 by Aaron Seigo <aseigo@kde.org> *
3 * Copyright 2007 by Riccardo Iaconelli <riccardo@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 <QImage>
25 #include <QPaintDevice>
26 #include <QLabel>
27 #include <QPixmap>
28 #include <QTimer>
29 #include <QPaintEvent>
30 #include <QPainter>
31 #include <QTime>
32 #include <QGraphicsItem>
33 #include <QColor>
35 #include <Plasma/Containment>
36 #include <Plasma/DataEngine>
38 #include <plasmaclock/clockapplet.h>
39 #include "ui_clockConfig.h"
41 class QTimer;
43 namespace Plasma
45 class Svg;
46 class Dialog;
49 class Clock : public ClockApplet
51 Q_OBJECT
52 public:
53 Clock(QObject *parent, const QVariantList &args);
54 ~Clock();
56 void init();
57 void constraintsEvent(Plasma::Constraints constraints);
58 QPainterPath shape() const;
59 void paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option, const QRect &contentsRect);
61 public slots:
62 void dataUpdated(const QString &name, const Plasma::DataEngine::Data &data);
64 protected:
65 void createClockConfigurationInterface(KConfigDialog *parent);
66 void changeEngineTimezone(const QString &oldTimezone, const QString &newTimezone);
68 protected slots:
69 void clockConfigAccepted();
70 void repaintNeeded();
71 void moveSecondHand();
73 private:
74 void connectToEngine();
75 void drawHand(QPainter *p, const QRect &rect, const qreal verticalTranslation, const qreal rotation, const QString &handName);
77 bool m_showSecondHand;
78 bool m_fancyHands;
79 bool m_showTimezoneString;
80 Plasma::Svg* m_theme;
81 QTime m_time;
82 QTime m_lastTimeSeen;
83 enum RepaintCache {
84 RepaintNone,
85 RepaintAll,
86 RepaintHands
88 RepaintCache m_repaintCache;
89 QPixmap m_faceCache;
90 QPixmap m_handsCache;
91 QPixmap m_glassCache;
92 qreal m_verticalTranslation;
93 QTimer *m_secondHandUpdateTimer;
94 int m_animationStart;
95 /// Designer Config file
96 Ui::clockConfig ui;
99 K_EXPORT_PLASMA_APPLET(clock, Clock)
101 #endif