1 //-----------------------------------------------------------------------------
3 // KDE Display screen saver setup module
5 // Copyright (c) Martin R. Jones 1996,1999,2002
7 // Converted to a kcc module by Matthias Hoelzer 1997
11 #include <config-workspace.h>
17 #include <sys/types.h>
20 #include <kservicetypetrader.h>
21 #include <kstandarddirs.h>
23 #include <Qt3Support/Q3Header>
26 #include <Qt3Support/Q3CheckListItem>
27 #include <QPushButton>
30 #include <kmacroexpander.h>
35 #include <QTextStream>
37 #include <QHBoxLayout>
39 #include <QVBoxLayout>
40 #include <QResizeEvent>
41 #include <QMouseEvent>
44 #include <QtDBus/QtDBus>
45 #include <kaboutdata.h>
46 #include <kapplication.h>
49 #include <kiconloader.h>
50 #include <knuminput.h>
51 #include <k3process.h>
52 #include <kservicegroup.h>
59 #include <QDesktopWidget>
60 #include <kscreensaver_interface.h>
61 #include <KPluginFactory>
62 #include <KPluginLoader>
63 #include <KMessageBox>
65 template class QList
<SaverConfig
*>;
67 const uint widgetEventMask
= // X event mask
74 //===========================================================================
75 // DLL Interface for kcontrol
76 K_PLUGIN_FACTORY(KSSFactory
,
77 registerPlugin
<KScreenSaver
>(); // K_EXPORT_COMPONENT_FACTORY (screensaver
79 K_EXPORT_PLUGIN(KSSFactory("kcmscreensaver"))
82 static QString
findExe(const QString
&exe
) {
83 QString result
= KStandardDirs::locate("exe", exe
);
85 result
= KStandardDirs::findExe(exe
);
89 KScreenSaver::KScreenSaver(QWidget
*parent
, const QVariantList
&)
90 : KCModule(KSSFactory::componentData(), parent
)
100 setQuickHelp( i18n("<h1>Screen Saver</h1> <p>This module allows you to enable and"
101 " configure a screen saver. Note that you can enable a screen saver"
102 " even if you have power saving features enabled for your display.</p>"
103 " <p>Besides providing an endless variety of entertainment and"
104 " preventing monitor burn-in, a screen saver also gives you a simple"
105 " way to lock your display if you are going to leave it unattended"
106 " for a while. If you want the screen saver to lock the session, make sure you enable"
107 " the \"Require password\" feature of the screen saver; if you do not, you can still"
108 " explicitly lock the session using the desktop's \"Lock Session\" action.</p>"));
110 setButtons( KCModule::Help
| KCModule::Default
| KCModule::Apply
);
116 mSetupProc
= new K3Process
;
117 connect(mSetupProc
, SIGNAL(processExited(K3Process
*)),
118 this, SLOT(slotSetupDone(K3Process
*)));
120 mPreviewProc
= new K3Process
;
121 connect(mPreviewProc
, SIGNAL(processExited(K3Process
*)),
122 this, SLOT(slotPreviewExited(K3Process
*)));
124 QBoxLayout
*topLayout
= new QHBoxLayout(this);
125 topLayout
->setMargin(0);
126 topLayout
->setSpacing(KDialog::spacingHint());
129 QVBoxLayout
*leftColumnLayout
= new QVBoxLayout( );
130 topLayout
->addItem( leftColumnLayout
);
131 leftColumnLayout
->setSpacing( KDialog::spacingHint() );
133 mSaverGroup
= new QGroupBox(i18n("Screen Saver"), this );
134 QVBoxLayout
*groupLayout
= new QVBoxLayout( mSaverGroup
);
135 leftColumnLayout
->addWidget(mSaverGroup
);
136 leftColumnLayout
->setStretchFactor( mSaverGroup
, 10 );
138 mSaverListView
= new Q3ListView( mSaverGroup
);
139 mSaverListView
->setMinimumHeight( 120 );
140 mSaverListView
->setSizePolicy(QSizePolicy::Preferred
, QSizePolicy::Expanding
);
141 mSaverListView
->addColumn("");
142 mSaverListView
->header()->hide();
144 groupLayout
->addWidget( mSaverListView
, 10 );
145 connect( mSaverListView
, SIGNAL(doubleClicked ( Q3ListViewItem
*)), this, SLOT( slotSetup()));
146 mSaverListView
->setWhatsThis( i18n("Select the screen saver to use.") );
148 QBoxLayout
* hlay
= new QHBoxLayout();
149 groupLayout
->addLayout(hlay
);
150 mSetupBt
= new QPushButton( i18n("&Setup..."), mSaverGroup
);
151 connect( mSetupBt
, SIGNAL( clicked() ), SLOT( slotSetup() ) );
152 mSetupBt
->setEnabled(false);
153 hlay
->addWidget( mSetupBt
);
154 mSetupBt
->setWhatsThis( i18n("Configure the screen saver's options, if any.") );
156 mTestBt
= new QPushButton( i18n("&Test"), mSaverGroup
);
157 connect( mTestBt
, SIGNAL( clicked() ), SLOT( slotTest() ) );
158 mTestBt
->setEnabled(false);
159 hlay
->addWidget( mTestBt
);
160 mTestBt
->setWhatsThis( i18n("Show a full screen preview of the screen saver.") );
162 mSettingsGroup
= new QGroupBox( i18n("Settings"), this );
163 groupLayout
= new QVBoxLayout( mSettingsGroup
);
164 leftColumnLayout
->addWidget( mSettingsGroup
);
166 mEnabledCheckBox
= new QCheckBox(i18n(
167 "Start a&utomatically"), mSettingsGroup
);
168 mEnabledCheckBox
->setChecked(mEnabled
);
169 mEnabledCheckBox
->setWhatsThis( i18n(
170 "Automatically start the screen saver after a period of inactivity.") );
171 connect(mEnabledCheckBox
, SIGNAL(toggled(bool)),
172 this, SLOT(slotEnable(bool)));
173 groupLayout
->addWidget(mEnabledCheckBox
);
175 QBoxLayout
*hbox
= new QHBoxLayout();
176 groupLayout
->addLayout(hbox
);
177 hbox
->addSpacing(30);
178 mActivateLbl
= new QLabel(i18n("After:"), mSettingsGroup
);
179 mActivateLbl
->setEnabled(mEnabled
);
180 hbox
->addWidget(mActivateLbl
);
181 mWaitEdit
= new QSpinBox(mSettingsGroup
);
182 //mWaitEdit->setSteps(1, 10);
183 mWaitEdit
->setRange(1, INT_MAX
);
184 mWaitEdit
->setSuffix(i18n(" min"));
185 mWaitEdit
->setValue(mTimeout
/60);
186 mWaitEdit
->setEnabled(mEnabled
);
187 connect(mWaitEdit
, SIGNAL(valueChanged(int)),
188 this, SLOT(slotTimeoutChanged(int)));
189 mActivateLbl
->setBuddy(mWaitEdit
);
190 hbox
->addWidget(mWaitEdit
);
192 QString wtstr
= i18n(
193 "The period of inactivity "
194 "after which the screen saver should start.");
195 mActivateLbl
->setWhatsThis( wtstr
);
196 mWaitEdit
->setWhatsThis( wtstr
);
198 mLockCheckBox
= new QCheckBox( i18n(
199 "&Require password to stop"), mSettingsGroup
);
200 mLockCheckBox
->setEnabled( mEnabled
);
201 mLockCheckBox
->setChecked( mLock
);
202 connect( mLockCheckBox
, SIGNAL( toggled( bool ) ),
203 this, SLOT( slotLock( bool ) ) );
204 groupLayout
->addWidget(mLockCheckBox
);
205 mLockCheckBox
->setWhatsThis( i18n(
206 "Prevent potential unauthorized use by requiring a password"
207 " to stop the screen saver.") );
208 hbox
= new QHBoxLayout();
209 groupLayout
->addLayout(hbox
);
210 hbox
->addSpacing(30);
211 mLockLbl
= new QLabel(i18n("After:"), mSettingsGroup
);
212 mLockLbl
->setEnabled(mEnabled
&& mLock
);
213 mLockLbl
->setWhatsThis( i18n(
214 "The amount of time, after the screen saver has started, to ask for the unlock password.") );
215 hbox
->addWidget(mLockLbl
);
216 mWaitLockEdit
= new QSpinBox(mSettingsGroup
);
217 //mWaitLockEdit->setSteps(1, 10);
218 mWaitLockEdit
->setRange(1, 300);
219 mWaitLockEdit
->setSuffix(i18n(" sec"));
220 mWaitLockEdit
->setValue(mLockTimeout
/1000);
221 mWaitLockEdit
->setEnabled(mEnabled
&& mLock
);
222 if ( mWaitLockEdit
->sizeHint().width() <
223 mWaitEdit
->sizeHint().width() ) {
224 mWaitLockEdit
->setFixedWidth( mWaitEdit
->sizeHint().width() );
225 mWaitEdit
->setFixedWidth( mWaitEdit
->sizeHint().width() );
228 mWaitEdit
->setFixedWidth( mWaitLockEdit
->sizeHint().width() );
229 mWaitLockEdit
->setFixedWidth( mWaitLockEdit
->sizeHint().width() );
231 connect(mWaitLockEdit
, SIGNAL(valueChanged(int)),
232 this, SLOT(slotLockTimeoutChanged(int)));
233 mLockLbl
->setBuddy(mWaitLockEdit
);
234 hbox
->addWidget(mWaitLockEdit
);
236 QString wltstr
= i18n(
238 "after which the display will be locked. ");
239 mLockLbl
->setWhatsThis( wltstr
);
240 mWaitLockEdit
->setWhatsThis( wltstr
);
242 mPlasmaCheckBox
= new QCheckBox(i18n("Allow widgets on screen saver"), mSaverGroup
);
243 mPlasmaCheckBox
->setChecked(mPlasmaEnabled
);
244 mPlasmaCheckBox
->setWhatsThis(i18n("Add widgets to your screensaver"));
245 connect(mPlasmaCheckBox
, SIGNAL(toggled(bool)), this, SLOT(slotEnablePlasma(bool)));
246 groupLayout
->addWidget(mPlasmaCheckBox
);
248 hbox
= new QHBoxLayout();
249 groupLayout
->addLayout(hbox
);
250 hbox
->addSpacing(30);
251 mPlasmaSetup
= new QPushButton(i18n("Setup..."), mSaverGroup
);
252 mPlasmaSetup
->setEnabled(mPlasmaEnabled
);
253 connect(mPlasmaSetup
, SIGNAL(clicked()), this, SLOT(slotPlasmaSetup()));
254 hbox
->addWidget(mPlasmaSetup
);
255 hbox
->addItem(new QSpacerItem(40, 20, QSizePolicy::Expanding
, QSizePolicy::Minimum
));
258 QBoxLayout
* rightColumnLayout
= new QVBoxLayout();
259 topLayout
->addItem( rightColumnLayout
);
260 rightColumnLayout
->setSpacing( KDialog::spacingHint() );
262 mMonitorLabel
= new QLabel( this );
263 mMonitorLabel
->setAlignment( Qt::AlignCenter
);
264 mMonitorLabel
->setPixmap( QPixmap(KStandardDirs::locate("data",
265 "kcontrol/pics/monitor.png")));
266 rightColumnLayout
->addWidget(mMonitorLabel
, 0);
267 mMonitorLabel
->setWhatsThis( i18n("A preview of the selected screen saver.") );
269 QBoxLayout
* advancedLayout
= new QHBoxLayout();
270 rightColumnLayout
->addItem( advancedLayout
);
271 advancedLayout
->setSpacing( 3 );
272 advancedLayout
->addWidget( new QWidget( this ) );
273 QPushButton
* advancedBt
= new QPushButton(
274 i18n( "Advanced &Options" ), this );
275 advancedBt
->setObjectName("advancedBtn");
276 advancedBt
->setSizePolicy( QSizePolicy(
277 QSizePolicy::Fixed
, QSizePolicy::Fixed
) );
278 connect( advancedBt
, SIGNAL( clicked() ),
279 this, SLOT( slotAdvanced() ) );
280 advancedLayout
->addWidget( advancedBt
);
281 advancedLayout
->addWidget( new QWidget( this ) );
283 rightColumnLayout
->addStretch();
287 setButtons(buttons() & ~Default
);
288 mSettingsGroup
->setEnabled(false);
289 mSaverGroup
->setEnabled(false);
292 // finding the savers can take some time, so defer loading until
295 mLoadTimer
= new QTimer( this );
296 connect( mLoadTimer
, SIGNAL(timeout()), SLOT(findSavers()) );
297 mLoadTimer
->start( 100 );
302 new KAboutData(I18N_NOOP("kcmscreensaver"), 0, ki18n("KDE Screen Saver Control Module"),
303 0, KLocalizedString(), KAboutData::License_GPL
,
304 ki18n("(c) 1997-2002 Martin R. Jones\n"
305 "(c) 2003-2004 Chris Howells"));
306 about
->addAuthor(ki18n("Chris Howells"), KLocalizedString(), "howells@kde.org");
307 about
->addAuthor(ki18n("Martin R. Jones"), KLocalizedString(), "jones@kde.org");
309 setAboutData( about
);
313 //---------------------------------------------------------------------------
315 void KScreenSaver::resizeEvent( QResizeEvent
* )
320 mMonitor
->setGeometry( (mMonitorLabel
->width()-200)/2+23,
321 (mMonitorLabel
->height()-186)/2+14, 151, 115 );
325 //---------------------------------------------------------------------------
327 void KScreenSaver::mousePressEvent( QMouseEvent
*)
333 //---------------------------------------------------------------------------
335 void KScreenSaver::keyPressEvent( QKeyEvent
*)
340 //---------------------------------------------------------------------------
342 KScreenSaver::~KScreenSaver()
346 if (mPreviewProc
->isRunning())
348 mPreviewProc
->kill( );
349 mPreviewProc
->wait( );
358 qDeleteAll(mSaverList
);
361 //---------------------------------------------------------------------------
363 void KScreenSaver::load()
367 //with the following line, the Test and Setup buttons are not enabled correctly
368 //if no saver was selected, the "Reset" and the "Enable screensaver", it is only called when starting and when pressing reset, aleXXX
371 Q3ListViewItem
*selectedItem
= 0;
372 Q_FOREACH( SaverConfig
* saver
, mSaverList
){
373 if (saver
->file() == mSaver
)
375 selectedItem
= mSaverListView
->findItem ( saver
->name(), 0 );
385 mSaverListView
->setSelected( selectedItem
, true );
386 mSaverListView
->setCurrentItem( selectedItem
);
387 slotScreenSaver( selectedItem
);
395 //------------------------------------------------------------After---------------
397 void KScreenSaver::readSettings()
399 KConfigGroup
config( KSharedConfig::openConfig( "kscreensaverrc"), "ScreenSaver" );
401 mImmutable
= config
.isImmutable();
403 mEnabled
= config
.readEntry("Enabled", false);
404 mTimeout
= config
.readEntry("Timeout", 300);
405 mLockTimeout
= config
.readEntry("LockGrace", 60000);
406 mLock
= config
.readEntry("Lock", false);
407 mSaver
= config
.readEntry("Saver");
408 mPlasmaEnabled
= config
.readEntry("PlasmaEnabled", false);
410 if (mTimeout
< 60) mTimeout
= 60;
411 if (mLockTimeout
< 0) mLockTimeout
= 0;
412 if (mLockTimeout
> 300000) mLockTimeout
= 300000;
417 //---------------------------------------------------------------------------
419 void KScreenSaver::updateValues()
423 mWaitEdit
->setValue(mTimeout
/60);
427 mWaitEdit
->setValue(0);
430 mWaitLockEdit
->setValue(mLockTimeout
/1000);
431 mLockCheckBox
->setChecked(mLock
);
434 //---------------------------------------------------------------------------
436 void KScreenSaver::defaults()
438 if (mImmutable
) return;
440 slotScreenSaver( 0 );
442 Q3ListViewItem
*item
= mSaverListView
->firstChild();
444 mSaverListView
->setSelected( item
, true );
445 mSaverListView
->setCurrentItem( item
);
446 mSaverListView
->ensureItemVisible( item
);
448 slotTimeoutChanged( 5 );
449 slotLockTimeoutChanged( 60 );
451 mEnabledCheckBox
->setChecked(false);
452 mPlasmaCheckBox
->setChecked(false);
453 mPlasmaSetup
->setEnabled(false);
460 //---------------------------------------------------------------------------
462 void KScreenSaver::save()
467 KConfigGroup
config(KSharedConfig::openConfig( "kscreensaverrc"), "ScreenSaver" );
469 config
.writeEntry("Enabled", mEnabled
);
470 config
.writeEntry("Timeout", mTimeout
);
471 config
.writeEntry("LockGrace", mLockTimeout
);
472 config
.writeEntry("Lock", mLock
);
473 config
.writeEntry("PlasmaEnabled", mPlasmaEnabled
);
475 if ( !mSaver
.isEmpty() )
476 config
.writeEntry("Saver", mSaver
);
479 org::kde::screensaver
kscreensaver("org.kde.screensaver", "/ScreenSaver", QDBusConnection::sessionBus());
480 kscreensaver
.configure();
486 //---------------------------------------------------------------------------
488 void KScreenSaver::findSavers()
491 mSaverServices
= KServiceTypeTrader::self()->query( "ScreenSaver");
492 new Q3ListViewItem ( mSaverListView
, i18n("Loading...") );
493 if ( mSaverServices
.isEmpty() )
496 mLoadTimer
->start( 50 );
498 for( KService::List::const_iterator it
= mSaverServices
.constBegin();
499 it
!= mSaverServices
.constEnd(); it
++,mNumLoaded
++)
501 SaverConfig
*saver
= new SaverConfig
;
502 QString file
= KStandardDirs::locate("services", (*it
)->entryPath());
503 if (saver
->read(file
)) {
504 mSaverList
.append(saver
);
509 if ( mNumLoaded
== mSaverServices
.count() ) {
510 Q3ListViewItem
*selectedItem
= 0;
511 int categoryCount
= 0;
516 qSort(mSaverList
.begin(), mSaverList
.end());
519 mSaverListView
->clear();
520 Q_FOREACH( SaverConfig
*s
, mSaverList
)
522 Q3ListViewItem
*item
;
523 if (s
->category().isEmpty())
524 item
= new Q3ListViewItem ( mSaverListView
, s
->name(), '2' + s
->name() );
527 Q3ListViewItem
*categoryItem
= mSaverListView
->findItem( s
->category(), 0 );
528 if ( !categoryItem
) {
529 categoryItem
= new Q3ListViewItem ( mSaverListView
, s
->category(), '1' + s
->category() );
530 categoryItem
->setPixmap ( 0, SmallIcon ( "preferences-desktop-screensaver" ) );
532 item
= new Q3ListViewItem ( categoryItem
, s
->name(), s
->name() );
535 if (s
->file() == mSaver
) {
542 // Delete categories with only one item
543 Q3ListViewItemIterator
it ( mSaverListView
);
544 for ( ; it
.current(); it
++ )
545 if ( it
.current()->childCount() == 1 ) {
546 Q3ListViewItem
*item
= it
.current()->firstChild();
547 it
.current()->takeItem( item
);
548 mSaverListView
->insertItem ( item
);
553 mSaverListView
->setRootIsDecorated ( categoryCount
> 0 );
554 mSaverListView
->setSorting ( 1 );
556 if ( mSelected
> -1 )
558 mSaverListView
->setSelected(selectedItem
, true);
559 mSaverListView
->setCurrentItem(selectedItem
);
560 mSaverListView
->ensureItemVisible(selectedItem
);
561 mSetupBt
->setEnabled(!mSaverList
.at(mSelected
)->setup().isEmpty());
562 mTestBt
->setEnabled(true);
565 connect( mSaverListView
, SIGNAL( currentChanged( Q3ListViewItem
* ) ),
566 this, SLOT( slotScreenSaver( Q3ListViewItem
* ) ) );
572 //---------------------------------------------------------------------------
574 void KScreenSaver::setMonitor()
576 if (mPreviewProc
->isRunning())
577 // CC: this will automatically cause a "slotPreviewExited"
578 // when the viewer exits
579 mPreviewProc
->kill();
581 slotPreviewExited(mPreviewProc
);
584 //---------------------------------------------------------------------------
586 void KScreenSaver::slotPreviewExited(K3Process
*)
588 // Ugly hack to prevent continual respawning of savers that crash
589 if (mSelected
== mPrevSelected
)
592 if ( mSaverList
.isEmpty() ) // safety check
595 // Some xscreensaver hacks do something nasty to the window that
596 // requires a new one to be created (or proper investigation of the
600 mMonitor
= new KSSMonitor(mMonitorLabel
);
602 palette
.setColor(mMonitor
->backgroundRole(), Qt::black
);
603 mMonitor
->setPalette(palette
);
604 mMonitor
->setGeometry((mMonitorLabel
->width()-200)/2+23,
605 (mMonitorLabel
->height()-186)/2+14, 151, 115);
607 // So that hacks can XSelectInput ButtonPressMask
608 XSelectInput(QX11Info::display(), mMonitor
->winId(), widgetEventMask
);
610 if (mSelected
>= 0) {
611 mPreviewProc
->clearArguments();
613 QString saver
= mSaverList
.at(mSelected
)->saver();
614 QHash
<QChar
, QString
> keyMap
;
615 keyMap
.insert('w', QString::number(mMonitor
->winId()));
616 *mPreviewProc
<< KShell::splitArgs(KMacroExpander::expandMacrosShellQuote(saver
, keyMap
));
618 mPreviewProc
->start();
621 mPrevSelected
= mSelected
;
624 //---------------------------------------------------------------------------
626 void KScreenSaver::slotEnable(bool e
)
629 mActivateLbl
->setEnabled( e
);
630 mWaitEdit
->setEnabled( e
);
631 mLockCheckBox
->setEnabled( e
);
632 mLockLbl
->setEnabled( e
&& mLock
);
633 mWaitLockEdit
->setEnabled( e
&& mLock
);
638 void KScreenSaver::slotEnablePlasma(bool enable
)
640 mPlasmaEnabled
= enable
;
641 //FIXME even though the button's enabled, plasma isn't until the user hits apply
642 //so the button will just show the screensaver, no plasma.
643 //what should I do about this?
644 mPlasmaSetup
->setEnabled(mPlasmaEnabled
);
649 void KScreenSaver::slotPlasmaSetup()
651 org::kde::screensaver
kscreensaver("org.kde.screensaver", "/ScreenSaver", QDBusConnection::sessionBus());
652 kscreensaver
.setupPlasma();
656 //---------------------------------------------------------------------------
658 void KScreenSaver::slotScreenSaver(Q3ListViewItem
*item
)
663 int i
= 0, indx
= -1;
664 Q_FOREACH( SaverConfig
* saver
, mSaverList
){
665 if ( item
->parent() )
667 if ( item
->parent()->text( 0 ) == saver
->category() && saver
->name() == item
->text (0))
675 if ( saver
->name() == item
->text (0) )
688 bool bChanged
= (indx
!= mSelected
);
690 if (!mSetupProc
->isRunning())
691 mSetupBt
->setEnabled(!mSaverList
.at(indx
)->setup().isEmpty());
692 mTestBt
->setEnabled(true);
693 mSaver
= mSaverList
.at(indx
)->file();
704 //---------------------------------------------------------------------------
706 void KScreenSaver::slotSetup()
711 if (mSetupProc
->isRunning())
714 mSetupProc
->clearArguments();
716 QString saver
= mSaverList
.at(mSelected
)->setup();
719 QTextStream
ts(&saver
, QIODevice::ReadOnly
);
723 bool kxsconfig
= word
== "kxsconfig";
724 QString path
= findExe(word
);
728 (*mSetupProc
) << path
;
730 // Add caption and icon to about dialog
733 (*mSetupProc
) << word
;
734 word
= mSaverList
.at(mSelected
)->name();
735 (*mSetupProc
) << word
;
737 (*mSetupProc
) << word
;
738 word
= "kscreensaver";
739 (*mSetupProc
) << word
;
745 (*mSetupProc
) << word
;
748 // Pass translated name to kxsconfig
750 word
= mSaverList
.at(mSelected
)->name();
751 (*mSetupProc
) << word
;
754 mSetupBt
->setEnabled( false );
761 //---------------------------------------------------------------------------
763 void KScreenSaver::slotAdvanced()
765 KScreenSaverAdvancedDialog
dlg( window() );
772 //---------------------------------------------------------------------------
774 void KScreenSaver::slotTest()
776 if ( mSelected
== -1 )
780 mTestProc
= new K3Process
;
782 mPreviewProc
->kill();
783 mPreviewProc
->wait();
784 mTestProc
->clearArguments();
789 mTestWin
= new TestWin();
790 mTestWin
->setAttribute(Qt::WA_NoSystemBackground
, true);
791 mTestWin
->setAttribute(Qt::WA_PaintOnScreen
, true);
792 mTestWin
->setGeometry(qApp
->desktop()->geometry());
797 mTestWin
->setFocus();
798 // So that hacks can XSelectInput ButtonPressMask
799 XSelectInput(QX11Info::display(), mTestWin
->winId(), widgetEventMask
);
804 mTestBt
->setEnabled( false );
806 QString saver
= mSaverList
.at(mSelected
)->saver();
807 QHash
<QChar
, QString
> keyMap
;
808 keyMap
.insert('w', QString::number(mTestWin
->winId()));
809 *mTestProc
<< KShell::splitArgs(KMacroExpander::expandMacrosShellQuote(saver
, keyMap
));
811 mTestProc
->start(K3Process::NotifyOnExit
);
816 //---------------------------------------------------------------------------
818 void KScreenSaver::slotStopTest()
820 if (mTestProc
->isRunning()) {
827 mTestBt
->setEnabled(true);
833 //---------------------------------------------------------------------------
835 void KScreenSaver::slotTimeoutChanged(int to
)
842 //-----------------------------------------------------------------------
844 void KScreenSaver::slotLockTimeoutChanged(int to
)
846 mLockTimeout
= to
* 1000;
852 //---------------------------------------------------------------------------
854 void KScreenSaver::slotLock( bool l
)
857 mLockLbl
->setEnabled( l
);
858 mWaitLockEdit
->setEnabled( l
);
863 //---------------------------------------------------------------------------
865 void KScreenSaver::slotSetupDone(K3Process
*)
867 mPrevSelected
= -1; // see ugly hack in slotPreviewExited()
869 mSetupBt
->setEnabled( true );
873 #include "scrnsave.moc"