Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / kcontrol / kdm / background / bgrender.h
blob69e9b0c4dcb048e7a3231738180a07861ac2d0f0
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 //Added by qt3to4:
16 #include <QPixmap>
17 #include <QImage>
18 #include <Qt3Support/Q3PtrVector>
19 #include <ksharedconfig.h>
21 #include "bgsettings.h"
23 class QSize;
24 class QRect;
25 class QString;
26 class QTimer;
28 class K3Process;
29 class KTemporaryFile;
30 class K3ShellProcess;
31 class KStandardDirs;
33 /**
34 * This class renders a desktop background to a QImage. The operation is
35 * asynchronous: connect to the signal imageDone() to find out when the
36 * rendering is finished. It also has support for preview images, like
37 * the monitor in kcmdisplay.
39 class KBackgroundRenderer:
40 public QObject,
41 public KBackgroundSettings
43 Q_OBJECT
45 public:
46 KBackgroundRenderer(int desk, int screen, bool drawBackgroundPerScreen, const KSharedConfigPtr &config = KSharedConfigPtr(), bool kdmMode = false);
47 ~KBackgroundRenderer();
49 void load(int desk, int screen, bool drawBackgroundPerScreen, bool reparseConfig=true);
51 void setPreview(const QSize &size);
52 void setSize(const QSize &size);
54 QPixmap pixmap();
55 QImage image();
56 bool isActive() { return m_State & Rendering; }
57 void cleanup();
58 void saveCacheFile();
59 void enableTiling( bool enable ) { m_TilingEnabled = enable; }
61 public Q_SLOTS:
62 void start(bool enableBusyCursor = false);
63 void stop();
64 void desktopResized();
66 Q_SIGNALS:
67 void imageDone(int desk, int screen);
68 void programFailure(int desk, int exitstatus); //Guaranteed either programFailure or
69 void programSuccess(int desk); //programSuccess is emitted after imageDone
71 private Q_SLOTS:
72 void slotBackgroundDone(K3Process *);
73 void render();
74 void done();
76 private:
77 enum { Error, Wait, WaitUpdate, Done };
78 enum { Rendering = 1, InitCheck = 2,
79 BackgroundStarted = 4, BackgroundDone = 8,
80 WallpaperStarted = 0x10, WallpaperDone = 0x20,
81 AllDone = 0x40 };
83 QString buildCommand();
84 void createTempFile();
85 void tile(QImage& dst, const QRect &rect, const QImage& src);
86 void blend(QImage& dst, const QRect &dr, const QImage& src, const QPoint &soffs = QPoint(0, 0), int blendFactor=100);
88 void wallpaperBlend();
89 void fastWallpaperBlend();
90 void fullWallpaperBlend();
92 int doBackground(bool quit=false);
93 int doWallpaper(bool quit=false);
94 void setBusyCursor(bool isBusy);
95 QString cacheFileName();
96 bool useCacheFile() const;
97 bool canTile() const;
99 bool m_isBusyCursor;
100 bool m_enableBusyCursor;
101 bool m_bPreview;
102 int m_State;
103 bool m_Cached;
104 bool m_TilingEnabled;
106 KTemporaryFile* m_Tempfile;
107 QSize m_Size, m_rSize;
108 QRect m_WallpaperRect;
109 QImage m_Image, m_Background, m_Wallpaper;
110 QPixmap m_Pixmap;
111 QTimer *m_pTimer;
113 KStandardDirs *m_pDirs;
114 K3ShellProcess *m_pProc;
118 * In xinerama mode, each screen is rendered separately by KBackgroundRenderer.
119 * This class controls a set of renderers for a desktop, and coallates the
120 * images. Usage is similar to KBackgroundRenderer: connect to the imageDone
121 * signal.
123 class KVirtualBGRenderer : public QObject
125 Q_OBJECT
126 public:
127 explicit KVirtualBGRenderer(int desk, const KSharedConfigPtr &config = KSharedConfigPtr(), bool kdmMode = false);
128 ~KVirtualBGRenderer();
130 KBackgroundRenderer * renderer(unsigned screen);
131 unsigned numRenderers() const { return m_numRenderers; }
133 QPixmap pixmap();
135 void setPreview(const QSize & size);
137 bool needProgramUpdate();
138 void programUpdate();
140 bool needWallpaperChange();
141 void changeWallpaper();
143 int hash();
144 bool isActive();
145 void setEnabled( bool enable );
146 void desktopResized();
148 void load(int desk, bool reparseConfig=true);
149 void start();
150 void stop();
151 void cleanup();
152 void saveCacheFile();
153 void enableTiling( bool enable );
155 signals:
156 void imageDone(int desk);
158 private slots:
159 void screenDone(int desk, int screen);
161 private:
162 QSize renderSize(int screen); // the size the renderer should be
163 void initRenderers();
165 KSharedConfigPtr m_pConfig;
166 float m_scaleX;
167 float m_scaleY;
168 int m_desk;
169 unsigned m_numRenderers;
170 bool m_bDrawBackgroundPerScreen;
171 bool m_bCommonScreen;
172 bool m_kdmMode;
173 QSize m_size;
175 QVector<bool> m_bFinished;
176 Q3PtrVector<KBackgroundRenderer> m_renderer;
177 QPixmap *m_pPixmap;
181 #endif // BGRender_h_Included