~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kdm/kcm/background/bgsettings.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* vi: ts=8 sts=4 sw=4
 
2
 * kate: space-indent on; indent-width 4; indent-mode cstyle;
 
3
 *
 
4
 * This file is part of the KDE project, module kdesktop.
 
5
 * Copyright (C) 1999 Geert Jansen <g.t.jansen@stud.tue.nl>
 
6
 *
 
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
 */
 
10
 
 
11
#ifndef __BGSettings_h_Included__
 
12
#define __BGSettings_h_Included__
 
13
 
 
14
 
 
15
#include <QColor>
 
16
#include <QMap>
 
17
#include <ksharedconfig.h>
 
18
 
 
19
template <class QString, class T> class QMap;
 
20
class KStandardDirs;
 
21
class KDesktopFile;
 
22
class QString;
 
23
 
 
24
/**
 
25
 * A class to manipulate/read/write/list KDE desktop patterns.
 
26
 *
 
27
 * A pattern is a raster image. An entry for earch pattern is
 
28
 * stored as a .desktop file in $(datadir)/kdesktop/patterns.
 
29
 */
 
30
class KBackgroundPattern {
 
31
public:
 
32
    explicit KBackgroundPattern(const QString &name = QString());
 
33
    ~KBackgroundPattern();
 
34
 
 
35
    void copyConfig(const KBackgroundPattern *);
 
36
 
 
37
    QString name() const { return m_Name; }
 
38
    void load(const QString &name);
 
39
 
 
40
    void setComment(const QString &comment);
 
41
    QString comment() const {return m_Comment; }
 
42
 
 
43
    void setPattern(const QString &file);
 
44
    QString pattern() const { return m_Pattern; }
 
45
 
 
46
    void readSettings();
 
47
    void writeSettings();
 
48
 
 
49
    bool isAvailable();
 
50
    bool isGlobal()const { return m_bReadOnly; }
 
51
    bool remove();
 
52
 
 
53
    int hash();
 
54
 
 
55
    static QStringList list();
 
56
 
 
57
private:
 
58
    void init(bool force_rw = false);
 
59
    QString fingerprint();
 
60
 
 
61
    bool dirty, hashdirty;
 
62
    bool m_bReadOnly;
 
63
    int m_Hash;
 
64
    QString m_Name, m_Comment;
 
65
    QString m_Pattern, m_File;
 
66
    KStandardDirs *m_pDirs;
 
67
    KDesktopFile *m_pConfig;
 
68
};
 
69
 
 
70
 
 
71
/**
 
72
 * A class to manipulate/read/write/list KDE desktop programs (a la xearth).
 
73
 *
 
74
 * A program is described by a string like:
 
75
 *
 
76
 *   a_program -xres %x -yres %y -outfile %f
 
77
 *
 
78
 * Possible escape sequences:
 
79
 *
 
80
 *   %x    Horizontal resolution in pixels.
 
81
 *   %y    Vertical resolution in pixels.
 
82
 *   %f    Filename to dump to.
 
83
 *
 
84
 * An entry for each program is stored as a .desktop file in
 
85
 * $(datadir)/kdesktop/programs.
 
86
 */
 
87
class KBackgroundProgram {
 
88
public:
 
89
    explicit KBackgroundProgram(const QString &name = QString());
 
90
    ~KBackgroundProgram();
 
91
 
 
92
    void copyConfig(const KBackgroundProgram *);
 
93
 
 
94
    QString name()const { return m_Name; }
 
95
    void load(const QString & name);
 
96
 
 
97
    void setComment(const QString &comment);
 
98
    QString comment()const { return m_Comment; }
 
99
 
 
100
    void setCommand(const QString &command);
 
101
    QString command()const { return m_Command; }
 
102
 
 
103
    void setPreviewCommand(const QString &command);
 
104
    QString previewCommand()const { return m_PreviewCommand; }
 
105
 
 
106
    void setRefresh(int refresh);
 
107
    int refresh()const { return m_Refresh; }
 
108
 
 
109
    void setExecutable(const QString &executable);
 
110
    QString executable()const { return m_Executable; }
 
111
 
 
112
    void readSettings();
 
113
    void writeSettings();
 
114
 
 
115
    void update();
 
116
    bool needUpdate();
 
117
 
 
118
    int hash();
 
119
 
 
120
    bool isAvailable();
 
121
    bool isGlobal()const { return m_bReadOnly; }
 
122
    bool remove();
 
123
 
 
124
    static QStringList list();
 
125
 
 
126
private:
 
127
    void init(bool force_rw = false);
 
128
    QString fingerprint();
 
129
 
 
130
    bool dirty, hashdirty;
 
131
    bool m_bReadOnly;
 
132
    int m_Refresh, m_Hash, m_LastChange;
 
133
    QString m_Name, m_Command;
 
134
    QString m_PreviewCommand, m_Comment;
 
135
    QString m_Executable, m_File;
 
136
    KStandardDirs *m_pDirs;
 
137
    KDesktopFile *m_pConfig;
 
138
};
 
