Back to index

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

#include <banner.h>

Collaboration diagram for KBannerSetup:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 KBannerSetup (QWidget *parent=NULL)

Protected Member Functions

void readSettings ()
void fillFontSizes ()

Private Slots

void slotFamily (const QFont &)
void slotSize (int)
void slotSizeEdit (const QString &)
void slotColor (const QColor &)
void slotCyclingColor (bool on)
void slotBold (bool)
void slotItalic (bool)
void slotSpeed (int)
void slotMessage (const QString &)
void slotOk ()
void slotHelp ()
void slotTimeToggled (bool on)

Private Attributes

QWidget * preview
KColorButton * colorPush
KBannerSaversaver
QLineEdit * ed
QComboBox * comboSizes
QString message
bool showTime
QString fontFamily
int fontSize
QColor fontColor
bool cyclingColor
bool bold
bool italic
int speed
QList< int > sizes

Detailed Description

Definition at line 68 of file banner.h.


Constructor & Destructor Documentation

KBannerSetup::KBannerSetup ( QWidget *  parent = NULL)

Definition at line 70 of file banner.cpp.

       : KDialog( parent)
         , saver( 0 ), ed(0), speed( 50 )
{
       setButtons(Ok|Cancel|Help);
       setDefaultButton(Ok);
       setCaption(i18n( "Setup Banner Screen Saver" ));
       setModal(true);
       setButtonText( Help, i18n( "A&bout" ) );
       readSettings();

        QWidget *main = new QWidget(this);
       setMainWidget(main);

       QLabel *label;

       QVBoxLayout *tl = new QVBoxLayout( main );
       QHBoxLayout *tl1 = new QHBoxLayout();
       tl->addLayout(tl1);
       QVBoxLayout *tl11 = new QVBoxLayout();
       tl1->addLayout(tl11);

       QGroupBox *group = new QGroupBox( i18n("Font"), main );
        QVBoxLayout *vbox = new QVBoxLayout;
        group->setLayout(vbox);
        QGridLayout *gl = new QGridLayout();
        vbox->addLayout(gl);
        gl->setSpacing(spacingHint());

       label = new QLabel( i18n("Family:"), group );
       gl->addWidget(label, 1, 0);

       KFontComboBox* comboFonts = new KFontComboBox( group );
       comboFonts->setCurrentFont( fontFamily );
       gl->addWidget(comboFonts, 1, 1);
       connect( comboFonts, SIGNAL(currentFontChanged( const QFont& ) ),
                     SLOT( slotFamily( const QFont& ) ) );

       label = new QLabel( i18n("Size:"), group );
       gl->addWidget(label, 2, 0);

       comboSizes = new QComboBox( group );
        comboSizes->setEditable( true );
        fillFontSizes();
       gl->addWidget(comboSizes, 2, 1);
       connect( comboSizes, SIGNAL( activated( int ) ), SLOT( slotSize( int ) ) );
       connect( comboSizes, SIGNAL( editTextChanged( const QString & ) ),
                     SLOT( slotSizeEdit( const QString &  ) ) );

       QCheckBox *cb = new QCheckBox( i18n("Bold"),
                                   group );
       cb->setChecked( bold );
       connect( cb, SIGNAL( toggled( bool ) ), SLOT( slotBold( bool ) ) );
       gl->addWidget(cb, 3, 0);

       cb = new QCheckBox( i18n("Italic"), group );
       cb->setChecked( italic );
       gl->addWidget(cb, 3, 1);
       connect( cb, SIGNAL( toggled( bool ) ), SLOT( slotItalic( bool ) ) );

       label = new QLabel( i18n("Color:"), group );
       gl->addWidget(label, 4, 0);

       colorPush = new KColorButton( fontColor, group );
       gl->addWidget(colorPush, 4, 1);
       connect( colorPush, SIGNAL( changed(const QColor &) ),
               SLOT( slotColor(const QColor &) ) );

        QCheckBox *cyclingColorCb=new QCheckBox(i18n("Cycling color"),group);
        cyclingColorCb->setMinimumSize(cyclingColorCb->sizeHint());
        gl->addWidget(cyclingColorCb, 5, 0,5,1);
        connect(cyclingColorCb,SIGNAL(toggled(bool)),this,SLOT(slotCyclingColor(bool)));
        cyclingColorCb->setChecked(cyclingColor);

       preview = new QWidget( main );
       preview->setFixedSize( 220, 170 );
        {
            QPalette palette;
            palette.setColor( preview->backgroundRole(), Qt::black );
            preview->setPalette( palette );
           preview->setAutoFillBackground(true);
        }
       preview->show();    // otherwise saver does not get correct size
       saver = new KBannerSaver( preview->winId() );
       tl1->addWidget(preview);

       tl11->addWidget(group);

       label = new QLabel( i18n("Speed:"), main );
       tl11->addStretch(1);
       tl11->addWidget(label);

       QSlider *sb = new QSlider( Qt::Horizontal, main );
        sb->setMinimum(0);
        sb->setMaximum(100);
        sb->setPageStep(10);
        sb->setValue(speed);
       sb->setMinimumWidth( 180);
       sb->setFixedHeight(20);
        sb->setTickPosition(QSlider::TicksBelow);
        sb->setTickInterval(10);
       tl11->addWidget(sb);
       connect( sb, SIGNAL( valueChanged( int ) ), SLOT( slotSpeed( int ) ) );

       QHBoxLayout *tl2 = new QHBoxLayout;
       tl->addLayout(tl2);

       label = new QLabel( i18n("Message:"), main );
       tl2->addWidget(label);

       ed = new QLineEdit( main );
       tl2->addWidget(ed);
       ed->setText( message );
       connect( ed, SIGNAL( textChanged( const QString & ) ),
                     SLOT( slotMessage( const QString &  ) ) );

   QCheckBox *timeCb=new QCheckBox( i18n("Show current time"), main);
   timeCb->setFixedSize(timeCb->sizeHint());
   tl->addWidget(timeCb,0,Qt::AlignLeft);
   connect(timeCb,SIGNAL(toggled(bool)),this,SLOT(slotTimeToggled(bool)));
   timeCb->setChecked(showTime);
   connect(this,SIGNAL(okClicked()),this,SLOT(slotOk()));
   connect(this,SIGNAL(helpClicked()),this,SLOT(slotHelp()));
   tl->addStretch();
}

