Back to index

kdeartwork  4.3.2
Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | Private Member Functions
kLinesSaver Class Reference

#include <lines.h>

Collaboration diagram for kLinesSaver:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 kLinesSaver (WId id)
virtual ~kLinesSaver ()
void setLines (int len)
void setSpeed (int spd)
void setColor (const QColor &, const QColor &, const QColor &)

Protected Slots

void slotTimeout ()

Protected Member Functions

void paintEvent (QPaintEvent *event)

Protected Attributes

KRandomSequence rnd
QTimer timer
unsigned numLines
int speed
QColor colors [64]
QColor colstart
QColor colmid
QColor colend
double colscale
Lineslines

Private Member Functions

void readSettings ()
void initialiseLines ()
void initialiseColor ()

Detailed Description

Definition at line 38 of file lines.h.


Constructor & Destructor Documentation

Definition at line 308 of file lines.cpp.

                                 : KScreenSaver( id ){
       readSettings();
       lines=new Lines(numLines);
       initialiseColor();
       initialiseLines();
       timer.start(speed);
       connect(&timer, SIGNAL(timeout()), SLOT(slotTimeout()));
        {
            QPalette palette;
            palette.setColor( backgroundRole(), Qt::black );
            setPalette( palette );
           setAutoFillBackground(true);
        }
       show();
}

Here is the call graph for this function:

Definition at line 324 of file lines.cpp.

                         {
       timer.stop();
       delete lines;
}

Member Function Documentation

void kLinesSaver::initialiseColor ( ) [private]

Definition at line 431 of file lines.cpp.

                                 {
       int i;
       double mr, mg, mb;
       double cr, cg, cb;
    mr=(double)(colmid.red()-colstart.red())/32;
    mg=(double)(colmid.green()-colstart.green())/32;
    mb=(double)(colmid.blue()-colstart.blue())/32;
    cr=colstart.red();
    cg=colstart.green();
    cb=colstart.blue();
       for(i=0; i<32; i++){
              colors[63-i].setRgb((int)(mr*i+cr), (int)(mg*i+cg), (int)(mb*i+cb));
       }
       mr=(double)(colend.red()-colmid.red())/32;
       mg=(double)(colend.green()-colmid.green())/32;
       mb=(double)(colend.blue()-colmid.blue())/32;
       cr=colmid.red();
       cg=colmid.green();
       cb=colmid.blue();
       for(i=0; i<32; i++){
              colors[31-1].setRgb((int)(mr*i+cr), (int)(mg*i+cg), (int)(mb*i+cb));
       }
       colscale=64.0/(double)numLines;
}

Here is the caller graph for this function:

void kLinesSaver::initialiseLines ( ) [private]

Definition at line 414 of file lines.cpp.

                                 {
       uint i;
       int x1,y1,x2,y2;
       delete lines;
       lines=new Lines(numLines);
       lines->reset();
       x1=rnd.getLong(width());
       y1=rnd.getLong(height());
       x2=rnd.getLong(width());
       y2=rnd.getLong(height());
       for(i=0; i<numLines; i++){
              lines->setKoord(x1,y1,x2,y2);
              lines->next();
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void kLinesSaver::paintEvent ( QPaintEvent *  event) [protected]

Definition at line 389 of file lines.cpp.

{
        setAttribute( Qt::WA_NoSystemBackground ); // Only after initial clear

        uint i;
        int x1,y1,x2,y2;
        int col=0;

        lines->reset();

     QPainter p( this );
    p.setPen( Qt::black );

        for(i=0; i<numLines; i++){
                lines->getKoord(x1,y1,x2,y2);
        p.drawLine( x1, y1, x2, y2 );
                p.setPen( colors[col] );
                col=(int)(i*colscale);
                if(col>63) col=0;
        }
        lines->turn(width(), height());

}

Here is the call graph for this function:

void kLinesSaver::readSettings ( ) [private]

Definition at line 353 of file lines.cpp.

                              {
    KConfigGroup config(KGlobal::config(), "Settings");

    numLines=config.readEntry("Length", 10);
    speed = 100- config.readEntry("Speed", 50);
    if(numLines>MAXLENGTH) numLines=MAXLENGTH;
    else if(numLines<1) numLines = 1;

    colstart=config.readEntry("StartColor", QColor(Qt::white));
    colmid=config.readEntry("MidColor", QColor(Qt::blue));
    colend=config.readEntry("EndColor", QColor(Qt::black));
}

Here is the caller graph for this function:

void kLinesSaver::setColor ( const QColor &  cs,
const QColor &  cm,
const QColor &  ce 
)

Definition at line 345 of file lines.cpp.

                                                                              {
       colstart=cs;
       colmid=cm;
       colend=ce;
        initialiseColor();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void kLinesSaver::setLines ( int  len)

Definition at line 330 of file lines.cpp.

                                 {
       timer.stop();
       numLines=len;
       initialiseLines();
       initialiseColor();
       timer.start(speed);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void kLinesSaver::setSpeed ( int  spd)

Definition at line 339 of file lines.cpp.

                                 {
       timer.stop();
       speed=100-spd;
       timer.start(speed);
}

Here is the caller graph for this function:

void kLinesSaver::slotTimeout ( ) [protected, slot]

Definition at line 367 of file lines.cpp.

                             {
   update();
/*
       uint i;
       int x1,y1,x2,y2;
       int col=0;

       lines->reset();
    QPainter p( this );
    p.setPen( Qt::black );

       for(i=0; i<numLines; i++){
              lines->getKoord(x1,y1,x2,y2);
        p.drawLine( x1, y1, x2, y2 );
              p.setPen( colors[col] );
              col=(int)(i*colscale);
              if(col>63) col=0;
       }
       lines->turn(width(), height());
*/
}

Here is the caller graph for this function:


Member Data Documentation

QColor kLinesSaver::colend [protected]

Definition at line 64 of file lines.h.

QColor kLinesSaver::colmid [protected]

Definition at line 64 of file lines.h.

QColor kLinesSaver::colors[64] [protected]

Definition at line 63 of file lines.h.

double kLinesSaver::colscale [protected]

Definition at line 65 of file lines.h.

QColor kLinesSaver::colstart [protected]

Definition at line 64 of file lines.h.

Lines* kLinesSaver::lines [protected]

Definition at line 66 of file lines.h.

unsigned kLinesSaver::numLines [protected]

Definition at line 61 of file lines.h.

KRandomSequence kLinesSaver::rnd [protected]

Definition at line 59 of file lines.h.

int kLinesSaver::speed [protected]

Definition at line 62 of file lines.h.

QTimer kLinesSaver::timer [protected]

Definition at line 60 of file lines.h.


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