static const char* defaultText[] =
{
I18N_NOOP( "Regular" ),
I18N_NOOP( "Cosmic Strings" ),
I18N_NOOP( "Cold Pricklies" ),
I18N_NOOP( "Space Fur" ),
I18N_NOOP( "Jiggly" ),
I18N_NOOP( "Undertow" ),
I18N_NOOP( "(Random)" ),
0
};
KSWindsSetup::KSWindsSetup( QWidget* parent )
: KDialog( parent)
{
setButtonText( Help, i18n( "A&bout" ) );
setButtons(Ok|Cancel|Help);
setDefaultButton(Ok);
setCaption(i18n( "Setup Solar Wind" ));
setModal(true);
showButtonSeparator(true);
setButtonText( Help, i18n( "A&bout" ) );
QWidget *main = new QWidget(this);
setMainWidget(main);
QHBoxLayout* top = new QHBoxLayout( main );
top->setSpacing( spacingHint() );
QVBoxLayout* leftCol = new QVBoxLayout;
top->addLayout( leftCol );
QLabel* label = new QLabel( i18n("Mode:"), main );
leftCol->addWidget( label );
modeW = new QComboBox( main );
int i = 0;
while (defaultText[i])
modeW->addItem( i18n(defaultText[i++]) );
leftCol->addWidget( modeW );
leftCol->addStretch();
// Preview
QWidget* preview;
preview = new QWidget( main );
preview->setFixedSize( 220, 165 );
{
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 KSWindsScreenSaver( preview->winId() );
top->addWidget(preview);
// Now that we have _saver...
modeW->setCurrentIndex( _saver->mode() ); // set before we connect
connect( modeW, SIGNAL(activated(int)), _saver, SLOT(setMode(int)) );
connect( this, SIGNAL(okClicked()), this, SLOT(slotOk()));
connect( this, SIGNAL(helpClicked()),this,SLOT(slotHelp()));
}
KSWindsSetup::~KSWindsSetup()
{
delete _saver;
}
void KSWindsSetup::slotHelp()
{
KMessageBox::about(this,
i18n("Solar Winds 1.0
\nCopyright (c) 2002 Terence M. Welsh
\nhttp://www.reallyslick.com/
\n\nPorted to KDE by Karl Robillard
"),
QString(), KMessageBox::AllowLink);
}
/**
Ok pressed - save settings and exit
*/
void KSWindsSetup::slotOk()
{
KConfigGroup config(KGlobal::config(), "Settings");
QString val;
val.setNum( modeW->currentIndex() );
config.writeEntry("Mode", val );
config.sync();
accept();
}
#endif
//----------------------------------------------------------------------------
#ifdef UNIT_TEST
// moc SolarWinds.h -o SolarWinds.moc
// g++ -g -DUNIT_TEST SolarWinds.cpp -I/usr/lib/qt3/include -lqt -L/usr/lib/qt3/lib -lGLU -lGL
#include
int main( int argc, char** argv )
{
QApplication app( argc, argv );
SWindsWidget w;
app.setMainWidget( &w );
w.show();
return app.exec();
}
#endif
//EOF