MauiKit Terminal

ColorScheme.cpp
1/*
2 This source file is part of Konsole, a terminal emulator.
3
4 Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
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// Own
23#include "ColorScheme.h"
24#include "tools.h"
25
26// Qt
27#include <QBrush>
28#include <QFile>
29#include <QFileInfo>
30#include <QDebug>
31#include <QSettings>
32#include <QDir>
33#include <QRegularExpression>
34#include <QRandomGenerator>
35
36using namespace Konsole;
37
38constexpr std::array<ColorEntry, TABLE_COLORS> DEFAULT_TABLE =
39 // The following are almost IBM standard color codes, with some slight
40 // gamma correction for the dim colors to compensate for bright X screens.
41 // It contains the 8 ansiterm/xterm colors in 2 intensities.
42 {
43 ColorEntry(QColor(0x00, 0x00, 0x00), false),
44 ColorEntry(QColor(0xFF, 0xFF, 0xFF), true), // Dfore, Dback
45 ColorEntry(QColor(0x00, 0x00, 0x00), false),
46 ColorEntry(QColor(0xB2, 0x18, 0x18), false), // Black, Red
47 ColorEntry(QColor(0x18, 0xB2, 0x18), false),
48 ColorEntry(QColor(0xB2, 0x68, 0x18), false), // Green, Yellow
49 ColorEntry(QColor(0x18, 0x18, 0xB2), false),
50 ColorEntry(QColor(0xB2, 0x18, 0xB2), false), // Blue, Magenta
51 ColorEntry(QColor(0x18, 0xB2, 0xB2), false),
52 ColorEntry(QColor(0xB2, 0xB2, 0xB2), false), // Cyan, White
53 // intensive
54 ColorEntry(QColor(0x00, 0x00, 0x00), false),
55 ColorEntry(QColor(0xFF, 0xFF, 0xFF), true),
56 ColorEntry(QColor(0x68, 0x68, 0x68), false),
57 ColorEntry(QColor(0xFF, 0x54, 0x54), false),
58 ColorEntry(QColor(0x54, 0xFF, 0x54), false),
59 ColorEntry(QColor(0xFF, 0xFF, 0x54), false),
60 ColorEntry(QColor(0x54, 0x54, 0xFF), false),
61 ColorEntry(QColor(0xFF, 0x54, 0xFF), false),
62 ColorEntry(QColor(0x54, 0xFF, 0xFF), false),
63 ColorEntry(QColor(0xFF, 0xFF, 0xFF), false)};
64
65std::array<ColorEntry, TABLE_COLORS> Konsole::defaultColorTable()
66{
67 return DEFAULT_TABLE;
68}
69
70constexpr std::array<QStringView, TABLE_COLORS> COLOR_NAMES = {u"Foreground",
71 u"Background",
72 u"Color0",
73 u"Color1",
74 u"Color2",
75 u"Color3",
76 u"Color4",
77 u"Color5",
78 u"Color6",
79 u"Color7",
80 u"ForegroundIntense",
81 u"BackgroundIntense",
82 u"Color0Intense",
83 u"Color1Intense",
84 u"Color2Intense",
85 u"Color3Intense",
86 u"Color4Intense",
87 u"Color5Intense",
88 u"Color6Intense",
89 u"Color7Intense"};
90
91std::array<const char *, TABLE_COLORS> TRANSLATED_COLOR_NAMES = {QT_TR_NOOP("Foreground"),
92 QT_TR_NOOP("Background"),
93 QT_TR_NOOP("Color 1"),
94 QT_TR_NOOP("Color 2"),
95 QT_TR_NOOP("Color 3"),
96 QT_TR_NOOP("Color 4"),
97 QT_TR_NOOP("Color 5"),
98 QT_TR_NOOP("Color 6"),
99 QT_TR_NOOP("Color 7"),
100 QT_TR_NOOP("Color 8"),
101 QT_TR_NOOP("Foreground (Intense)"),
102 QT_TR_NOOP("Background (Intense)"),
103 QT_TR_NOOP("Color 1 (Intense)"),
104 QT_TR_NOOP("Color 2 (Intense)"),
105 QT_TR_NOOP("Color 3 (Intense)"),
106 QT_TR_NOOP("Color 4 (Intense)"),
107 QT_TR_NOOP("Color 5 (Intense)"),
108 QT_TR_NOOP("Color 6 (Intense)"),
109 QT_TR_NOOP("Color 7 (Intense)"),
110 QT_TR_NOOP("Color 8 (Intense)")};
111
112
114{
115 _table = {};
116 _randomTable = {};
117 _opacity = 1.0;
118}
119
120ColorScheme::~ColorScheme()
121{
122}
123
124void ColorScheme::setDescription(const QString& description)
125{
126 _description = description;
127}
128
130{
131 return _description;
132}
133
135{
136 _name = name;
137}
138
140{
141 return _name;
142}
143
144void ColorScheme::setColorTableEntry(int index , const ColorEntry& entry)
145{
146 Q_ASSERT( index >= 0 && index < TABLE_COLORS );
147
148 if (!_table)
149 {
150 _table = std::vector<ColorEntry>(DEFAULT_TABLE.begin(), DEFAULT_TABLE.end());
151 }
152
153 // we always have a value set at this point, see above
154 _table.value()[index] = entry;
155}
156
157void ColorScheme::setColor(int index, QColor color)
158{
160 if (colorEntry.color != color)
161 {
162 colorEntry.color = color;
164 Q_EMIT colorChanged(index);
165 }
166}
167
168ColorEntry ColorScheme::colorEntry(int index , uint randomSeed) const
169{
170 Q_ASSERT( index >= 0 && index < TABLE_COLORS );
171
172 ColorEntry entry = colorTable()[index];
173
174 if (randomSeed != 0 && _randomTable.has_value() && !_randomTable->data()[index].isNull())
175 {
176 const RandomizationRange &range = _randomTable->data()[index];
177
178 int hueDifference = range.hue ? QRandomGenerator::system()->bounded(range.hue) - range.hue / 2 : 0;
179 int saturationDifference = range.saturation ? (QRandomGenerator::system()->bounded(range.saturation)) - range.saturation / 2 : 0;
180 int valueDifference = range.value ? (QRandomGenerator::system()->bounded(range.value)) - range.value / 2 : 0;
181
182 QColor &color = entry.color;
183
184 int newHue = qAbs((color.hue() + hueDifference) % MAX_HUE);
185 int newValue = qMin(qAbs(color.value() + valueDifference), 255);
186 int newSaturation = qMin(qAbs(color.saturation() + saturationDifference), 255);
187
188 color.setHsv(newHue, newSaturation, newValue);
189 }
190
191 return entry;
192
193}
194
195std::array<ColorEntry, TABLE_COLORS> ColorScheme::getColorTable(uint randomSeed) const
196{
197 std::array<ColorEntry, TABLE_COLORS> table;
198
199 for (int i = 0; i < TABLE_COLORS; i++)
200 table[i] = colorEntry(i, randomSeed);
201
202 return table;
203}
204
206{
207 return _randomTable.has_value() ? !_randomTable->data()[1].isNull() : false;
208}
209
211{
212 // the hue of the background colour is allowed to be randomly
213 // adjusted as much as possible.
214 //
215 // the value and saturation are left alone to maintain read-ability
216 if ( randomize )
217 {
218 setRandomizationRange( 1 /* background color index */ , MAX_HUE , 255 , 0 );
219 }
220 else
221 {
222 if ( _randomTable )
223 setRandomizationRange( 1 /* background color index */ , 0 , 0 , 0 );
224 }
225}
226
227void ColorScheme::setRandomizationRange( int index , quint16 hue , quint8 saturation , quint8 value )
228{
229 Q_ASSERT( hue <= MAX_HUE );
230 Q_ASSERT( index >= 0 && index < TABLE_COLORS );
231
232 if (!_randomTable)
233 _randomTable = std::vector<RandomizationRange>(TABLE_COLORS);
234
235 _randomTable->data()[index].hue = hue;
236 _randomTable->data()[index].value = value;
237 _randomTable->data()[index].saturation = saturation;
238}
239
240const std::span<const ColorEntry> ColorScheme::colorTable() const
241{
242 if ( _table.has_value() )
243 return *_table;
244 else
245 return std::span(DEFAULT_TABLE);
246}
247
249{
250 return colorTable()[0].color;
251}
252
254{
255 return colorTable()[1].color;
256}
257
259{
260 // value can range from 0 - 255, with larger values indicating higher brightness.
261 // so 127 is in the middle, anything less is deemed 'dark'
262 return backgroundColor().value() < 127;
263}
264
265void ColorScheme::setOpacity(qreal opacity)
266{
267 _opacity = opacity;
268}
269
271{
272 return _opacity;
273}
274
275void ColorScheme::read(const QString & fileName)
276{
277 QSettings s(fileName, QSettings::IniFormat);
278 s.beginGroup(QLatin1String("General"));
279
280 _description = s.value(QLatin1String("Description"), QObject::tr("Un-named Color Scheme")).toString();
281 _opacity = s.value(QLatin1String("Opacity"),qreal(1.0)).toDouble();
282 s.endGroup();
283
284 for (int i=0 ; i < TABLE_COLORS ; i++)
285 {
286 readColorEntry(&s, i);
287 }
288}
289
290#if 0
291// implemented upstream - user apps
292void ColorScheme::read(KConfig& config)
293{
294 KConfigGroup configGroup = config.group("General");
295
296 QString description = configGroup.readEntry("Description", QObject::tr("Un-named Color Scheme"));
297
298 _description = tr(description.toUtf8());
299 _opacity = configGroup.readEntry("Opacity",qreal(1.0));
300
301 for (int i=0 ; i < TABLE_COLORS ; i++)
302 {
303 readColorEntry(config,i);
304 }
305}
306
307
308void ColorScheme::write(KConfig& config) const
309{
310 KConfigGroup configGroup = config.group("General");
311
312 configGroup.writeEntry("Description",_description);
313 configGroup.writeEntry("Opacity",_opacity);
314
315 for (int i=0 ; i < TABLE_COLORS ; i++)
316 {
317 RandomizationRange random = _randomTable != 0 ? _randomTable[i] : RandomizationRange();
318 writeColorEntry(config,colorNameForIndex(i),colorTable()[i],random);
319 }
320}
321#endif
322
323QString ColorScheme::colorNameForIndex(int index)
324{
325 Q_ASSERT( index >= 0 && index < TABLE_COLORS );
326
327 return COLOR_NAMES.at(index).toString();
328}
329QString ColorScheme::translatedColorNameForIndex(int index)
330{
331 Q_ASSERT( index >= 0 && index < TABLE_COLORS );
332
333 return QObject::tr(TRANSLATED_COLOR_NAMES.at(index));
334}
335
336void ColorScheme::readColorEntry(QSettings * s , int index)
337{
338 QString colorName = colorNameForIndex(index);
339
340 s->beginGroup(colorName);
341
342 ColorEntry entry;
343
344 QVariant colorValue = s->value(QLatin1String("Color"));
345 QString colorStr;
346 int r, g, b;
347 bool ok = false;
348 // XXX: Undocumented(?) QSettings behavior: values with commas are parsed
349 // as QStringList and others QString
350#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
351 if (colorValue.type() == QVariant::StringList)
352#else
353 if (colorValue.metaType().id() == QMetaType::QStringList)
354#endif
355 {
356 QStringList rgbList = colorValue.toStringList();
357 colorStr = rgbList.join(QLatin1Char(','));
358 if (rgbList.count() == 3)
359 {
360 bool parse_ok;
361
362 ok = true;
363 r = rgbList[0].toInt(&parse_ok);
364 ok = ok && parse_ok && (r >= 0 && r <= 0xff);
365 g = rgbList[1].toInt(&parse_ok);
366 ok = ok && parse_ok && (g >= 0 && g <= 0xff);
367 b = rgbList[2].toInt(&parse_ok);
368 ok = ok && parse_ok && (b >= 0 && b <= 0xff);
369 }
370 }
371 else
372 {
373 colorStr = colorValue.toString();
374 QRegularExpression hexColorPattern(QLatin1String("^#[0-9a-f]{6}$"),
376 if (hexColorPattern.match(colorStr).hasMatch())
377 {
378// Parsing is always ok as already matched by the regexp
379 r = QStringView(colorStr).mid(1, 2).toInt(nullptr, 16);
380 g = QStringView(colorStr).mid(3, 2).toInt(nullptr, 16);
381 b = QStringView(colorStr).mid(5, 2).toInt(nullptr, 16);
382 ok = true;
383 }
384 }
385 if (!ok)
386 {
387 qWarning().nospace() << "Invalid color value " << colorStr
388 << " for " << colorName << ". Fallback to black.";
389 r = g = b = 0;
390 }
391 entry.color = QColor(r, g, b);
392
393 entry.transparent = s->value(QLatin1String("Transparent"),false).toBool();
394
395 // Deprecated key from KDE 4.0 which set 'Bold' to true to force
396 // a color to be bold or false to use the current format
397 //
398 // TODO - Add a new tri-state key which allows for bold, normal or
399 // current format
400 if (s->contains(QLatin1String("Bold")))
401 entry.fontWeight = s->value(QLatin1String("Bold"),false).toBool() ? ColorEntry::Bold :
403
404 quint16 hue = s->value(QLatin1String("MaxRandomHue"),0).toInt();
405 quint8 value = s->value(QLatin1String("MaxRandomValue"),0).toInt();
406 quint8 saturation = s->value(QLatin1String("MaxRandomSaturation"),0).toInt();
407
408 setColorTableEntry( index , entry );
409
410 if ( hue != 0 || value != 0 || saturation != 0 )
411 setRandomizationRange( index , hue , saturation , value );
412
413 s->endGroup();
414}
415
416// implemented upstream - user apps
417// void ColorScheme::writeColorEntry(KConfig& config , const QString& colorName, const ColorEntry& entry , const RandomizationRange& random) const
418// {
419// KConfigGroup configGroup(&config,colorName);
420
421// configGroup.writeEntry("Color",entry.color);
422// configGroup.writeEntry("Transparency",(bool)entry.transparent);
423// if (entry.fontWeight != ColorEntry::UseCurrentFormat)
424// {
425// configGroup.writeEntry("Bold",entry.fontWeight == ColorEntry::Bold);
426// }
427
428// // record randomization if this color has randomization or
429// // if one of the keys already exists
430// if ( !random.isNull() || configGroup.hasKey("MaxRandomHue") )
431// {
432// configGroup.writeEntry("MaxRandomHue",(int)random.hue);
433// configGroup.writeEntry("MaxRandomValue",(int)random.value);
434// configGroup.writeEntry("MaxRandomSaturation",(int)random.saturation);
435// }
436// }
437
438//
439// Work In Progress - A color scheme for use on KDE setups for users
440// with visual disabilities which means that they may have trouble
441// reading text with the supplied color schemes.
442//
443// This color scheme uses only the 'safe' colors defined by the
444// KColorScheme class.
445//
446// A complication this introduces is that each color provided by
447// KColorScheme is defined as a 'background' or 'foreground' color.
448// Only foreground colors are allowed to be used to render text and
449// only background colors are allowed to be used for backgrounds.
450//
451// The ColorEntry and TerminalDisplay classes do not currently
452// support this restriction.
453//
454// Requirements:
455// - A color scheme which uses only colors from the KColorScheme class
456// - Ability to restrict which colors the TerminalDisplay widget
457// uses as foreground and background color
458// - Make use of KGlobalSettings::allowDefaultBackgroundImages() as
459// a hint to determine whether this accessible color scheme should
460// be used by default.
461//
462//
463// -- Robert Knight <robertknight@gmail.com> 21/07/2007
464//
465AccessibleColorScheme::AccessibleColorScheme()
466 : ColorScheme()
467{
468#if 0
469// It's not finished in konsole and it breaks Qt4 compilation as well
470 // basic attributes
471 setName("accessible");
472 setDescription(QObject::tr("Accessible Color Scheme"));
473
474 // setup colors
475 const int ColorRoleCount = 8;
476
477 const KColorScheme colorScheme(QPalette::Active);
478
479 QBrush colors[ColorRoleCount] =
480 {
481 colorScheme.foreground( colorScheme.NormalText ),
482 colorScheme.background( colorScheme.NormalBackground ),
483
484 colorScheme.foreground( colorScheme.InactiveText ),
485 colorScheme.foreground( colorScheme.ActiveText ),
486 colorScheme.foreground( colorScheme.LinkText ),
487 colorScheme.foreground( colorScheme.VisitedText ),
488 colorScheme.foreground( colorScheme.NegativeText ),
489 colorScheme.foreground( colorScheme.NeutralText )
490 };
491
492 for ( int i = 0 ; i < TABLE_COLORS ; i++ )
493 {
494 ColorEntry entry;
495 entry.color = colors[ i % ColorRoleCount ].color();
496
497 setColorTableEntry( i , entry );
498 }
499#endif
500}
501
503 : _haveLoadedAll(false)
504{
505}
506
508
509void ColorSchemeManager::loadAllColorSchemes()
510{
511 qDebug() << "loadAllColorSchemes";
512 int failed = 0;
513
514 QList<QString> nativeColorSchemes = listColorSchemes();
515 QListIterator<QString> nativeIter(nativeColorSchemes);
516 while ( nativeIter.hasNext() )
517 {
518 if ( !loadColorScheme( nativeIter.next() ) )
519 failed++;
520 }
521
522 if ( failed > 0 )
523 qDebug() << "failed to load " << failed << " color schemes.";
524
525 _haveLoadedAll = true;
526}
527
529{
530 if ( !_haveLoadedAll )
531 {
532 loadAllColorSchemes();
533 }
534
535 QList<ColorScheme *> schemes;
536 for (const auto &[k, scheme] : _colorSchemes) {
537 schemes.push_back(scheme.get());
538 }
539 return schemes;
540}
541
542#if 0
543void ColorSchemeManager::addColorScheme(ColorScheme* scheme)
544{
545 _colorSchemes.insert(scheme->name(),scheme);
546
547 // save changes to disk
548 QString path = KGlobal::dirs()->saveLocation("data","konsole/") + scheme->name() + ".colorscheme";
549 KConfig config(path , KConfig::NoGlobals);
550
551 scheme->write(config);
552}
553#endif
554
556{
557 if (path.endsWith(QLatin1String(".colorscheme")))
558 return loadColorScheme(path);
559
560 return false;
561}
562
564{
565 add_custom_color_scheme_dir(custom_dir);
566}
567
568bool ColorSchemeManager::loadColorScheme(const QString& filePath)
569{
570 if ( !filePath.endsWith(QLatin1String(".colorscheme")) || !QFile::exists(filePath) )
571 return false;
572
573 QFileInfo info(filePath);
574
575 const QString& schemeName = info.baseName();
576
577 auto scheme = std::make_unique<ColorScheme>();
578 scheme->setName(schemeName);
579 scheme->read(filePath);
580
581 if (scheme->name().isEmpty())
582 {
583 qDebug() << "Color scheme in" << filePath << "does not have a valid name and was not loaded.";
584 scheme.reset();
585 return false;
586 }
587
588 if ( !_colorSchemes.contains(schemeName) )
589 {
590 _colorSchemes.insert_or_assign(schemeName, std::move(scheme));
591 }
592 else
593 {
594 qDebug() << "color scheme with name" << schemeName << "has already been" <<
595 "found, ignoring.";
596
597 scheme.reset();
598 }
599
600 return true;
601}
602
603
604QList<QString> ColorSchemeManager::listColorSchemes()
605{
606 QStringList ret;
607 for (const QString &scheme_dir : get_color_schemes_dirs())
608 {
609 const QString dname(scheme_dir);
610 QDir dir(dname);
611 QStringList filters;
612 filters << QLatin1String("*.colorscheme");
613 dir.setNameFilters(filters);
614 QStringList list = dir.entryList(filters);
615 for (const QString &i : list)
616 ret << dname + QLatin1Char('/') + i;
617 }
618 return ret;
619 // return KGlobal::dirs()->findAllResources("data",
620 // "konsole/*.colorscheme",
621 // KStandardDirs::NoDuplicates);
622}
623
624const ColorScheme ColorSchemeManager::_defaultColorScheme;
626{
627 return &_defaultColorScheme;
628}
629
631{
632 Q_ASSERT( _colorSchemes.contains(name) );
633
634 // lookup the path and delete
635 QString path = findColorSchemePath(name);
636 if ( QFile::remove(path) )
637 {
638 _colorSchemes.erase(name);
639 return true;
640 }
641 else
642 {
643 qDebug() << "Failed to remove color scheme -" << path;
644 return false;
645 }
646}
647QString ColorSchemeManager::findColorSchemePath(const QString& name) const
648{
649 // QString path = KStandardDirs::locate("data","konsole/"+name+".colorscheme");
650 const QStringList dirs = get_color_schemes_dirs();
651 if ( dirs.isEmpty() )
652 return QString();
653
654 const QString dir = dirs.first();
655 QString path(dir + QLatin1Char('/')+ name + QLatin1String(".colorscheme"));
656 if ( !path.isEmpty() )
657 return path;
658
659 //path = KStandardDirs::locate("data","konsole/"+name+".schema");
660 path = dir + QLatin1Char('/')+ name + QLatin1String(".schema");
661
662 return path;
663}
664
666{
667 if (name.isEmpty())
668 return defaultColorScheme();
669
670 if (_colorSchemes.contains(name))
671 {
672 return _colorSchemes[name].get();
673 }else
674 {
675 // look for this color scheme
676 QString path = findColorSchemePath(name);
677 if (!path.isEmpty() && loadColorScheme(path) )
678 {
679 return findColorScheme(name);
680 }
681
682 qDebug() << "Could not find color scheme - " << name;
683
684 return defaultColorScheme();
685 }
686}
687Q_GLOBAL_STATIC(ColorSchemeManager, theColorSchemeManager)
689{
690 return theColorSchemeManager;
691}
KConfigGroup group(const QString &group)
void writeEntry(const char *key, const char *value, WriteConfigFlags pFlags=Normal)
QString readEntry(const char *key, const char *aDefault=nullptr) const
An entry in a terminal display's color palette.
@ UseCurrentFormat
Use the current font weight set by the terminal application.
@ Bold
Always draw text in this color with a bold weight.
FontWeight fontWeight
Specifies the font weight to use when drawing text with this color.
QColor color
The color value of this entry for display.
bool transparent
If true character backgrounds using this color should be transparent.
Manages the color schemes available for use by terminal displays.
ColorSchemeManager()
Constructs a new ColorSchemeManager and loads the list of available color schemes.
QList< ColorScheme * > allColorSchemes()
Returns a list of the all the available color schemes.
const ColorScheme * defaultColorScheme() const
Returns the default color scheme for Konsole.
const ColorScheme * findColorScheme(const QString &name)
Returns the color scheme with the given name or 0 if no scheme with that name exists.
~ColorSchemeManager()
Destroys the ColorSchemeManager and saves any modified color schemes to disk.
bool deleteColorScheme(const QString &name)
Deletes a color scheme.
void addCustomColorSchemeDir(const QString &custom_dir)
Allows to add a custom location of color schemes.
bool loadCustomColorScheme(const QString &path)
Loads a custom color scheme under given path.
Represents a color scheme for a terminal display.
Definition ColorScheme.h:56
qreal opacity() const
Returns the opacity level for this color scheme, see setOpacity() TODO: More documentation.
void setColorTableEntry(int index, const ColorEntry &entry)
Sets a single entry within the color palette.
QColor foregroundColor() const
Convenience method.
QString description() const
Returns the descriptive name of the color scheme.
void setName(const QString &name)
Sets the name of the color scheme.
void setOpacity(qreal opacity)
Sets the opacity level of the display background.
bool hasDarkBackground() const
Returns true if this color scheme has a dark background.
std::array< ColorEntry, TABLE_COLORS > getColorTable(uint randomSeed=0) const
Copies the color entries which form the palette for this color scheme into table.
void setRandomizedBackgroundColor(bool randomize)
Enables randomization of the background color.
bool randomizedBackgroundColor() const
Returns true if the background color is randomized.
QColor backgroundColor() const
Convenience method.
QString name() const
Returns the name of the color scheme.
ColorEntry colorEntry(int index, uint randomSeed=0) const
Retrieves a single color entry from the table.
void setDescription(const QString &description)
Sets the descriptive name of the color scheme.
KGUIADDONS_EXPORT qreal hue(const QColor &)
KIOCORE_EXPORT QString dir(const QString &fileClass)
KIOCORE_EXPORT QStringList list(const QString &fileClass)
const QColor & color() const const
int hue() const const
int saturation() const const
void setHsv(int h, int s, int v, int a)
int value() const const
bool exists() const const
bool remove()
qsizetype count() const const
T & first()
bool isEmpty() const const
void push_back(parameter_type value)
int id() const const
Q_EMITQ_EMIT
QString tr(const char *sourceText, const char *disambiguation, int n)
double bounded(double highest)
QRandomGenerator * system()
void beginGroup(QAnyStringView prefix)
bool contains(QAnyStringView key) const const
void endGroup()
QVariant value(QAnyStringView key) const const
bool endsWith(QChar c, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
QByteArray toUtf8() const const
QString join(QChar separator) const const
QStringView mid(qsizetype start, qsizetype length) const const
int toInt(bool *ok, int base) const const
Type type() const const
QMetaType metaType() const const
bool toBool() const const
int toInt(bool *ok) const const
QString toString() const const
QStringList toStringList() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:55:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.