KGuiAddons

kcolorcollection.h
1/* This file is part of the KDE libraries
2 SPDX-FileCopyrightText: 1999 Waldo Bastian <bastian@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7// KDE color collection.
8
9#ifndef KDELIBS_KCOLORCOLLECTION_H
10#define KDELIBS_KCOLORCOLLECTION_H
11
12#include <kguiaddons_export.h>
13
14#include <QColor>
15#include <QSharedDataPointer>
16#include <QString>
17#include <QStringList>
18
19#if KGUIADDONS_ENABLE_DEPRECATED_SINCE(6, 3)
20/**
21 * @class KColorCollection kcolorcollection.h KColorCollection
22 *
23 * Class for handling color collections ("palettes").
24 *
25 * This class makes it easy to handle color collections, sometimes referred to
26 * as "palettes". This class can read and write collections from and to a file.
27 *
28 * This class uses the "GIMP" palette file format.
29 *
30 * @author Waldo Bastian (bastian@kde.org)
31 *
32 * @deprecated since 6.3, unused and backing data no longer available
33 */
34class KGUIADDONS_EXPORT KGUIADDONS_DEPRECATED_VERSION(6, 3, "unused") KColorCollection
35{
36public:
37 /**
38 * Query which KDE color collections are installed.
39 *
40 * @return A list with installed color collection names.
41 */
42 static QStringList installedCollections();
43
44 /**
45 * KColorCollection constructor. Creates a KColorCollection from a file
46 * the filename is derived from the name.
47 * @param name The name of collection as returned by installedCollections()
48 */
49 explicit KColorCollection(const QString &name = QString());
50
51 /**
52 * KColorCollection copy constructor.
53 */
55
56 /**
57 * KColorCollection destructor.
58 */
60
61 /**
62 * KColorCollection assignment operator
63 */
64 KColorCollection &operator=(const KColorCollection &);
65
66 /**
67 * Save the collection
68 *
69 * @return 'true' if successful
70 */
71 bool save();
72
73 /**
74 * Get the description of the collection.
75 * @return the description of the collection.
76 */
77 QString description() const;
78
79 /**
80 * Set the description of the collection.
81 * @param desc the new description
82 */
83 void setDescription(const QString &desc);
84
85 /**
86 * Get the name of the collection.
87 * @return the name of the collection
88 */
89 QString name() const;
90
91 /**
92 * Set the name of the collection.
93 * @param name the name of the collection
94 */
95 void setName(const QString &name);
96
97 /**
98 * Used to specify whether a collection may be edited.
99 * @see editable()
100 * @see setEditable()
101 */
102 enum Editable {
103 Yes, ///< Collection may be edited
104 No, ///< Collection may not be edited
105 Ask, ///< Ask user before editing
106 };
107
108 /**
109 * Returns whether the collection may be edited.
110 * @return the state of the collection
111 */
112 Editable editable() const;
113
114 /**
115 * Change whether the collection may be edited.
116 * @param editable the state of the collection
117 */
118 void setEditable(Editable editable);
119
120 /**
121 * Return the number of colors in the collection.
122 * @return the number of colors
123 */
124 int count() const;
125
126 /**
127 * Find color by index.
128 * @param index the index of the desired color
129 * @return The @p index -th color of the collection, null if not found.
130 */
131 QColor color(int index) const;
132
133 /**
134 * Find index by @p color.
135 * @param color the color to find
136 * @return The index of the color in the collection or -1 if the
137 * color is not found.
138 */
139 int findColor(const QColor &color) const;
140
141 /**
142 * Find color name by @p index.
143 * @param index the index of the color
144 * @return The name of the @p index -th color.
145 * Note that not all collections have named the colors. Null is
146 * returned if the color does not exist or has no name.
147 */
148 QString name(int index) const;
149
150 /**
151 * Find color name by @p color.
152 * @return The name of color according to this collection.
153 * Note that not all collections have named the colors.
154 * Note also that each collection can give the same color
155 * a different name.
156 */
157 QString name(const QColor &color) const;
158
159 /**
160 * Add a color.
161 * @param newColor The color to add.
162 * @param newColorName The name of the color, null to remove
163 * the name.
164 * @return The index of the added color.
165 */
166 int addColor(const QColor &newColor, const QString &newColorName = QString());
167
168 /**
169 * Change a color.
170 * @param index Index of the color to change
171 * @param newColor The new color.
172 * @param newColorName The new color name, null to remove
173 * the name.
174 * @return The index of the new color or -1 if the color couldn't
175 * be changed.
176 */
177 int changeColor(int index, const QColor &newColor, const QString &newColorName = QString());
178
179 /**
180 * Change a color.
181 * @param oldColor The original color
182 * @param newColor The new color.
183 * @param newColorName The new color name, null to remove
184 * the name.
185 * @return The index of the new color or -1 if the color couldn't
186 * be changed.
187 */
188 int changeColor(const QColor &oldColor, const QColor &newColor, const QString &newColorName = QString());
189
190private:
192};
193#endif
194
195#endif // KDELIBS_KCOLORCOLLECTION_H
QString name(StandardAction id)
const QList< QKeySequence > & save()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:48 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.