Back to index

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

KPendulum screen saver setup dialog. More...

#include <pendulum.h>

Collaboration diagram for KPendulumSetup:
Collaboration graph
[legend]

List of all members.

Public Slots

void okButtonClickedSlot (void)
 slot for the "OK" button: save settings and exit
void aboutButtonClickedSlot (void)
 slot for the "About" button: show the About dialog
void mEditLostFocusSlot (void)
 slot is called if the mass ratio edit field looses its focus.
void lEditLostFocusSlot (void)
 slot is called if the length ratio edit field looses its focus.
void gEditLostFocusSlot (void)
 slot is called if the gravitational constant edit field looses its focus.
void eEditLostFocusSlot (void)
 slot is called if the energy edit field looses its focus.
void persChangeEnteredSlot (int t)
 slot is called if the perspective change interval spin box changed.
void barColorButtonClickedSlot (void)
 slot is called if the bar color button was clicked.
void m1ColorButtonClickedSlot (void)
 slot is called if the mass 1 color button was clicked.
void m2ColorButtonClickedSlot (void)
 slot is called if the mass 2 color button was clicked.

Public Member Functions

 KPendulumSetup (QWidget *parent=0)
 Constructor for the KPendulum screen saver setup dialog.
 ~KPendulumSetup (void)
 Destructor of the KPendulum screen saver setup dialog.

Private Attributes

KPendulumSaverm_saver
 Pointer to the screen saver object.

Detailed Description

KPendulum screen saver setup dialog.

This class handles the KPendulum screen saver setup dialog.

Definition at line 366 of file pendulum.h.


Constructor & Destructor Documentation

KPendulumSetup::KPendulumSetup ( QWidget *  parent = 0)

Constructor for the KPendulum screen saver setup dialog.

Parameters:
parentPointer to the parent widget, passed to KPendulumSetupUi

The dialog box is set up and the screen saver object KPendulumSetup::saver is instantiated.

