~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to plasma/generic/applets/analog-clock/clock.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 ***************************************************************************/
 
20
 
 
21
#ifndef CLOCK_H
 
22
#define CLOCK_H
 
23
 
 
24
#include <QPixmap>
 
25
#include <QTimer>
 
26
#include <QPainter>
 
27
#include <QTime>
 
28
#include <QGraphicsItem>
 
29
 
 
30
#include <Plasma/Containment>
 
31
#include <Plasma/DataEngine>
 
32
 
 
33
#include <plasmaclock/clockapplet.h>
 
34
#include "ui_clockConfig.h"
 
35
 
 
36
class QTimer;
 
37
 
 
38
namespace Plasma
 
39
{
 
40
    class FrameSvg;
 
41
    class Svg;
 
42
    class Dialog;
 
43
}
 
44
 
 
45
class Clock : public ClockApplet
 
46
{
 
47
    Q_OBJECT
 
48
    public:
 
49
        Clock(QObject *parent, const QVariantList &args);
 
50
        ~Clock();
 
51
 
 
52
        void init();
 
53
        void constraintsEvent(Plasma::Constraints constraints);
 
54
        QPainterPath shape() const;
 
55
        void paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option, const QRect &contentsRect);
 
56
 
 
57
    public slots:
 
58
        void dataUpdated(const QString &name, const Plasma::DataEngine::Data &data);
 
59
 
 
60
    protected:
 
61
        void createClockConfigurationInterface(KConfigDialog *parent);
 
62
        void changeEngineTimezone(const QString &oldTimezone, const QString &newTimezone);
 
63
 
 
64
    protected slots:
 
65
        void clockConfigAccepted();
 
66
        void clockConfigChanged();
 
67
        void repaintNeeded();
 
68
        void moveSecondHand();
 
69
 
 
70
    private:
 
71
        void connectToEngine();
 
72
        void drawHand(QPainter *p, const QRect &rect, const qreal verticalTranslation, const qreal rotation, const QString &handName);
 
73
        QRect tzRect(const QString &text);
 
74
        Plasma::FrameSvg *tzFrame();
 
75
        void invalidateCache();
 
76
 
 
77
        QString m_oldTimezone;
 
78
        bool m_showSecondHand;
 
79
        bool m_fancyHands;
 
80
        bool m_showTimezoneString;
 
81
        bool m_showingTimezone;
 
82
        Plasma::FrameSvg *m_tzFrame;
 
83
        Plasma::Svg *m_theme;
 
84
        QTime m_time;
 
85
        enum RepaintCache {
 
86
            RepaintNone,
 
87
            RepaintAll,
 
88
            RepaintHands
 
89
        };
 
90
        RepaintCache m_repaintCache;
 
91
        QPixmap m_faceCache;
 
92
        QPixmap m_handsCache;
 
93
        QPixmap m_glassCache;
 
94
        qreal m_verticalTranslation;
 
95
        QTimer *m_secondHandUpdateTimer;
 
96
        bool m_animateSeconds;
 
97
        int m_animationStart;
 
98
        /// Designer Config file
 
99
        Ui::clockConfig ui;
 
100
};
 
101
 
 
102
K_EXPORT_PLASMA_APPLET(clock, Clock)
 
103
 
 
104
#endif