Debian Codegraph @

lib/ColorScheme.h

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 /*
2 This source file is part of Konsole, a terminal emulator.
3
4 Copyright 2007-2008 by Robert Knight <[email protected]>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
20 */
21
22 #ifndef COLORSCHEME_H
23 #define COLORSCHEME_Hcxx . . $ `lib/ColorScheme.h:23:9`!
24
25 // Qt
26 #include <QHash>
27 #include <QList>
28 #include <QMetaType>
29 #include <QIODevice>
30 #include <QSet>
31 #include <QSettings>
32
33 // Konsole
34 #include "CharacterColor.h"cxx . . $ `<file>/lib/CharacterColor.h`/
35
36 class QIODevicecxx . . $ QIODevice#;
37 //class KConfig;
38
39 namespace Konsolecxx . . $ Konsole/
40 {
41
42 /**
43 * Represents a color scheme for a terminal display.
44 *
45 * The color scheme includes the palette of colors used to draw the text and character backgrounds
46 * in the display and the opacity level of the display background.
47 */
•48 class ColorSchemecxx . . $ Konsole/ColorScheme# : public QObjectcxx . . $ QObject#
49 {
•50 Q_OBJECTcxx . . $ Konsole/ColorScheme#QPrivateSignal#
51
52 public:
53 /**
54 * Constructs a new color scheme which is initialised to the default color set
55 * for Konsole.
56 */
•57 ColorSchemecxx . . $ Konsole/ColorScheme#ColorScheme(749de1b6ae65bddd).(QObjectcxx . . $ QObject# *parent = nullptr);
58 ~cxx . . $ Konsole/ColorScheme#`~ColorScheme`(ced63f7c635d850d).ColorSchemecxx . . $ Konsole/ColorScheme#();
59
60 /** Sets the descriptive name of the color scheme. */
61 void setDescriptioncxx . . $ Konsole/ColorScheme#setDescription(3520e46b33348bf6).(const QStringcxx . . $ QString#& description);
62 /** Returns the descriptive name of the color scheme. */
63 QStringcxx . . $ QString# descriptioncxx . . $ Konsole/ColorScheme#description(6ef7b6c27b00b43d).() const;
64
65 /** Sets the name of the color scheme */
66 void setNamecxx . . $ Konsole/ColorScheme#setName(3520e46b33348bf6).(const QStringcxx . . $ QString#& name);
67 /** Returns the name of the color scheme */
68 QStringcxx . . $ QString# namecxx . . $ Konsole/ColorScheme#name(6ef7b6c27b00b43d).() const;
69
70 #if 0
71 // Implemented upstream - in user apps
72 /** Reads the color scheme from the specified configuration source */
73 void read(KConfig& config);
74 /** Writes the color scheme to the specified configuration source */
75 void write(KConfig& config) const;
76 #endif
77 void readcxx . . $ Konsole/ColorScheme#read(3520e46b33348bf6).(const QStringcxx . . $ QString# & filename);
•78 Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! void writecxx . . $ Konsole/ColorScheme#write(7fba01612ab56717).(const QStringcxx . . $ QString# & filename) const;
79
80 /** Sets a single entry within the color palette. */
81 void setColorTableEntrycxx . . $ Konsole/ColorScheme#setColorTableEntry(3c6840e24643ea34).(int index , const ColorEntrycxx . . $ Konsole/ColorEntry#& entry);
82
83 /**
84 * Copies the color entries which form the palette for this color scheme
85 * into @p table. @p table should be an array with TABLE_COLORS entries.
86 *
87 * @param table Array into which the color entries for this color scheme
88 * are copied.
89 * @param randomSeed Color schemes may allow certain colors in their
90 * palette to be randomized. The seed is used to pick the random color.
91 */
92 void getColorTablecxx . . $ Konsole/ColorScheme#getColorTable(3c246d1658e3993f).(ColorEntrycxx . . $ Konsole/ColorEntry#* table, uintcxx . . $ uint# randomSeed = 0) const;
93
94 /**
95 * Retrieves a single color entry from the table.
96 *
97 * See getColorTable()
98 */
99 ColorEntrycxx . . $ Konsole/ColorEntry# colorEntrycxx . . $ Konsole/ColorScheme#colorEntry(fa55034f524c1199).(int index , uintcxx . . $ uint# randomSeed = 0) const;
100
•101 Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! QColorcxx . . $ QColor# getColorcxx . . $ Konsole/ColorScheme#getColor(579fadac8368efbd).(int index) const;
102 Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! void setColorcxx . . $ Konsole/ColorScheme#setColor(9df84616657c19d9).(int index, QColorcxx . . $ QColor# color);
103 Q_SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:125:9`! void colorChangedcxx . . $ Konsole/ColorScheme#colorChanged(d4f767463ce0a6b3).(int index);
104
105 /**
106 * Convenience method. Returns the
107 * foreground color for this scheme,
108 * this is the primary color used to draw the
109 * text in this scheme.
110 */
111 QColorcxx . . $ QColor# foregroundColorcxx . . $ Konsole/ColorScheme#foregroundColor(6d62b116d5d1b12f).() const;
112 /**
113 * Convenience method. Returns the background color for
114 * this scheme, this is the primary color used to
115 * draw the terminal background in this scheme.
116 */
117 QColorcxx . . $ QColor# backgroundColorcxx . . $ Konsole/ColorScheme#backgroundColor(6d62b116d5d1b12f).() const;
118
119 /**
120 * Returns true if this color scheme has a dark background.
121 * The background color is said to be dark if it has a value of less than 127
122 * in the HSV color space.
123 */
124 bool hasDarkBackgroundcxx . . $ Konsole/ColorScheme#hasDarkBackground(50ce9a9e25b4a850).() const;
125
126 /**
127 * Sets the opacity level of the display background. @p opacity ranges
128 * between 0 (completely transparent background) and 1 (completely
129 * opaque background).
130 *
131 * Defaults to 1.
132 *
133 * TODO: More documentation
134 */
•135 Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! void setOpacitycxx . . $ Konsole/ColorScheme#setOpacity(ba8836b59fb42830).(qrealcxx . . $ qreal# opacity);
136 /**
137 * Returns the opacity level for this color scheme, see setOpacity()
138 * TODO: More documentation
139 */
•140 Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! qrealcxx . . $ qreal# opacitycxx . . $ Konsole/ColorScheme#opacity(21b6c25e127938e2).() const;
141 Q_SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:125:9`! void opacityChangedcxx . . $ Konsole/ColorScheme#opacityChanged(49f6e7a06ebc5aa8).();
142
143 /**
144 * Enables randomization of the background color. This will cause
145 * the palette returned by getColorTable() and colorEntry() to
146 * be adjusted depending on the value of the random seed argument
147 * to them.
148 */
149 void setRandomizedBackgroundColorcxx . . $ Konsole/ColorScheme#setRandomizedBackgroundColor(b45ddcbc8423892c).(bool randomize);
150
151 /** Returns true if the background color is randomized. */
152 bool randomizedBackgroundColorcxx . . $ Konsole/ColorScheme#randomizedBackgroundColor(50ce9a9e25b4a850).() const;
153
154 static QStringcxx . . $ QString# colorNameForIndexcxx . . $ Konsole/ColorScheme#colorNameForIndex(ce915ed341d4a7f0).(int index);
155 static QStringcxx . . $ QString# translatedColorNameForIndexcxx . . $ Konsole/ColorScheme#translatedColorNameForIndex(ce915ed341d4a7f0).(int index);
156
157 private:
158 // specifies how much a particular color can be randomized by
159 class RandomizationRangecxx . . $ Konsole/ColorScheme#RandomizationRange#
160 {
161 public:
162 RandomizationRangecxx . . $ Konsole/ColorScheme#RandomizationRange#RandomizationRange(49f6e7a06ebc5aa8).() : huecxx . . $ Konsole/ColorScheme#RandomizationRange#hue.(0) , saturationcxx . . $ Konsole/ColorScheme#RandomizationRange#saturation.(0) , valuecxx . . $ Konsole/ColorScheme#RandomizationRange#value.(0) {}
163
164 bool isNullcxx . . $ Konsole/ColorScheme#RandomizationRange#isNull(50ce9a9e25b4a850).() const
165 {
166 return ( huecxx . . $ Konsole/ColorScheme#RandomizationRange#hue. == 0 && saturationcxx . . $ Konsole/ColorScheme#RandomizationRange#saturation. == 0 && valuecxx . . $ Konsole/ColorScheme#RandomizationRange#value. == 0 );
167 }
168
169 quint16cxx . . $ quint16# huecxx . . $ Konsole/ColorScheme#RandomizationRange#hue.;
170 quint8cxx . . $ quint8# saturationcxx . . $ Konsole/ColorScheme#RandomizationRange#saturation.;
171 quint8cxx . . $ quint8# valuecxx . . $ Konsole/ColorScheme#RandomizationRange#value.;
172 };
173
174 // returns the active color table. if none has been set specifically,
175 // this is the default color table.
176 const ColorEntrycxx . . $ Konsole/ColorEntry#* colorTablecxx . . $ Konsole/ColorScheme#colorTable(ec15202fc6ea9dfb).() const;
177
178 #if 0
179 // implemented upstream - user apps
180 // reads a single colour entry from a KConfig source
181 // and sets the palette entry at 'index' to the entry read.
182 void readColorEntry(KConfig& config , int index);
183 // writes a single colour entry to a KConfig source
184 void writeColorEntry(KConfig& config , const QString& colorName, const ColorEntry& entry,const RandomizationRange& range) const;
185 #endif
186 void readColorEntrycxx . . $ Konsole/ColorScheme#readColorEntry(2bca0edb2e1897ed).(QSettingscxx . . $ QSettings# *s, int index);
•187 void writeColorEntrycxx . . $ Konsole/ColorScheme#writeColorEntry(40501a4d721c9e5d).(QSettingscxx . . $ QSettings# *s, int index, const ColorEntrycxx . . $ Konsole/ColorEntry#& entry) const;
188
189 // sets the amount of randomization allowed for a particular color
190 // in the palette. creates the randomization table if
191 // it does not already exist
192 void setRandomizationRangecxx . . $ Konsole/ColorScheme#setRandomizationRange(1345fdb3466ed04e).( int index , quint16cxx . . $ quint16# hue , quint8cxx . . $ quint8# saturation , quint8cxx . . $ quint8# value );
193
194 QStringcxx . . $ QString# _descriptioncxx . . $ Konsole/ColorScheme#_description.;
195 QStringcxx . . $ QString# _namecxx . . $ Konsole/ColorScheme#_name.;
196 qrealcxx . . $ qreal# _opacitycxx . . $ Konsole/ColorScheme#_opacity.;
197 ColorEntrycxx . . $ Konsole/ColorEntry#* _tablecxx . . $ Konsole/ColorScheme#_table.; // pointer to custom color table or 0 if the default
198 // color scheme is being used
199
200
201 static const quint16cxx . . $ quint16# MAX_HUEcxx . . $ Konsole/ColorScheme#MAX_HUE. = 340;
202
203 RandomizationRangecxx . . $ Konsole/ColorScheme#RandomizationRange#* _randomTablecxx . . $ Konsole/ColorScheme#_randomTable.; // pointer to randomization table or 0
204 // if no colors in the color scheme support
205 // randomization
206
207 static const char* const colorNamescxx . . $ Konsole/ColorScheme#colorNames.[TABLE_COLORScxx . . $ `lib/CharacterColor.h:103:9`!];
208 static const char* const translatedColorNamescxx . . $ Konsole/ColorScheme#translatedColorNames.[TABLE_COLORScxx . . $ `lib/CharacterColor.h:103:9`!];
209
210 static const ColorEntrycxx . . $ Konsole/ColorEntry# defaultTablecxx . . $ Konsole/ColorScheme#defaultTable.[]; // table of default color entries
211 };
212
213 /**
214 * A color scheme which uses colors from the standard KDE color palette.
215 *
216 * This is designed primarily for the benefit of users who are using specially
217 * designed colors.
218 *
219 * TODO Implement and make it the default on systems with specialized KDE
220 * color schemes.
221 */
222 class AccessibleColorSchemecxx . . $ Konsole/AccessibleColorScheme# : public ColorSchemecxx . . $ Konsole/ColorScheme#
223 {
224 public:
225 AccessibleColorSchemecxx . . $ Konsole/AccessibleColorScheme#AccessibleColorScheme(49f6e7a06ebc5aa8).();
226 };
227
228 /**
229 * Manages the color schemes available for use by terminal displays.
230 * See ColorScheme
231 */
•232 class ColorSchemeManagercxx . . $ Konsole/ColorSchemeManager# : public QObjectcxx . . $ QObject#
233 {
•234 Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`!
235
236 public:
237
238 /**
239 * Constructs a new ColorSchemeManager and loads the list
240 * of available color schemes.
241 *
242 * The color schemes themselves are not loaded until they are first
243 * requested via a call to findColorScheme()
244 */
245 ColorSchemeManagercxx . . $ Konsole/ColorSchemeManager#ColorSchemeManager(49f6e7a06ebc5aa8).();
246 /**
247 * Destroys the ColorSchemeManager and saves any modified color schemes to disk.
248 */
249 ~cxx . . $ Konsole/ColorSchemeManager#`~ColorSchemeManager`(ced63f7c635d850d).ColorSchemeManagercxx . . $ Konsole/ColorSchemeManager#();
250
251 /**
252 * Returns the default color scheme for Konsole
253 */
254 const ColorSchemecxx . . $ Konsole/ColorScheme#* defaultColorSchemecxx . . $ Konsole/ColorSchemeManager#defaultColorScheme(b3d5baf7ec74d27d).() const;
255
256 /**
257 * Returns the color scheme with the given name or 0 if no
258 * scheme with that name exists. If @p name is empty, the
259 * default color scheme is returned.
260 *
261 * The first time that a color scheme with a particular name is
262 * requested, the configuration information is loaded from disk.
263 */
•264 Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! const Konsolecxx . . $ Konsole/::ColorSchemecxx . . $ Konsole/ColorScheme#* findColorSchemecxx . . $ Konsole/ColorSchemeManager#findColorScheme(c2b30146a6fdc030).(const QStringcxx . . $ QString#& name);
265
266 #if 0
267 /**
268 * Adds a new color scheme to the manager. If @p scheme has the same name as
269 * an existing color scheme, it replaces the existing scheme.
270 *
271 * TODO - Ensure the old color scheme gets deleted
272 */
273 void addColorScheme(ColorScheme* scheme);
274 #endif
275 /**
276 * Deletes a color scheme. Returns true on successful deletion or false otherwise.
277 */
278 bool deleteColorSchemecxx . . $ Konsole/ColorSchemeManager#deleteColorScheme(e1defb592416720d).(const QStringcxx . . $ QString#& name);
279
280 /**
281 * Returns a list of the all the available color schemes.
282 * This may be slow when first called because all of the color
283 * scheme resources on disk must be located, read and parsed.
284 *
285 * Subsequent calls will be inexpensive.
286 */
287 QListcxx . . $ QList#<const ColorSchemecxx . . $ Konsole/ColorScheme#*> allColorSchemescxx . . $ Konsole/ColorSchemeManager#allColorSchemes(de974b58986d672).();
288
289 /** Returns the global color scheme manager instance. */
290 static ColorSchemeManagercxx . . $ Konsole/ColorSchemeManager#* instancecxx . . $ Konsole/ColorSchemeManager#instance(604bba33ddb2d782).();
291
292 /** @brief Loads a custom color scheme under given \em path.
293 *
294 * The \em path may refer to either KDE 4 .colorscheme or KDE 3
295 * .schema file
296 *
297 * The loaded color scheme is available under the name equal to
298 * the base name of the \em path via the allColorSchemes() and
299 * findColorScheme() methods after this call if loaded successfully.
300 *
301 * @param[in] path The path to KDE 4 .colorscheme or KDE 3 .schema.
302 * @return Whether the color scheme is loaded successfully.
303 */
•304 Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! bool loadCustomColorSchemecxx . . $ Konsole/ColorSchemeManager#loadCustomColorScheme(e1defb592416720d).(const QStringcxx . . $ QString#& path);
305
306 /**
307 * @brief Allows to add a custom location of color schemes.
308 *
309 * @param[in] custom_dir Custom location of color schemes (must end with /).
310 */
311 void addCustomColorSchemeDircxx . . $ Konsole/ColorSchemeManager#addCustomColorSchemeDir(3520e46b33348bf6).(const QStringcxx . . $ QString#& custom_dir);
312
313 private:
314 // loads a color scheme from a KDE 4+ .colorscheme file
315 bool loadColorSchemecxx . . $ Konsole/ColorSchemeManager#loadColorScheme(e1defb592416720d).(const QStringcxx . . $ QString#& path);
316 // returns a list of paths of color schemes in the KDE 4+ .colorscheme file format
317 QListcxx . . $ QList#<QStringcxx . . $ QString#> listColorSchemescxx . . $ Konsole/ColorSchemeManager#listColorSchemes(346f0183abd8f69).();
318 // loads all of the color schemes
319 void loadAllColorSchemescxx . . $ Konsole/ColorSchemeManager#loadAllColorSchemes(49f6e7a06ebc5aa8).();
320 // finds the path of a color scheme
321 QStringcxx . . $ QString# findColorSchemePathcxx . . $ Konsole/ColorSchemeManager#findColorSchemePath(5555d9024dcf93fb).(const QStringcxx . . $ QString#& name) const;
322
323 QHashcxx . . $ QHash#<QStringcxx . . $ QString#,const ColorSchemecxx . . $ Konsole/ColorScheme#*> _colorSchemescxx . . $ Konsole/ColorSchemeManager#_colorSchemes.;
324 QSetcxx . . $ QSet#<ColorSchemecxx . . $ Konsole/ColorScheme#*> _modifiedSchemescxx . . $ Konsole/ColorSchemeManager#_modifiedSchemes.;
325
326 bool _haveLoadedAllcxx . . $ Konsole/ColorSchemeManager#_haveLoadedAll.;
327
328 static const ColorSchemecxx . . $ Konsole/ColorScheme# _defaultColorSchemecxx . . $ Konsole/ColorSchemeManager#_defaultColorScheme.;
329 };
330
331 }
332
333 Q_DECLARE_METATYPEcxx . . $ quintptr#(const Konsole::ColorScheme*)
334
335 #endif //COLORSCHEME_H