139
 
 
140
 
 
141
/**
 
142
 * KBackgroundSettings: A class to read/write/manipulate
 
143
 * KDE desktop settings.
 
144
 */
 
145
class KBackgroundSettings
 
146
    : public KBackgroundPattern,
 
147
      public KBackgroundProgram {
 
148
public:
 
149
    /**
 
150
     * @param drawBackgroundPerScreen if false, then all screens (in xinerama
 
151
     * mode) will be treated as one big display, and the "screen" paramater
 
152
     * will be ignored.
 
153
     */
 
154
    KBackgroundSettings(int screen, bool drawBackgroundPerScreen, const KSharedConfigPtr &config);
 
155
    ~KBackgroundSettings();
 
156
 
 
157
    void copyConfig(const KBackgroundSettings *);
 
158
 
 
159
    bool drawBackgroundPerScreen() const { return m_bDrawBackgroundPerScreen; }
 
160
    void setDrawBackgroundPerScreen(bool draw);
 
161
 
 
162
    int screen() const { return m_Screen; }
 
163
    void load(int screen, bool drawBackgroundPerScreen, bool reparseConfig);
 
164
 
 
165
    void setColorA(const QColor &color);
 
166
    QColor colorA() const { return m_ColorA; }
 
167
    void setColorB(const QColor &color);
 
168
    QColor colorB() const { return m_ColorB; }
 
169
 
 
170
    void setProgram(const QString &program);
 
171
    void setPatternName(const QString &pattern);
 
172
 
 
173
    enum BackgroundMode {
 
174
        Flat, Pattern, Program,
 
175
        HorizontalGradient, VerticalGradient, PyramidGradient,
 
176
        PipeCrossGradient, EllipticGradient, lastBackgroundMode
 
177
    };
 
178
    void setBackgroundMode(int mode);
 
179
    int backgroundMode() const { return m_BackgroundMode; }
 
180
 
 
181
    enum BlendMode {
 
182
        NoBlending, FlatBlending,
 
183
        HorizontalBlending, VerticalBlending, PyramidBlending,
 
184
        PipeCrossBlending, EllipticBlending,
 
185
        IntensityBlending, SaturateBlending, ContrastBlending,
 
186
        HueShiftBlending, lastBlendMode
 
187
    };
 
188
    void setBlendMode(int mode);
 
189
    int blendMode() const { return m_BlendMode; }
 
190
 
 
191
    void setReverseBlending(bool value);
 
192
    bool reverseBlending() const { return m_ReverseBlending; }
 
193
 
 
194
    void setBlendBalance(int value);
 
195
    int blendBalance() const { return m_BlendBalance; }
 
196
 
 
197
    void setWallpaper(const QString &name);
 
198
    QString wallpaper() const { return m_Wallpaper; }
 
199
 
 
200
    enum WallpaperMode {
 
201
        NoWallpaper, Centred, Tiled, CenterTiled, CentredMaxpect, TiledMaxpect,
 
202
        Scaled, CentredAutoFit, ScaleAndCrop, lastWallpaperMode
 
203
    };
 
204
    void setWallpaperMode(int mode);
 
205
    int wallpaperMode() const { return m_WallpaperMode; }
 
206
 
 
207
    void setWallpaperList(const QStringList&);
 
208
    QStringList wallpaperList() const;
 
209
    QStringList wallpaperFiles() const;
 
210
 
 
211
    void setWallpaperChangeInterval(int);
 
212
    int wallpaperChangeInterval() const { return m_Interval; }
 
213
 
 
214
    enum MultiMode {
 
215
        NoMulti, InOrder, Random, NoMultiRandom
 
216
    };
 
217
    void setMultiWallpaperMode(int mode);
 
218
    int multiWallpaperMode() const { return m_MultiMode; }
 
219
 
 
220
    enum MinOptDepth {
 
221
        AlwaysOpt, Opt16bpp, Opt15bpp, NeverOpt
 
222
    };
 
223
 
 
224
    void setMinOptimizationDepth(int mode);
 
225
    int minOptimizationDepth() const { return m_MinOptimizationDepth; }
 
226
    bool optimize() const;
 
227
 
 
228
    void setUseShm(bool use);
 
229
    bool useShm() const { return m_bShm; }
 
230
 
 
231
    void changeWallpaper(bool init = false);
 
232
    void updateWallpaperFiles();
 
233
    void randomizeWallpaperFiles();
 
234
 
 
235
    QString currentWallpaper() const;
 
236
    /**
 
237
     * @return true if the currentWallpaper has changed
 
238
     */
 
239
    bool discardCurrentWallpaper();
 
240
    int lastWallpaperChange() const { return m_LastChange; }
 
241
    bool needWallpaperChange();
 
242
 
 
243
    void readSettings(bool reparse = false);
 
244
    void writeSettings();
 
245
    QString configGroupName() const;
 
246
 
 
247
    int hash();
 
248
    QString fingerprint();
 
249
 
 
250
    void setEnabled(const bool enable);
 
251
    bool enabled() const { return m_bEnabled; }
 
252
 
 
253
private:
 
254
    void updateHash();
 
255
 
 
256
    bool dirty;
 
257
    bool hashdirty;
 
258
    int m_Screen, m_Hash;
 
259
 
 
260
    QColor m_ColorA, defColorA;
 
261
    QColor m_ColorB, defColorB;
 
262
    QString m_Wallpaper;
 
263
    QStringList m_WallpaperList, m_WallpaperFiles;
 
264
 
 
265
    int m_BackgroundMode, defBackgroundMode;
 
266
    int m_WallpaperMode, defWallpaperMode;
 
267
    int m_BlendMode, defBlendMode;
 
268
    int m_BlendBalance, defBlendBalance;
 
269
    bool m_ReverseBlending, defReverseBlending;
 
270
    int m_MinOptimizationDepth;
 
271
    bool m_bShm;
 
272
    bool m_bDrawBackgroundPerScreen;
 
273
 
 
274
    int m_MultiMode, defMultiMode;
 
275
    int m_Interval, m_LastChange;
 
276
    int m_CurrentWallpaper;
 
277
    QString m_CurrentWallpaperName;
 
278
 
 
279
    KSharedConfigPtr m_pConfig;
 
280
    KStandardDirs *m_pDirs;
 
281
    bool m_bDeleteConfig;
 
282
    bool m_bEnabled;
 
283
 
 
284
public:
 
285
    QMap<QString, int> m_BMMap;
 
286
    QMap<QString, int> m_WMMap;
 
287
    QMap<QString, int> m_MMMap;
 
288
    QMap<QString, int> m_BlMMap;
 
289
    char *m_BMRevMap[16];
 
290
    char *m_WMRevMap[16];
 
291
    char *m_MMRevMap[16];
 
292
    char *m_BlMRevMap[16];
 
293
};
 
