KWidgetsAddons

kcolorcombo.h
1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 1997 Martin Jones <mjones@kde.org>
4 SPDX-FileCopyrightText: 2007 David Jarvie <djarvie@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8//-----------------------------------------------------------------------------
9// KDE color selection combo box
10
11// layout management added Oct 1997 by Mario Weilguni
12// <mweilguni@sime.com>
13
14#ifndef KCOLORCOMBO_H
15#define KCOLORCOMBO_H
16
17#include <QComboBox>
18#include <QList>
19
20#include <kwidgetsaddons_export.h>
21
22#include <memory>
23
24/**
25 * @class KColorCombo kcolorcombo.h KColorCombo
26 *
27 * Combobox for colors.
28 *
29 * The combobox provides some preset colors to be selected, and an entry to
30 * select a custom color using a color dialog.
31 *
32 * \image html kcolorcombo.png "KColorCombo Widget"
33 */
34class KWIDGETSADDONS_EXPORT KColorCombo : public QComboBox
35{
36 Q_OBJECT
37 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY activated USER true)
38 Q_PROPERTY(QList<QColor> colors READ colors WRITE setColors)
39
40public:
41 /**
42 * Constructs a color combo box.
43 */
44 explicit KColorCombo(QWidget *parent = nullptr);
45 ~KColorCombo() override;
46
47 /**
48 * Selects the color @p col.
49 */
50 void setColor(const QColor &col);
51
52 /**
53 * Returns the currently selected color.
54 */
55 QColor color() const;
56
57 /**
58 * Find whether the currently selected color is a custom color selected
59 * using a color dialog.
60 */
61 bool isCustomColor() const;
62
63 /**
64 * Set a custom list of colors to choose from, in place of the standard
65 * list.
66 * @param colors list of colors. If empty, the selection list reverts to
67 * the standard list.
68 */
69 void setColors(const QList<QColor> &colors);
70
71 /**
72 * Return the list of colors available for selection.
73 * @return list of colors
74 */
75 QList<QColor> colors() const;
76
77 /**
78 * Clear the color list and don't show it, till the next setColor() call
79 */
80 void showEmptyList();
81
83 /**
84 * Emitted when a new color box has been selected.
85 */
86 void activated(const QColor &col);
87 /**
88 * Emitted when a new item has been highlighted.
89 */
90 void highlighted(const QColor &col);
91
92protected:
93 void paintEvent(QPaintEvent *event) override;
94
95private:
96 friend class KColorComboPrivate;
97 std::unique_ptr<class KColorComboPrivate> const d;
98
100};
101
102#endif // KCOLORCOMBO_H
Combobox for colors.
Definition kcolorcombo.h:35
void activated(const QColor &col)
Emitted when a new color box has been selected.
void highlighted(const QColor &col)
Emitted when a new item has been highlighted.
virtual void paintEvent(QPaintEvent *e) override
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
T qobject_cast(QObject *object)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:14:43 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.