summaryrefslogtreecommitdiffstats
path: root/kcontrol/screensaver
diff options
context:
space:
mode:
Diffstat (limited to 'kcontrol/screensaver')
-rw-r--r--kcontrol/screensaver/CMakeLists.txt37
-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.cpp1019
-rw-r--r--kcontrol/screensaver/scrnsave.h131
-rw-r--r--kcontrol/screensaver/testwin.cpp13
-rw-r--r--kcontrol/screensaver/testwin.h14
19 files changed, 2327 insertions, 0 deletions
diff --git a/kcontrol/screensaver/CMakeLists.txt b/kcontrol/screensaver/CMakeLists.txt
new file mode 100644
index 000000000..bb6bd8bf0
--- /dev/null
+++ b/kcontrol/screensaver/CMakeLists.txt
@@ -0,0 +1,37 @@
+#################################################
+#
+# (C) 2010-2011 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}
+ ${TDE_INCLUDE_DIR}
+ ${TQT_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+)
+
+##### other data ################################
+
+install( FILES screensaver.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )
+
+
+##### kcm_screensaver (module) ##################
+
+tde_add_kpart( kcm_screensaver AUTOMOC
+ SOURCES
+ advanceddialogimpl.ui scrnsave.cpp testwin.cpp
+ saverlist.cpp saverconfig.cpp advanceddialog.cpp
+ kswidget.cpp
+ LINK tdeio-shared ${GL_LIBRARIES}
+ DESTINATION ${PLUGIN_INSTALL_DIR}
+)
diff --git a/kcontrol/screensaver/Makefile.am b/kcontrol/screensaver/Makefile.am
new file mode 100644
index 000000000..cf79d11b6
--- /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_TDESYCOCA) $(DPMSLIB) $(GLLIB)
+METASOURCES = AUTO
+
+noinst_HEADERS = scrnsave.h
+
+messages: rc.cpp
+ sed 's/X-TDE-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..7a28178d5
--- /dev/null
+++ b/kcontrol/screensaver/advanceddialog.cpp
@@ -0,0 +1,174 @@
+#include <tdelocale.h>
+#include <kstandarddirs.h>
+#include <tqcombobox.h>
+#include <kdebug.h>
+
+#include <tqwhatsthis.h>
+#include <tqstring.h>
+
+#include <config.h>
+
+#include "advanceddialog.h"
+#include "advanceddialogimpl.h"
+#include "stdlib.h"
+
+#include "advanceddialog.moc"
+
+KScreenSaverAdvancedDialog::KScreenSaverAdvancedDialog(TQWidget *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, TQT_SIGNAL(activated(int)),
+ this, TQT_SLOT(slotPriorityChanged(int)));
+
+ connect(dialog->qcbTopLeft, TQT_SIGNAL(activated(int)),
+ this, TQT_SLOT(slotChangeTopLeftCorner(int)));
+ connect(dialog->qcbTopRight, TQT_SIGNAL(activated(int)),
+ this, TQT_SLOT(slotChangeTopLeftCorner(int)));
+ connect(dialog->qcbBottomLeft, TQT_SIGNAL(activated(int)),
+ this, TQT_SLOT(slotChangeTopLeftCorner(int)));
+ connect(dialog->qcbBottomRight, TQT_SIGNAL(activated(int)),
+ this, TQT_SLOT(slotChangeTopLeftCorner(int)));
+
+#ifndef HAVE_SETPRIORITY
+ dialog->qgbPriority->setEnabled(false);
+#endif
+}
+
+void KScreenSaverAdvancedDialog::readSettings()
+{
+ TDEConfig *config = new TDEConfig("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)
+ {
+ TDEConfig *config = new TDEConfig("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(TQWidget *parent, const char *name) : AdvancedDialogImpl(parent, name)
+{
+ monitorLabel->setPixmap(TQPixmap(locate("data", "kcontrol/pics/monitor.png")));
+ TQWhatsThis::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>");
+ TQString 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>");
+ TQString 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>");
+ TQString 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>");
+ TQString 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>");
+ TQWhatsThis::add(qlTopLeft, qsTopLeft);
+ TQWhatsThis::add(qcbTopLeft, qsTopLeft);
+ TQWhatsThis::add(qlTopRight, qsTopRight);
+ TQWhatsThis::add(qcbTopRight, qsTopRight);
+ TQWhatsThis::add(qlBottomLeft, qsBottomLeft);
+ TQWhatsThis::add(qcbBottomLeft, qsBottomLeft);
+ TQWhatsThis::add(qlBottomRight, qsBottomRight);
+ TQWhatsThis::add(qcbBottomRight, qsBottomRight);
+}
+
+AdvancedDialog::~AdvancedDialog()
+{
+
+}
+
+void AdvancedDialog::setMode(TQComboBox *box, int i)
+{
+ box->setCurrentItem(i);
+}
+
+int AdvancedDialog::mode(TQComboBox *box)
+{
+ return box->currentItem();
+}
diff --git a/kcontrol/screensaver/advanceddialog.h b/kcontrol/screensaver/advanceddialog.h
new file mode 100644
index 000000000..87ee03a31
--- /dev/null
+++ b/kcontrol/screensaver/advanceddialog.h
@@ -0,0 +1,61 @@
+#ifndef ADVANCEDDIALOG_H
+#define ADVANCEDDIALOG_H
+
+#include <kdialogbase.h>
+#include <tqwidget.h>
+#include <tdeconfig.h>
+#include <tqlabel.h>
+#include <tqlayout.h>
+#include <tqwhatsthis.h>
+#include <tqgroupbox.h>
+#include <tqobject.h>
+#include <tqcheckbox.h>
+#include <tqslider.h>
+
+#include "advanceddialogimpl.h"
+
+class AdvancedDialog : public AdvancedDialogImpl
+{
+public:
+ AdvancedDialog(TQWidget *parent = 0, const char *name = 0);
+ ~AdvancedDialog();
+ void setMode(TQComboBox *box, int i);
+ int mode(TQComboBox *box);
+};
+
+/* =================================================================================================== */
+
+class KScreenSaverAdvancedDialog : public KDialogBase
+{
+ Q_OBJECT
+public:
+ KScreenSaverAdvancedDialog(TQWidget *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();
+
+ TQCheckBox *m_topLeftCorner;
+ TQCheckBox *m_bottomLeftCorner;
+ TQCheckBox *m_topRightCorner;
+ TQCheckBox *m_bottomRightCorner;
+ TQSlider *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..09def2a6f
--- /dev/null
+++ b/kcontrol/screensaver/advanceddialogimpl.ui
@@ -0,0 +1,397 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>AdvancedDialogImpl</class>
+<widget class="TQWidget">
+ <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="TQGroupBox" 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="TQComboBox" 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="TQGroupBox" 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="TQLabel" row="3" column="0" rowspan="2" colspan="2">
+ <property name="name">
+ <cstring>qlMonitorLabel</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget" 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="TQLayoutWidget">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>qlTopLeft</cstring>
+ </property>
+ <property name="text">
+ <string>Top left:</string>
+ </property>
+ </widget>
+ <widget class="TQComboBox">
+ <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="TQLayoutWidget">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>qlTopRight</cstring>
+ </property>
+ <property name="text">
+ <string>Top right:</string>
+ </property>
+ </widget>
+ <widget class="TQComboBox">
+ <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="TQLayoutWidget" 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="TQLayoutWidget">
+ <property name="name">
+ <cstring>layout4</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>qlBottomLeft</cstring>
+ </property>
+ <property name="text">
+ <string>Bottom left:</string>
+ </property>
+ </widget>
+ <widget class="TQComboBox">
+ <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="TQLayoutWidget">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>qlBottomRight</cstring>
+ </property>
+ <property name="text">
+ <string>Bottom right:</string>
+ </property>
+ </widget>
+ <widget class="TQComboBox">
+ <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="TQLayoutWidget" 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="TQLabel">
+ <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..947937995
--- /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-TDE-Category=Banners & Pictures
+X-TDE-Category=Desktop Distortions
+X-TDE-Category=Flying Things
+X-TDE-Category=Fractals
+X-TDE-Category=Gadgets & Simulations
+X-TDE-Category=Illusions of Depth
+X-TDE-Category=Miscellaneous
+X-TDE-Category=OpenGL Screen Savers
+X-TDE-Category=Rapid Motion
+X-TDE-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..93f05653d
--- /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( TQWidget *parent ) : KSWidget( parent ) {}
+
+ // we don't want no steenking palette change
+ virtual void setPalette( const TQPalette & ) {}
+};
+
+#endif
diff --git a/kcontrol/screensaver/kswidget.cpp b/kcontrol/screensaver/kswidget.cpp
new file mode 100644
index 000000000..0b11c3e23
--- /dev/null
+++ b/kcontrol/screensaver/kswidget.cpp
@@ -0,0 +1,71 @@
+#include <config.h>
+
+#include <twin.h>
+#include "testwin.h"
+
+#ifdef HAVE_GLXCHOOSEVISUAL
+#include <GL/glx.h>
+#endif
+
+KSWidget::KSWidget( TQWidget* parent, const char* name, int f )
+ : QXEmbed( parent, name, (WFlags)f ), colormap( None )
+{
+// use visual with support for double-buffering, for opengl
+// this code is duplicated in tdebase/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..11ec33a74
--- /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( TQWidget *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..75ee227f1
--- /dev/null
+++ b/kcontrol/screensaver/saverconfig.cpp
@@ -0,0 +1,38 @@
+#include <kdesktopfile.h>
+#include <tdelocale.h>
+
+#include "saverconfig.h"
+
+SaverConfig::SaverConfig()
+{
+}
+
+bool SaverConfig::read(const TQString &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-TDE-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..82be8e01f
--- /dev/null
+++ b/kcontrol/screensaver/saverconfig.h
@@ -0,0 +1,29 @@
+#ifndef SAVERCONFIG_H
+#define SAVERCONFIG_H
+
+#include <tqstring.h>
+
+class SaverConfig
+{
+public:
+ SaverConfig();
+
+ bool read(const TQString &file);
+
+ TQString exec() const { return mExec; }
+ TQString setup() const { return mSetup; }
+ TQString saver() const { return mSaver; }
+ TQString name() const { return mName; }
+ TQString file() const { return mFile; }
+ TQString category() const { return mCategory; }
+
+protected:
+ TQString mExec;
+ TQString mSetup;
+ TQString mSaver;
+ TQString mName;
+ TQString mFile;
+ TQString mCategory;
+};
+
+#endif
diff --git a/kcontrol/screensaver/saverlist.cpp b/kcontrol/screensaver/saverlist.cpp
new file mode 100644
index 000000000..65a36ab30
--- /dev/null
+++ b/kcontrol/screensaver/saverlist.cpp
@@ -0,0 +1,13 @@
+
+#include "saverlist.h"
+
+class SaverConfig;
+class TQPtrCollection;
+
+int SaverList::compareItems(TQPtrCollection::Item item1, TQPtrCollection::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..0030d6761
--- /dev/null
+++ b/kcontrol/screensaver/saverlist.h
@@ -0,0 +1,14 @@
+#ifndef SAVERLIST_H
+#define SAVERLIST_H
+
+#include <tqptrlist.h>
+
+#include "saverconfig.h"
+
+class SaverList : public TQPtrList<SaverConfig>
+{
+protected:
+ virtual int compareItems(TQPtrCollection::Item item1, TQPtrCollection::Item item2);
+};
+
+#endif
diff --git a/kcontrol/screensaver/screensaver.desktop b/kcontrol/screensaver/screensaver.desktop
new file mode 100644
index 000000000..f9cc9077a
--- /dev/null
+++ b/kcontrol/screensaver/screensaver.desktop
@@ -0,0 +1,240 @@
+[Desktop Entry]
+Exec=tdecmshell screensaver
+Icon=tdescreensaver
+Type=Application
+X-DocPath=kcontrol/screensaver/index.html
+
+
+X-TDE-Library=screensaver
+X-TDE-FactoryName=screensaver
+X-TDE-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;TDE;X-TDE-settings-looknfeel;
diff --git a/kcontrol/screensaver/scrnsave.cpp b/kcontrol/screensaver/scrnsave.cpp
new file mode 100644
index 000000000..a0b26ae46
--- /dev/null
+++ b/kcontrol/screensaver/scrnsave.cpp
@@ -0,0 +1,1019 @@
+//-----------------------------------------------------------------------------
+//
+// 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 <sys/stat.h>
+
+#include <tqbuttongroup.h>
+#include <tqcheckbox.h>
+#include <tqheader.h>
+#include <tqlabel.h>
+#include <tqlayout.h>
+#include <tqlistview.h>
+#include <tqpushbutton.h>
+#include <tqslider.h>
+#include <tqtimer.h>
+#include <tqfileinfo.h>
+#include <tqwhatsthis.h>
+
+#include <dcopclient.h>
+
+#include <tdeaboutdata.h>
+#include <tdeapplication.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 <ksimpleconfig.h>
+
+#include <X11/Xlib.h>
+
+#include "scrnsave.h"
+
+#include <fixx11h.h>
+
+#define OPEN_TDMCONFIG_AND_SET_GROUP \
+if( stat( KDE_CONFDIR "/tdm/tdmdistrc" , &st ) == 0) { \
+ mTDMConfig = new KSimpleConfig( TQString::fromLatin1( KDE_CONFDIR "/tdm/tdmdistrc" )); \
+} \
+else { \
+ mTDMConfig = new KSimpleConfig( TQString::fromLatin1( KDE_CONFDIR "/tdm/tdmrc" )); \
+} \
+mTDMConfig->setGroup("X-:*-Greeter");
+
+template class TQPtrList<SaverConfig>;
+
+const uint widgetEventMask = // X event mask
+(uint)(
+ ExposureMask |
+ PropertyChangeMask |
+ StructureNotifyMask
+ );
+
+//===========================================================================
+// DLL Interface for kcontrol
+typedef KGenericFactory<KScreenSaver, TQWidget > KSSFactory;
+K_EXPORT_COMPONENT_FACTORY (kcm_screensaver, KSSFactory("kcmscreensaver") )
+
+
+static TQString findExe(const TQString &exe) {
+ TQString result = locate("exe", exe);
+ if (result.isEmpty())
+ result = TDEStandardDirs::findExe(exe);
+ return result;
+}
+
+KScreenSaver::KScreenSaver(TQWidget *parent, const char *name, const TQStringList&)
+ : TDECModule(KSSFactory::instance(), parent, name)
+{
+ mSetupProc = 0;
+ mPreviewProc = 0;
+ mTestWin = 0;
+ mTestProc = 0;
+ mPrevSelected = -2;
+ mMonitor = 0;
+ mTesting = false;
+
+ struct stat st;
+ OPEN_TDMCONFIG_AND_SET_GROUP
+
+ // Add non-TDE path
+ TDEGlobal::dirs()->addResourceType("scrsav",
+ TDEGlobal::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( TDECModule::Help | TDECModule::Default | TDECModule::Apply );
+
+ // Add KDE specific screensaver path
+ TQString relPath="System/ScreenSavers/";
+ KServiceGroup::Ptr servGroup = KServiceGroup::baseGroup( "screensavers" );
+ if (servGroup)
+ {
+ relPath=servGroup->relPath();
+ kdDebug() << "relPath=" << relPath << endl;
+ }
+
+ TDEGlobal::dirs()->addResourceType("scrsav",
+ TDEGlobal::dirs()->kde_default("apps") +
+ relPath);
+
+ readSettings( false );
+
+ mSetupProc = new TDEProcess;
+ connect(mSetupProc, TQT_SIGNAL(processExited(TDEProcess *)),
+ this, TQT_SLOT(slotSetupDone(TDEProcess *)));
+
+ mPreviewProc = new TDEProcess;
+ connect(mPreviewProc, TQT_SIGNAL(processExited(TDEProcess *)),
+ this, TQT_SLOT(slotPreviewExited(TDEProcess *)));
+
+ TQBoxLayout *topLayout = new TQHBoxLayout(this, 0, KDialog::spacingHint());
+
+ // left column
+ TQVBoxLayout *leftColumnLayout =
+ new TQVBoxLayout(topLayout, KDialog::spacingHint());
+ TQBoxLayout *vLayout =
+ new TQVBoxLayout(leftColumnLayout, KDialog::spacingHint());
+
+ mSaverGroup = new TQGroupBox(i18n("Screen Saver"), this );
+ mSaverGroup->setColumnLayout( 0, Qt::Horizontal );
+ vLayout->addWidget(mSaverGroup);
+ vLayout->setStretchFactor( mSaverGroup, 10 );
+ TQBoxLayout *groupLayout = new TQVBoxLayout( mSaverGroup->layout(),
+ KDialog::spacingHint() );
+
+ mSaverListView = new TQListView( mSaverGroup );
+ mSaverListView->setMinimumHeight( 120 );
+ mSaverListView->setSizePolicy(TQSizePolicy::Preferred, TQSizePolicy::Expanding);
+ mSaverListView->addColumn("");
+ mSaverListView->header()->hide();
+ mSelected = -1;
+ groupLayout->addWidget( mSaverListView, 10 );
+ connect( mSaverListView, TQT_SIGNAL(doubleClicked ( TQListViewItem *)), this, TQT_SLOT( slotSetup()));
+ TQWhatsThis::add( mSaverListView, i18n("Select the screen saver to use.") );
+
+ TQBoxLayout* hlay = new TQHBoxLayout(groupLayout, KDialog::spacingHint());
+ mSetupBt = new TQPushButton( i18n("&Setup..."), mSaverGroup );
+ connect( mSetupBt, TQT_SIGNAL( clicked() ), TQT_SLOT( slotSetup() ) );
+ mSetupBt->setEnabled(false);
+ hlay->addWidget( mSetupBt );
+ TQWhatsThis::add( mSetupBt, i18n("Configure the screen saver's options, if any.") );
+
+ mTestBt = new TQPushButton( i18n("&Test"), mSaverGroup );
+ connect( mTestBt, TQT_SIGNAL( clicked() ), TQT_SLOT( slotTest() ) );
+ mTestBt->setEnabled(false);
+ hlay->addWidget( mTestBt );
+ TQWhatsThis::add( mTestBt, i18n("Show a full screen preview of the screen saver.") );
+
+ mSettingsGroup = new TQGroupBox( i18n("Settings"), this );
+ mSettingsGroup->setColumnLayout( 0, Qt::Vertical );
+ leftColumnLayout->addWidget( mSettingsGroup );
+ TQGridLayout *settingsGroupLayout = new TQGridLayout( mSettingsGroup->layout(), 5, 2, KDialog::spacingHint() );
+
+ mEnabledCheckBox = new TQCheckBox(i18n("Start a&utomatically"), mSettingsGroup);
+ mEnabledCheckBox->setChecked(mEnabled);
+ TQWhatsThis::add( mEnabledCheckBox, i18n("Automatically start the screen saver after a period of inactivity.") );
+ connect(mEnabledCheckBox, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotEnable(bool)));
+ settingsGroupLayout->addWidget(mEnabledCheckBox, 0, 0);
+
+ TQBoxLayout *hbox = new TQHBoxLayout();
+ settingsGroupLayout->addLayout(hbox, 1, 0);
+ hbox->addSpacing(30);
+ mActivateLbl = new TQLabel(i18n("After:"), mSettingsGroup);
+ mActivateLbl->setEnabled(mEnabled);
+ hbox->addWidget(mActivateLbl);
+ mWaitEdit = new TQSpinBox(mSettingsGroup);
+ mWaitEdit->setSteps(1, 10);
+ mWaitEdit->setRange(1, INT_MAX);
+ mWaitEdit->setSuffix(i18n(" min"));
+ mWaitEdit->setValue(mTimeout/60);
+ mWaitEdit->setEnabled(mEnabled);
+ connect(mWaitEdit, TQT_SIGNAL(valueChanged(int)),
+ this, TQT_SLOT(slotTimeoutChanged(int)));
+ mActivateLbl->setBuddy(mWaitEdit);
+ hbox->addWidget(mWaitEdit);
+ hbox->addStretch(1);
+ TQString wtstr = i18n("The period of inactivity after which the screen saver should start.");
+ TQWhatsThis::add( mActivateLbl, wtstr );
+ TQWhatsThis::add( mWaitEdit, wtstr );
+
+ mLockCheckBox = new TQCheckBox( i18n("&Require password to stop"), mSettingsGroup );
+ mLockCheckBox->setEnabled( mEnabled );
+ mLockCheckBox->setChecked( mLock );
+ connect( mLockCheckBox, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotLock( bool ) ) );
+ settingsGroupLayout->addWidget(mLockCheckBox, 2, 0);
+ TQWhatsThis::add( mLockCheckBox, i18n("Prevent potential unauthorized use by requiring a password to stop the screen saver.") );
+
+ hbox = new TQHBoxLayout();
+ settingsGroupLayout->addLayout(hbox, 3, 0);
+ hbox->addSpacing(30);
+ mLockLbl = new TQLabel(i18n("After:"), mSettingsGroup);
+ mLockLbl->setEnabled(mEnabled && mLock);
+ TQWhatsThis::add( mLockLbl, i18n("The amount of time, after the screen saver has started, to ask for the unlock password.") );
+ hbox->addWidget(mLockLbl);
+ mWaitLockEdit = new TQSpinBox(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, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(slotLockTimeoutChanged(int)));
+ mLockLbl->setBuddy(mWaitLockEdit);
+ hbox->addWidget(mWaitLockEdit);
+ hbox->addStretch(1);
+ TQString wltstr = i18n("Choose the period after which the display will be locked. ");
+ TQWhatsThis::add( mLockLbl, wltstr );
+ TQWhatsThis::add( mWaitLockEdit, wltstr );
+
+ mDelaySaverStartCheckBox = new TQCheckBox( i18n("&Delay saver start after lock"), mSettingsGroup );
+ mDelaySaverStartCheckBox->setEnabled( true );
+ mDelaySaverStartCheckBox->setChecked( mDelaySaverStart );
+ connect( mDelaySaverStartCheckBox, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotDelaySaverStart( bool ) ) );
+ settingsGroupLayout->addWidget(mDelaySaverStartCheckBox, 0, 1);
+ TQWhatsThis::add( mDelaySaverStartCheckBox, i18n("When manually locking the screen, wait to start the screen saver until the configured start delay has elapsed.") );
+
+ mUseTSAKCheckBox = new TQCheckBox( i18n("&Use Secure Attention Key"), mSettingsGroup );
+ mUseTSAKCheckBox->setEnabled( true );
+ mUseTSAKCheckBox->setChecked( mUseTSAK );
+ connect( mUseTSAKCheckBox, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotUseTSAK( bool ) ) );
+ settingsGroupLayout->addWidget(mUseTSAKCheckBox, 1, 1);
+ TQWhatsThis::add( mUseTSAKCheckBox, i18n("Require Secure Attention Key prior to displaying the unlock dialog.") );
+
+ mUseUnmanagedLockWindowsCheckBox = new TQCheckBox( i18n("Use &legacy lock windows"), mSettingsGroup );
+ mUseUnmanagedLockWindowsCheckBox->setEnabled( true );
+ mUseUnmanagedLockWindowsCheckBox->setChecked( mUseUnmanagedLockWindows );
+ connect( mUseUnmanagedLockWindowsCheckBox, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotUseUnmanagedLockWindows( bool ) ) );
+ settingsGroupLayout->addWidget(mUseUnmanagedLockWindowsCheckBox, 2, 1);
+ TQWhatsThis::add( mUseUnmanagedLockWindowsCheckBox, i18n("Use old-style unmanaged X11 lock windows.") );
+
+ mHideActiveWindowsFromSaverCheckBox = new TQCheckBox( i18n("Hide active &windows from saver"), mSettingsGroup );
+ mHideActiveWindowsFromSaverCheckBox->setEnabled( true );
+ mHideActiveWindowsFromSaverCheckBox->setChecked( mHideActiveWindowsFromSaver );
+ connect( mHideActiveWindowsFromSaverCheckBox, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotHideActiveWindowsFromSaver( bool ) ) );
+ settingsGroupLayout->addWidget(mHideActiveWindowsFromSaverCheckBox, 3, 1);
+ TQWhatsThis::add( mHideActiveWindowsFromSaverCheckBox, i18n("Hide all active windows from the screen saver and use the desktop background as the screen saver input.") );
+
+ mHideCancelButtonCheckBox = new TQCheckBox( i18n("Hide &cancel button"), mSettingsGroup );
+ mHideCancelButtonCheckBox->setEnabled( true );
+ mHideCancelButtonCheckBox->setChecked( mHideCancelButton );
+ connect( mHideCancelButtonCheckBox, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotHideCancelButton(bool)) );
+ settingsGroupLayout->addWidget(mHideCancelButtonCheckBox, 4, 1);
+ TQWhatsThis::add(mHideCancelButtonCheckBox, i18n("Hide Cancel button from the \"Desktop Session Locked\" dialog."));
+
+ // right column
+ TQBoxLayout* rightColumnLayout = new TQVBoxLayout(topLayout, KDialog::spacingHint());
+
+ mMonitorLabel = new TQLabel( this );
+ mMonitorLabel->setAlignment( AlignCenter );
+ mMonitorLabel->setPixmap( TQPixmap(locate("data", "kcontrol/pics/monitor.png")));
+ rightColumnLayout->addWidget(mMonitorLabel, 0);
+ TQWhatsThis::add( mMonitorLabel, i18n("A preview of the selected screen saver.") );
+
+ TQBoxLayout* advancedLayout = new TQHBoxLayout( rightColumnLayout, 3 );
+ advancedLayout->addWidget( new TQWidget( this ) );
+ TQPushButton* advancedBt = new TQPushButton(
+ i18n( "Advanced &Options" ), this, "advancedBtn" );
+ advancedBt->setSizePolicy( TQSizePolicy(
+ TQSizePolicy::Fixed, TQSizePolicy::Fixed) );
+ connect( advancedBt, TQT_SIGNAL( clicked() ),
+ this, TQT_SLOT( slotAdvanced() ) );
+ advancedLayout->addWidget( advancedBt );
+ advancedLayout->addWidget( new TQWidget( 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 TQTimer( this );
+ connect( mLoadTimer, TQT_SIGNAL(timeout()), TQT_SLOT(findSavers()) );
+ mLoadTimer->start( 100 );
+ mChanged = false;
+ emit changed(false);
+
+ TDEAboutData *about =
+ new TDEAboutData(I18N_NOOP("kcmscreensaver"), I18N_NOOP("TDE Screen Saver Control Module"),
+ 0, 0, TDEAboutData::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);
+
+ processLockouts();
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::resizeEvent( TQResizeEvent * )
+{
+
+ if (mMonitor)
+ {
+ mMonitor->setGeometry( (mMonitorLabel->width()-200)/2+23,
+ (mMonitorLabel->height()-186)/2+14, 151, 115 );
+ }
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::mousePressEvent( TQMouseEvent *)
+{
+ if ( mTesting )
+ slotStopTest();
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::keyPressEvent( TQKeyEvent *)
+{
+ 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;
+
+ delete mTDMConfig;
+}
+
+//---------------------------------------------------------------------------
+//
+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;
+ TQListViewItem *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 )
+{
+ TDEConfig *config = new TDEConfig( "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);
+ mDelaySaverStart = config->readBoolEntry("DelaySaverStart", true);
+ mUseTSAK = config->readBoolEntry("UseTDESAK", true);
+ mUseUnmanagedLockWindows = config->readBoolEntry("UseUnmanagedLockWindows", false);
+ mHideActiveWindowsFromSaver = config->readBoolEntry("HideActiveWindowsFromSaver", true);
+ mHideCancelButton = config->readBoolEntry("HideCancelButton", 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;
+
+ TDEConfig *config = new TDEConfig( "kdesktoprc");
+ config->setGroup( "ScreenSaver" );
+
+ config->writeEntry("Enabled", mEnabled);
+ config->writeEntry("Timeout", mTimeout);
+ config->writeEntry("LockGrace", mLockTimeout);
+ config->writeEntry("Lock", mLock);
+ config->writeEntry("DelaySaverStart", mDelaySaverStart);
+ config->writeEntry("UseTDESAK", mUseTSAK);
+ config->writeEntry("UseUnmanagedLockWindows", mUseUnmanagedLockWindows);
+ config->writeEntry("HideActiveWindowsFromSaver", mHideActiveWindowsFromSaver);
+ config->writeEntry("HideCancelButton", mHideCancelButton);
+
+ 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()", TQString(""));
+
+ mChanged = false;
+ emit changed(false);
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::findSavers()
+{
+ if ( !mNumLoaded ) {
+ mSaverFileList = TDEGlobal::dirs()->findAllResources("scrsav",
+ "*.desktop", false, true);
+ new TQListViewItem ( mSaverListView, i18n("Loading...") );
+ if ( mSaverFileList.isEmpty() )
+ mLoadTimer->stop();
+ else
+ mLoadTimer->start( 50 );
+ }
+
+ for ( int i = 0; i < 5 &&
+ (unsigned)mNumLoaded < mSaverFileList.count();
+ i++, mNumLoaded++ ) {
+ TQString file = mSaverFileList[mNumLoaded];
+ SaverConfig *saver = new SaverConfig;
+ if (saver->read(file)) {
+ TQString saverexec = TQString("%1/%2").arg(XSCREENSAVER_HACKS_DIR).arg(saver->exec());
+ // find the xscreensaver executable
+ //work around a TDEStandardDirs::findExe() "feature" where it looks in $TDEDIR/bin first no matter what and sometimes finds the wrong executable
+ TQFileInfo checkExe;
+ checkExe.setFile(saverexec);
+ if (checkExe.exists() && checkExe.isExecutable() && checkExe.isFile()) {
+ mSaverList.append(saver);
+ }
+ else {
+ // Executable not present in XScreenSaver directory!
+ // Try standard paths
+ if (TDEStandardDirs::findExe(saver->exec()) != TQString::null) {
+ mSaverList.append(saver);
+ }
+ else {
+ delete saver;
+ }
+ }
+ }
+ else {
+ delete saver;
+ }
+ }
+
+ if ( (unsigned)mNumLoaded == mSaverFileList.count() ) {
+ TQListViewItem *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())
+ {
+ TQListViewItem *item;
+ if (s->category().isEmpty())
+ item = new TQListViewItem ( mSaverListView, s->name(), "2" + s->name() );
+ else
+ {
+ TQListViewItem *categoryItem = mSaverListView->findItem( s->category(), 0 );
+ if ( !categoryItem ) {
+ categoryItem = new TQListViewItem ( mSaverListView, s->category(), "1" + s->category() );
+ categoryItem->setPixmap ( 0, SmallIcon ( "tdescreensaver" ) );
+ }
+ item = new TQListViewItem ( categoryItem, s->name(), s->name() );
+ categoryCount++;
+ }
+ if (s->file() == mSaver) {
+ mSelected = indx;
+ selectedItem = item;
+ }
+ indx++;
+ }
+
+ // Delete categories with only one item
+ TQListViewItemIterator it ( mSaverListView );
+ for ( ; it.current(); it++ )
+ if ( it.current()->childCount() == 1 ) {
+ TQListViewItem *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, TQT_SIGNAL( currentChanged( TQListViewItem * ) ),
+ this, TQT_SLOT( slotScreenSaver( TQListViewItem * ) ) );
+
+ 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(TDEProcess *)
+{
+ // 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(tqt_xdisplay(), mMonitor->winId(), widgetEventMask );
+
+ if (mSelected >= 0) {
+ mPreviewProc->clearArguments();
+
+ TQString saver = mSaverList.at(mSelected)->saver();
+ TQTextStream ts(&saver, IO_ReadOnly);
+
+ TQString word;
+ ts >> word;
+ TQString 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;
+ processLockouts();
+ mChanged = true;
+ emit changed(true);
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::processLockouts()
+{
+ bool useSAK = mTDMConfig->readBoolEntry("UseSAK", false);
+ mActivateLbl->setEnabled( mEnabled );
+ mWaitEdit->setEnabled( mEnabled );
+ mLockCheckBox->setEnabled( mEnabled );
+ if (mEnabled && !mUseUnmanagedLockWindows) {
+ mDelaySaverStartCheckBox->setEnabled( true );
+ mDelaySaverStartCheckBox->setChecked( mDelaySaverStart );
+ }
+ else {
+ mDelaySaverStartCheckBox->setEnabled( false );
+ mDelaySaverStartCheckBox->setChecked( false );
+ }
+ if (!mUseUnmanagedLockWindows && useSAK) {
+ mUseTSAKCheckBox->setEnabled( true );
+ mUseTSAKCheckBox->setChecked( mUseTSAK );
+ }
+ else {
+ mUseTSAKCheckBox->setEnabled( false );
+ mUseTSAKCheckBox->setChecked( false );
+ }
+ if (!mUseUnmanagedLockWindows) {
+ mHideActiveWindowsFromSaverCheckBox->setEnabled( true );
+ mHideActiveWindowsFromSaverCheckBox->setChecked( mHideActiveWindowsFromSaver );
+ }
+ else {
+ mHideActiveWindowsFromSaverCheckBox->setEnabled( false );
+ mHideActiveWindowsFromSaverCheckBox->setChecked( false );
+ }
+ if (mUseUnmanagedLockWindows || (useSAK && mUseTSAK)) {
+ mHideCancelButtonCheckBox->setEnabled( false );
+ mHideCancelButtonCheckBox->setChecked( false );
+ }
+ else {
+ mHideCancelButtonCheckBox->setEnabled( true );
+ mHideCancelButtonCheckBox->setChecked( mHideCancelButton );
+ }
+ mLockLbl->setEnabled( mEnabled && mLock );
+ mWaitLockEdit->setEnabled( mEnabled && mLock );
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::slotScreenSaver(TQListViewItem *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();
+
+ TQString saver = mSaverList.at(mSelected)->setup();
+ if( saver.isEmpty())
+ return;
+ TQTextStream ts(&saver, IO_ReadOnly);
+
+ TQString word;
+ ts >> word;
+ bool kxsconfig = word == "kxsconfig";
+ TQString 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 = "tdescreensaver";
+ (*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 TDEProcess;
+ }
+
+ mTestProc->clearArguments();
+ TQString saver = mSaverList.at(mSelected)->saver();
+ TQTextStream ts(&saver, IO_ReadOnly);
+
+ TQString word;
+ ts >> word;
+ TQString path = findExe(word);
+
+ if (!path.isEmpty())
+ {
+ (*mTestProc) << path;
+
+ if (!mTestWin)
+ {
+ mTestWin = new TestWin();
+ mTestWin->setBackgroundMode(TQWidget::NoBackground);
+ mTestWin->setGeometry(0, 0, kapp->desktop()->width(),
+ kapp->desktop()->height());
+ }
+
+ mTestWin->show();
+ mTestWin->raise();
+ mTestWin->setFocus();
+ // So that hacks can XSelectInput ButtonPressMask
+ XSelectInput(tqt_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(TDEProcess::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::slotDelaySaverStart( bool d )
+{
+ if (mDelaySaverStartCheckBox->isEnabled()) mDelaySaverStart = d;
+ processLockouts();
+ mChanged = true;
+ emit changed(true);
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::slotUseTSAK( bool u )
+{
+ if (mUseTSAKCheckBox->isEnabled()) mUseTSAK = u;
+ processLockouts();
+ mChanged = true;
+ emit changed(true);
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::slotUseUnmanagedLockWindows( bool u )
+{
+ if (mUseUnmanagedLockWindowsCheckBox->isEnabled()) mUseUnmanagedLockWindows = u;
+ processLockouts();
+ mChanged = true;
+ emit changed(true);
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::slotHideActiveWindowsFromSaver( bool h )
+{
+ if (mHideActiveWindowsFromSaverCheckBox->isEnabled()) mHideActiveWindowsFromSaver = h;
+ processLockouts();
+ mChanged = true;
+ emit changed(true);
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::slotHideCancelButton( bool h )
+{
+ if (mHideCancelButtonCheckBox->isEnabled()) mHideCancelButton = h;
+ processLockouts();
+ mChanged = true;
+ emit changed(true);
+}
+
+//---------------------------------------------------------------------------
+//
+void KScreenSaver::slotSetupDone(TDEProcess *)
+{
+ 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..d52c81227
--- /dev/null
+++ b/kcontrol/screensaver/scrnsave.h
@@ -0,0 +1,131 @@
+//-----------------------------------------------------------------------------
+//
+// KDE Display screen saver setup module
+//
+// Copyright (c) Martin R. Jones 1996
+// Copyright (C) Chris Howells 2004
+//
+
+#ifndef __SCRNSAVE_H__
+#define __SCRNSAVE_H__
+
+#include <tqwidget.h>
+#include <tdecmodule.h>
+
+#include "kssmonitor.h"
+#include "saverconfig.h"
+#include "testwin.h"
+#include "advanceddialog.h"
+#include "kssmonitor.h"
+#include "saverlist.h"
+
+class TQTimer;
+class TQSpinBox;
+class TQSlider;
+class TQCheckBox;
+class TQLabel;
+class TQListView;
+class TQListViewItem;
+class TQPushButton;
+class KIntNumInput;
+class TDEProcess;
+
+//===========================================================================
+class KScreenSaver : public TDECModule
+{
+ Q_OBJECT
+public:
+ KScreenSaver(TQWidget *parent, const char *name, const TQStringList &);
+ ~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( TQListViewItem* );
+ void slotSetup();
+ void slotAdvanced();
+ void slotTest();
+ void slotStopTest();
+ void slotTimeoutChanged( int );
+ void slotLockTimeoutChanged( int );
+ void slotLock( bool );
+ void slotDelaySaverStart( bool );
+ void slotUseTSAK( bool );
+ void slotUseUnmanagedLockWindows( bool );
+ void slotHideActiveWindowsFromSaver( bool );
+ void slotHideCancelButton( bool );
+ void processLockouts();
+ void slotSetupDone(TDEProcess*);
+ // when selecting a new screensaver, the old preview will
+ // be killed. -- This callback is responsible for restarting the
+ // new preview
+ void slotPreviewExited(TDEProcess *);
+ void findSavers();
+
+protected:
+ void writeSettings();
+ void getSaverNames();
+ void setMonitor();
+ void setDefaults();
+ void resizeEvent( TQResizeEvent * );
+ void mousePressEvent(TQMouseEvent *);
+ void keyPressEvent(TQKeyEvent *);
+
+protected:
+ TestWin *mTestWin;
+ TDEProcess *mTestProc;
+ TDEProcess *mSetupProc;
+ TDEProcess *mPreviewProc;
+ KSSMonitor *mMonitor;
+ TQPushButton *mSetupBt;
+ TQPushButton *mTestBt;
+ TQListView *mSaverListView;
+ TQSpinBox *mWaitEdit;
+ TQSpinBox *mWaitLockEdit;
+ TQCheckBox *mLockCheckBox;
+ TQCheckBox *mStarsCheckBox;
+ TQCheckBox *mEnabledCheckBox;
+ TQLabel *mMonitorLabel;
+ TQLabel *mActivateLbl;
+ TQLabel *mLockLbl;
+ TQStringList mSaverFileList;
+ SaverList mSaverList;
+ TQTimer *mLoadTimer;
+ TQGroupBox *mSaverGroup;
+ TQGroupBox *mSettingsGroup;
+ TQCheckBox *mDelaySaverStartCheckBox;
+ TQCheckBox *mUseTSAKCheckBox;
+ TQCheckBox *mUseUnmanagedLockWindowsCheckBox;
+ TQCheckBox *mHideActiveWindowsFromSaverCheckBox;
+ TQCheckBox *mHideCancelButtonCheckBox;
+
+ int mSelected;
+ int mPrevSelected;
+ int mNumLoaded;
+ bool mChanged;
+ bool mTesting;
+
+ // Settings
+ int mTimeout;
+ int mLockTimeout;
+ bool mLock;
+ bool mEnabled;
+ TQString mSaver;
+ bool mImmutable;
+ bool mDelaySaverStart;
+ bool mUseTSAK;
+ bool mUseUnmanagedLockWindows;
+ bool mHideActiveWindowsFromSaver;
+ bool mHideCancelButton;
+
+ KSimpleConfig* mTDMConfig;
+};
+
+#endif
diff --git a/kcontrol/screensaver/testwin.cpp b/kcontrol/screensaver/testwin.cpp
new file mode 100644
index 000000000..dd250e084
--- /dev/null
+++ b/kcontrol/screensaver/testwin.cpp
@@ -0,0 +1,13 @@
+#include <twin.h>
+#include "testwin.h"
+
+class QXEmbed;
+
+TestWin::TestWin()
+ : KSWidget(0, 0, WStyle_Customize | WStyle_NoBorder | WX11BypassWM )
+{
+ setFocusPolicy(TQ_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
+