Definition at line 726 of file pendulum.cpp.

   : QDialog(parent)
{
   setupUi(this);

   // the dialog should block, no other control center input should be possible
   // until the dialog is closed
   setModal(true);

   // create input validators
   m_mEdit->setValidator(
      new QDoubleValidator(
         KPendulumSaver::sm_massRatioLimitLower,
         KPendulumSaver::sm_massRatioLimitUpper,
         5, m_mEdit));
   m_lEdit->setValidator(
      new QDoubleValidator(
         KPendulumSaver::sm_lengthRatioLimitLower,
         KPendulumSaver::sm_lengthRatioLimitUpper,
         5, m_lEdit));
   m_gEdit->setValidator(
      new QDoubleValidator(
         KPendulumSaver::sm_gLimitLower,
         KPendulumSaver::sm_gLimitUpper,
         5, m_gEdit));
   m_eEdit->setValidator(
      new QDoubleValidator(
         KPendulumSaver::sm_ELimitLower,
         KPendulumSaver::sm_ELimitUpper,
         5, m_eEdit));

   // set input limits for the perspective change interval time
   m_persSpinBox->setMinimum(KPendulumSaver::sm_persChangeIntervalLimitLower);
   m_persSpinBox->setMaximum(KPendulumSaver::sm_persChangeIntervalLimitUpper);

   // set tool tips of editable fields
   m_mEdit->setToolTip(
      ki18n("Ratio of 2nd mass to sum of both masses.\nValid values from %1 to %2.")
      .subs(KPendulumSaver::sm_massRatioLimitLower, 0, 'f', 2)
      .subs(KPendulumSaver::sm_massRatioLimitUpper, 0, 'f', 2)
      .toString());
   m_lEdit->setToolTip(
      ki18n("Ratio of 2nd pendulum part length to the sum of both part lengths.\nValid values from %1 to %2.")
      .subs(KPendulumSaver::sm_lengthRatioLimitLower, 0, 'f', 2)
      .subs(KPendulumSaver::sm_lengthRatioLimitUpper, 0, 'f', 2)
      .toString());
   m_gEdit->setToolTip(
      ki18n("Gravitational constant in arbitrary units.\nValid values from %1 to %2.")
      .subs(KPendulumSaver::sm_gLimitLower, 0, 'f', 2)
      .subs(KPendulumSaver::sm_gLimitUpper, 0, 'f', 2)
      .toString());
   m_eEdit->setToolTip(
      ki18n("Energy in units of the maximum potential energy of the given configuration.\nValid values from %1 to %2.")
      .subs(KPendulumSaver::sm_ELimitLower, 0, 'f', 2)
      .subs(KPendulumSaver::sm_ELimitUpper, 0, 'f', 2)
      .toString());
   m_persSpinBox->setToolTip(
      ki18n("Time in seconds after which a random perspective change occurs.\nValid values from %1 to %2.")
      .subs(KPendulumSaver::sm_persChangeIntervalLimitLower)
      .subs(KPendulumSaver::sm_persChangeIntervalLimitUpper)
      .toString());

   // init preview area
   QPalette palette;
   palette.setColor(m_preview->backgroundRole(), Qt::black);
   m_preview->setPalette(palette);
   m_preview->setAutoFillBackground(true);
   m_preview->show();    // otherwise saver does not get correct size

   // create saver and give it the WinID of the preview area
   m_saver = new KPendulumSaver(m_preview->winId());

   // read settings from saver and update GUI elements with these values, saver
   // has read settings in its constructor

   // set editable fields with stored values as defaults
   QString text;
   text.setNum(m_saver->massRatio());
   m_mEdit->setText(text);
   text.setNum(m_saver->lengthRatio());
   m_lEdit->setText(text);
   text.setNum(m_saver->g());
   m_gEdit->setText(text);
   text.setNum(m_saver->E());
   m_eEdit->setText(text);

   m_persSpinBox->setValue(m_saver->persChangeInterval());

   palette.setColor(m_barColorButton->backgroundRole(), m_saver->barColor());
   m_barColorButton->setPalette(palette);
   palette.setColor(m_m1ColorButton->backgroundRole(), m_saver->m1Color());
   m_m1ColorButton->setPalette(palette);
   palette.setColor(m_m2ColorButton->backgroundRole(), m_saver->m2Color());
   m_m2ColorButton->setPalette(palette);

   // if the preview area is resized it emits the resized() event which is
   // caught by m_saver.  The embedded GLArea is resized to fit into the preview
   // area.
   connect(m_preview, SIGNAL(resized(QResizeEvent*)),
           m_saver,   SLOT(resizeGlArea(QResizeEvent*)));

   connect(m_okButton,       SIGNAL(clicked()),         this, SLOT(okButtonClickedSlot()));
   connect( m_cancelButton,  SIGNAL(clicked()),         this, SLOT(reject() ) );
   connect(m_aboutButton,    SIGNAL(clicked()),         this, SLOT(aboutButtonClickedSlot()));

   connect(m_lEdit,          SIGNAL(lostFocus()),       this, SLOT(lEditLostFocusSlot()));
   connect(m_gEdit,          SIGNAL(lostFocus()),       this, SLOT(gEditLostFocusSlot()));
   connect(m_eEdit,          SIGNAL(lostFocus()),       this, SLOT(eEditLostFocusSlot()));
   connect(m_persSpinBox,    SIGNAL(valueChanged(int)), this, SLOT(persChangeEnteredSlot(int)));
   connect(m_mEdit,          SIGNAL(lostFocus()),       this, SLOT(mEditLostFocusSlot()));
   connect(m_barColorButton, SIGNAL(clicked()),         this, SLOT(barColorButtonClickedSlot()));
   connect(m_m1ColorButton,  SIGNAL(clicked()),         this, SLOT(m1ColorButtonClickedSlot()));
   connect(m_m2ColorButton,  SIGNAL(clicked()),         this, SLOT(m2ColorButtonClickedSlot()));
}

Here is the call graph for this function:

Destructor of the KPendulum screen saver setup dialog.

Only KPendulumSetup::saver is deleted.

Definition at line 841 of file pendulum.cpp.

{
   delete m_saver;
}

Member Function Documentation

slot for the "About" button: show the About dialog

Definition at line 865 of file pendulum.cpp.

{
   KMessageBox::about(this, i18n("\
<h3>KPendulum Screen Saver for KDE</h3>\
<p>Simulation of a two-part pendulum</p>\
<p>Copyright (c) Georg&nbsp;Drenkhahn 2004</p>\
<p><tt>Georg.Drenkhahn@gmx.net</tt></p>"));
}

Here is the caller graph for this function:

slot is called if the bar color button was clicked.

A color dialog is opened and the result is given to KPendulumSaver::setBarColor().

Definition at line 931 of file pendulum.cpp.

