Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / kcontrol / kdm / background / bgsettings.h
blob723341edc283026316b2cca3cafb8993eac10759
1 /* vi: ts=8 sts=4 sw=4
2 * kate: space-indent on; 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 __BGSettings_h_Included__
12 #define __BGSettings_h_Included__
15 #include <QColor>
16 #include <QMap>
17 #include <QVector>
18 #include <ksharedconfig.h>
20 template <class QString, class T> class QMap;
21 class KStandardDirs;
22 class KDesktopFile;
23 class QString;
25 /**
26 * A class to manipulate/read/write/list KDE desktop patterns.
28 * A pattern is a raster image. An entry for earch pattern is
29 * stored as a .desktop file in $(datadir)/kdesktop/patterns.
31 class KBackgroundPattern
33 public:
34 explicit KBackgroundPattern(bool _kdmMode, const QString &name = QString());
35 ~KBackgroundPattern();
37 void copyConfig(const KBackgroundPattern*);
39 QString name() const { return m_Name; }
40 void load(const QString &name);
42 void setComment(const QString &comment);
43 QString comment() const {return m_Comment; }
45 void setPattern(const QString &file);
46 QString pattern() const { return m_Pattern; }
48 void readSettings();
49 void writeSettings();
51 bool isAvailable();
52 bool isGlobal()const { return m_bReadOnly; }
53 bool remove();
55 int hash();
57 static QStringList list();
59 private:
60 void init(bool force_rw=false);
61 QString fingerprint();
63 bool dirty, hashdirty;
64 bool m_bReadOnly;
65 bool m_kdmMode;
66 int m_Hash;
67 QString m_Name, m_Comment;
68 QString m_Pattern, m_File;
69 KStandardDirs *m_pDirs;
70 KDesktopFile *m_pConfig;
74 /**
75 * A class to manipulate/read/write/list KDE desktop programs (a la xearth).
77 * A program is described by a string like:
79 * a_program -xres %x -yres %y -outfile %f
81 * Possible escape sequences:
83 * %x Horizontal resolution in pixels.
84 * %y Vertical resolution in pixels.
85 * %f Filename to dump to.
87 * An entry for each program is stored as a .desktop file in
88 * $(datadir)/kdesktop/programs.
90 class KBackgroundProgram
92 public:
93 explicit KBackgroundProgram(bool _kdmMode, const QString &name = QString());
94 ~KBackgroundProgram();
96 void copyConfig(const KBackgroundProgram*);
98 QString name()const { return m_Name; }
99 void load(const QString & name);
101 void setComment(const QString &comment);
102 QString comment()const { return m_Comment; }
104 void setCommand(const QString &command);
105 QString command()const { return m_Command; }
107 void setPreviewCommand(const QString &command);
108 QString previewCommand()const { return m_PreviewCommand; }
110 void setRefresh(int refresh);
111 int refresh()const { return m_Refresh; }
113 void setExecutable(const QString &executable);
114 QString executable()const { return m_Executable; }
116 void readSettings();
117 void writeSettings();
119 void update();
120 bool needUpdate();
122 int hash();
124 bool isAvailable();
125 bool isGlobal()const { return m_bReadOnly; }
126 bool remove();
128 static QStringList list();
130 private:
131 void init(bool force_rw=false);
132 QString fingerprint();
134 bool dirty, hashdirty;
135 bool m_bReadOnly;
136 bool m_kdmMode;
137 int m_Refresh, m_Hash, m_LastChange;
138 QString m_Name, m_Command;
139 QString m_PreviewCommand, m_Comment;
140 QString m_Executable, m_File;
141 KStandardDirs *m_pDirs;
142 KDesktopFile *m_pConfig;
147 * KBackgroundSettings: A class to read/write/manipulate
148 * KDE desktop settings.
150 class KBackgroundSettings
151 : public KBackgroundPattern,
152 public KBackgroundProgram
154 public:
156 * @param drawBackgroundPerScreen if false, then all screens (in xinerama
157 * mode) will be treated as one big display, and the "screen" paramater
158 * will be ignored.
160 KBackgroundSettings(int desk, int screen, bool drawBackgroundPerScreen, const KSharedConfigPtr &config, bool _kdmMode);
161 ~KBackgroundSettings();
163 void copyConfig(const KBackgroundSettings*);
165 bool drawBackgroundPerScreen() const { return m_bDrawBackgroundPerScreen; }
166 void setDrawBackgroundPerScreen(bool draw);
168 int desk() const { return m_Desk; }
169 int screen() const { return m_Screen; }
170 // void load(int desk, int screen, bool drawBackgroundPerScreen, bool reparseConfig=true);
171 void load(int desk, int screen, bool drawBackgroundPerScreen, bool reparseConfig);
173 void setColorA(const QColor &color);
174 QColor colorA() const { return m_ColorA; }
175 void setColorB(const QColor &color);
176 QColor colorB() const { return m_ColorB; }
178 void setProgram(const QString &program);
179 void setPatternName(const QString &pattern);
181 enum BackgroundMode {
182 Flat, Pattern, Program,
183 HorizontalGradient, VerticalGradient, PyramidGradient,
184 PipeCrossGradient, EllipticGradient, lastBackgroundMode
186 void setBackgroundMode(int mode);
187 int backgroundMode() const { return m_BackgroundMode; }
189 enum BlendMode {
190 NoBlending, FlatBlending,
191 HorizontalBlending, VerticalBlending, PyramidBlending,
192 PipeCrossBlending, EllipticBlending,
193 IntensityBlending, SaturateBlending, ContrastBlending,
194 HueShiftBlending, lastBlendMode
196 void setBlendMode(int mode);
197 int blendMode() const { return m_BlendMode; }
199 void setReverseBlending(bool value);
200 bool reverseBlending() const { return m_ReverseBlending; }
202 void setBlendBalance(int value);
203 int blendBalance() const { return m_BlendBalance; }
205 void setWallpaper(const QString &name);
206 QString wallpaper() const { return m_Wallpaper; }
208 enum WallpaperMode {
209 NoWallpaper, Centred, Tiled, CenterTiled, CentredMaxpect, TiledMaxpect,
210 Scaled, CentredAutoFit, ScaleAndCrop, lastWallpaperMode
212 void setWallpaperMode(int mode);
213 int wallpaperMode() const { return m_WallpaperMode; }
215 void setWallpaperList(const QStringList&);
216 QStringList wallpaperList() const;
217 QStringList wallpaperFiles() const;
219 void setWallpaperChangeInterval(int);
220 int wallpaperChangeInterval() const { return m_Interval; }
222 enum MultiMode {
223 NoMulti, InOrder, Random, NoMultiRandom
225 void setMultiWallpaperMode(int mode);
226 int multiWallpaperMode() const { return m_MultiMode; }
228 enum MinOptDepth {
229 AlwaysOpt, Opt16bpp, Opt15bpp, NeverOpt };
231 void setMinOptimizationDepth( int mode );
232 int minOptimizationDepth() const { return m_MinOptimizationDepth; }
233 bool optimize() const;
235 void setUseShm( bool use );
236 bool useShm() const { return m_bShm; }
238 void changeWallpaper(bool init=false);
239 void updateWallpaperFiles();
240 void randomizeWallpaperFiles();
242 QString currentWallpaper() const;
244 * @return true if the currentWallpaper has changed
246 bool discardCurrentWallpaper();
247 int lastWallpaperChange() const { return m_LastChange; }
248 bool needWallpaperChange();
250 void readSettings(bool reparse=false);
251 void writeSettings();
252 QString configGroupName() const;
254 int hash();
255 QString fingerprint();
257 void setEnabled( const bool enable );
258 bool enabled() const { return m_bEnabled; }
260 private:
261 void updateHash();
263 bool dirty;
264 bool hashdirty;
265 bool m_kdmMode;
266 int m_Screen, m_Desk, m_Hash;
268 QColor m_ColorA, defColorA;
269 QColor m_ColorB, defColorB;
270 QString m_Wallpaper;
271 QStringList m_WallpaperList, m_WallpaperFiles;
273 int m_BackgroundMode, defBackgroundMode;
274 int m_WallpaperMode, defWallpaperMode;
275 int m_BlendMode, defBlendMode;
276 int m_BlendBalance, defBlendBalance;
277 bool m_ReverseBlending, defReverseBlending;
278 int m_MinOptimizationDepth;
279 bool m_bShm;
280 bool m_bDrawBackgroundPerScreen;
282 int m_MultiMode, defMultiMode;
283 int m_Interval, m_LastChange;
284 int m_CurrentWallpaper;
285 QString m_CurrentWallpaperName;
287 KSharedConfigPtr m_pConfig;
288 KStandardDirs *m_pDirs;
289 bool m_bDeleteConfig;
290 bool m_bEnabled;
292 public:
293 QMap<QString,int> m_BMMap;
294 QMap<QString,int> m_WMMap;
295 QMap<QString,int> m_MMMap;
296 QMap<QString,int> m_BlMMap;
297 char *m_BMRevMap[16];
298 char *m_WMRevMap[16];
299 char *m_MMRevMap[16];
300 char *m_BlMRevMap[16];
305 * A class to read/modify the global desktop background settings.
307 class KGlobalBackgroundSettings
309 public:
310 KGlobalBackgroundSettings(const KSharedConfigPtr &config);
312 QString deskName(int desk);
313 //void setDeskName(int desk, QString name);
315 int cacheSize() { return m_CacheSize; }
316 void setCacheSize(int size);
318 bool drawBackgroundPerScreen(int desk) const;
319 void setDrawBackgroundPerScreen(int desk, bool perScreen);
321 bool limitCache() { return m_bLimitCache; }
322 void setLimitCache(bool limit);
324 bool commonScreenBackground() { return m_bCommonScreen; }
325 void setCommonScreenBackground(bool common);
327 bool commonDeskBackground() { return m_bCommonDesk; }
328 void setCommonDeskBackground(bool common);
330 bool dockPanel() { return m_bDock; }
331 void setDockPanel(bool dock);
333 bool exportBackground() {return m_bExport; }
334 void setExportBackground(bool _export);
336 void setTextColor(const QColor &_color);
337 QColor textColor() const { return m_TextColor; }
339 void setTextBackgroundColor(const QColor &_color);
340 QColor textBackgroundColor() const { return m_TextBackgroundColor; }
342 void setShadowEnabled(bool enabled);
343 bool shadowEnabled() const { return m_shadowEnabled; }
345 void setTextLines(int lines);
346 int textLines() const { return m_textLines; }
347 void setTextWidth(int width);
348 int textWidth() const { return m_textWidth; }
350 void readSettings();
351 void writeSettings();
353 private:
354 bool dirty;
355 bool m_bCommonDesk;
356 bool m_bCommonScreen;
357 bool m_bDock;
358 bool m_bLimitCache, m_bExport;
359 int m_CacheSize;
360 QStringList m_Names;
362 QColor m_TextColor;
363 QColor m_TextBackgroundColor;
364 bool m_shadowEnabled;
365 int m_textLines;
366 int m_textWidth;
367 KSharedConfigPtr m_pConfig;
368 QVector<bool> m_bDrawBackgroundPerScreen; // m_bDrawBackgroundPerScreen[desk]
372 #endif // __BGSettings_h_Included__