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.
11 #ifndef __BGSettings_h_Included__
12 #define __BGSettings_h_Included__
18 #include <ksharedconfig.h>
20 template <class QString
, class T
> class QMap
;
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
34 explicit KBackgroundPattern(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
; }
52 bool isGlobal()const { return m_bReadOnly
; }
57 static QStringList
list();
60 void init(bool force_rw
=false);
61 QString
fingerprint();
63 bool dirty
, hashdirty
;
66 QString m_Name
, m_Comment
;
67 QString m_Pattern
, m_File
;
68 KStandardDirs
*m_pDirs
;
69 KDesktopFile
*m_pConfig
;
74 * A class to manipulate/read/write/list KDE desktop programs (a la xearth).
76 * A program is described by a string like:
78 * a_program -xres %x -yres %y -outfile %f
80 * Possible escape sequences:
82 * %x Horizontal resolution in pixels.
83 * %y Vertical resolution in pixels.
84 * %f Filename to dump to.
86 * An entry for each program is stored as a .desktop file in
87 * $(datadir)/kdesktop/programs.
89 class KBackgroundProgram
92 explicit KBackgroundProgram(const QString
&name
= QString());
93 ~KBackgroundProgram();
95 void copyConfig(const KBackgroundProgram
*);
97 QString
name()const { return m_Name
; }
98 void load(const QString
& name
);
100 void setComment(const QString
&comment
);
101 QString
comment()const { return m_Comment
; }
103 void setCommand(const QString
&command
);
104 QString
command()const { return m_Command
; }
106 void setPreviewCommand(const QString
&command
);
107 QString
previewCommand()const { return m_PreviewCommand
; }
109 void setRefresh(int refresh
);
110 int refresh()const { return m_Refresh
; }
112 void setExecutable(const QString
&executable
);
113 QString
executable()const { return m_Executable
; }
116 void writeSettings();
124 bool isGlobal()const { return m_bReadOnly
; }
127 static QStringList
list();
130 void init(bool force_rw
=false);
131 QString
fingerprint();
133 bool dirty
, hashdirty
;
135 int m_Refresh
, m_Hash
, m_LastChange
;
136 QString m_Name
, m_Command
;
137 QString m_PreviewCommand
, m_Comment
;
138 QString m_Executable
, m_File
;
139 KStandardDirs
*m_pDirs
;
140 KDesktopFile
*m_pConfig
;
145 * KBackgroundSettings: A class to read/write/manipulate
146 * KDE desktop settings.
148 class KBackgroundSettings
149 : public KBackgroundPattern
,
150 public KBackgroundProgram
154 * @param drawBackgroundPerScreen if false, then all screens (in xinerama
155 * mode) will be treated as one big display, and the "screen" paramater
158 KBackgroundSettings(int screen
, bool drawBackgroundPerScreen
, const KSharedConfigPtr
&config
);
159 ~KBackgroundSettings();
161 void copyConfig(const KBackgroundSettings
*);
163 bool drawBackgroundPerScreen() const { return m_bDrawBackgroundPerScreen
; }
164 void setDrawBackgroundPerScreen(bool draw
);
166 int screen() const { return m_Screen
; }
167 void load(int screen
, bool drawBackgroundPerScreen
, bool reparseConfig
);
169 void setColorA(const QColor
&color
);
170 QColor
colorA() const { return m_ColorA
; }
171 void setColorB(const QColor
&color
);
172 QColor
colorB() const { return m_ColorB
; }
174 void setProgram(const QString
&program
);
175 void setPatternName(const QString
&pattern
);
177 enum BackgroundMode
{
178 Flat
, Pattern
, Program
,
179 HorizontalGradient
, VerticalGradient
, PyramidGradient
,
180 PipeCrossGradient
, EllipticGradient
, lastBackgroundMode
182 void setBackgroundMode(int mode
);
183 int backgroundMode() const { return m_BackgroundMode
; }
186 NoBlending
, FlatBlending
,
187 HorizontalBlending
, VerticalBlending
, PyramidBlending
,
188 PipeCrossBlending
, EllipticBlending
,
189 IntensityBlending
, SaturateBlending
, ContrastBlending
,
190 HueShiftBlending
, lastBlendMode
192 void setBlendMode(int mode
);
193 int blendMode() const { return m_BlendMode
; }
195 void setReverseBlending(bool value
);
196 bool reverseBlending() const { return m_ReverseBlending
; }
198 void setBlendBalance(int value
);
199 int blendBalance() const { return m_BlendBalance
; }
201 void setWallpaper(const QString
&name
);
202 QString
wallpaper() const { return m_Wallpaper
; }
205 NoWallpaper
, Centred
, Tiled
, CenterTiled
, CentredMaxpect
, TiledMaxpect
,
206 Scaled
, CentredAutoFit
, ScaleAndCrop
, lastWallpaperMode
208 void setWallpaperMode(int mode
);
209 int wallpaperMode() const { return m_WallpaperMode
; }
211 void setWallpaperList(const QStringList
&);
212 QStringList
wallpaperList() const;
213 QStringList
wallpaperFiles() const;
215 void setWallpaperChangeInterval(int);
216 int wallpaperChangeInterval() const { return m_Interval
; }
219 NoMulti
, InOrder
, Random
, NoMultiRandom
221 void setMultiWallpaperMode(int mode
);
222 int multiWallpaperMode() const { return m_MultiMode
; }
225 AlwaysOpt
, Opt16bpp
, Opt15bpp
, NeverOpt
};
227 void setMinOptimizationDepth( int mode
);
228 int minOptimizationDepth() const { return m_MinOptimizationDepth
; }
229 bool optimize() const;
231 void setUseShm( bool use
);
232 bool useShm() const { return m_bShm
; }
234 void changeWallpaper(bool init
=false);
235 void updateWallpaperFiles();
236 void randomizeWallpaperFiles();
238 QString
currentWallpaper() const;
240 * @return true if the currentWallpaper has changed
242 bool discardCurrentWallpaper();
243 int lastWallpaperChange() const { return m_LastChange
; }
244 bool needWallpaperChange();
246 void readSettings(bool reparse
=false);
247 void writeSettings();
248 QString
configGroupName() const;
251 QString
fingerprint();
253 void setEnabled( const bool enable
);
254 bool enabled() const { return m_bEnabled
; }
261 int m_Screen
, m_Hash
;
263 QColor m_ColorA
, defColorA
;
264 QColor m_ColorB
, defColorB
;
266 QStringList m_WallpaperList
, m_WallpaperFiles
;
268 int m_BackgroundMode
, defBackgroundMode
;
269 int m_WallpaperMode
, defWallpaperMode
;
270 int m_BlendMode
, defBlendMode
;
271 int m_BlendBalance
, defBlendBalance
;
272 bool m_ReverseBlending
, defReverseBlending
;
273 int m_MinOptimizationDepth
;
275 bool m_bDrawBackgroundPerScreen
;
277 int m_MultiMode
, defMultiMode
;
278 int m_Interval
, m_LastChange
;
279 int m_CurrentWallpaper
;
280 QString m_CurrentWallpaperName
;
282 KSharedConfigPtr m_pConfig
;
283 KStandardDirs
*m_pDirs
;
284 bool m_bDeleteConfig
;
288 QMap
<QString
,int> m_BMMap
;
289 QMap
<QString
,int> m_WMMap
;
290 QMap
<QString
,int> m_MMMap
;
291 QMap
<QString
,int> m_BlMMap
;
292 char *m_BMRevMap
[16];
293 char *m_WMRevMap
[16];
294 char *m_MMRevMap
[16];
295 char *m_BlMRevMap
[16];
300 * A class to read/modify the global desktop background settings.
302 class KGlobalBackgroundSettings
305 KGlobalBackgroundSettings(const KSharedConfigPtr
&config
);
307 int cacheSize() { return m_CacheSize
; }
308 void setCacheSize(int size
);
310 bool drawBackgroundPerScreen() const;
311 void setDrawBackgroundPerScreen(bool perScreen
);
313 bool limitCache() { return m_bLimitCache
; }
314 void setLimitCache(bool limit
);
316 bool commonScreenBackground() { return m_bCommonScreen
; }
317 void setCommonScreenBackground(bool common
);
320 void writeSettings();
324 bool m_bCommonScreen
;
328 KSharedConfigPtr m_pConfig
;
329 bool m_bDrawBackgroundPerScreen
;
333 #endif // __BGSettings_h_Included__