Mercurial > octave-nkf
annotate gui/konsole/ColorScheme.h @ 14242:637675470c58 gui
Added OctaveDEs konsole sources.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Sun, 22 Jan 2012 14:18:05 +0100 |
parents | |
children |
rev | line source |
---|---|
14242
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1 /* |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2 This source file is part of Konsole, a terminal emulator. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
3 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
4 Copyright 2007-2008 by Robert Knight <robertknight@gmail.com> |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
5 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
6 This program is free software; you can redistribute it and/or modify |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
7 it under the terms of the GNU General Public License as published by |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
8 the Free Software Foundation; either version 2 of the License, or |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
9 (at your option) any later version. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
10 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
11 This program is distributed in the hope that it will be useful, |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
14 GNU General Public License for more details. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
15 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
16 You should have received a copy of the GNU General Public License |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
17 along with this program; if not, write to the Free Software |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
19 02110-1301 USA. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
20 */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
21 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
22 #ifndef COLORSCHEME_H |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
23 #define COLORSCHEME_H |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
24 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
25 // Qt |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
26 #include <QtCore/QHash> |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
27 #include <QtCore/QList> |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
28 #include <QtCore/QMetaType> |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
29 #include <QtCore/QIODevice> |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
30 #include <QtCore/QSet> |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
31 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
32 // Konsole |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
33 #include "CharacterColor.h" |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
34 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
35 class QIODevice; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
36 class KConfig; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
37 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
38 namespace Konsole |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
39 { |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
40 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
41 /** |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
42 * Represents a color scheme for a terminal display. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
43 * |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
44 * The color scheme includes the palette of colors used to draw the text and character backgrounds |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
45 * in the display and the opacity level of the display background. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
46 */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
47 class ColorScheme |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
48 { |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
49 public: |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
50 /** |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
51 * Constructs a new color scheme which is initialised to the default color set |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
52 * for Konsole. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
53 */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
54 ColorScheme(); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
55 ColorScheme(const ColorScheme& other); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
56 ~ColorScheme(); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
57 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
58 /** Sets the descriptive name of the color scheme. */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
59 void setDescription(const QString& description); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
60 /** Returns the descriptive name of the color scheme. */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
61 QString description() const; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
62 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
63 /** Sets the name of the color scheme */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
64 void setName(const QString& name); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
65 /** Returns the name of the color scheme */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
66 QString name() const; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
67 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
68 /** Reads the color scheme from the specified configuration source */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
69 void read(KConfig& config); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
70 /** Writes the color scheme to the specified configuration source */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
71 void write(KConfig& config) const; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
72 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
73 /** Sets a single entry within the color palette. */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
74 void setColorTableEntry(int index , const ColorEntry& entry); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
75 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
76 /** |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
77 * Copies the color entries which form the palette for this color scheme |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
78 * into @p table. @p table should be an array with TABLE_COLORS entries. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
79 * |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
80 * @param table Array into which the color entries for this color scheme |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
81 * are copied. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
82 * @param randomSeed Color schemes may allow certain colors in their |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
83 * palette to be randomized. The seed is used to pick the random color. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
84 */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
85 void getColorTable(ColorEntry* table, uint randomSeed = 0) const; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
86 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
87 /** |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
88 * Retrieves a single color entry from the table. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
89 * |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
90 * See getColorTable() |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
91 */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
92 ColorEntry colorEntry(int index , uint randomSeed = 0) const; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
93 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
94 /** |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
95 * Convenience method. Returns the |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
96 * foreground color for this scheme, |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
97 * this is the primary color used to draw the |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
98 * text in this scheme. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
99 */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
100 QColor foregroundColor() const; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
101 /** |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
102 * Convenience method. Returns the background color for |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
103 * this scheme, this is the primary color used to |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
104 * draw the terminal background in this scheme. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
105 */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
106 QColor backgroundColor() const; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
107 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
108 /** |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
109 * Returns true if this color scheme has a dark background. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
110 * The background color is said to be dark if it has a value of less than 127 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
111 * in the HSV color space. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
112 */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
113 bool hasDarkBackground() const; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
114 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
115 /** |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
116 * Sets the opacity level of the display background. @p opacity ranges |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
117 * between 0 (completely transparent background) and 1 (completely |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
118 * opaque background). |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
119 * |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
120 * Defaults to 1. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
121 * |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
122 * TODO: More documentation |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
123 */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
124 void setOpacity(qreal opacity); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
125 /** |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
126 * Returns the opacity level for this color scheme, see setOpacity() |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
127 * TODO: More documentation |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
128 */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
129 qreal opacity() const; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
130 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
131 /** |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
132 * Enables randomization of the background color. This will cause |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
133 * the palette returned by getColorTable() and colorEntry() to |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
134 * be adjusted depending on the value of the random seed argument |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
135 * to them. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
136 */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
137 void setRandomizedBackgroundColor(bool randomize); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
138 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
139 /** Returns true if the background color is randomized. */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
140 bool randomizedBackgroundColor() const; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
141 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
142 static QString colorNameForIndex(int index); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
143 static QString translatedColorNameForIndex(int index); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
144 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
145 private: |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
146 // specifies how much a particular color can be randomized by |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
147 class RandomizationRange |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
148 { |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
149 public: |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
150 RandomizationRange() : hue(0) , saturation(0) , value(0) {} |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
151 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
152 bool isNull() const |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
153 { |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
154 return ( hue == 0 && saturation == 0 && value == 0 ); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
155 } |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
156 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
157 quint16 hue; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
158 quint8 saturation; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
159 quint8 value; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
160 }; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
161 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
162 // returns the active color table. if none has been set specifically, |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
163 // this is the default color table. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
164 const ColorEntry* colorTable() const; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
165 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
166 // reads a single colour entry from a KConfig source |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
167 // and sets the palette entry at 'index' to the entry read. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
168 void readColorEntry(KConfig& config , int index); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
169 // writes a single colour entry to a KConfig source |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
170 void writeColorEntry(KConfig& config , const QString& colorName, const ColorEntry& entry,const RandomizationRange& range) const; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
171 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
172 // sets the amount of randomization allowed for a particular color |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
173 // in the palette. creates the randomization table if |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
174 // it does not already exist |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
175 void setRandomizationRange( int index , quint16 hue , quint8 saturation , quint8 value ); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
176 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
177 QString _description; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
178 QString _name; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
179 qreal _opacity; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
180 ColorEntry* _table; // pointer to custom color table or 0 if the default |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
181 // color scheme is being used |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
182 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
183 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
184 static const quint16 MAX_HUE = 340; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
185 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
186 RandomizationRange* _randomTable; // pointer to randomization table or 0 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
187 // if no colors in the color scheme support |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
188 // randomization |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
189 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
190 static const char* const colorNames[TABLE_COLORS]; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
191 static const char* const translatedColorNames[TABLE_COLORS]; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
192 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
193 static const ColorEntry defaultTable[]; // table of default color entries |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
194 }; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
195 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
196 /** |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
197 * A color scheme which uses colors from the standard KDE color palette. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
198 * |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
199 * This is designed primarily for the benefit of users who are using specially |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
200 * designed colors. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
201 * |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
202 * TODO Implement and make it the default on systems with specialized KDE |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
203 * color schemes. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
204 */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
205 class AccessibleColorScheme : public ColorScheme |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
206 { |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
207 public: |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
208 AccessibleColorScheme(); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
209 }; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
210 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
211 /** |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
212 * Reads a color scheme stored in the .schema format used in the KDE 3 incarnation |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
213 * of Konsole |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
214 * |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
215 * Only the basic essentials ( title and color palette entries ) are currently |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
216 * supported. Additional options such as background image and background |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
217 * blend colors are ignored. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
218 */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
219 class KDE3ColorSchemeReader |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
220 { |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
221 public: |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
222 /** |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
223 * Constructs a new reader which reads from the specified device. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
224 * The device should be open in read-only mode. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
225 */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
226 KDE3ColorSchemeReader( QIODevice* device ); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
227 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
228 /** |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
229 * Reads and parses the contents of the .schema file from the input |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
230 * device and returns the ColorScheme defined within it. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
231 * |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
232 * Returns a null pointer if an error occurs whilst parsing |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
233 * the contents of the file. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
234 */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
235 ColorScheme* read(); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
236 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
237 private: |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
238 // reads a line from the file specifying a colour palette entry |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
239 // format is: color [index] [red] [green] [blue] [transparent] [bold] |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
240 bool readColorLine(const QString& line , ColorScheme* scheme); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
241 bool readTitleLine(const QString& line , ColorScheme* scheme); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
242 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
243 QIODevice* _device; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
244 }; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
245 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
246 /** |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
247 * Manages the color schemes available for use by terminal displays. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
248 * See ColorScheme |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
249 */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
250 class ColorSchemeManager |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
251 { |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
252 public: |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
253 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
254 /** |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
255 * Constructs a new ColorSchemeManager and loads the list |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
256 * of available color schemes. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
257 * |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
258 * The color schemes themselves are not loaded until they are first |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
259 * requested via a call to findColorScheme() |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
260 */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
261 ColorSchemeManager(); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
262 /** |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
263 * Destroys the ColorSchemeManager and saves any modified color schemes to disk. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
264 */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
265 ~ColorSchemeManager(); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
266 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
267 /** |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
268 * Returns the default color scheme for Konsole |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
269 */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
270 const ColorScheme* defaultColorScheme() const; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
271 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
272 /** |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
273 * Returns the color scheme with the given name or 0 if no |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
274 * scheme with that name exists. If @p name is empty, the |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
275 * default color scheme is returned. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
276 * |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
277 * The first time that a color scheme with a particular name is |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
278 * requested, the configuration information is loaded from disk. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
279 */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
280 const ColorScheme* findColorScheme(const QString& name); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
281 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
282 /** |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
283 * Adds a new color scheme to the manager. If @p scheme has the same name as |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
284 * an existing color scheme, it replaces the existing scheme. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
285 * |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
286 * TODO - Ensure the old color scheme gets deleted |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
287 */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
288 void addColorScheme(ColorScheme* scheme); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
289 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
290 /** |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
291 * Deletes a color scheme. Returns true on successful deletion or false otherwise. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
292 */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
293 bool deleteColorScheme(const QString& name); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
294 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
295 /** |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
296 * Returns a list of the all the available color schemes. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
297 * This may be slow when first called because all of the color |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
298 * scheme resources on disk must be located, read and parsed. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
299 * |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
300 * Subsequent calls will be inexpensive. |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
301 */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
302 QList<const ColorScheme*> allColorSchemes(); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
303 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
304 /** Returns the global color scheme manager instance. */ |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
305 static ColorSchemeManager* instance(); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
306 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
307 private: |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
308 // loads a color scheme from a KDE 4+ .colorscheme file |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
309 bool loadColorScheme(const QString& path); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
310 // loads a color scheme from a KDE 3 .schema file |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
311 bool loadKDE3ColorScheme(const QString& path); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
312 // returns a list of paths of color schemes in the KDE 4+ .colorscheme file format |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
313 QList<QString> listColorSchemes(); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
314 // returns a list of paths of color schemes in the .schema file format |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
315 // used in KDE 3 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
316 QList<QString> listKDE3ColorSchemes(); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
317 // loads all of the color schemes |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
318 void loadAllColorSchemes(); |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
319 // finds the path of a color scheme |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
320 QString findColorSchemePath(const QString& name) const; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
321 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
322 QHash<QString,const ColorScheme*> _colorSchemes; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
323 QSet<ColorScheme*> _modifiedSchemes; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
324 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
325 bool _haveLoadedAll; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
326 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
327 static const ColorScheme _defaultColorScheme; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
328 }; |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
329 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
330 } |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
331 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
332 Q_DECLARE_METATYPE(const Konsole::ColorScheme*) |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
333 |
637675470c58
Added OctaveDEs konsole sources.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
334 #endif //COLORSCHEME_H |