Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / kscreensaver / libkscreensaver / kscreensaver.h
blob8c577b58b3fc0442a57910f460a351856da69bea
1 /* This file is part of the KDE libraries
3 Copyright (c) 2001 Martin R. Jones <mjones@kde.org>
4 Copyright 2006 David Faure <faure@kde.org>
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
22 #ifndef KSCREENSAVER_H
23 #define KSCREENSAVER_H
25 #include <QtGui/QWidget>
27 #include <kdemacros.h>
28 #include <kaboutdata.h> // needed by all users of this header, so no point in a forward declaration
30 class KScreenSaverPrivate;
31 class KBlankEffectPrivate;
33 /**
34 * Provides a QWidget for a screensaver to draw into.
36 * You should derive from this widget and implement your screensaver's
37 * functionality.
39 * @see KScreenSaverInterface
41 * @short Provides a QWidget for a screensaver to draw into.
42 * @author Martin R. Jones <mjones@kde.org>
44 class KDE_EXPORT KScreenSaver : public QWidget
46 Q_OBJECT
47 public:
48 /**
49 * @param id The winId() of the widget to draw the screensaver into.
51 KScreenSaver( WId id=0 );
52 ~KScreenSaver();
54 protected:
55 /**
56 * You cannot create a new widget with this widget as parent, since this
57 * widget may not be owned by your application. In order to create
58 * widgets with a KScreenSaver as parent, create the widget with no parent,
59 * call embed(), and then show() the widget.
61 * @param widget The widget to embed in the screensaver widget.
63 void embed( QWidget *widget );
65 private:
66 KScreenSaverPrivate *d;
69 /**
71 * To use libkscreensaver, derive from KScreenSaverInterface and reimplement
72 * its virtual methods. Then write
73 * <code>
74 * int main( int argc, char *argv[] )
75 * {
76 * MyKScreenSaverInterface kssi;
77 * return kScreenSaverMain( argc, argv, kssi );
78 * }
79 * </code>
81 * In order to convert a KDE-3 screensaver (which used to export kss_* symbols and had no main function)
82 * to KDE-4, you can use the following python script
83 * kdebase/workspace/kscreensaver/libkscreensaver/kscreensaver-kde3to4-porting.py
85 class KDE_EXPORT KScreenSaverInterface
87 public:
88 /**
89 * Destructor
91 virtual ~KScreenSaverInterface();
92 /**
93 * Reimplement this method to return the KAboutData instance describing your screensaver
95 virtual KAboutData *aboutData() = 0;
96 /**
97 * Reimplement this method to return your KScreenSaver-derived screensaver
99 virtual KScreenSaver* create( WId id ) = 0;
101 * Reimplement this method to return your modal setup dialog
103 virtual QDialog* setup();
107 * The entry point for the program's main()
108 * @see KScreenSaverInterface
110 KDE_EXPORT int kScreenSaverMain( int argc, char** argv, KScreenSaverInterface& screenSaverInterface );
114 * Blanks a widget using various effects.
116 * @short Blanks a widget using various effects.
117 * @author Martin R. Jones <mjones@kde.org>
119 class KBlankEffect : public QObject
121 Q_OBJECT
122 public:
123 KBlankEffect( QObject *parent=0 );
124 ~KBlankEffect();
126 enum Effect { Random=-1, Blank=0, SweepRight, SweepDown, Blocks,
127 MaximumEffects };
130 * Blank a widget using the specified effect.
131 * Some blanking effects take some time, so you should connect to
132 * doneBlank() to know when the blanking is complete.
134 * @param w The widget to blank.
135 * @param effect The type of effect to use.
137 void blank( QWidget *w, Effect effect=Random );
139 typedef void (KBlankEffect::*BlankEffect)();
141 Q_SIGNALS:
143 * emitted when a blanking effect has completed.
145 void doneBlank();
147 protected Q_SLOTS:
148 void timeout();
150 protected:
151 void finished();
153 void blankNormal();
154 void blankSweepRight();
155 void blankSweepDown();
156 void blankBlocks();
158 protected:
159 static BlankEffect effects[];
160 KBlankEffectPrivate *d;
162 #endif