{
    QColor color = m_saver->barColor();
    if ( KColorDialog::getColor( color, this) )
    {
        if (color.isValid())
        {
            m_saver->setBarColor(color);
            QPalette palette;
            palette.setColor(m_barColorButton->backgroundRole(), color);
            m_barColorButton->setPalette(palette);
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KPendulumSetup::eEditLostFocusSlot ( void  ) [slot]

slot is called if the energy edit field looses its focus.

If the input is acceptable KPendulumSaver::setE() is called.

Definition at line 913 of file pendulum.cpp.

{
   if (m_eEdit->hasAcceptableInput())
   {
      m_saver->setE(m_eEdit->text().toDouble());
   }
   else
   {  // write current setting back into input field
      QString text;
      text.setNum(m_saver->E());
      m_eEdit->setText(text);
   }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KPendulumSetup::gEditLostFocusSlot ( void  ) [slot]

slot is called if the gravitational constant edit field looses its focus.

If the input is acceptable KPendulumSaver::setG() is called.

Definition at line 900 of file pendulum.cpp.

{
   if (m_gEdit->hasAcceptableInput())
   {
      m_saver->setG(m_gEdit->text().toDouble());
   }
   else
   {  // write current setting back into input field
      QString text;
      text.setNum(m_saver->g());
      m_gEdit->setText(text);
   }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KPendulumSetup::lEditLostFocusSlot ( void  ) [slot]

slot is called if the length ratio edit field looses its focus.

If the input is acceptable KPendulumSaver::setLengthRatio() is called.

Definition at line 887 of file pendulum.cpp.

{
   if (m_lEdit->hasAcceptableInput())
   {
      m_saver->setLengthRatio(m_lEdit->text().toDouble());
   }
   else
   {  // write current setting back into input field
      QString text;
      text.setNum(m_saver->lengthRatio());
      m_lEdit->setText(text);
   }
}

Here is the call graph for this function:

Here is the caller graph for this function:

slot is called if the mass 1 color button was clicked.

A color dialog is opened and the result is given to KPendulumSaver::setM1Color().

Definition at line 946 of file pendulum.cpp.

{
    QColor color =m_saver->m1Color();
    if ( KColorDialog::getColor( color, this) )
    {
        if (color.isValid())
        {
            m_saver->setM1Color(color);
            QPalette palette;
            palette.setColor(m_m1ColorButton->backgroundRole(), color);
            m_m1ColorButton->setPalette(palette);
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

slot is called if the mass 2 color button was clicked.

A color dialog is opened and the result is given to KPendulumSaver::setM2Color().

Definition at line 960 of file pendulum.cpp.

{
    QColor color = m_saver->m2Color();
    if ( KColorDialog::getColor( color, this) )
    {
        if (color.isValid())
        {
            m_saver->setM2Color(color);
            QPalette palette;
            palette.setColor(m_m2ColorButton->backgroundRole(), color);
            m_m2ColorButton->setPalette(palette);
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KPendulumSetup::mEditLostFocusSlot ( void  ) [slot]

slot is called if the mass ratio edit field looses its focus.

If the input is acceptable KPendulumSaver::setMassRatio() is called.

Definition at line 874 of file pendulum.cpp.

{
   if (m_mEdit->hasAcceptableInput())
   {
      m_saver->setMassRatio(m_mEdit->text().toDouble());
   }
   else
   {  // write current setting back into input field
      QString text;
      text.setNum(m_saver->massRatio());
      m_mEdit->setText(text);
   }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KPendulumSetup::okButtonClickedSlot ( void  ) [slot]

slot for the "OK" button: save settings and exit

Definition at line 847 of file pendulum.cpp.

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

   config.writeEntry("mass ratio",   m_saver->massRatio());
   config.writeEntry("length ratio", m_saver->lengthRatio());
   config.writeEntry("g",            m_saver->g());
   config.writeEntry("E",            m_saver->E());
   config.writeEntry("perspective change interval",
                      m_saver->persChangeInterval());
   config.writeEntry("bar color",    m_saver->barColor());
   config.writeEntry("m1 color",     m_saver->m1Color());
   config.writeEntry("m2 color",     m_saver->m2Color());

   config.sync();
   accept();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KPendulumSetup::persChangeEnteredSlot ( int  t) [slot]

slot is called if the perspective change interval spin box changed.

If the input is acceptable KPendulumSaver::setPersChangeInterval() is called.

Definition at line 926 of file pendulum.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Pointer to the screen saver object.

Its member KPendulumSaver::glArea is displayed in the preview area

Definition at line 418 of file pendulum.h.


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