Back to index

kdeartwork  4.3.2
Public Member Functions | Private Slots | Private Member Functions | Private Attributes
KClockSaver Class Reference

#include <kclock.h>

List of all members.

Public Member Functions

 KClockSaver (WId id)
void setBgndColor (const QColor &c)
void setScaleColor (const QColor &c)
void setHourColor (const QColor &c)
void setMinColor (const QColor &c)
void setSecColor (const QColor &c)
void setKeepCentered (bool b)
void resizeClock (int size)
void paintEvent (QPaintEvent *)
void resizeEvent (QResizeEvent *)
void showEvent (QShowEvent *)
void hideEvent (QHideEvent *)

Private Slots

void slotTimeout ()

Private Member Functions

void readSettings ()

Private Attributes

QTimer _timer
QColor _bgndColor
QColor _scaleColor
QColor _hourColor
QColor _minColor
QColor _secColor
bool _keepCentered
int _size
int _x
int _y
int _xstep
int _ystep
int _diameter
int _hour
int _minute
int _second

Detailed Description

Definition at line 77 of file kclock.h.


Constructor & Destructor Documentation

Definition at line 376 of file kclock.cpp.

                               :
       KScreenSaver(id),
       _timer(this),
       _xstep(1),
       _ystep(-1),
       _hour(-1),
       _minute(-1),
       _second(-1)
{
       setAttribute(Qt::WA_NoSystemBackground);
       setMinimumSize(50, 50);
       readSettings();
       resizeClock(_size);

       QPalette p = palette();
       p.setColor(backgroundRole(), _bgndColor);
       setPalette(p);

       connect(&_timer, SIGNAL(timeout()), this, SLOT(slotTimeout()));
       show();
}

Here is the call graph for this function:


Member Function Documentation

void KClockSaver::hideEvent ( QHideEvent *  )

Definition at line 456 of file kclock.cpp.

{
       _timer.stop();
}
void KClockSaver::paintEvent ( QPaintEvent *  )

Definition at line 491 of file kclock.cpp.

{
       double hour_angle = _hour * 30.0 + _minute * .5 + _second / 120.0;
       double minute_angle = _minute * 6.0 + _second * .1;
       double second_angle = _second * 6.0;

       QImage clock(_diameter, _diameter, QImage::Format_RGB32);
       ClockPainter c(&clock, _diameter);
       c.fillRect(-1000, -1000, 2000, 2000, _bgndColor);

       if (_scaleColor != _bgndColor)
              c.drawScale(_scaleColor);
       if (_hourColor != _bgndColor)
              c.drawHand(hour_angle, 600.0, 55.0, _hourColor, false);
       if (_minColor != _bgndColor)
              c.drawHand(minute_angle, 900.0, 40.0, _minColor);
       if (_secColor != _bgndColor)
              c.drawHand(second_angle, 900.0, 30.0, _secColor);

       QPainter p(this);
       p.drawImage(_x, _y, clock);
       p.eraseRect(0, 0, _x, height());                                        // left ver
       p.eraseRect(_x + _diameter, 0, width(), height());                      // right ver
       p.eraseRect(_x, 0, _diameter, _y);                                      // top hor
       p.eraseRect(_x, _y + _diameter, _diameter, height() - _y - _diameter);  // bottom hor
}

Here is the call graph for this function:

void KClockSaver::readSettings ( ) [private]

Definition at line 399 of file kclock.cpp.

