Seamly2D
Code documentation
vcolorpropertyeditor.h
Go to the documentation of this file.
1 /************************************************************************
2  **
3  ** @file vcolorpropertyeditor.h
4  ** @author hedgeware <internal(at)hedgeware.net>
5  ** @date
6  **
7  ** @brief
8  ** @copyright
9  ** All rights reserved. This program and the accompanying materials
10  ** are made available under the terms of the GNU Lesser General Public License
11  ** (LGPL) version 2.1 which accompanies this distribution, and is available at
12  ** http://www.gnu.org/licenses/lgpl-2.1.html
13  **
14  ** This library is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  ** Lesser General Public License for more details.
18  **
19  *************************************************************************/
20 
21 #ifndef VCOLORPROPERTYEDITOR_H
22 #define VCOLORPROPERTYEDITOR_H
23 
24 #include <qcompilerdetection.h>
25 #include <QColor>
26 #include <QLabel>
27 #include <QLineEdit>
28 #include <QMetaObject>
29 #include <QObject>
30 #include <QPixmap>
31 #include <QSpacerItem>
32 #include <QString>
33 #include <QToolButton>
34 #include <QWidget>
35 #include <QtGlobal>
36 
37 namespace VPE
38 {
39 
40 class VColorPropertyEditor : public QWidget
41 {
42  Q_OBJECT
43 
44 public:
45  //! Constructor taking a widget as parent
46  explicit VColorPropertyEditor(QWidget *parent);
47 
48  //! Destructor
49  virtual ~VColorPropertyEditor() Q_DECL_OVERRIDE;
50 
51 
52  //! Returns the color currently set
53  QColor getLineColor() const;
54 
55  //! A little helper function generating an image to represent a color
56  //! \param color The color to fill the image with
57  //! \size The size of the generated pixmap
58  //! \return Returns a QPixmap
59  static QPixmap GetColorPixmap(const QColor &color, quint32 size = 16);
60 
61  //! A helper function to convert a color into a string.
62  //! \param color The color to fill the image with
63  //! \return The color as string, usually in the format [RRR, GGG, BBB] (AAA)
64  static QString GetColorString(const QColor &color);
65 
66  //! Needed for proper event handling
67  virtual bool eventFilter(QObject *obj, QEvent *ev) Q_DECL_OVERRIDE;
68 
69 signals:
70  //! This is emitted, when the user changes the color
71  void dataChangedByUser(const QColor &GetColor, VColorPropertyEditor *editor);
72 
73  void dataChanged();
74 
75 public slots:
76  //! Sets the color of the widget
77  void setLineColor(const QColor &color_);
78 
79 private slots:
80  void onToolButtonClicked();
81 
82 private:
83  Q_DISABLE_COPY(VColorPropertyEditor)
84  QColor Color;
85  QToolButton *ToolButton;
86  QLabel *TextLabel;
87  QLabel *ColorLabel;
88  QSpacerItem *Spacer;
89 };
90 
91 }
92 
93 #endif // QFILEPROPERTYEDITOR_H
static QString GetColorString(const QColor &color)
A helper function to convert a color into a string.
VColorPropertyEditor(QWidget *parent)
Constructor taking a widget as parent.
static QPixmap GetColorPixmap(const QColor &color, quint32 size=16)
A little helper function generating an image to represent a color.
virtual bool eventFilter(QObject *obj, QEvent *ev) Q_DECL_OVERRIDE
Needed for proper event handling.
void dataChangedByUser(const QColor &GetColor, VColorPropertyEditor *editor)
This is emitted, when the user changes the color.
QColor getLineColor() const
Returns the color currently set.
virtual ~VColorPropertyEditor() Q_DECL_OVERRIDE
Destructor.
void setLineColor(const QColor &color_)
Sets the color of the widget.