Back to index

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

#include <science.h>

Collaboration diagram for KScienceSetup:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 KScienceSetup (QWidget *parent=0)
 ~KScienceSetup ()

Protected Member Functions

void updateSettings ()
void readSettings ()

Private Slots

void slotMode (int)
void slotInverse ()
void slotGravity ()
void slotHideBG ()
void slotMoveX (int)
void slotMoveY (int)
void slotSize (int)
void slotIntensity (int)
void slotSliderPressed ()
void slotSliderReleased ()
void slotSpeed (int)
void slotOk ()
void slotHelp ()

Private Attributes

KPreviewWidgetpreview
KScienceSaversaver
QSlider * slideSize
QSlider * slideSpeed
QSlider * slideIntensity
QSlider * slideMoveX
QSlider * slideMoveY
QCheckBox * checkInverse
QCheckBox * checkGravity
QCheckBox * checkHideBG
int mode
bool inverse [MAX_MODES]
bool gravity [MAX_MODES]
bool hideBG [MAX_MODES]
int moveX [MAX_MODES]
int moveY [MAX_MODES]
int size [MAX_MODES]
int intensity [MAX_MODES]
int speed [MAX_MODES]

Detailed Description

Definition at line 106 of file science.h.


Constructor & Destructor Documentation

KScienceSetup::KScienceSetup ( QWidget *  parent = 0)

Definition at line 861 of file science.cpp.

       : KDialog( parent)
         , saver( 0 )
{
       setCaption(i18n( "Setup Science Screen Saver" ));
       setModal(true);
       setButtons(Ok|Cancel|Help);
       setDefaultButton(Ok);
       showButtonSeparator(true);
       readSettings();
       initModeInfo();

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

       QHBoxLayout *lt  = new QHBoxLayout( main );
        lt->setSpacing( spacingHint() );
       QVBoxLayout *ltm = new QVBoxLayout;
       lt->addLayout( ltm );
       QVBoxLayout *ltc = new QVBoxLayout;
       lt->addLayout( ltc );

       // mode
       QLabel *label = new QLabel( i18n("Mode:"), main );
       ltm->addWidget( label );

       QListWidget *c = new QListWidget( main );
       for(int i = 0; i<MAX_MODES; i++)
              c->addItem( modeInfo[i].name );
       c->setCurrentRow( mode );
       c->setFixedHeight( 5 * c->fontMetrics().height() );
       connect( c, SIGNAL( currentRowChanged( int ) ), SLOT( slotMode( int ) ) );
       ltm->addWidget( c );

       // inverse
       QCheckBox *cbox = checkInverse = new QCheckBox( i18n("Inverse"), main );
       cbox->setEnabled( modeInfo[mode].inverseEnable );
       cbox->setChecked( inverse[mode] );
       connect( cbox, SIGNAL( clicked() ), SLOT( slotInverse() ) );
       ltm->addWidget( cbox );

       // gravity
       cbox = checkGravity = new QCheckBox( i18n("Gravity"), main );
       cbox->setChecked( gravity[mode] );
       connect( cbox, SIGNAL( clicked() ), SLOT( slotGravity() ) );
       ltm->addWidget( cbox );

       // hide background
       cbox = checkHideBG = new QCheckBox( i18n("Hide background"), main );
       cbox->setChecked( hideBG[mode] );
       connect( cbox, SIGNAL( clicked() ), SLOT( slotHideBG() ) );
       ltm->addWidget( cbox );
       ltm->addStretch();

       // size
       label = new QLabel( i18n("Size:"), main );
       ltc->addWidget( label );

       slideSize = new QSlider(Qt::Horizontal, main );
       slideSize->setMinimum(9);
       slideSize->setMaximum(50);
       slideSize->setPageStep(5);
       slideSize->setValue(size[mode]);
       slideSize->setMinimumSize( 90, 20 );
       slideSize->setTickPosition(QSlider::TicksBelow);
       slideSize->setTickInterval(5);
       connect( slideSize, SIGNAL( sliderMoved( int ) ),
              SLOT( slotSize( int ) ) );
       connect( slideSize, SIGNAL( sliderPressed() ),
              SLOT( slotSliderPressed() ) );
       connect( slideSize, SIGNAL( sliderReleased() ),
              SLOT( slotSliderReleased() ) );

       ltc->addWidget( slideSize );

       // intensity
       label = new QLabel( i18n("Intensity:"), main );
       ltc->addWidget( label );

       slideIntensity = new QSlider(Qt::Horizontal, main );
       slideIntensity->setMinimum(0);
       slideIntensity->setMaximum(10);
       slideIntensity->setPageStep(1);
       slideIntensity->setValue(intensity[mode]);
       slideIntensity->setMinimumSize( 90, 20 );
       slideIntensity->setTickPosition(QSlider::TicksBelow);
       slideIntensity->setTickInterval(1);
       connect( slideIntensity, SIGNAL( sliderMoved( int ) ),
              SLOT( slotIntensity( int )) );
       connect( slideIntensity, SIGNAL( sliderPressed() ),
              SLOT( slotSliderPressed() ) );
       connect( slideIntensity, SIGNAL( sliderReleased() ),
              SLOT( slotSliderReleased() ) );
       ltc->addWidget( slideIntensity );

       // speed
       label = new QLabel( i18n("Speed:"), main );
       ltc->addWidget( label );

       slideSpeed = new QSlider(Qt::Horizontal, main );
       slideSpeed->setMinimum(0);
       slideSpeed->setMaximum(SCI_MAX_SPEED);
       slideSpeed->setPageStep(10);
       slideSpeed->setValue(speed[mode]);
       slideSpeed->setMinimumSize( 90, 20 );
       slideSpeed->setTickPosition(QSlider::TicksBelow);
       slideSpeed->setTickInterval(10);
       connect( slideSpeed, SIGNAL( sliderMoved( int ) ),
              SLOT( slotSpeed( int ) ) );
       ltc->addWidget( slideSpeed );

       // motion
       label = new QLabel( i18n("Motion:"), main );
       ltc->addWidget( label );

       QHBoxLayout *ltcm = new QHBoxLayout;
       ltc->addLayout( ltcm );

       slideMoveX = new QSlider(Qt::Horizontal, main );
       slideMoveX->setMinimum(0);
       slideMoveX->setMaximum(SCI_MAX_MOVE);
       slideMoveX->setPageStep(5);
       slideMoveX->setValue(moveX[mode]);
       slideMoveX->setMinimumSize( 40, 20 );
       slideMoveX->setTickPosition(QSlider::TicksBelow);
       slideMoveX->setTickInterval(5);
       connect( slideMoveX, SIGNAL( sliderMoved( int ) ),
              SLOT( slotMoveX( int ) ) );
       ltcm->addWidget( slideMoveX );

       slideMoveY = new QSlider(Qt::Horizontal, main );
       slideMoveY->setMinimum(0);
       slideMoveY->setMaximum(SCI_MAX_MOVE);
       slideMoveY->setPageStep(5);
       slideMoveY->setValue(moveY[mode]);
       slideMoveY->setMinimumSize( 40, 20 );
       slideMoveY->setTickPosition(QSlider::TicksBelow);
       slideMoveY->setTickInterval(5);
       connect( slideMoveY, SIGNAL( sliderMoved( int ) ),
              SLOT( slotMoveY( int ) ) );
       ltcm->addWidget( slideMoveY );

       ltc->addStretch();

       // preview
       preview = new KPreviewWidget( main );
       preview->setFixedSize( 220, 170 );
       QPixmap p( KStandardDirs::locate("data", "kscreensaver/pics/kscience.png") );
       QPalette palette;
       if( p.isNull() ) {
              palette.setColor( preview->backgroundRole(), Qt::black );
       } else {
              palette.setBrush( preview->backgroundRole(), QBrush( p ) );
       }
       preview->setPalette( palette );
       preview->setAutoFillBackground(true);
       preview->show();     // otherwise saver does not get correct size
       lt->addWidget( preview );

       // let the preview window display before creating the saver
       kapp->processEvents();

       saver = new KScienceSaver( preview->winId(), true, !p.isNull() );
       preview->notifySaver( saver );
       connect(this,SIGNAL(okClicked()),SLOT(slotOk()));
       connect(this,SIGNAL(helpClicked()),SLOT(slotHelp()));
}