Here is the call graph for this function:


Member Function Documentation

void KBannerSetup::fillFontSizes ( ) [protected]

Definition at line 217 of file banner.cpp.

{
    bool block = comboSizes->signalsBlocked();
    comboSizes->blockSignals( true );
    comboSizes->clear();
    int i = 0;
    sizes = QFontDatabase().pointSizes( fontFamily );
    sizes << 96 << 128 << 156 << 0;
    int current = 0;
    while ( sizes[i] )
       {
       QString num;
       num.setNum( sizes[i] );
       comboSizes->insertItem( i, num );
       if ( fontSize == sizes[i] ) // fontsize equals one of the defined ones
           {
            current = i;
           comboSizes->setCurrentIndex( current );
           slotSize( current );
           }
       i++;
       }
    if ( current == 0 ) // fontsize seems to be entered by hand
        {
       QString fsize;
       fsize.setNum( fontSize );
       comboSizes->setEditText(fsize);
       slotSizeEdit( fsize );
       }
    comboSizes->blockSignals( block );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KBannerSetup::readSettings ( ) [protected]

Definition at line 197 of file banner.cpp.

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

   speed=config.readEntry("Speed",50);
/*     if ( speed > 100 )
              speed = 100;
       else if ( speed < 50 )
              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);
}

Here is the caller graph for this function:

void KBannerSetup::slotBold ( bool  state) [private, slot]

Definition at line 293 of file banner.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void KBannerSetup::slotColor ( const QColor &  col) [private, slot]

Definition at line 273 of file banner.cpp.

{
    fontColor = col;
    if ( saver )
       saver->setColor(fontColor);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KBannerSetup::slotCyclingColor ( bool  on) [private, slot]

Definition at line 280 of file banner.cpp.

{
   colorPush->setEnabled(!on);
   cyclingColor=on;

   if ( saver )
   {
      saver->setCyclingColor( on );
      if ( !on )
         saver->setColor( fontColor );
   }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KBannerSetup::slotFamily ( const QFont &  f) [private, slot]

Definition at line 249 of file banner.cpp.

{
       fontFamily = f.family();
        fillFontSizes(); // different font, different sizes
       if ( saver )
              saver->setFont( fontFamily, fontSize, fontColor, bold, italic );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KBannerSetup::slotHelp ( ) [private, slot]

Definition at line 368 of file banner.cpp.

{
       KMessageBox::about(this,
                          i18n("Banner Version 2.2.1\n\nWritten by Martin R. Jones 1996\nmjones@kde.org\nExtended by Alexander Neundorf 2000\nalexander.neundorf@rz.tu-ilmenau.de\n"));
}

Here is the caller graph for this function:

void KBannerSetup::slotItalic ( bool  state) [private, slot]

Definition at line 300 of file banner.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void KBannerSetup::slotMessage ( const QString &  msg) [private, slot]

Definition at line 314 of file banner.cpp.

{
       message = msg;
       if ( saver )
              saver->setMessage( message );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KBannerSetup::slotOk ( ) [private, slot]

Definition at line 338 of file banner.cpp.

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

       config.writeEntry( "Speed", speed );
       config.writeEntry( "Message", message );
       config.writeEntry( "ShowTime", showTime );
       config.writeEntry( "FontFamily", fontFamily );

       QString fsize;
       if (fontSize == 0) // an non-number was entered in the font size combo
       {
              fontSize = 48;
       }
       fsize.setNum( fontSize );
       config.writeEntry( "FontSize", fsize );

       QString colName;
       colName.sprintf( "#%02x%02x%02x", fontColor.red(), fontColor.green(),
              fontColor.blue() );
       config.writeEntry( "FontColor", colName );
       config.writeEntry( "CyclingColor", cyclingColor );
       config.writeEntry( "FontBold", bold );
       config.writeEntry( "FontItalic", italic );

       config.sync();

       accept();
}

Here is the caller graph for this function:

void KBannerSetup::slotSize ( int  indx) [private, slot]

Definition at line 257 of file banner.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void KBannerSetup::slotSizeEdit ( const QString &  fs) [private, slot]

Definition at line 264 of file banner.cpp.

{
       bool ok;
        fontSize = fs.toInt( &ok, 10 );
       if ( ok )
              if ( saver )
                     saver->setFont( fontFamily, fontSize, fontColor, bold, italic );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KBannerSetup::slotSpeed ( int  num) [private, slot]

Definition at line 307 of file banner.cpp.

{
       speed = num;
       if ( saver )
              saver->setSpeed( speed );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KBannerSetup::slotTimeToggled ( bool  on) [private, slot]

Definition at line 321 of file banner.cpp.

{
   ed->setEnabled(!on);
   showTime=on;
   if (saver)
   {
      if (showTime)
         saver->setTimeDisplay();
      else
      {
         message=ed->text();
         saver->setMessage(message);
      }
   }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

bool KBannerSetup::bold [private]

Definition at line 105 of file banner.h.

KColorButton* KBannerSetup::colorPush [private]

Definition at line 94 of file banner.h.

QComboBox* KBannerSetup::comboSizes [private]

Definition at line 97 of file banner.h.

Definition at line 104 of file banner.h.

QLineEdit* KBannerSetup::ed [private]

Definition at line 96 of file banner.h.

QColor KBannerSetup::fontColor [private]

Definition at line 103 of file banner.h.

QString KBannerSetup::fontFamily [private]

Definition at line 101 of file banner.h.

int KBannerSetup::fontSize [private]

Definition at line 102 of file banner.h.

bool KBannerSetup::italic [private]

Definition at line 106 of file banner.h.

QString KBannerSetup::message [private]

Definition at line 99 of file banner.h.

QWidget* KBannerSetup::preview [private]

Definition at line 93 of file banner.h.

Definition at line 95 of file banner.h.

bool KBannerSetup::showTime [private]

Definition at line 100 of file banner.h.

QList<int> KBannerSetup::sizes [private]

Definition at line 108 of file banner.h.

int KBannerSetup::speed [private]

Definition at line 107 of file banner.h.


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