SVN_SILENT made messages (.desktop file) - always resolve ours
[kdepim.git] / kalarm / lib / colourbutton.h
blob347021282bead4a3d4b45eea4bbd99ee1fbda838
1 /*
2 * colourbutton.h - colour selection button
3 * Program: kalarm
4 * Copyright © 2008 by David Jarvie <djarvie@kde.org>
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.
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.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #ifndef COLOURBUTTON_H
22 #define COLOURBUTTON_H
24 #include <kcolorbutton.h>
27 /**
28 * @short A colour selection button with read-only option.
30 * The ColourButton class is a KColorButton with a read-only option.
32 * The widget may be set as read-only. This has the same effect as disabling it, except
33 * that its appearance is unchanged.
35 * @author David Jarvie <djarvie@kde.org>
37 class ColourButton : public KColorButton
39 Q_OBJECT
40 public:
41 /** Constructor.
42 * @param parent The parent object of this widget.
44 explicit ColourButton(QWidget* parent = Q_NULLPTR);
45 /** Returns the selected colour. */
46 QColor colour() const { return color(); }
47 /** Sets the selected colour to @p c. */
48 void setColour(const QColor& c) { setColor(c); }
49 /** Returns true if the widget is read only. */
50 bool isReadOnly() const { return mReadOnly; }
51 /** Sets whether the button can be changed by the user.
52 * @param readOnly True to set the widget read-only, false to set it read-write.
54 virtual void setReadOnly(bool readOnly);
55 protected:
56 void mousePressEvent(QMouseEvent*) Q_DECL_OVERRIDE;
57 void mouseReleaseEvent(QMouseEvent*) Q_DECL_OVERRIDE;
58 void mouseMoveEvent(QMouseEvent*) Q_DECL_OVERRIDE;
59 void keyPressEvent(QKeyEvent*) Q_DECL_OVERRIDE;
60 void keyReleaseEvent(QKeyEvent*) Q_DECL_OVERRIDE;
61 private:
62 bool mReadOnly; // value cannot be changed
65 #endif // COLOURBUTTON_H
67 // vim: et sw=4: