add more spacing
[personal-kdebase.git] / workspace / kcontrol / kdm / background / bgrender.h
blob83106ba909f72d9bb158d1e359bb8c2041a4685b
1 /* vi: ts=8 sts=4 sw=4
2 * kate: space-indent on; tab-width 8; indent-width 4; indent-mode cstyle;
4 * This file is part of the KDE project, module kdesktop.
5 * Copyright (C) 1999 Geert Jansen <g.t.jansen@stud.tue.nl>
7 * You can Freely distribute this program under the GNU Library General
8 * Public License. See the file "COPYING.LIB" for the exact licensing terms.
9 */
11 #ifndef BGRender_h_Included
12 #define BGRender_h_Included
14 #include <QObject>
15 #include <QPixmap>
16 #include <QImage>
17 #include <KProcess>
18 #include <ksharedconfig.h>
20 #include "bgsettings.h"
22 class QSize;
23 class QRect;
24 class QString;
25 class QTimer;
27 class KTemporaryFile;
28 class KStandardDirs;
30 /**
31 * This class renders a desktop background to a QImage. The operation is
32 * asynchronous: connect to the signal imageDone() to find out when the
33 * rendering is finished. It also has support for preview images, like
34 * the monitor in kcmdisplay.
36 class KBackgroundRenderer:
37 public QObject,
38 public KBackgroundSettings
40 Q_OBJECT
42 public:
43 KBackgroundRenderer(int screen, bool drawBackgroundPerScreen, const KSharedConfigPtr &config);
44 ~KBackgroundRenderer();
46 void load(int screen, bool drawBackgroundPerScreen, bool reparseConfig=true);
48 void setPreview(const QSize &size);
49 void setSize(const QSize &size);
51 QPixmap pixmap();
52 QImage image();
53 bool isActive() { return m_State & Rendering; }
54 void cleanup();
55 void saveCacheFile();
56 void enableTiling( bool enable ) { m_TilingEnabled = enable; }
58 public Q_SLOTS:
59 void start(bool enableBusyCursor = false);
60 void stop();
61 void desktopResized();
63 Q_SIGNALS:
64 void imageDone(int screen);
65 void programFailure(int exitstatus); //Guaranteed either programFailure or
66 void programSuccess(); //programSuccess is emitted after imageDone
68 private Q_SLOTS:
69 void slotBackgroundDone(int exitCode, QProcess::ExitStatus exitStatus);
70 void render();
71 void done();
73 private:
74 enum { Error, Wait, WaitUpdate, Done };
75 enum { Rendering = 1, InitCheck = 2,
76 BackgroundStarted = 4, BackgroundDone = 8,
77 WallpaperStarted = 0x10, WallpaperDone = 0x20,
78 AllDone = 0x40 };
80 QString buildCommand();
81 void createTempFile();
82 void tile(QImage& dst, const QRect &rect, const QImage& src);
83 void blend(QImage& dst, const QRect &dr, const QImage& src, const QPoint &soffs = QPoint(0, 0), int blendFactor=100);
85 void wallpaperBlend();
86 void fastWallpaperBlend();
87 void fullWallpaperBlend();
89 int doBackground(bool quit=false);
90 int doWallpaper(bool quit=false);
91 void setBusyCursor(bool isBusy);
92 QString cacheFileName();
93 bool useCacheFile() const;
94 bool canTile() const;
96 bool m_isBusyCursor;
97 bool m_enableBusyCursor;
98 bool m_bPreview;
99 int m_State;
100 bool m_Cached;
101 bool m_TilingEnabled;
103 KTemporaryFile* m_Tempfile;
104 QSize m_Size, m_rSize;
105 QRect m_WallpaperRect;
106 QImage m_Image, m_Background, m_Wallpaper;
107 QPixmap m_Pixmap;
108 QTimer *m_pTimer;
110 KStandardDirs *m_pDirs;
111 KProcess *m_pProc;
115 #endif // BGRender_h_Included