Changeset View
Changeset View
Standalone View
Standalone View
src/ColorScheme.h
Show First 20 Lines • Show All 126 Lines • ▼ Show 20 Line(s) | 73 | public: | |||
---|---|---|---|---|---|
127 | * Convenience method. Returns the background color for | 127 | * Convenience method. Returns the background color for | ||
128 | * this scheme, this is the primary color used to | 128 | * this scheme, this is the primary color used to | ||
129 | * draw the terminal background in this scheme. | 129 | * draw the terminal background in this scheme. | ||
130 | */ | 130 | */ | ||
131 | QColor backgroundColor() const; | 131 | QColor backgroundColor() const; | ||
132 | 132 | | |||
133 | /** | 133 | /** | ||
134 | * Returns true if this color scheme has a dark background. | 134 | * Returns true if this color scheme has a dark background. | ||
135 | * The background color is said to be dark if it has a value of less than 127 | 135 | * The background color is said to be dark if it has a lightness | ||
136 | * in the HSV color space. | 136 | * of less than 50% in the HSLuv color space. | ||
137 | */ | 137 | */ | ||
138 | bool hasDarkBackground() const; | 138 | bool hasDarkBackground() const; | ||
139 | 139 | | |||
140 | /** | 140 | /** | ||
141 | * Sets the opacity level of the display background. @p opacity ranges | 141 | * Sets the opacity level of the display background. @p opacity ranges | ||
142 | * between 0 (completely transparent background) and 1 (completely | 142 | * between 0 (completely transparent background) and 1 (completely | ||
143 | * opaque background). | 143 | * opaque background). | ||
144 | * | 144 | * | ||
Show All 19 Lines | |||||
164 | */ | 164 | */ | ||
165 | bool blur() const; | 165 | bool blur() const; | ||
166 | 166 | | |||
167 | void setWallpaper(const QString &path); | 167 | void setWallpaper(const QString &path); | ||
168 | 168 | | |||
169 | ColorSchemeWallpaper::Ptr wallpaper() const; | 169 | ColorSchemeWallpaper::Ptr wallpaper() const; | ||
170 | 170 | | |||
171 | /** | 171 | /** | ||
172 | * Enables randomization of the background color. This will cause | 172 | * Enables colors randomization. This will cause the palette | ||
173 | * the palette returned by getColorTable() and colorEntry() to | 173 | * returned by getColorTable() and colorEntry() to be adjusted | ||
174 | * be adjusted depending on the value of the random seed argument | 174 | * depending on the parameters of color randomization and the | ||
175 | * to them. | 175 | * random seed parameter passed to them. | ||
176 | */ | 176 | */ | ||
177 | void setRandomizedBackgroundColor(bool randomize); | 177 | void setColorRandomization(bool randomize); | ||
178 | 178 | | |||
179 | /** Returns true if the background color is randomized. */ | 179 | /** Returns true if color randomization is enabled. */ | ||
180 | bool randomizedBackgroundColor() const; | 180 | bool isColorRandomizationEnabled() const; | ||
181 | 181 | | |||
182 | static const ColorEntry defaultTable[]; // table of default color entries | 182 | static const ColorEntry defaultTable[]; // table of default color entries | ||
183 | 183 | | |||
184 | static QString colorNameForIndex(int index); | 184 | static QString colorNameForIndex(int index); | ||
185 | static QString translatedColorNameForIndex(int index); | 185 | static QString translatedColorNameForIndex(int index); | ||
186 | 186 | | |||
187 | private: | 187 | private: | ||
188 | // specifies how much a particular color can be randomized by | 188 | // specifies how much a particular color can be randomized by | ||
189 | class RandomizationRange | 189 | class RandomizationRange | ||
190 | { | 190 | { | ||
191 | public: | 191 | public: | ||
192 | RandomizationRange() : hue(0), | 192 | RandomizationRange() : hue(0.0), | ||
193 | saturation(0), | 193 | saturation(0.0), | ||
194 | value(0) | 194 | lightness(0.0) | ||
195 | { | 195 | { | ||
196 | } | 196 | } | ||
197 | 197 | | |||
198 | bool isNull() const | 198 | bool isNull() const | ||
199 | { | 199 | { | ||
200 | return hue == 0 && saturation == 0 && value == 0; | 200 | return qFuzzyIsNull(hue) && qFuzzyIsNull(saturation) && qFuzzyIsNull(lightness); | ||
201 | } | 201 | } | ||
202 | 202 | | |||
203 | quint16 hue; | 203 | double hue; | ||
204 | quint8 saturation; | 204 | double saturation; | ||
205 | quint8 value; | 205 | double lightness; | ||
206 | }; | 206 | }; | ||
207 | 207 | | |||
208 | // returns the active color table. if none has been set specifically, | 208 | // returns the active color table. if none has been set specifically, | ||
209 | // this is the default color table. | 209 | // this is the default color table. | ||
210 | const ColorEntry *colorTable() const; | 210 | const ColorEntry *colorTable() const; | ||
211 | 211 | | |||
212 | // reads a single color entry from a KConfig source | 212 | // reads a single color entry from a KConfig source | ||
213 | // and sets the palette entry at 'index' to the entry read. | 213 | // and sets the palette entry at 'index' to the entry read. | ||
214 | void readColorEntry(const KConfig &config, int index); | 214 | void readColorEntry(const KConfig &config, int index); | ||
215 | // writes a single color entry to a KConfig source | 215 | // writes a single color entry to a KConfig source | ||
216 | void writeColorEntry(KConfig &config, int index) const; | 216 | void writeColorEntry(KConfig &config, int index) const; | ||
217 | 217 | | |||
218 | // sets the amount of randomization allowed for a particular color | 218 | // sets the amount of randomization allowed for a particular color | ||
219 | // in the palette. creates the randomization table if | 219 | // in the palette. creates the randomization table if | ||
220 | // it does not already exist | 220 | // it does not already exist | ||
221 | void setRandomizationRange(int index, quint16 hue, quint8 saturation, quint8 value); | 221 | void setRandomizationRange(int index, double hue, double saturation, double lightness); | ||
222 | 222 | | |||
223 | QString _description; | 223 | QString _description; | ||
224 | QString _name; | 224 | QString _name; | ||
225 | 225 | | |||
226 | // pointer to custom color table, or 0 if the default color table is | 226 | // pointer to custom color table, or 0 if the default color table is | ||
227 | // being used | 227 | // being used | ||
228 | ColorEntry *_table; | 228 | ColorEntry *_table; | ||
229 | 229 | | |||
230 | // pointer to randomization table, or 0 if no colors in the color | 230 | // pointer to randomization table, or 0 if no colors in the color | ||
231 | // scheme support randomization | 231 | // scheme support randomization | ||
232 | RandomizationRange *_randomTable; | 232 | RandomizationRange *_randomTable; | ||
233 | 233 | | |||
234 | qreal _opacity; | 234 | qreal _opacity; | ||
235 | 235 | | |||
236 | // enables blur behind the terminal window | 236 | // enables blur behind the terminal window | ||
237 | bool _blur; | 237 | bool _blur; | ||
238 | 238 | | |||
239 | ColorSchemeWallpaper::Ptr _wallpaper; | 239 | bool _colorRandomization; | ||
240 | 240 | | |||
241 | static const quint16 MAX_HUE = 340; | 241 | ColorSchemeWallpaper::Ptr _wallpaper; | ||
242 | 242 | | |||
243 | static const char * const colorNames[TABLE_COLORS]; | 243 | static const char * const colorNames[TABLE_COLORS]; | ||
244 | static const char * const translatedColorNames[TABLE_COLORS]; | 244 | static const char * const translatedColorNames[TABLE_COLORS]; | ||
245 | }; | 245 | }; | ||
246 | } | 246 | } | ||
247 | 247 | | |||
248 | Q_DECLARE_METATYPE(const Konsole::ColorScheme *) | 248 | Q_DECLARE_METATYPE(const Konsole::ColorScheme *) | ||
249 | 249 | | |||
250 | #endif //COLORSCHEME_H | 250 | #endif //COLORSCHEME_H |