blob: b16945d6662ac8dc7865d66648f5a5c205190456 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
// $Id$
//
// kclock - Clock screen saver for KDE
// Copyright (c) 2003 Melchior FRANZ
//
// License: GPL v2
// Author: Melchior FRANZ <mfranz@kde.org>
// Dependencies: libart_lgpl_2 http://www.levien.com/libart/
//
#ifndef __KCLOCK_H__
#define __KCLOCK_H__
#include <qtimer.h>
#include <kdialogbase.h>
#include <kscreensaver.h>
class KClockPainter
{
int m_width;
int m_height;
Q_UINT8 *m_buf;
double m_matrix[6];
Q_UINT32 m_color;
Q_UINT32 m_shadow;
public:
KClockPainter(int width, int height);
~KClockPainter();
void copy(KClockPainter *p);
void drawToImage(QImage *q, int x, int y);
inline int width() { return m_width; }
inline int height() { return m_height; }
inline void *image() { return (void *)m_buf; }
void setColor(const QColor &color);
void setShadowColor(const QColor &color);
void fill(const QColor &color);
void drawRadial(double alpha, double r0, double r1, double width);
void drawDisc(double radius);
void drawHand(const QColor &color, double angle, double length,
double width, bool disc);
};
class KClockSaver : public KScreenSaver
{
Q_OBJECT
public:
KClockSaver(WId id);
virtual ~KClockSaver();
inline void setBgndColor(const QColor &c) { m_bgndColor = c; drawScale(); setBackgroundColor(c); };
inline void setScaleColor(const QColor &c) { m_scaleColor = c; drawScale(); };
inline void setHourColor(const QColor &c) { m_hourColor = c; forceRedraw(); };
inline void setMinColor(const QColor &c) { m_minColor = c; forceRedraw(); };
inline void setSecColor(const QColor &c) { m_secColor = c; forceRedraw(); };
void setKeepCentered(bool b);
void restart(int siz);
inline void forceRedraw() { m_second = -1; }
private:
void readSettings();
void drawScale();
void drawClock();
void start(int size);
void stop();
protected slots:
void slotTimeout();
protected:
QTimer m_timer;
QImage *m_image;
KClockPainter *m_scale;
KClockPainter *m_clock;
int m_x;
int m_y;
int m_diameter;
int m_size;
bool m_showSecond;
bool m_keepCentered;
int m_hour;
int m_minute;
int m_second;
QColor m_bgndColor;
QColor m_scaleColor;
QColor m_hourColor;
QColor m_minColor;
QColor m_secColor;
};
class KClockSetup : public KDialogBase
{
Q_OBJECT
public:
KClockSetup(QWidget *parent = 0, const char *name = 0);
~KClockSetup();
protected:
void readSettings();
private slots:
void slotOk();
void slotHelp();
void slotBgndColor(const QColor &);
void slotScaleColor(const QColor &);
void slotHourColor(const QColor &);
void slotMinColor(const QColor &);
void slotSecColor(const QColor &);
void slotSliderMoved(int);
void slotKeepCenteredChanged(int);
private:
KClockSaver *m_saver;
QColor m_bgndColor;
QColor m_scaleColor;
QColor m_hourColor;
QColor m_minColor;
QColor m_secColor;
int m_size;
bool m_keepCentered;
};
#endif
|