Here is the call graph for this function:

Definition at line 1029 of file science.cpp.

{
       delete saver;        // be sure to delete this first
}

Member Function Documentation

void KScienceSetup::readSettings ( ) [protected]

Definition at line 1049 of file science.cpp.

{
    KConfigGroup group = KGlobal::config()->group("Settings");
        QString sMode;

       mode = group.readEntry( "ModeNr", SCI_DEFAULT_MODE );

       for(int i=0; i < MAX_MODES; i++)
       {
              sMode.setNum( i );
              group = KGlobal::config()->group( "Mode" + sMode );
              moveX[i]     = group.readEntry(  "MoveX",     SCI_DEFAULT_MOVEX);
              moveY[i]     = group.readEntry(  "MoveY",     SCI_DEFAULT_MOVEY);
              size[i]      = group.readEntry(  "Size",      SCI_DEFAULT_SIZE);
              speed[i]     = group.readEntry(  "Speed",     SCI_DEFAULT_SPEED);
              intensity[i] = group.readEntry(  "Intensity", SCI_DEFAULT_INTENSITY);
              inverse[i]   = group.readEntry( "Inverse",   SCI_DEFAULT_INVERSE);
              gravity[i]   = group.readEntry( "Gravity",   SCI_DEFAULT_GRAVITY);
              hideBG[i]    = group.readEntry( "HideBG",    SCI_DEFAULT_HIDE);
       }
}

Here is the caller graph for this function:

void KScienceSetup::slotGravity ( ) [private, slot]

Definition at line 1089 of file science.cpp.

