summaryrefslogtreecommitdiffstats
path: root/kcontrol/screensaver
diff options
context:
space:
mode:
Diffstat (limited to 'kcontrol/screensaver')
-rw-r--r--kcontrol/screensaver/Makefile.am20
-rw-r--r--kcontrol/screensaver/advanceddialog.cpp174
-rw-r--r--kcontrol/screensaver/advanceddialog.h61
-rw-r--r--kcontrol/screensaver/advanceddialogimpl.ui397
-rw-r--r--kcontrol/screensaver/category_list16
-rw-r--r--kcontrol/screensaver/configure.in.in8
-rw-r--r--kcontrol/screensaver/kssmonitor.h15
-rw-r--r--kcontrol/screensaver/kswidget.cpp71
-rw-r--r--kcontrol/screensaver/kswidget.h17
-rw-r--r--kcontrol/screensaver/saverconfig.cpp38
-rw-r--r--kcontrol/screensaver/saverconfig.h29
-rw-r--r--kcontrol/screensaver/saverlist.cpp13
-rw-r--r--kcontrol/screensaver/saverlist.h14
-rw-r--r--kcontrol/screensaver/screensaver.desktop240
-rw-r--r--kcontrol/screensaver/scrnsave.cpp862
-rw-r--r--kcontrol/screensaver/scrnsave.h113
-rw-r--r--kcontrol/screensaver/testwin.cpp13
-rw-r--r--kcontrol/screensaver/testwin.h14
18 files changed, 2115 insertions, 0 deletions
diff --git a/kcontrol/screensaver/Makefile.am b/kcontrol/screensaver/Makefile.am
new file mode 100644
index 000000000..f5fc4eec3
--- /dev/null
+++ b/kcontrol/screensaver/Makefile.am
@@ -0,0 +1,20 @@
+
+AM_CPPFLAGS = $(GLINC) $(all_includes)
+
+kde_module_LTLIBRARIES = kcm_screensaver.la
+
+kcm_screensaver_la_SOURCES = advanceddialogimpl.ui scrnsave.cpp testwin.cpp saverlist.cpp \
+ saverconfig.cpp advanceddialog.cpp kswidget.cpp
+kcm_screensaver_la_LDFLAGS = -module -avoid-version $(all_libraries) -no-undefined
+kcm_screensaver_la_LIBADD = $(LIB_KSYCOCA) $(DPMSLIB) $(GLLIB)
+METASOURCES = AUTO
+
+noinst_HEADERS = scrnsave.h
+
+messages: rc.cpp
+ sed 's/X-KDE-Category=\(.*\)/i18n\("Screen saver category","\1"\);/' < category_list > category_list.cpp
+ $(XGETTEXT) *.cpp -o $(podir)/kcmscreensaver.pot
+ -rm -f category_list.cpp
+
+xdg_apps_DATA = screensaver.desktop
+
diff --git a/kcontrol/screensaver/advanceddialog.cpp b/kcontrol/screensaver/advanceddialog.cpp
new file mode 100644
index 000000000..273888960
--- /dev/null
+++ b/kcontrol/screensaver/advanceddialog.cpp
@@ -0,0 +1,174 @@
+#include <klocale.h>
+#include <kstandarddirs.h>
+#include <qcombobox.h>
+#include <kdebug.h>
+
+#include <qwhatsthis.h>
+#include <qstring.h>
+
+#include <config.h>
+
+#include "advanceddialog.h"
+#include "advanceddialogimpl.h"
+#include "stdlib.h"
+
+#include "advanceddialog.moc"
+
+KScreenSaverAdvancedDialog::KScreenSaverAdvancedDialog(QWidget *parent, const char* name)
+ : KDialogBase( parent, name, true, i18n( "Advanced Options" ),
+ Ok | Cancel, Ok, true )
+{
+
+ dialog = new AdvancedDialog(this);
+ setMainWidget(dialog);
+
+ readSettings();
+
+ connect(dialog->qcbPriority, SIGNAL(activated(int)),
+ this, SLOT(slotPriorityChanged(int)));
+
+ connect(dialog->qcbTopLeft, SIGNAL(activated(int)),
+ this, SLOT(slotChangeTopLeftCorner(int)));
+ connect(dialog->qcbTopRight, SIGNAL(activated(int)),
+ this, SLOT(slotChangeTopLeftCorner(int)));
+ connect(dialog->qcbBottomLeft, SIGNAL(activated(int)),
+ this, SLOT(slotChangeTopLeftCorner(int)));
+ connect(dialog->qcbBottomRight, SIGNAL(activated(int)),
+ this, SLOT(slotChangeTopLeftCorner(int)));
+
+#ifndef HAVE_SETPRIORITY
+ dialog->qgbPriority->setEnabled(false);
+#endif
+}
+
+void KScreenSaverAdvancedDialog::readSettings()
+{
+ KConfig *config = new KConfig("kdesktoprc");
+ config->setGroup("ScreenSaver");
+
+ mPriority = config->readNumEntry("Priority", 19);
+ if (mPriority < 0) mPriority = 0;
+ if (mPriority > 19) mPriority = 19;
+
+ dialog->qcbTopLeft->setCurrentItem(config->readNumEntry("ActionTopLeft", 0));
+ dialog->qcbTopRight->setCurrentItem(config->readNumEntry("ActionTopRight", 0));
+ dialog->qcbBottomLeft->setCurrentItem(config->readNumEntry("ActionBottomLeft", 0));
+ dialog->qcbBottomRight->setCurrentItem(config->readNumEntry("ActionBottomRight", 0));
+
+
+ switch(mPriority)
+ {
+ case 19: // Low
+ dialog->qcbPriority->setCurrentItem(0);
+ kdDebug() << "setting low" << endl;
+ break;
+ case 10: // Medium
+ dialog->qcbPriority->setCurrentItem(1);
+ kdDebug() << "setting medium" << endl;
+ break;
+ case 0: // High
+ dialog->qcbPriority->setCurrentItem(2);
+ kdDebug() << "setting high" << endl;
+ break;
+ }
+
+ mChanged = false;
+ delete config;
+}
+
+void KScreenSaverAdvancedDialog::slotPriorityChanged(int val)
+{
+ switch (val)
+ {
+ case 0: // Low
+ mPriority = 19;
+ kdDebug() << "low priority" << endl;
+ break;
+ case 1: // Medium
+ mPriority = 10;
+ kdDebug() << "medium priority" << endl;
+ break;
+ case 2: // High
+ mPriority = 0;
+ kdDebug() << "high priority" << endl;
+ break;
+ }
+ mChanged = true;
+}
+
+void KScreenSaverAdvancedDialog::slotOk()
+{
+ if (mChanged)
+ {
+ KConfig *config = new KConfig("kdesktoprc");
+ config->setGroup( "ScreenSaver" );
+
+ config->writeEntry("Priority", mPriority);
+ config->writeEntry(
+ "ActionTopLeft", dialog->qcbTopLeft->currentItem());
+ config->writeEntry(
+ "ActionTopRight", dialog->qcbTopRight->currentItem());
+ config->writeEntry(
+ "ActionBottomLeft", dialog->qcbBottomLeft->currentItem());
+ config->writeEntry(
+ "ActionBottomRight", dialog->qcbBottomRight->currentItem());
+ config->sync();
+ delete config;
+ }
+ accept();
+}
+
+void KScreenSaverAdvancedDialog::slotChangeBottomRightCorner(int)
+{
+ mChanged = true;
+}
+
+void KScreenSaverAdvancedDialog::slotChangeBottomLeftCorner(int)
+{
+ mChanged = true;
+}
+
+void KScreenSaverAdvancedDialog::slotChangeTopRightCorner(int)
+{
+ mChanged = true;
+}
+
+void KScreenSaverAdvancedDialog::slotChangeTopLeftCorner(int)
+{
+ mChanged = true;
+}
+
+/* =================================================================================================== */
+
+AdvancedDialog::AdvancedDialog(QWidget *parent, const char *name) : AdvancedDialogImpl(parent, name)
+{
+ monitorLabel->setPixmap(QPixmap(locate("data", "kcontrol/pics/monitor.png")));
+ QWhatsThis::add(qcbPriority, "<qt>" + i18n("Specify the priority that the screensaver will run at. A higher priority may mean that the screensaver runs faster, though may reduce the speed that other programs run at while the screensaver is active.") + "</qt>");
+ QString qsTopLeft("<qt>" + i18n("The action to take when the mouse cursor is located in the top left corner of the screen for 15 seconds.") + "</qt>");
+ QString qsTopRight("<qt>" + i18n("The action to take when the mouse cursor is located in the top right corner of the screen for 15 seconds.") + "</qt>");
+ QString qsBottomLeft("<qt>" + i18n("The action to take when the mouse cursor is located in the bottom left corner of the screen for 15 seconds.") + "</qt>");
+ QString qsBottomRight("<qt>" + i18n("The action to take when the mouse cursor is located in the bottom right corner of the screen for 15 seconds.") + "</qt>");
+ QWhatsThis::add(qlTopLeft, qsTopLeft);
+ QWhatsThis::add(qcbTopLeft, qsTopLeft);
+ QWhatsThis::add(qlTopRight, qsTopRight);
+ QWhatsThis::add(qcbTopRight, qsTopRight);
+ QWhatsThis::add(qlBottomLeft, qsBottomLeft);
+ QWhatsThis::add(qcbBottomLeft, qsBottomLeft);
+ QWhatsThis::add(qlBottomRight, qsBottomRight);
+ QWhatsThis::add(qcbBottomRight, qsBottomRight);
+}
+
+AdvancedDialog::~AdvancedDialog()
+{
+
+}
+
+void AdvancedDialog::setMode(QComboBox *box, int i)
+{
+ box->setCurrentItem(i);
+}
+
+int AdvancedDialog::mode(QComboBox *box)
+{
+ return box->currentItem();
+}
diff --git a/kcontrol/screensaver/advanceddialog.h b/kcontrol/screensaver/advanceddialog.h
new file mode 100644
index 000000000..813c9fc82
--- /dev/null
+++ b/kcontrol/screensaver/advanceddialog.h
@@ -0,0 +1,61 @@
+#ifndef ADVANCEDDIALOG_H
+#define ADVANCEDDIALOG_H
+
+#include <kdialogbase.h>
+#include <qwidget.h>
+#include <kconfig.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qwhatsthis.h>
+#include <qgroupbox.h>
+#include <qobject.h>
+#include <qcheckbox.h>
+#include <qslider.h>
+
+#include "advanceddialogimpl.h"
+
+class AdvancedDialog : public AdvancedDialogImpl
+{
+public:
+ AdvancedDialog(QWidget *parent = 0, const char *name = 0);
+ ~AdvancedDialog();
+ void setMode(QComboBox *box, int i);
+ int mode(QComboBox *box);
+};
+
+/* =================================================================================================== */
+
+class KScreenSaverAdvancedDialog : public KDialogBase
+{
+ Q_OBJECT
+public:
+ KScreenSaverAdvancedDialog(QWidget *parent, const char* name = 0);
+
+public slots:
+ void slotOk();
+
+protected slots:
+ void slotPriorityChanged(int val);
+ void slotChangeBottomRightCorner(int);
+ void slotChangeBottomLeftCorner(int);
+ void slotChangeTopRightCorner(int);
+ void slotChangeTopLeftCorner(int);
+
+private:
+ void readSettings();
+
+ QCheckBox *m_topLeftCorner;
+ QCheckBox *m_bottomLeftCorner;
+ QCheckBox *m_topRightCorner;
+ QCheckBox *m_bottomRightCorner;
+ QSlider *mPrioritySlider;
+
+ bool mChanged;
+ int mPriority;
+ AdvancedDialog *dialog;
+
+};
+
+
+#endif
+
diff --git a/kcontrol/screensaver/advanceddialogimpl.ui b/kcontrol/screensaver/advanceddialogimpl.ui
new file mode 100644
index 000000000..814a3867c
--- /dev/null
+++ b/kcontrol/screensaver/advanceddialogimpl.ui
@@ -0,0 +1,397 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>AdvancedDialogImpl</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>Form1</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>403</width>
+ <height>399</height>
+ </rect>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QGroupBox" row="1" column="0">
+ <property name="name">
+ <cstring>qgbPriority</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="title">
+ <string>Screen Saver Priority</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QComboBox" row="0" column="0">
+ <item>
+ <property name="text">
+ <string>Low</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Medium</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>High</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>qcbPriority</cstring>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string></string>
+ </property>
+ </widget>
+ <spacer row="0" column="1">
+ <property name="name">
+ <cstring>spacer5</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>31</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <widget class="QGroupBox" row="0" column="0">
+ <property name="name">
+ <cstring>groupBox1</cstring>
+ </property>
+ <property name="title">
+ <string>Screen Corner Actions</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="3" column="0" rowspan="2" colspan="2">
+ <property name="name">
+ <cstring>qlMonitorLabel</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>layout8</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>qlTopLeft</cstring>
+ </property>
+ <property name="text">
+ <string>Top left:</string>
+ </property>
+ </widget>
+ <widget class="QComboBox">
+ <item>
+ <property name="text">
+ <string>No Action</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Lock Screen</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Prevent Locking</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>qcbTopLeft</cstring>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer6</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>41</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>qlTopRight</cstring>
+ </property>
+ <property name="text">
+ <string>Top right:</string>
+ </property>
+ </widget>
+ <widget class="QComboBox">
+ <item>
+ <property name="text">
+ <string>No Action</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Lock Screen</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Prevent Locking</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>qcbTopRight</cstring>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="5" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>layout9</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout4</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>qlBottomLeft</cstring>
+ </property>
+ <property name="text">
+ <string>Bottom left:</string>
+ </property>
+ </widget>
+ <widget class="QComboBox">
+ <item>
+ <property name="text">
+ <string>No Action</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Lock Screen</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Prevent Locking</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>qcbBottomLeft</cstring>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer7</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>qlBottomRight</cstring>
+ </property>
+ <property name="text">
+ <string>Bottom right:</string>
+ </property>
+ </widget>
+ <widget class="QComboBox">
+ <item>
+ <property name="text">
+ <string>No Action</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Lock Screen</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Prevent Locking</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>qcbBottomRight</cstring>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="2" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>layout10</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer8</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>monitorLabel</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer9</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>31</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <spacer row="1" column="1">
+ <property name="name">
+ <cstring>spacer10</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <spacer row="4" column="1">
+ <property name="name">
+ <cstring>spacer11</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/kcontrol/screensaver/category_list b/kcontrol/screensaver/category_list
new file mode 100644
index 000000000..61115c0dc
--- /dev/null
+++ b/kcontrol/screensaver/category_list
@@ -0,0 +1,16 @@
+// This list contains all screen saver categories.
+// The categories are extracted for translation (see Makefile.am).
+
+// To show a screen saver in the list under a category, add the
+// category in the screen saver desktop file using the syntax below.
+
+X-KDE-Category=Banners & Pictures
+X-KDE-Category=Desktop Distortions
+X-KDE-Category=Flying Things
+X-KDE-Category=Fractals
+X-KDE-Category=Gadgets & Simulations
+X-KDE-Category=Illusions of Depth
+X-KDE-Category=Miscellaneous
+X-KDE-Category=OpenGL Screen Savers
+X-KDE-Category=Rapid Motion
+X-KDE-Category=Visit to Flatland
diff --git a/kcontrol/screensaver/configure.in.in b/kcontrol/screensaver/configure.in.in
new file mode 100644
index 000000000..3ea3b292d
--- /dev/null
+++ b/kcontrol/screensaver/configure.in.in
@@ -0,0 +1,8 @@
+AC_HAVE_GL(
+ [
+ AC_CHECK_LIB(GL,glXChooseVisual,
+ [
+ AC_DEFINE(HAVE_GLXCHOOSEVISUAL, 1, [Define if you have glXChooseVisual()])
+ ])
+ ],[]
+ )
diff --git a/kcontrol/screensaver/kssmonitor.h b/kcontrol/screensaver/kssmonitor.h
new file mode 100644
index 000000000..72122e979
--- /dev/null
+++ b/kcontrol/screensaver/kssmonitor.h
@@ -0,0 +1,15 @@
+#ifndef KSSMONITOR_H
+#define KSSMONITOR_H
+
+#include "kswidget.h"
+
+class KSSMonitor : public KSWidget
+{
+public:
+ KSSMonitor( QWidget *parent ) : KSWidget( parent ) {}
+
+ // we don't want no steenking palette change
+ virtual void setPalette( const QPalette & ) {}
+};
+
+#endif
diff --git a/kcontrol/screensaver/kswidget.cpp b/kcontrol/screensaver/kswidget.cpp
new file mode 100644
index 000000000..58f28ff31
--- /dev/null
+++ b/kcontrol/screensaver/kswidget.cpp
@@ -0,0 +1,71 @@
+#include <config.h>
+
+#include <kwin.h>
+#include "testwin.h"
+
+#ifdef HAVE_GLXCHOOSEVISUAL
+#include <GL/glx.h>
+#endif
+
+KSWidget::KSWidget( QWidget* parent, const char* name, int f )
+ : QXEmbed( parent, name, f ), colormap( None )
+{
+// use visual with support for double-buffering, for opengl
+// this code is duplicated in kdebase/kdesktop/lock/
+#ifdef HAVE_GLXCHOOSEVISUAL
+ Visual* visual = CopyFromParent;
+ XSetWindowAttributes attrs;
+ int flags = 0;
+ if( true /*mOpenGLVisual*/ )
+ {
+ static int attribs[][ 15 ] =
+ {
+ #define R GLX_RED_SIZE
+ #define G GLX_GREEN_SIZE
+ #define B GLX_BLUE_SIZE
+ { GLX_RGBA, R, 8, G, 8, B, 8, GLX_DEPTH_SIZE, 8, GLX_DOUBLEBUFFER, GLX_STENCIL_SIZE, 1, None },
+ { GLX_RGBA, R, 4, G, 4, B, 4, GLX_DEPTH_SIZE, 4, GLX_DOUBLEBUFFER, GLX_STENCIL_SIZE, 1, None },
+ { GLX_RGBA, R, 8, G, 8, B, 8, GLX_DEPTH_SIZE, 8, GLX_DOUBLEBUFFER, None },
+ { GLX_RGBA, R, 4, G, 4, B, 4, GLX_DEPTH_SIZE, 4, GLX_DOUBLEBUFFER, None },
+ { GLX_RGBA, R, 8, G, 8, B, 8, GLX_DEPTH_SIZE, 8, GLX_STENCIL_SIZE, 1, None },
+ { GLX_RGBA, R, 4, G, 4, B, 4, GLX_DEPTH_SIZE, 4, GLX_STENCIL_SIZE, 1, None },
+ { GLX_RGBA, R, 8, G, 8, B, 8, GLX_DEPTH_SIZE, 8, None },
+ { GLX_RGBA, R, 4, G, 4, B, 4, GLX_DEPTH_SIZE, 4, None },
+ { GLX_RGBA, GLX_DEPTH_SIZE, 8, GLX_DOUBLEBUFFER, GLX_STENCIL_SIZE, 1, None },
+ { GLX_RGBA, GLX_DEPTH_SIZE, 8, GLX_DOUBLEBUFFER, None },
+ { GLX_RGBA, GLX_DEPTH_SIZE, 8, GLX_STENCIL_SIZE, 1, None },
+ { GLX_RGBA, GLX_DEPTH_SIZE, 8, None }
+ #undef R
+ #undef G
+ #undef B
+ };
+ for( unsigned int i = 0;
+ i < sizeof( attribs ) / sizeof( attribs[ 0 ] );
+ ++i )
+ {
+ if( XVisualInfo* info = glXChooseVisual( x11Display(), x11Screen(), attribs[ i ] ))
+ {
+ visual = info->visual;
+ colormap = XCreateColormap( x11Display(), RootWindow( x11Display(), x11Screen()), visual, AllocNone );
+ attrs.colormap = colormap;
+ flags |= CWColormap;
+ XFree( info );
+ break;
+ }
+ }
+ }
+ Window w = XCreateWindow( x11Display(), parentWidget() ? parentWidget()->winId() : RootWindow( x11Display(), x11Screen()),
+ x(), y(), width(), height(), 0, x11Depth(), InputOutput, visual, flags, &attrs );
+ create( w );
+#endif
+}
+
+KSWidget::~KSWidget()
+{
+#ifdef HAVE_GLXCHOOSEVISUAL
+ if( colormap != None )
+ XFreeColormap( x11Display(), colormap );
+#endif
+}
+
+#include "kswidget.moc"
diff --git a/kcontrol/screensaver/kswidget.h b/kcontrol/screensaver/kswidget.h
new file mode 100644
index 000000000..56d731955
--- /dev/null
+++ b/kcontrol/screensaver/kswidget.h
@@ -0,0 +1,17 @@
+#ifndef KSWIDGET_H
+#define KSWIDGET_H
+
+#include <qxembed.h>
+#include <X11/X.h>
+
+class KSWidget : public QXEmbed
+{
+ Q_OBJECT
+public:
+ KSWidget( QWidget *parent = NULL, const char* name = NULL, int flags = 0 );
+ virtual ~KSWidget();
+private:
+ Colormap colormap;
+};
+
+#endif
diff --git a/kcontrol/screensaver/saverconfig.cpp b/kcontrol/screensaver/saverconfig.cpp
new file mode 100644
index 000000000..a32d61e0e
--- /dev/null
+++ b/kcontrol/screensaver/saverconfig.cpp
@@ -0,0 +1,38 @@
+#include <kdesktopfile.h>
+#include <klocale.h>
+
+#include "saverconfig.h"
+
+SaverConfig::SaverConfig()
+{
+}
+
+bool SaverConfig::read(const QString &file)
+{
+ KDesktopFile config(file, true);
+ if( !config.tryExec())
+ return false;
+ mExec = config.readPathEntry("Exec");
+ mName = config.readEntry("Name");
+ mCategory = i18n("Screen saver category", // Must be same in Makefile.am
+ config.readEntry("X-KDE-Category").utf8());
+
+ if (config.hasActionGroup("Setup"))
+ {
+ config.setActionGroup("Setup");
+ mSetup = config.readPathEntry("Exec");
+ }
+
+ if (config.hasActionGroup("InWindow"))
+ {
+ config.setActionGroup("InWindow");
+ mSaver = config.readPathEntry("Exec");
+ }
+
+ int indx = file.findRev('/');
+ if (indx >= 0) {
+ mFile = file.mid(indx+1);
+ }
+
+ return !mSaver.isEmpty();
+}
diff --git a/kcontrol/screensaver/saverconfig.h b/kcontrol/screensaver/saverconfig.h
new file mode 100644
index 000000000..1327dfdaa
--- /dev/null
+++ b/kcontrol/screensaver/saverconfig.h
@@ -0,0 +1,29 @@
+#ifndef SAVERCONFIG_H
+#define SAVERCONFIG_H
+
+#include <qstring.h>
+
+class SaverConfig
+{
+public:
+ SaverConfig();
+
+ bool read(const QString &file);
+
+ QString exec() const { return mExec; }
+ QString setup() const { return mSetup; }
+ QString saver() const { return mSaver; }
+ QString name() const { return mName; }
+ QString file() const { return mFile; }
+ QString category() const { return mCategory; }
+
+protected:
+ QString mExec;
+ QString mSetup;
+ QString mSaver;
+ QString mName;
+ QString mFile;
+ QString mCategory;
+};
+
+#endif
diff --git a/kcontrol/screensaver/saverlist.cpp b/kcontrol/screensaver/saverlist.cpp
new file mode 100644
index 000000000..6b27973e0
--- /dev/null
+++ b/kcontrol/screensaver/saverlist.cpp
@@ -0,0 +1,13 @@
+
+#include "saverlist.h"
+
+class SaverConfig;
+class QPtrCollection;
+
+int SaverList::compareItems(QPtrCollection::Item item1, QPtrCollection::Item item2)
+{
+ SaverConfig *s1 = (SaverConfig *)item1;
+ SaverConfig *s2 = (SaverConfig *)item2;
+
+ return s1->name().localeAwareCompare(s2->name());
+}
diff --git a/kcontrol/screensaver/saverlist.h b/kcontrol/screensaver/saverlist.h
new file mode 100644
index 000000000..e6f36be18
--- /dev/null
+++ b/kcontrol/screensaver/saverlist.h
@@ -0,0 +1,14 @@
+#ifndef SAVERLIST_H
+#define SAVERLIST_H
+
+#include <qptrlist.h>
+
+#include "saverconfig.h"
+
+class SaverList : public QPtrList<SaverConfig>
+{
+protected:
+ virtual int compareItems(QPtrCollection::Item item1, QPtrCollection::Item item2);
+};
+
+#endif
diff --git a/kcontrol/screensaver/screensaver.desktop b/kcontrol/screensaver/screensaver.desktop
new file mode 100644
index 000000000..faab59047
--- /dev/null
+++ b/kcontrol/screensaver/screensaver.desktop
@@ -0,0 +1,240 @@
+[Desktop Entry]
+Exec=kcmshell screensaver
+Icon=kscreensaver
+Type=Application
+DocPath=kcontrol/screensaver/index.html
+
+
+X-KDE-Library=screensaver
+X-KDE-FactoryName=screensaver
+X-KDE-ParentApp=kcontrol
+
+Name=Screen Saver
+Name[af]=Skerm Bewaarder
+Name[ar]=مدخِر الشاشة
+Name[be]=Зберагальнік экрана
+Name[bg]=Екранен предпазител
+Name[bn]=স্ক্রীন সেভার
+Name[br]=Damanter Skramm
+Name[bs]=Zaštita ekrana (screen saver)
+Name[ca]=Salvapantalles
+Name[cs]=Šetřič obrazovky
+Name[csb]=Wëgaszôcz ekranu
+Name[cy]=Arbedydd Sgrîn
+Name[da]=Pauseskærm
+Name[de]=Bildschirmschoner
+Name[el]=Προφύλαξη οθόνης
+Name[eo]=Ekrankurteno
+Name[es]=Salvapantallas
+Name[et]=Ekraanisäästja
+Name[eu]=Pantaila babeslea
+Name[fa]=محافظ صفحه نمایش
+Name[fi]=Näytönsäästäjä
+Name[fr]=Écran de veille
+Name[fy]=Skermbefeiliging
+Name[ga]=Spárálaí Scáileáin
+Name[gl]=Protector de Pantalla
+Name[he]=שומר מסך
+Name[hi]=स्क्रीन सेवर
+Name[hr]=Zaštita zaslona
+Name[hu]=Képernyővédők
+Name[is]=Skjásvæfur
+Name[it]=Salvaschermo
+Name[ja]=スクリーンセーバー
+Name[kk]=Экран қорғаушысы
+Name[km]=ធាតុ​សន្សំ​អេក្រង់
+Name[ko]=화면 보호기
+Name[lo]=ໂປຣແກຣມຮັກສາຫນ້າຈໍ
+Name[lt]=Ekrano užsklanda
+Name[lv]=Ekrāna saudzētāji
+Name[mk]=Екрански чувар
+Name[mn]=Дэлгэц гамнагч
+Name[mt]=Screen saver
+Name[nb]=Pauseskjerm
+Name[nds]=Pausschirm
+Name[ne]=स्क्रिनसेभर
+Name[nl]=Schermbeveiliging
+Name[nn]=Pauseskjerm
+Name[nso]=Seboloki sa Pontsho
+Name[pa]=ਸਕਰੀਨ-ਸੇਵਰ
+Name[pl]=Wygaszacz ekranu
+Name[pt]=Protector de Ecrã
+Name[pt_BR]=Protetor de Tela
+Name[ro]=Protecție de ecran
+Name[ru]=Хранитель экрана
+Name[rw]=Muzigama Mugaragaza
+Name[se]=Šearbmasiestejeaddji
+Name[sk]=Šetrič obrazovky
+Name[sl]=Ohranjevalnik zaslona
+Name[sr]=Чувар екрана
+Name[sr@Latn]=Čuvar ekrana
+Name[ss]=Sigcini-skrini
+Name[sv]=Skärmsläckare
+Name[ta]=திரைக் காப்பு
+Name[te]=స్క్రీన్ సేవర్
+Name[tg]=Ноҷи парда
+Name[th]=โปรแกรมรักษาหน้าจอ
+Name[tr]=Ekran Koruyucusu
+Name[tt]=Küräk Saqlağıç
+Name[uk]=Зберігач екрана
+Name[uz]=Ekran saqlovchisi
+Name[uz@cyrillic]=Экран сақловчиси
+Name[ven]=Tshivhulungi tsha tshikirini
+Name[vi]=Bảo vệ Màn hình
+Name[wa]=Sipårgneu di waitroûle
+Name[xh]=Umgcini Wekhusi
+Name[zh_CN]=屏幕保护程序
+Name[zh_TW]=螢幕保護程式
+Name[zu]=Umgcini skrini
+
+Comment=Screen Saver Settings
+Comment[af]=Skerm Bewaarder Instellings
+Comment[ar]=تعيينات مدخِر الشاشة
+Comment[be]=Настаўленні ахоўніка экрана
+Comment[bg]=Настройване предпазителя на екрана
+Comment[bn]=স্ক্রীন সেভার সেটিংস
+Comment[br]=Kefluniadur an Damanter Skramm
+Comment[bs]=Postavke screen savera
+Comment[ca]=Arranjament del salvapantalles
+Comment[cs]=Nastavení šetřiče obrazovky
+Comment[csb]=Nsatôw wëgaszôcza ekranu
+Comment[cy]=Gosodiadau Arbedydd Sgrîn
+Comment[da]=Opsætning af pauseskærm
+Comment[de]=Einstellungen für Bildschirmschoner
+Comment[el]=Ρυθμίσεις προφύλαξης οθόνης
+Comment[eo]=Agordo de la ekrankurteno
+Comment[es]=Preferencias del salvapantallas
+Comment[et]=Ekraanisäästja seadistused
+Comment[eu]=Pantaila babeslearen ezarpenak
+Comment[fa]=تنظیمات محافظ صفحه نمایش
+Comment[fi]=Näytönsäästäjän asetukset
+Comment[fr]=Configuration de l'écran de veille
+Comment[fy]=Skermbefeiliging ynstelle
+Comment[ga]=Socruithe na Spárálaithe Scáileáin
+Comment[gl]=Opcións do Protector de Pantalla
+Comment[he]=שינוי הגדרות שומר המסך
+Comment[hi]=स्क्रीन सेवर विन्यास
+Comment[hr]=Postavke zaštite zaslona
+Comment[hu]=A képernyővédő beállításai
+Comment[is]=Stillingar skjásvæfu
+Comment[it]=Impostazioni salvaschermo
+Comment[ja]=スクリーンセーバーの設定
+Comment[ka]=Screen Saver-ის კონფიგურაცია
+Comment[kk]=Экран қорғаушысының параметрлері
+Comment[km]=ការ​កំណត់​ធាតុ​សន្សំ​អេក្រង់
+Comment[ko]=화면 보호기 설정
+Comment[lo]=ຕົວຢ່າງໂປຣແກຣມຮັກສາຫນ້າຈໍ
+Comment[lt]=Ekrano užsklandos nustatymai
+Comment[lv]=Ekrāna saudzētāju parametri
+Comment[mk]=Поставувања на екранскиот чувар
+Comment[mn]=Дэлгэц гамнагчийн тохируулга
+Comment[ms]=Seting Screen Saver
+Comment[mt]=Setings tal-iscreensaver
+Comment[nb]=Tilpasning av pauseskjerm
+Comment[nds]=Instellen för den Pausschirm
+Comment[ne]=स्क्रिनसेभर सेटिङ
+Comment[nl]=Schermbeveiliging instellen
+Comment[nn]=Innstillingar for pauseskjerm
+Comment[nso]=Dipeakanyo tsa Seboloki sa Pontsho
+Comment[pa]=ਸਕਰੀਨ-ਸੇਵਰ (ਸਕਰੀਨ-ਸੇਵਰ) ਸੈਟਿੰਗ
+Comment[pl]=Ustawienia wygaszacza ekranu
+Comment[pt]=Configuração do Protector de Ecrã
+Comment[pt_BR]=Configurações do Protetor de Tela
+Comment[ro]=Configurează setările pentru protecția de ecran
+Comment[ru]=Настройка хранителя экрана
+Comment[rw]=Amagenamiterere Muzigama Mugaragaza
+Comment[se]=Šearbmasiestejeaddji heivehusat
+Comment[sk]=Nastavenie šetriča obrazovky
+Comment[sl]=Nastavitve za ohranjevalnik zaslona
+Comment[sr]=Поставке чувара екрана
+Comment[sr@Latn]=Postavke čuvara ekrana
+Comment[ss]=Kuhleleka kwesigcini-skrini
+Comment[sv]=Anpassa skärmsläckare
+Comment[ta]=திரை காப்பு அமைப்புகள்
+Comment[te]=స్క్రీన్ సేవర్ అమరికలు
+Comment[tg]=Танзимоти ноҷи парда
+Comment[th]=ตั้งค่าโปรแกรมรักษาหน้าจอ
+Comment[tr]=Ekran Koruyucusu Ayarları
+Comment[tt]=Küräk Saqlağıçın Caylaw
+Comment[uk]=Налаштування зберігача екрана
+Comment[uz]=Ekran saqlovchisining moslamalari
+Comment[uz@cyrillic]=Экран сақловчисининг мосламалари
+Comment[ven]=Mavhekanyele a tshivhulungo tsha tshikirini
+Comment[vi]=Thiết lập Trình bảo vệ Màn hình
+Comment[wa]=Apontiaedjes do spårgneu di waitroûle
+Comment[xh]=Izicwangciso Zomgcini Wekhusi
+Comment[zh_CN]=屏幕保护程序设置
+Comment[zh_TW]=螢幕保護程式設定
+Comment[zu]=Izilungiselelo Zomgcini skrini
+
+
+Keywords=screensavers,Priority
+Keywords[ar]=مدخري الشاشة,الأولوية
+Keywords[az]=ekran qoruyucular,Üstünlük,ekran qoruyucusu,ekran qoruyucuları
+Keywords[be]=Зберагальнік экрану.Прыярытэт,screensavers,Priority
+Keywords[bg]=предпазител, екран, приоритет, screensavers, Priority
+Keywords[ca]=salvapantalles,Prioritat
+Keywords[cs]=Šetřiče obrazovky,Priorita
+Keywords[csb]=wëgaszaczë ekranu,prioritet
+Keywords[cy]=arbedyddion sgrîn,Blaenoriaeth
+Keywords[da]=pauseskærme,Prioritet
+Keywords[de]=Bildschirmschoner,Priorität
+Keywords[el]=προφύλαξη οθόνης,Προτεραιότητα
+Keywords[eo]=ekrano,kurteno,prioritato
+Keywords[es]=salvapantallas,Prioridad
+Keywords[et]=ekraanisäästjad,prioriteet
+Keywords[eu]=pantaila babesleak,lehentasuna
+Keywords[fa]=محافظهای صفحه نمایش، اولویت
+Keywords[fi]=näytönsäästäjät,prioriteetti
+Keywords[fr]=écrans de veille,priorité,économiseur
+Keywords[fy]=screensavers,skermbefeiliging,prioriteit,skermferskoatteling
+Keywords[ga]=spárálaithe scáileáin,tosaíocht
+Keywords[gl]=protectores de pantalla,Prioridade
+Keywords[he]=שומרי מסך,עדיפות, screensavers,Priority
+Keywords[hi]=स्क्रीन-सेवर्स,प्राथमिकता
+Keywords[hr]=screensavers,Priority,zaštita zaslona,prioritet
+Keywords[hu]=képernyővédők,prioritás
+Keywords[id]=screensavers,Prioritas
+Keywords[is]=skjásvæfa,forgangur
+Keywords[it]=salvaschermi,priorità
+Keywords[ja]=スクリーンセーバー,優先度
+Keywords[km]=ធាតុ​សន្សំ​អេក្រង់,អាទិភាព
+Keywords[lo]=ຄວາມສຳຄັນຂອງໂປຣແກຣມຮັກສາຈໍພາບ
+Keywords[lt]=ekrano užsklanda,ekrano užsklandos,Pirmenybė
+Keywords[lv]=ekrāna saudzētāji,Prioritāte
+Keywords[mk]=screensavers,Priority,екран,екрански чувар,приоритет
+Keywords[mn]=Дэлгэц гамнагч,Давуу эрх
+Keywords[ms]=gantian skrin, Keutamaan
+Keywords[nb]=skjermbeskyttere,pauseskjerme,prioritet
+Keywords[nds]=screensavers,Pausschirmen,Prioriteet
+Keywords[ne]=स्क्रिनसेभर, प्राथमिकता
+Keywords[nl]=screensavers,schermbeveiliging,prioriteit,schermvergrendeling
+Keywords[nn]=pauseskjerm,prioritet
+Keywords[nso]=diboloki tsa pontsho,Kgethokgolo
+Keywords[pa]=ਸਕਰੀਨ-ਸੇਵਰ,ਦਰਜਾ
+Keywords[pl]=wygaszacze ekranu,priorytet
+Keywords[pt]=protectores de ecrã,prioridade
+Keywords[pt_BR]=protetores de tela,prioridade
+Keywords[ro]=protecție de ecran,prioritate
+Keywords[rw]=MuzigamaMugaragaza,Uburenganzira
+Keywords[se]=šearbmasiestejeaddji,ovdavuorru
+Keywords[sk]=Šetriče obrazovky, Priorita
+Keywords[sl]=ohranjevalniki zaslona,prednost
+Keywords[sr]=screensavers,Priority,чувари екрана,приоритет
+Keywords[sr@Latn]=screensavers,Priority,čuvari ekrana,prioritet
+Keywords[sv]=skärmsläckare,Prioritet
+Keywords[ta]=திரைக்காப்பு, முக்கியத்துவம்
+Keywords[th]=ความสำคัญ,โปรแกรมรักษาจอภาพ
+Keywords[tr]=ekran koruyucular,Öncelik,ekran koruyucusu,ekran koruyucuları
+Keywords[uk]=зберігачі екрана,пріоритет
+Keywords[uz]=ekran saqlovchilari,Muhimlik darajasi
+Keywords[uz@cyrillic]=экран сақловчилари,Муҳимлик даражаси
+Keywords[ven]=Tshifhatuwo tsha khomupwutha,Zwithogomelwaho
+Keywords[vi]=bảo vệ màn hình,Ưu tiên
+Keywords[wa]=sipårgneu di waitroûle,prumiristé
+Keywords[xh]=abagcini bekhusi,Ukubaluleka
+Keywords[zh_CN]=screensavers,Priority,优先级,屏幕保护程序
+Keywords[zh_TW]=screensavers,Priority,螢幕保護程式,優先權
+Keywords[zu]=abagcini zikrini,Ukubaluleka
+
+Categories=Qt;KDE;X-KDE-settings-looknfeel;
diff --git a/kcontrol/screensaver/scrnsave.cpp b/kcontrol/screensaver/scrnsave.cpp
new file mode 100644
index 000000000..a40c51919
--- /dev/null
+++ b/kcontrol/screensaver/scrnsave.cpp
@@ -0,0 +1,862 @@
+//-----------------------------------------------------------------------------
+//
+// KDE Display screen saver setup module
+//
+// Copyright (c) Martin R. Jones 1996,1999,2002
+//
+// Converted to a kcc module by Matthias Hoelzer 1997
+//
+
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <unistd.h>
+
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include <qbuttongroup.h>
+#include <qcheckbox.h>
+#include <qheader.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlistview.h>
+#include <qpushbutton.h>
+#include <qslider.h>
+#include <qtimer.h>
+#include <qwhatsthis.h>
+
+#include <dcopclient.h>
+
+#include <kaboutdata.h>
+#include <kapplication.h>
+#include <kdebug.h>
+#include <kdialog.h>
+#include <kdialogbase.h>
+#include <kgenericfactory.h>
+#include <kiconloader.h>
+#include <knuminput.h>
+#include <kprocess.h>
+#include <kservicegroup.h>
+#include <kstandarddirs.h>
+
+#include <X11/Xlib.h>
+
+#include "scrnsave.h"
+
+#include <fixx11h.h>
+
+template class QPtrList<SaverConfig>;
+
+const uint widgetEventMask = // X event mask
+(uint)(
+ ExposureMask |
+ PropertyChangeMask |
+ StructureNotifyMask
+ );
+
+//===========================================================================
+// DLL Interface for kcontrol
+typedef KGenericFactory<KScreenSaver, QWidget > KSSFactory;
+K_EXPORT_COMPONENT_FACTORY (kcm_screensaver, KSSFactory("kcmscreensaver") )
+
+
+static QString findExe(const QString &exe) {
+ QString result = locate("exe", exe);
+ if (result.isEmpty())
+ result = KStandardDirs::findExe(exe);
+ return result;
+}
+
+KScreenSaver::KScreenSaver(QWidget *parent, const char *name, const QStringList&)
+ : KCModule(KSSFactory::instance(), parent, name)
+{
+ mSetupProc = 0;
+ mPreviewProc = 0;
+ mTestWin = 0;
+ mTestProc = 0;
+ mPrevSelected = -2;
+ mMonitor = 0;
+ mTesting = false;
+
+ // Add non-KDE path
+ KGlobal::dirs()->addResourceType("scrsav",
+ KGlobal::dirs()->kde_default("apps") +
+ "apps/ScreenSavers/");
+
+ setQuickHelp( i18n("<h1>Screen Saver</h1> This module allows you to enable and"
+ " configure a screen saver. Note that you can enable a screen saver"
+ " even if you have power saving features enabled for your display.<p>"
+ " Besides providing an endless variety of entertainment and"
+ " preventing monitor burn-in, a screen saver also gives you a simple"
+ " way to lock your display if you are going to leave it unattended"
+ " for a while. If you want the screen saver to lock the session, make sure you enable"
+ " the \"Require password\" feature of the screen saver; if you do not, you can still"
+ " explicitly lock the session using the desktop's \"Lock Session\" action."));
+
+ setButtons( KCModule::Help | KCModule::Default | KCModule::Apply );
+
+ // Add KDE specific screensaver path
+ QString relPath="System/ScreenSavers/";
+ KServiceGroup::Ptr servGroup = KServiceGroup::baseGroup( "screensavers" );
+ if (servGroup)
+ {
+ relPath=servGroup->relPath();
+ kdDebug() << "relPath=" << relPath << endl;
+ }
+
+ KGlobal::dirs()->addResourceType("scrsav",
+ KGlobal::dirs()->kde_default("apps") +
+ relPath);
+
+ readSettings( false );
+
+ mSetupProc = new KProcess;
+ connect(mSetupProc, SIGNAL(processExited(KProcess *)),
+ this, SLOT(slotSetupDone(KProcess *)));
+
+ mPreviewProc = new KProcess;
+ connect(mPreviewProc, SIGNAL(processExited(KProcess *)),
+ this, SLOT(slotPreviewExited(KProcess *)));
+
+ QBoxLayout *topLayout = new QHBoxLayout(this, 0, KDialog::spacingHint());
+
+ // left column
+ QVBoxLayout *leftColumnLayout =
+ new QVBoxLayout(topLayout, KDialog::spacingHint());
+ QBoxLayout *vLayout =
+ new QVBoxLayout(leftColumnLayout, KDialog::spacingHint());
+
+ mSaverGroup = new QGroupBox(i18n("Screen Saver"), this );
+ mSaverGroup->setColumnLayout( 0, Qt::Horizontal );
+ vLayout->addWidget(mSaverGroup);
+ vLayout->setStretchFactor( mSaverGroup, 10 );
+ QBoxLayout *groupLayout = new QVBoxLayout( mSaverGroup->layout(),
+ KDialog::spacingHint() );
+
+ mSaverListView = new QListView( mSaverGroup );
+ mSaverListView->setMinimumHeight( 120 );
+ mSaverListView->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
+ mSaverListView->addColumn("");
+ mSaverListView->header()->hide();
+ mSelected = -1;
+ groupLayout->addWidget( mSaverListView, 10 );
+ connect( mSaverListView, SIGNAL(doubleClicked ( QListViewItem *)), this, SLOT( slotSetup()));
+ QWhatsThis::add( mSaverListView, i18n("Select the screen saver to use.") );
+
+ QBoxLayout* hlay = new QHBoxLayout(groupLayout, KDialog::spacingHint());
+ mSetupBt = new QPushButton( i18n("&Setup..."), mSaverGroup );
+ connect( mSetupBt, SIGNAL( clicked() ), SLOT( slotSetup() ) );
+ mSetupBt->setEnabled(false);
+ hlay->addWidget( mSetupBt );
+ QWhatsThis::add( mSetupBt, i18n("Configure the screen saver's options, if any.") );
+
+ mTestBt = new QPushButton( i18n("&Test"), mSaverGroup );
+ connect( mTestBt, SIGNAL( clicked() ), SLOT( slotTest() ) );
+ mTestBt->setEnabled(false);
+ hlay->addWidget( mTestBt );
+ QWhatsThis::add( mTestBt, i18n("Show a full screen preview of the screen saver.") );
+
+ mSettingsGroup = new QGroupBox( i18n("Settings"), this );
+ mSettingsGroup->setColumnLayout( 0, Qt::Vertical );
+ leftColumnLayout->addWidget( mSettingsGroup );
+ groupLayout = new QVBoxLayout( mSettingsGroup->layout(),
+ KDialog::spacingHint() );
+
+ mEnabledCheckBox = new QCheckBox(i18n(
+ "Start a&utomatically"), mSettingsGroup);
+ mEnabledCheckBox->setChecked(mEnabled);
+ QWhatsThis::add( mEnabledCheckBox, i18n(
+ "Automatically start the screen saver after a period of inactivity.") );
+ connect(mEnabledCheckBox, SIGNAL(toggled(bool)),
+ this, SLOT(slotEnable(bool)));
+ groupLayout->addWidget(mEnabledCheckBox);
+
+ QBoxLayout *hbox = new QHBoxLayout();
+ groupLayout->addLayout(hbox);
+ hbox->addSpacing(30);
+ mActivateLbl = new QLabel(i18n("After:"), mSettingsGroup);
+ mActivateLbl->setEnabled(mEnabled);
+ hbox->addWidget(mActivateLbl);
+ mWaitEdit = new QSpinBox(mSettingsGroup);
+ mWaitEdit->setSteps(1, 10);
+ mWaitEdit->setRange(1, INT_MAX);
+ mWaitEdit->setSuffix(i18n(" min"));
+ mWaitEdit->setValue(mTimeout/60);
+ mWaitEdit->setEnabled(mEnabled);
+ connect(mWaitEdit, SIGNAL(valueChanged(int)),
+ this, SLOT(slotTimeoutChanged(int)));
+ mActivateLbl->setBuddy(mWaitEdit);
+ hbox->addWidget(mWaitEdit);
+ hbox->addStretch(1);
+ QString wtstr = i18n(
+ "The period of inactivity "
+ "after which the screen saver should start.");
+ QWhatsThis::add( mActivateLbl, wtstr );
+ QWhatsThis::add( mWaitEdit, wtstr );
+
+ mLockCheckBox = new QCheckBox( i18n(
+ "&Require password to stop"), mSettingsGroup );
+ mLockCheckBox->setEnabled( mEnabled );
+ mLockCheckBox->setChecked( mLock );
+ connect( mLockCheckBox, SIGNAL( toggled( bool ) ),
+ this, SLOT( slotLock( bool ) ) );
+ groupLayout->addWidget(mLockCheckBox);
+ QWhatsThis::add( mLockCheckBox, i18n(
+ "Prevent potential unauthorized use by requiring a password"
+ " to stop the screen saver.") );
+ hbox = new QHBoxLayout();
+ groupLayout->addLayout(hbox);
+ hbox->addSpacing(30);
+ mLockLbl = new QLabel(i18n("After:"), mSettingsGroup);
+ mLockLbl->setEnabled(mEnabled && mLock);
+ QWhatsThis::add( mLockLbl, i18n(
+ "The amount of time, after the screen saver has started, to ask for the unlock password.") );
+ hbox->addWidget(mLockLbl);
+ mWaitLockEdit = new QSpinBox(mSettingsGroup);
+ mWaitLockEdit->setSteps(1, 10);
+ mWaitLockEdit->setRange(1, 300);
+ mWaitLockEdit->setSuffix(i18n(" sec"));
+ mWaitLockEdit->setValue(mLockTimeout/1000);
+ mWaitLockEdit->setEnabled(mEnabled && mLock);
+ if ( mWaitLockEdit->sizeHint().width() <
+ mWaitEdit->sizeHint().width() ) {
+ mWaitLockEdit->setFixedWidth( mWaitEdit->sizeHint().width() );
+ mWaitEdit->setFixedWidth( mWaitEdit->sizeHint().width() );
+ }
+ else {
+ mWaitEdit->setFixedWidth( mWaitLockEdit->sizeHint().width() );
+ mWaitLockEdit->setFixedWidth( mWaitLockEdit->sizeHint().width() );
+ }
+ connect(mWaitLockEdit, SIGNAL(valueChanged(int)),
+ this, SLOT(slotLockTimeoutChanged(int)));
+ mLockLbl->setBuddy(mWaitLockEdit);
+ hbox->addWidget(mWaitLockEdit);
+ hbox->addStretch(1);
+ QString wltstr = i18n(
+ "Choose the period "
+ "after which the display will be locked. ");
+ QWhatsThis::add( mLockLbl, wltstr );
+ QWhatsThis::add( mWaitLockEdit, wltstr );
+
+ // right column
+ QBoxLayout* rightColumnLayout =
+ new QVBoxLayout(topLayout, KDialog::spacingHint());
+
+ mMonitorLabel = new QLabel( this );
+ mMonitorLabel->setAlignment( AlignCenter );
+ mMonitorLabel->setPixmap( QPixmap(locate("data",
+ "kcontrol/pics/monitor.png")));
+ rightColumnLayout->addWidget(mMonitorLabel, 0);
+ QWhatsThis::add( mMonitorLabel, i18n("A preview of the selected screen saver.") );
+
+ QBoxLayout* advancedLayout = new QHBoxLayout( rightColumnLayout, 3 );
+ advancedLayout->addWidget( new QWidget( this ) );
+ QPushButton* advancedBt = new QPushButton(
+ i18n( "Advanced &Options" ), this, "advancedBtn" );
+ advancedBt->setSizePolicy( QSizePolicy(
+ QSizePolicy::Fixed, QSizePolicy::Fixed) );
+ connect( advancedBt, SIGNAL( clicked() ),
+ this, SLOT( slotAdvanced() ) );
+ advancedLayout->addWidget( advancedBt );
+ advancedLayout->addWidget( new QWidget( this ) );
+
+ rightColumnLayout->addStretch();
+
+ if (mImmutable)
+ {
+ setButtons(buttons() & ~Default);
+ mSettingsGroup->setEnabled(false);
+ mSaverGroup->setEnabled(false);
+ }
+
+ // finding the savers can take some time, so defer loading until
+ // we've started up.
+ mNumLoaded = 0;
+ mLoadTimer = new QTimer( this );
+ connect( mLoadTimer, SIGNAL(timeout()), SLOT(findSavers()) );
+ mLoadTimer->start( 100 );
+ mChanged = false;
+ emit changed(false);
+
+ KAboutData *about =
+ new KAboutData(I18N_NOOP("kcmscreensaver"), I18N_NOOP("KDE Screen Saver Control Module"),
+ 0, 0, KAboutData::License_GPL,
+ I18N_NOOP("(c) 1997-2002 Martin R. Jones\n"
+ "(c) 2003-2004 Chris Howells"));
+ about->addAuthor("Chris Howells", 0, "howells@kde.org");
+ about->addAuthor("Martin R. Jones", 0, "jones@kde.org");
+
+ setAboutData( about );
+
+ mSaverList.setAutoDelete(true);
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::resizeEvent( QResizeEvent * )
+{
+
+ if (mMonitor)
+ {
+ mMonitor->setGeometry( (mMonitorLabel->width()-200)/2+23,
+ (mMonitorLabel->height()-186)/2+14, 151, 115 );
+ }
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::mousePressEvent( QMouseEvent *)
+{
+ if ( mTesting )
+ slotStopTest();
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::keyPressEvent( QKeyEvent *)
+{
+ if ( mTesting )
+ slotStopTest();
+}
+//---------------------------------------------------------------------------
+//
+KScreenSaver::~KScreenSaver()
+{
+ if (mPreviewProc)
+ {
+ if (mPreviewProc->isRunning())
+ {
+ int pid = mPreviewProc->pid();
+ mPreviewProc->kill( );
+ waitpid(pid, (int *) 0,0);
+ }
+ delete mPreviewProc;
+ }
+
+ delete mTestProc;
+ delete mSetupProc;
+ delete mTestWin;
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::load()
+{
+ load( false );
+}
+
+void KScreenSaver::load( bool useDefaults )
+{
+ readSettings( useDefaults);
+
+//with the following line, the Test and Setup buttons are not enabled correctly
+//if no saver was selected, the "Reset" and the "Enable screensaver", it is only called when starting and when pressing reset, aleXXX
+// mSelected = -1;
+ int i = 0;
+ QListViewItem *selectedItem = 0;
+ for (SaverConfig* saver = mSaverList.first(); saver != 0; saver = mSaverList.next()) {
+ if (saver->file() == mSaver)
+ {
+ selectedItem = mSaverListView->findItem ( saver->name(), 0 );
+ if (selectedItem) {
+ mSelected = i;
+ break;
+ }
+ }
+ i++;
+ }
+ if ( selectedItem )
+ {
+ mSaverListView->setSelected( selectedItem, true );
+ mSaverListView->setCurrentItem( selectedItem );
+ slotScreenSaver( selectedItem );
+ }
+
+ updateValues();
+ mChanged = useDefaults;
+ emit changed( useDefaults );
+}
+
+//------------------------------------------------------------After---------------
+//
+void KScreenSaver::readSettings( bool useDefaults )
+{
+ KConfig *config = new KConfig( "kdesktoprc");
+
+ config->setReadDefaults( useDefaults );
+
+ mImmutable = config->groupIsImmutable("ScreenSaver");
+
+ config->setGroup( "ScreenSaver" );
+
+ mEnabled = config->readBoolEntry("Enabled", false);
+ mTimeout = config->readNumEntry("Timeout", 300);
+ mLockTimeout = config->readNumEntry("LockGrace", 60000);
+ mLock = config->readBoolEntry("Lock", false);
+ mSaver = config->readEntry("Saver");
+
+ if (mTimeout < 60) mTimeout = 60;
+ if (mLockTimeout < 0) mLockTimeout = 0;
+ if (mLockTimeout > 300000) mLockTimeout = 300000;
+
+ mChanged = false;
+ delete config;
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::updateValues()
+{
+ if (mEnabled)
+ {
+ mWaitEdit->setValue(mTimeout/60);
+ }
+ else
+ {
+ mWaitEdit->setValue(0);
+ }
+
+ mWaitLockEdit->setValue(mLockTimeout/1000);
+ mLockCheckBox->setChecked(mLock);
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::defaults()
+{
+ load( true );
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::save()
+{
+ if ( !mChanged )
+ return;
+
+ KConfig *config = new KConfig( "kdesktoprc");
+ config->setGroup( "ScreenSaver" );
+
+ config->writeEntry("Enabled", mEnabled);
+ config->writeEntry("Timeout", mTimeout);
+ config->writeEntry("LockGrace", mLockTimeout);
+ config->writeEntry("Lock", mLock);
+
+ if ( !mSaver.isEmpty() )
+ config->writeEntry("Saver", mSaver);
+ config->sync();
+ delete config;
+
+ // TODO (GJ): When you changed anything, these two lines will give a segfault
+ // on exit. I don't know why yet.
+
+ DCOPClient *client = kapp->dcopClient();
+ client->send("kdesktop", "KScreensaverIface", "configure()", "");
+
+ mChanged = false;
+ emit changed(false);
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::findSavers()
+{
+ if ( !mNumLoaded ) {
+ mSaverFileList = KGlobal::dirs()->findAllResources("scrsav",
+ "*.desktop", false, true);
+ new QListViewItem ( mSaverListView, i18n("Loading...") );
+ if ( mSaverFileList.isEmpty() )
+ mLoadTimer->stop();
+ else
+ mLoadTimer->start( 50 );
+ }
+
+ for ( int i = 0; i < 5 &&
+ (unsigned)mNumLoaded < mSaverFileList.count();
+ i++, mNumLoaded++ ) {
+ QString file = mSaverFileList[mNumLoaded];
+ SaverConfig *saver = new SaverConfig;
+ if (saver->read(file)) {
+ mSaverList.append(saver);
+ } else
+ delete saver;
+ }
+
+ if ( (unsigned)mNumLoaded == mSaverFileList.count() ) {
+ QListViewItem *selectedItem = 0;
+ int categoryCount = 0;
+ int indx = 0;
+
+ mLoadTimer->stop();
+ delete mLoadTimer;
+ mSaverList.sort();
+
+ mSelected = -1;
+ mSaverListView->clear();
+ for ( SaverConfig *s = mSaverList.first(); s != 0; s = mSaverList.next())
+ {
+ QListViewItem *item;
+ if (s->category().isEmpty())
+ item = new QListViewItem ( mSaverListView, s->name(), "2" + s->name() );
+ else
+ {
+ QListViewItem *categoryItem = mSaverListView->findItem( s->category(), 0 );
+ if ( !categoryItem ) {
+ categoryItem = new QListViewItem ( mSaverListView, s->category(), "1" + s->category() );
+ categoryItem->setPixmap ( 0, SmallIcon ( "kscreensaver" ) );
+ }
+ item = new QListViewItem ( categoryItem, s->name(), s->name() );
+ categoryCount++;
+ }
+ if (s->file() == mSaver) {
+ mSelected = indx;
+ selectedItem = item;
+ }
+ indx++;
+ }
+
+ // Delete categories with only one item
+ QListViewItemIterator it ( mSaverListView );
+ for ( ; it.current(); it++ )
+ if ( it.current()->childCount() == 1 ) {
+ QListViewItem *item = it.current()->firstChild();
+ it.current()->takeItem( item );
+ mSaverListView->insertItem ( item );
+ delete it.current();
+ categoryCount--;
+ }
+
+ mSaverListView->setRootIsDecorated ( categoryCount > 0 );
+ mSaverListView->setSorting ( 1 );
+
+ if ( mSelected > -1 )
+ {
+ mSaverListView->setSelected(selectedItem, true);
+ mSaverListView->setCurrentItem(selectedItem);
+ mSaverListView->ensureItemVisible(selectedItem);
+ mSetupBt->setEnabled(!mSaverList.at(mSelected)->setup().isEmpty());
+ mTestBt->setEnabled(true);
+ }
+
+ connect( mSaverListView, SIGNAL( currentChanged( QListViewItem * ) ),
+ this, SLOT( slotScreenSaver( QListViewItem * ) ) );
+
+ setMonitor();
+ }
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::setMonitor()
+{
+ if (mPreviewProc->isRunning())
+ // CC: this will automatically cause a "slotPreviewExited"
+ // when the viewer exits
+ mPreviewProc->kill();
+ else
+ slotPreviewExited(mPreviewProc);
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::slotPreviewExited(KProcess *)
+{
+ // Ugly hack to prevent continual respawning of savers that crash
+ if (mSelected == mPrevSelected)
+ return;
+
+ if ( mSaverList.isEmpty() ) // safety check
+ return;
+
+ // Some xscreensaver hacks do something nasty to the window that
+ // requires a new one to be created (or proper investigation of the
+ // problem).
+ delete mMonitor;
+
+ mMonitor = new KSSMonitor(mMonitorLabel);
+ mMonitor->setBackgroundColor(black);
+ mMonitor->setGeometry((mMonitorLabel->width()-200)/2+23,
+ (mMonitorLabel->height()-186)/2+14, 151, 115);
+ mMonitor->show();
+ // So that hacks can XSelectInput ButtonPressMask
+ XSelectInput(qt_xdisplay(), mMonitor->winId(), widgetEventMask );
+
+ if (mSelected >= 0) {
+ mPreviewProc->clearArguments();
+
+ QString saver = mSaverList.at(mSelected)->saver();
+ QTextStream ts(&saver, IO_ReadOnly);
+
+ QString word;
+ ts >> word;
+ QString path = findExe(word);
+
+ if (!path.isEmpty())
+ {
+ (*mPreviewProc) << path;
+
+ while (!ts.atEnd())
+ {
+ ts >> word;
+ if (word == "%w")
+ {
+ word = word.setNum(mMonitor->winId());
+ }
+ (*mPreviewProc) << word;
+ }
+
+ mPreviewProc->start();
+ }
+ }
+
+ mPrevSelected = mSelected;
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::slotEnable(bool e)
+{
+ mEnabled = e;
+ mActivateLbl->setEnabled( e );
+ mWaitEdit->setEnabled( e );
+ mLockCheckBox->setEnabled( e );
+ mLockLbl->setEnabled( e && mLock );
+ mWaitLockEdit->setEnabled( e && mLock );
+ mChanged = true;
+ emit changed(true);
+}
+
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::slotScreenSaver(QListViewItem *item)
+{
+ if (!item)
+ return;
+
+ int i = 0, indx = -1;
+ for (SaverConfig* saver = mSaverList.first(); saver != 0; saver = mSaverList.next()) {
+ if ( item->parent() )
+ {
+ if ( item->parent()->text( 0 ) == saver->category() && saver->name() == item->text (0))
+ {
+ indx = i;
+ break;
+ }
+ }
+ else
+ {
+ if ( saver->name() == item->text (0) )
+ {
+ indx = i;
+ break;
+ }
+ }
+ i++;
+ }
+ if (indx == -1) {
+ mSelected = -1;
+ return;
+ }
+
+ bool bChanged = (indx != mSelected);
+
+ if (!mSetupProc->isRunning())
+ mSetupBt->setEnabled(!mSaverList.at(indx)->setup().isEmpty());
+ mTestBt->setEnabled(true);
+ mSaver = mSaverList.at(indx)->file();
+
+ mSelected = indx;
+ setMonitor();
+ if (bChanged)
+ {
+ mChanged = true;
+ emit changed(true);
+ }
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::slotSetup()
+{
+ if ( mSelected < 0 )
+ return;
+
+ if (mSetupProc->isRunning())
+ return;
+
+ mSetupProc->clearArguments();
+
+ QString saver = mSaverList.at(mSelected)->setup();
+ if( saver.isEmpty())
+ return;
+ QTextStream ts(&saver, IO_ReadOnly);
+
+ QString word;
+ ts >> word;
+ bool kxsconfig = word == "kxsconfig";
+ QString path = findExe(word);
+
+ if (!path.isEmpty())
+ {
+ (*mSetupProc) << path;
+
+ // Add caption and icon to about dialog
+ if (!kxsconfig) {
+ word = "-caption";
+ (*mSetupProc) << word;
+ word = mSaverList.at(mSelected)->name();
+ (*mSetupProc) << word;
+ word = "-icon";
+ (*mSetupProc) << word;
+ word = "kscreensaver";
+ (*mSetupProc) << word;
+ }
+
+ while (!ts.atEnd())
+ {
+ ts >> word;
+ (*mSetupProc) << word;
+ }
+
+ // Pass translated name to kxsconfig
+ if (kxsconfig) {
+ word = mSaverList.at(mSelected)->name();
+ (*mSetupProc) << word;
+ }
+
+ mSetupBt->setEnabled( false );
+ kapp->flushX();
+
+ mSetupProc->start();
+ }
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::slotAdvanced()
+{
+ KScreenSaverAdvancedDialog dlg( topLevelWidget() );
+ if ( dlg.exec() ) {
+ mChanged = true;
+ emit changed(true);
+ }
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::slotTest()
+{
+ if ( mSelected == -1 )
+ return;
+
+ if (!mTestProc) {
+ mTestProc = new KProcess;
+ }
+
+ mTestProc->clearArguments();
+ QString saver = mSaverList.at(mSelected)->saver();
+ QTextStream ts(&saver, IO_ReadOnly);
+
+ QString word;
+ ts >> word;
+ QString path = findExe(word);
+
+ if (!path.isEmpty())
+ {
+ (*mTestProc) << path;
+
+ if (!mTestWin)
+ {
+ mTestWin = new TestWin();
+ mTestWin->setBackgroundMode(QWidget::NoBackground);
+ mTestWin->setGeometry(0, 0, kapp->desktop()->width(),
+ kapp->desktop()->height());
+ }
+
+ mTestWin->show();
+ mTestWin->raise();
+ mTestWin->setFocus();
+ // So that hacks can XSelectInput ButtonPressMask
+ XSelectInput(qt_xdisplay(), mTestWin->winId(), widgetEventMask );
+
+ grabMouse();
+ grabKeyboard();
+
+ mTestBt->setEnabled( FALSE );
+ mPreviewProc->kill();
+
+ while (!ts.atEnd())
+ {
+ ts >> word;
+ if (word == "%w")
+ {
+ word = word.setNum(mTestWin->winId());
+ }
+ (*mTestProc) << word;
+ }
+
+ mTesting = true;
+ mTestProc->start(KProcess::NotifyOnExit);
+ }
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::slotStopTest()
+{
+ if (mTestProc->isRunning()) {
+ mTestProc->kill();
+ }
+ releaseMouse();
+ releaseKeyboard();
+ mTestWin->hide();
+ mTestBt->setEnabled(true);
+ mPrevSelected = -1;
+ setMonitor();
+ mTesting = false;
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::slotTimeoutChanged(int to )
+{
+ mTimeout = to * 60;
+ mChanged = true;
+ emit changed(true);
+}
+
+//-----------------------------------------------------------------------
+//
+void KScreenSaver::slotLockTimeoutChanged(int to )
+{
+ mLockTimeout = to * 1000;
+ mChanged = true;
+ emit changed(true);
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::slotLock( bool l )
+{
+ mLock = l;
+ mLockLbl->setEnabled( l );
+ mWaitLockEdit->setEnabled( l );
+ mChanged = true;
+ emit changed(true);
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::slotSetupDone(KProcess *)
+{
+ mPrevSelected = -1; // see ugly hack in slotPreviewExited()
+ setMonitor();
+ mSetupBt->setEnabled( true );
+ emit changed(true);
+}
+
+#include "scrnsave.moc"
diff --git a/kcontrol/screensaver/scrnsave.h b/kcontrol/screensaver/scrnsave.h
new file mode 100644
index 000000000..28d05b73c
--- /dev/null
+++ b/kcontrol/screensaver/scrnsave.h
@@ -0,0 +1,113 @@
+//-----------------------------------------------------------------------------
+//
+// KDE Display screen saver setup module
+//
+// Copyright (c) Martin R. Jones 1996
+// Copyright (C) Chris Howells 2004
+//
+
+#ifndef __SCRNSAVE_H__
+#define __SCRNSAVE_H__
+
+#include <qwidget.h>
+#include <kcmodule.h>
+
+#include "kssmonitor.h"
+#include "saverconfig.h"
+#include "testwin.h"
+#include "advanceddialog.h"
+#include "kssmonitor.h"
+#include "saverlist.h"
+
+class QTimer;
+class QSpinBox;
+class QSlider;
+class QCheckBox;
+class QLabel;
+class QListView;
+class QListViewItem;
+class QPushButton;
+class KIntNumInput;
+class KProcess;
+
+//===========================================================================
+class KScreenSaver : public KCModule
+{
+ Q_OBJECT
+public:
+ KScreenSaver(QWidget *parent, const char *name, const QStringList &);
+ ~KScreenSaver();
+
+ virtual void load();
+ virtual void load(bool useDefaults);
+ virtual void save();
+ virtual void defaults();
+
+ void updateValues();
+ void readSettings(bool useDefaults);
+
+protected slots:
+ void slotEnable( bool );
+ void slotScreenSaver( QListViewItem* );
+ void slotSetup();
+ void slotAdvanced();
+ void slotTest();
+ void slotStopTest();
+ void slotTimeoutChanged( int );
+ void slotLockTimeoutChanged( int );
+ void slotLock( bool );
+ void slotSetupDone(KProcess*);
+ // when selecting a new screensaver, the old preview will
+ // be killed. -- This callback is responsible for restarting the
+ // new preview
+ void slotPreviewExited(KProcess *);
+ void findSavers();
+
+protected:
+ void writeSettings();
+ void getSaverNames();
+ void setMonitor();
+ void setDefaults();
+ void resizeEvent( QResizeEvent * );
+ void mousePressEvent(QMouseEvent *);
+ void keyPressEvent(QKeyEvent *);
+
+protected:
+ TestWin *mTestWin;
+ KProcess *mTestProc;
+ KProcess *mSetupProc;
+ KProcess *mPreviewProc;
+ KSSMonitor *mMonitor;
+ QPushButton *mSetupBt;
+ QPushButton *mTestBt;
+ QListView *mSaverListView;
+ QSpinBox *mWaitEdit;
+ QSpinBox *mWaitLockEdit;
+ QCheckBox *mLockCheckBox;
+ QCheckBox *mStarsCheckBox;
+ QCheckBox *mEnabledCheckBox;
+ QLabel *mMonitorLabel;
+ QLabel *mActivateLbl;
+ QLabel *mLockLbl;
+ QStringList mSaverFileList;
+ SaverList mSaverList;
+ QTimer *mLoadTimer;
+ QGroupBox *mSaverGroup;
+ QGroupBox *mSettingsGroup;
+
+ int mSelected;
+ int mPrevSelected;
+ int mNumLoaded;
+ bool mChanged;
+ bool mTesting;
+
+ // Settings
+ int mTimeout;
+ int mLockTimeout;
+ bool mLock;
+ bool mEnabled;
+ QString mSaver;
+ bool mImmutable;
+};
+
+#endif
diff --git a/kcontrol/screensaver/testwin.cpp b/kcontrol/screensaver/testwin.cpp
new file mode 100644
index 000000000..a5d316be5
--- /dev/null
+++ b/kcontrol/screensaver/testwin.cpp
@@ -0,0 +1,13 @@
+#include <kwin.h>
+#include "testwin.h"
+
+class QXEmbed;
+
+TestWin::TestWin()
+ : KSWidget(0, 0, WStyle_Customize | WStyle_NoBorder | WX11BypassWM )
+{
+ setFocusPolicy(StrongFocus);
+ KWin::setState( winId(), NET::StaysOnTop );
+}
+
+#include "testwin.moc"
diff --git a/kcontrol/screensaver/testwin.h b/kcontrol/screensaver/testwin.h
new file mode 100644
index 000000000..ff77b6b4d
--- /dev/null
+++ b/kcontrol/screensaver/testwin.h
@@ -0,0 +1,14 @@
+#ifndef TESTWIN_H
+#define TESTWIN_H
+
+#include "kswidget.h"
+
+class TestWin : public KSWidget
+{
+ Q_OBJECT
+public:
+ TestWin();
+};
+
+#endif
+