{
       KConfigGroup settings(KGlobal::config(), "Settings");
       _keepCentered = settings.readEntry("KeepCentered", DEFAULT_KEEP_CENTERED);
       _size = settings.readEntry("Size", DEFAULT_CLOCK_SIZE);
       if (_size > MAX_CLOCK_SIZE)
              _size = MAX_CLOCK_SIZE;

       KConfigGroup colors(KGlobal::config(), "Colors");
       QColor c = Qt::black;
       setBgndColor(colors.readEntry("Background", c));

       c = Qt::white;
       setScaleColor(colors.readEntry("Scale", c));
       setHourColor(colors.readEntry("HourHand", c));
       setMinColor(colors.readEntry("MinuteHand", c));

       c = Qt::red;
       setSecColor(colors.readEntry("SecondHand", c));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KClockSaver::resizeClock ( int  size)

Definition at line 432 of file kclock.cpp.

{
       _size = size;
       _diameter = qMin(width(), height()) * (_size + 4) / 14;
       _x = (width() - _diameter) / 2;
       _y = (height() - _diameter) / 2;
       update();
}

Here is the caller graph for this function:

void KClockSaver::resizeEvent ( QResizeEvent *  )

Definition at line 442 of file kclock.cpp.

Here is the call graph for this function:

void KClockSaver::setBgndColor ( const QColor &  c) [inline]

Definition at line 81 of file kclock.h.

{ _second = -1; setPalette(QPalette(_bgndColor = c)); }

Here is the call graph for this function:

Here is the caller graph for this function:

void KClockSaver::setHourColor ( const QColor &  c) [inline]

Definition at line 83 of file kclock.h.

{ _second = -1; _hourColor = c; }

Here is the caller graph for this function:

void KClockSaver::setKeepCentered ( bool  b)

Definition at line 421 of file kclock.cpp.

{
       _keepCentered = b;
       if (b) {
              _x = (width() - _diameter) / 2;
              _y = (height() - _diameter) / 2;
       }
       update();
}

Here is the caller graph for this function:

void KClockSaver::setMinColor ( const QColor &  c) [inline]

Definition at line 84 of file kclock.h.

{ _second = -1; _minColor = c; }

Here is the caller graph for this function:

void KClockSaver::setScaleColor ( const QColor &  c) [inline]

Definition at line 82 of file kclock.h.

{ _second = -1; _scaleColor = c; }

Here is the caller graph for this function:

void KClockSaver::setSecColor ( const QColor &  c) [inline]

Definition at line 85 of file kclock.h.

{ _second = -1; _secColor = c; }

Here is the caller graph for this function:

void KClockSaver::showEvent ( QShowEvent *  )

Definition at line 448 of file kclock.cpp.

Here is the call graph for this function:

void KClockSaver::slotTimeout ( ) [private, slot]

Definition at line 462 of file kclock.cpp.

{
       QTime t = QTime::currentTime();
       int s = t.second();
       if (s == _second)
              return;

       _second = _secColor != _bgndColor ? s : 0;
       _hour = t.hour();
       _minute = t.minute();

       if (!_keepCentered) {
              int i;
              _x += _xstep;
              if (_x <= 0)
                     _x = 0, _xstep = 1;
              else if (_x >= (i = width() - _diameter))
                     _x = i, _xstep = -1;

              _y += _ystep;
              if (_y <= 0)
                     _y = 0, _ystep = 1;
              else if (_y >= (i = height() - _diameter))
                     _y = i, _ystep = -1;
       }
       update();
}

Here is the caller graph for this function:


Member Data Documentation

QColor KClockSaver::_bgndColor [private]

Definition at line 100 of file kclock.h.

int KClockSaver::_diameter [private]

Definition at line 112 of file kclock.h.

int KClockSaver::_hour [private]

Definition at line 113 of file kclock.h.

QColor KClockSaver::_hourColor [private]

Definition at line 102 of file kclock.h.

Definition at line 105 of file kclock.h.

QColor KClockSaver::_minColor [private]

Definition at line 103 of file kclock.h.

int KClockSaver::_minute [private]

Definition at line 114 of file kclock.h.

QColor KClockSaver::_scaleColor [private]

Definition at line 101 of file kclock.h.

QColor KClockSaver::_secColor [private]

Definition at line 104 of file kclock.h.

int KClockSaver::_second [private]

Definition at line 115 of file kclock.h.

int KClockSaver::_size [private]

Definition at line 106 of file kclock.h.

QTimer KClockSaver::_timer [private]

Definition at line 99 of file kclock.h.

int KClockSaver::_x [private]

Definition at line 108 of file kclock.h.

int KClockSaver::_xstep [private]

Definition at line 110 of file kclock.h.

int KClockSaver::_y [private]

Definition at line 109 of file kclock.h.

int KClockSaver::_ystep [private]

Definition at line 111 of file kclock.h.


The documentation for this class was generated from the following files: