Back to index

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

#include <banner.h>

List of all members.

Public Member Functions

 KBannerSaver (WId id)
virtual ~KBannerSaver ()
void setSpeed (int spd)
void setFont (const QString &family, int size, const QColor &color, bool b, bool i)
void setMessage (const QString &msg)
void setTimeDisplay ()
void setCyclingColor (bool on)
void setColor (QColor &color)

Protected Slots

void slotTimeout ()

Protected Member Functions

void paintEvent (QPaintEvent *event)

Protected Attributes

QFont font
QTimer timer
QString fontFamily
int fontSize
bool bold
bool italic
QColor fontColor
bool cyclingColor
int currentHue
bool needUpdate
QString message
bool showTime
int xpos
int ypos
int step
int fsize
KRandomSequence * krnd
int speed
QPixmap pixmap
QSize pixmapSize

Private Member Functions

void readSettings ()
void initialize ()

Detailed Description

Definition at line 23 of file banner.h.


Constructor & Destructor Documentation

Definition at line 376 of file banner.cpp.

                                   : KScreenSaver( id )
{
        QPalette palette;
        palette.setColor( backgroundRole(), Qt::black );
        setPalette( palette );
       krnd = new KRandomSequence();
       readSettings();
       initialize();
       timer.start( speed );
       connect( &timer, SIGNAL( timeout() ), SLOT( slotTimeout() ) );
       show();
}

Here is the call graph for this function:

Definition at line 389 of file banner.cpp.

{
       timer.stop();
       delete krnd;
}

Member Function Documentation

void KBannerSaver::initialize ( ) [private]

Definition at line 473 of file banner.cpp.

{
       fsize = fontSize * height() / QApplication::desktop()->height();

       font = QFont( fontFamily, fsize, bold ? QFont::Bold : QFont::Normal, italic );

       pixmapSize = QSize();
       setAttribute( Qt::WA_NoSystemBackground, false );

       xpos = width();
       ypos = fsize + (int) ((double)(height() - 3 * fsize) * krnd->getDouble());
       step = 2 * width() / QApplication::desktop()->width(); // 6 -> 2 -hhjb-
       if ( step == 0 )
              step = 1;
}

Here is the caller graph for this function:

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

Definition at line 494 of file banner.cpp.

{
    Q_UNUSED( event )

    setAttribute( Qt::WA_NoSystemBackground ); // Only after requested clear is done

    if (cyclingColor)
    {
        int hueStep = speed/10;
        currentHue=(currentHue+hueStep)%360;
        fontColor.setHsv(currentHue,SATURATION,VALUE);
    }
    if (showTime)
    {
        QString new_message = KGlobal::locale()->formatTime(QTime::currentTime(), true);
       if( new_message != message )
           needUpdate = true;
       message = new_message;
    }
    if ( !pixmapSize.isValid() || cyclingColor || needUpdate || !testAttribute( Qt::WA_NoSystemBackground ) )
    {
        QRect rect = QFontMetrics( font ).boundingRect( message );
       rect.setWidth( rect.width() + step );
       if ( rect.width() > pixmapSize.width() )
           pixmapSize.setWidth( rect.width() );
       if ( rect.height() > pixmapSize.height() )
           pixmapSize.setHeight( rect.height() );
       pixmap = QPixmap( pixmapSize );
       pixmap.fill( Qt::black );
       QPainter p( &pixmap );
       p.setFont( font );
       p.setPen( fontColor );
       p.drawText( -rect.x(), -rect.y(), message );
       needUpdate = false;
    }
    xpos -= step;

    QPainter p( this );

    if ( xpos < -pixmapSize.width() ) {
       p.fillRect( xpos + step, ypos, pixmapSize.width(), pixmapSize.height(), Qt::black );
       xpos = width();
       ypos = fsize + (int) ((double)(height() - 3 * fsize) * krnd->getDouble());
    }

    p.drawPixmap( xpos, ypos, pixmap );
}
void KBannerSaver::readSettings ( ) [private]

