Back to index

kdeartwork  4.3.2
kclock.h
Go to the documentation of this file.
00001 // kclock - Clock screen saver for KDE
00002 //
00003 // Copyright (c) 2003, 2006, 2007, 2008 Melchior FRANZ <mfranz # kde : org>
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 2 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018 
00019 #ifndef KCLOCK_H
00020 #define KCLOCK_H
00021 
00022 #include <QTimer>
00023 #include <QPainter>
00024 
00025 #include <KDialog>
00026 #include <kscreensaver.h>
00027 
00028 
00029 class KClockSaver;
00030 
00031 
00032 class KClockSetup : public KDialog {
00033        Q_OBJECT
00034 public:
00035        KClockSetup(QWidget *parent = 0);
00036        ~KClockSetup();
00037 
00038 private slots:
00039        void slotOk();
00040        void slotHelp();
00041 
00042        void slotBgndColor(const QColor &);
00043        void slotScaleColor(const QColor &);
00044        void slotHourColor(const QColor &);
00045        void slotMinColor(const QColor &);
00046        void slotSecColor(const QColor &);
00047        void slotSliderMoved(int);
00048        void slotKeepCenteredChanged(int);
00049 
00050 private:
00051        void readSettings();
00052        KClockSaver *_saver;
00053 
00054        QColor _bgndColor;
00055        QColor _scaleColor;
00056        QColor _hourColor;
00057        QColor _minColor;
00058        QColor _secColor;
00059 
00060        int _size;
00061        bool _keepCentered;
00062 };
00063 
00064 
00065 
00066 class ClockPainter : public QPainter {
00067 public:
00068        ClockPainter(QPaintDevice *device, int diameter);
00069        void drawTick(double angle, double from, double to, double width, const QColor &, bool shadow = false);
00070        void drawDisc(double width, const QColor &, bool shadow = false);
00071        void drawHand(double angle, double length, double width, const QColor &, bool disc = true);
00072        void drawScale(const QColor &);
00073 };
00074 
00075 
00076 
00077 class KClockSaver : public KScreenSaver {
00078        Q_OBJECT
00079 public:
00080        KClockSaver(WId id);
00081        inline void setBgndColor(const QColor &c) { _second = -1; setPalette(QPalette(_bgndColor = c)); }
00082        inline void setScaleColor(const QColor &c) { _second = -1; _scaleColor = c; }
00083        inline void setHourColor(const QColor &c) { _second = -1; _hourColor = c; }
00084        inline void setMinColor(const QColor &c) { _second = -1; _minColor = c; }
00085        inline void setSecColor(const QColor &c) { _second = -1; _secColor = c; }
00086        void setKeepCentered(bool b);
00087        void resizeClock(int size);
00088        void paintEvent(QPaintEvent *);
00089        void resizeEvent(QResizeEvent *);
00090        void showEvent(QShowEvent *);
00091        void hideEvent(QHideEvent *);
00092 
00093 private slots:
00094        void slotTimeout();
00095 
00096 private:
00097        void readSettings();
00098 
00099        QTimer _timer;
00100        QColor _bgndColor;
00101        QColor _scaleColor;
00102        QColor _hourColor;
00103        QColor _minColor;
00104        QColor _secColor;
00105        bool _keepCentered;
00106        int _size;
00107 
00108        int _x;
00109        int _y;
00110        int _xstep;
00111        int _ystep;
00112        int _diameter;
00113        int _hour;
00114        int _minute;
00115        int _second;
00116 };
00117 
00118 #endif