Class for handling color collections ("palettes").
More...
#include <KColorCollection>
Class for handling color collections ("palettes").
This class makes it easy to handle color collections, sometimes referred to as "palettes". This class can read and write collections from and to a file.
This class uses the "GIMP" palette file format.
- Author
- Waldo Bastian (basti.nosp@m.an@k.nosp@m.de.or.nosp@m.g)
◆ Editable
Used to specify whether a collection may be edited.
- See also
- editable()
-
setEditable()
Enumerator |
---|
Yes | Collection may be edited.
|
No | Collection may not be edited.
|
Ask | Ask user before editing.
|
◆ KColorCollection() [1/2]
KColorCollection::KColorCollection |
( |
const QString & |
name = QString() | ) |
|
|
explicit |
KColorCollection constructor.
Creates a KColorCollection from a file the filename is derived from the name.
- Parameters
-
name | The name of collection as returned by installedCollections() |
◆ KColorCollection() [2/2]
◆ ~KColorCollection()
KColorCollection::~KColorCollection |
( |
| ) |
|
◆ addColor()
int KColorCollection::addColor |
( |
const QColor & |
newColor, |
|
|
const QString & |
newColorName = QString() |
|
) |
| |
Add a color.
- Parameters
-
newColor | The color to add. |
newColorName | The name of the color, null to remove the name. |
- Returns
- The index of the added color.
◆ changeColor() [1/2]
int KColorCollection::changeColor |
( |
const QColor & |
oldColor, |
|
|
const QColor & |
newColor, |
|
|
const QString & |
newColorName = QString() |
|
) |
| |
Change a color.
- Parameters
-
oldColor | The original color |
newColor | The new color. |
newColorName | The new color name, null to remove the name. |
- Returns
- The index of the new color or -1 if the color couldn't be changed.
◆ changeColor() [2/2]
int KColorCollection::changeColor |
( |
int |
index, |
|
|
const QColor & |
newColor, |
|
|
const QString & |
newColorName = QString() |
|
) |
| |
Change a color.
- Parameters
-
index | Index of the color to change |
newColor | The new color. |
newColorName | The new color name, null to remove the name. |
- Returns
- The index of the new color or -1 if the color couldn't be changed.
◆ color()
QColor KColorCollection::color |
( |
int |
index | ) |
const |
Find color by index.
- Parameters
-
index | the index of the desired color |
- Returns
- The
index
-th color of the collection, null if not found.
◆ count()
int KColorCollection::count |
( |
| ) |
const |
Return the number of colors in the collection.
- Returns
- the number of colors
◆ description()
QString KColorCollection::description |
( |
| ) |
const |
Get the description of the collection.
- Returns
- the description of the collection.
◆ editable()
Editable KColorCollection::editable |
( |
| ) |
const |
Returns whether the collection may be edited.
- Returns
- the state of the collection
◆ findColor()
int KColorCollection::findColor |
( |
const QColor & |
color | ) |
const |
Find index by color
.
- Parameters
-
- Returns
- The index of the color in the collection or -1 if the color is not found.
◆ installedCollections()
static QStringList KColorCollection::installedCollections |
( |
| ) |
|
|
static |
Query which KDE color collections are installed.
- Returns
- A list with installed color collection names.
◆ name() [1/3]
QString KColorCollection::name |
( |
| ) |
const |
Get the name of the collection.
- Returns
- the name of the collection
◆ name() [2/3]
QString KColorCollection::name |
( |
const QColor & |
color | ) |
const |
Find color name by color
.
- Returns
- The name of color according to this collection. Note that not all collections have named the colors. Note also that each collection can give the same color a different name.
◆ name() [3/3]
QString KColorCollection::name |
( |
int |
index | ) |
const |
Find color name by index
.
- Parameters
-
index | the index of the color |
- Returns
- The name of the
index
-th color. Note that not all collections have named the colors. Null is returned if the color does not exist or has no name.
◆ operator=()
◆ save()
bool KColorCollection::save |
( |
| ) |
|
Save the collection.
- Returns
- 'true' if successful
◆ setDescription()
void KColorCollection::setDescription |
( |
const QString & |
desc | ) |
|
Set the description of the collection.
- Parameters
-
◆ setEditable()
void KColorCollection::setEditable |
( |
Editable |
editable | ) |
|
Change whether the collection may be edited.
- Parameters
-
editable | the state of the collection |
◆ setName()
void KColorCollection::setName |
( |
const QString & |
name | ) |
|
Set the name of the collection.
- Parameters
-
name | the name of the collection |