294
 
 
295
 
 
296
/**
 
297
 * A class to read/modify the global desktop background settings.
 
298
 */
 
299
class KGlobalBackgroundSettings {
 
300
public:
 
301
    KGlobalBackgroundSettings(const KSharedConfigPtr &config);
 
302
 
 
303
    int cacheSize() { return m_CacheSize; }
 
304
    void setCacheSize(int size);
 
305
 
 
306
    bool drawBackgroundPerScreen() const;
 
307
    void setDrawBackgroundPerScreen(bool perScreen);
 
308
 
 
309
    bool limitCache() { return m_bLimitCache; }
 
310
    void setLimitCache(bool limit);
 
311
 
 
312
    bool commonScreenBackground() { return m_bCommonScreen; }
 
313
    void setCommonScreenBackground(bool common);
 
314
 
 
315
    void readSettings();
 
316
    void writeSettings();
 
317
 
 
318
private:
 
319
    bool dirty;
 
320
    bool m_bCommonScreen;
 
321
    bool m_bLimitCache;
 
322
    int m_CacheSize;
 
323
 
 
324
    KSharedConfigPtr m_pConfig;
 
325
    bool m_bDrawBackgroundPerScreen;
 
326
};
 
327
 
 
328
#endif // __BGSettings_h_Included__