KProperty

KColorCombo.h
1/* This file is part of the KDE libraries
2 Copyright (C) 1997 Martin Jones (mjones@kde.org)
3 Copyright (c) 2007 David Jarvie (software@astrojar.org.uk)
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20//-----------------------------------------------------------------------------
21// KDE color selection combo box
22
23// layout management added Oct 1997 by Mario Weilguni
24// <mweilguni@sime.com>
25
26#ifndef KCOLORCOMBO_H
27#define KCOLORCOMBO_H
28
29#include <QComboBox>
30#include <QList>
31
32class KColorComboPrivate;
33
34/**
35 * Combobox for colors.
36 *
37 * The combobox provides some preset colors to be selected, and an entry to
38 * select a custom color using a color dialog.
39 *
40 * \image html kcolorcombo.png "KDE Color Combo Box"
41 */
42class KColorCombo : public QComboBox
43{
45 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY activated USER true)
46 Q_PROPERTY(QList<QColor> colors READ colors WRITE setColors)
47
48public:
49 /**
50 * Constructs a color combo box.
51 */
52 explicit KColorCombo(QWidget *parent = 0);
54
55 /**
56 * Selects the color @p col.
57 */
58 void setColor(const QColor &col);
59
60 /**
61 * Returns the currently selected color.
62 **/
63 QColor color() const;
64
65 /**
66 * Find whether the currently selected color is a custom color selected
67 * using a color dialog.
68 **/
69 bool isCustomColor() const;
70
71 /**
72 * Set a custom list of colors to choose from, in place of the standard
73 * list.
74 * @param cols list of colors. If empty, the selection list reverts to
75 * the standard list.
76 **/
77 void setColors(const QList<QColor> &colors);
78
79 /**
80 * Return the list of colors available for selection.
81 * @return list of colors
82 **/
83 QList<QColor> colors() const;
84
85 /**
86 * Clear the color list and don't show it, till the next setColor() call
87 **/
88 void showEmptyList();
89
91 /**
92 * Emitted when a new color box has been selected.
93 */
94 void activated(const QColor &col);
95 /**
96 * Emitted when a new item has been highlighted.
97 */
98 void highlighted(const QColor &col);
99
100protected:
101 void paintEvent(QPaintEvent *event) override;
102
103private:
104 friend class KColorComboPrivate;
105 KColorComboPrivate *const d;
106
107 Q_DISABLE_COPY(KColorCombo)
108
109 Q_PRIVATE_SLOT(d, void _k_slotActivated(int))
110 Q_PRIVATE_SLOT(d, void _k_slotHighlighted(int))
111};
112
113#endif // KCOLORCOMBO_H
void setColors(const QList< QColor > &colors)
void showEmptyList()
KColorCombo(QWidget *parent=nullptr)
void activated(const QColor &col)
void setColor(const QColor &col)
bool isCustomColor() const
void highlighted(const QColor &col)
virtual bool event(QEvent *event) override
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:09 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.