Definition at line 444 of file banner.cpp.

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

   setSpeed( config.readEntry("Speed",50) );

   message=config.readEntry("Message","KDE");

   showTime=config.readEntry("ShowTime",false);

   fontFamily=config.readEntry("FontFamily",(QApplication::font()).family());

   fontSize=config.readEntry("FontSize",48);

   fontColor.setNamedColor(config.readEntry("FontColor","red"));

   cyclingColor=config.readEntry("CyclingColor",false);

   bold=config.readEntry("FontBold",false);
   italic=config.readEntry("FontItalic",false);

    if ( cyclingColor )
    {
        currentHue=0;
        fontColor.setHsv(0,SATURATION,VALUE);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KBannerSaver::setColor ( QColor &  color)

Definition at line 415 of file banner.cpp.

{
    fontColor = color;
    cyclingColor = false;
    needUpdate = true;
}

Here is the caller graph for this function:

void KBannerSaver::setCyclingColor ( bool  on)

Definition at line 422 of file banner.cpp.

{
    cyclingColor = on;
    needUpdate = true;
}

Here is the caller graph for this function:

void KBannerSaver::setFont ( const QString &  family,
int  size,
const QColor &  color,
bool  b,
bool  i 
)

Definition at line 403 of file banner.cpp.

{
       fontFamily = family;
       fontSize = size;
       fontColor = color;
       bold = b;
       italic = i;

       initialize();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KBannerSaver::setMessage ( const QString &  msg)

Definition at line 428 of file banner.cpp.

{
    showTime = false;
    message = msg;
    pixmapSize = QSize();
    setAttribute( Qt::WA_NoSystemBackground, false );
}

Here is the caller graph for this function:

void KBannerSaver::setSpeed ( int  spd)

Definition at line 395 of file banner.cpp.

{
       timer.stop();
       int inv = 100 - spd;
       speed = 1 + ((inv * inv) / 100);
       timer.start( speed );
}

Here is the caller graph for this function:

Definition at line 436 of file banner.cpp.

{
    showTime = true;
    pixmapSize = QSize();
    setAttribute( Qt::WA_NoSystemBackground, false );
}

Here is the caller graph for this function:

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

Definition at line 489 of file banner.cpp.

{
  update();
}

Here is the caller graph for this function:


Member Data Documentation

bool KBannerSaver::bold [protected]

Definition at line 52 of file banner.h.

int KBannerSaver::currentHue [protected]

Definition at line 56 of file banner.h.

bool KBannerSaver::cyclingColor [protected]

Definition at line 55 of file banner.h.

QFont KBannerSaver::font [protected]

Definition at line 48 of file banner.h.

QColor KBannerSaver::fontColor [protected]

Definition at line 54 of file banner.h.

QString KBannerSaver::fontFamily [protected]

Definition at line 50 of file banner.h.

int KBannerSaver::fontSize [protected]

Definition at line 51 of file banner.h.

int KBannerSaver::fsize [protected]

Definition at line 60 of file banner.h.

bool KBannerSaver::italic [protected]

Definition at line 53 of file banner.h.

KRandomSequence* KBannerSaver::krnd [protected]

Definition at line 61 of file banner.h.

QString KBannerSaver::message [protected]

Definition at line 58 of file banner.h.

bool KBannerSaver::needUpdate [protected]

Definition at line 57 of file banner.h.

QPixmap KBannerSaver::pixmap [protected]

Definition at line 63 of file banner.h.

QSize KBannerSaver::pixmapSize [protected]

Definition at line 64 of file banner.h.

bool KBannerSaver::showTime [protected]

Definition at line 59 of file banner.h.

int KBannerSaver::speed [protected]

Definition at line 62 of file banner.h.

int KBannerSaver::step [protected]

Definition at line 60 of file banner.h.

QTimer KBannerSaver::timer [protected]

Definition at line 49 of file banner.h.

int KBannerSaver::xpos [protected]

Definition at line 60 of file banner.h.

int KBannerSaver::ypos [protected]

Definition at line 60 of file banner.h.


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