{
       gravity[mode] = checkGravity->isChecked();

       if( saver )
              saver->setGravity( gravity[mode] );
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1184 of file science.cpp.

{
       QString about = i18n("Science Version 0.26.5\n\nWritten by Rene Beutler (1998)\nrbeutler@g26.ethz.ch");
       KMessageBox::about(this,
                             about);
}

Here is the caller graph for this function:

void KScienceSetup::slotHideBG ( ) [private, slot]

Definition at line 1097 of file science.cpp.

{
       hideBG[mode] = checkHideBG->isChecked();

       if( saver )
              saver->setHideBG( hideBG[mode] );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KScienceSetup::slotIntensity ( int  i) [private, slot]

Definition at line 1137 of file science.cpp.

{
       intensity[mode] = i;

       if( saver )
              saver->setIntensity( i );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KScienceSetup::slotInverse ( ) [private, slot]

Definition at line 1081 of file science.cpp.

{
       inverse[mode] = checkInverse->isChecked();

       if( saver )
              saver->setInverse( inverse[mode] );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KScienceSetup::slotMode ( int  m) [private, slot]

Definition at line 1071 of file science.cpp.

{
       mode = m;

       if( saver )
              saver->setMode( mode );

       updateSettings();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KScienceSetup::slotMoveX ( int  x) [private, slot]

Definition at line 1105 of file science.cpp.

{
       moveX[mode] = x;

       if( saver )
              saver->setMoveX( x );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KScienceSetup::slotMoveY ( int  y) [private, slot]

Definition at line 1113 of file science.cpp.

{
       moveY[mode] = y;

       if( saver )
              saver->setMoveY( y );
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1158 of file science.cpp.

{
    KConfigGroup group = KGlobal::config()->group("Settings");
       QString sSize, sSpeed, sIntensity, sMode;

       group.writeEntry( "ModeNr", mode );

       for(int i=0; i<MAX_MODES; i++)
       {
              sMode.setNum( i );
              group = KGlobal::config()->group("Mode" + sMode );
              group.writeEntry( "MoveX",     moveX[i]     );
              group.writeEntry( "MoveY",     moveY[i]     );
              group.writeEntry( "Size",      size[i]      );
              group.writeEntry( "Speed",     speed[i]     );
              group.writeEntry( "Intensity", intensity[i] );
              group.writeEntry( "Inverse",   inverse[i]   );
              group.writeEntry( "Gravity",   gravity[i]   );
              group.writeEntry( "HideBG",    hideBG[i]    );
       }

       group.sync();

       accept();
}

Here is the caller graph for this function:

void KScienceSetup::slotSize ( int  s) [private, slot]

Definition at line 1121 of file science.cpp.

{
       size[mode] = s;

       if( saver )
              saver->setSize( s );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KScienceSetup::slotSliderPressed ( ) [private, slot]

Definition at line 1145 of file science.cpp.

{
       if( saver )
              saver->setMove( false );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KScienceSetup::slotSliderReleased ( ) [private, slot]

Definition at line 1151 of file science.cpp.

{
       if( saver )
              saver->setMove( true );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KScienceSetup::slotSpeed ( int  s) [private, slot]

Definition at line 1129 of file science.cpp.

{
       speed[mode] = s;

       if( saver )
              saver->setSpeed( s );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KScienceSetup::updateSettings ( ) [protected]

Definition at line 1034 of file science.cpp.

{
       // update dialog
       slideMoveX    ->setValue(   moveX[mode]     );
       slideMoveY    ->setValue(   moveY[mode]     );
       slideSize     ->setValue(   size[mode]      );
       slideSpeed    ->setValue(   speed[mode]     );
       slideIntensity->setValue(   intensity[mode] );
       checkInverse  ->setEnabled( modeInfo[mode].inverseEnable );
       checkInverse  ->setChecked( inverse[mode]   );
       checkGravity  ->setChecked( gravity[mode]   );
       checkHideBG   ->setChecked( hideBG[mode]    );
}

Here is the caller graph for this function:


Member Data Documentation

QCheckBox * KScienceSetup::checkGravity [private]

Definition at line 136 of file science.h.

QCheckBox * KScienceSetup::checkHideBG [private]

Definition at line 136 of file science.h.

QCheckBox* KScienceSetup::checkInverse [private]

Definition at line 136 of file science.h.

Definition at line 140 of file science.h.

Definition at line 141 of file science.h.

Definition at line 145 of file science.h.

Definition at line 139 of file science.h.

int KScienceSetup::mode [private]

Definition at line 138 of file science.h.

Definition at line 142 of file science.h.

Definition at line 143 of file science.h.

Definition at line 132 of file science.h.

Definition at line 133 of file science.h.

Definition at line 144 of file science.h.

QSlider * KScienceSetup::slideIntensity [private]

Definition at line 134 of file science.h.

QSlider* KScienceSetup::slideMoveX [private]

Definition at line 135 of file science.h.

QSlider * KScienceSetup::slideMoveY [private]

Definition at line 135 of file science.h.

QSlider* KScienceSetup::slideSize [private]

Definition at line 134 of file science.h.

QSlider * KScienceSetup::slideSpeed [private]

Definition at line 134 of file science.h.

Definition at line 146 of file science.h.


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