color_preview.hpp
Go to the documentation of this file.
1 
23 #ifndef COLOR_PREVIEW_HPP
24 #define COLOR_PREVIEW_HPP
25 
26 #include <QWidget>
27 
28 namespace color_widgets {
29 
33 class ColorPreview : public QWidget
34 {
35  Q_OBJECT
36  Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged DESIGNABLE true)
37  Q_PROPERTY(QColor comparisonColor READ comparisonColor WRITE setComparisonColor DESIGNABLE true)
38  Q_PROPERTY(DisplayMode display_mode READ displayMode WRITE setDisplayMode DESIGNABLE true)
39  Q_PROPERTY(QBrush background READ background WRITE setBackground DESIGNABLE true)
40  Q_ENUMS(DisplayMode)
41 public:
43  {
48  };
49 
50  explicit ColorPreview(QWidget *parent = 0);
51  ~ColorPreview();
52 
54  QBrush background() const;
55 
57  void setBackground(const QBrush &bk);
58 
60  DisplayMode displayMode() const;
61 
63  void setDisplayMode(DisplayMode dm);
64 
66  QColor color() const;
67 
69  QColor comparisonColor() const;
70 
71  QSize sizeHint () const;
72 
73  void paint(QPainter &painter, QRect rect) const;
74 
75 public slots:
77  void setColor(const QColor &c);
78 
80  void setComparisonColor(const QColor &c);
81 
82 signals:
84  void clicked();
85 
87  void colorChanged(QColor);
88 
89 protected:
90  void paintEvent(QPaintEvent *);
91  void resizeEvent(QResizeEvent *);
92  void mouseReleaseEvent(QMouseEvent *ev);
93  void mouseMoveEvent(QMouseEvent *ev);
94 
95 private:
96  class Private;
97  Private * const p;
98 };
99 
100 } // namespace color_widgets
101 
102 #endif // COLOR_PREVIEW_HPP
color
color
Definition: color.h:16
color_widgets::ColorPreview::setColor
void setColor(const QColor &c)
Set current color.
Definition: color_preview.cpp:131
color_widgets::ColorPreview::AllAlpha
@ AllAlpha
show current color with transparency
Definition: color_preview.hpp:45
color_widgets::ColorPreview::setComparisonColor
void setComparisonColor(const QColor &c)
Set the comparison color.
Definition: color_preview.cpp:138
color_widgets::ColorPreview::background
QBrush background
Definition: color_preview.hpp:39
color_widgets::ColorPreview::SplitColor
@ SplitColor
Show current and comparison colors side by side.
Definition: color_preview.hpp:47
color_widgets::ColorPreview::resizeEvent
void resizeEvent(QResizeEvent *)
Definition: color_preview.cpp:151
color_widgets::ColorPreview::paintEvent
void paintEvent(QPaintEvent *)
Definition: color_preview.cpp:144
color_widgets::ColorPreview::setDisplayMode
void setDisplayMode(DisplayMode dm)
Set how transparent colors are handled.
Definition: color_preview.cpp:72
color_widgets::ColorPreview::NoAlpha
@ NoAlpha
Show current color with no transparency.
Definition: color_preview.hpp:44
color_widgets::ColorPreview::SplitAlpha
@ SplitAlpha
Show both solid and transparent side by side.
Definition: color_preview.hpp:46
color_widgets::ColorPreview::setBackground
void setBackground(const QBrush &bk)
Change the background visible under transparent colors.
Definition: color_preview.cpp:56
color_widgets
Definition: color_dialog.hpp:33
color_widgets::ColorPreview::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *ev)
Definition: color_preview.cpp:156
color_widgets::ColorPreview::comparisonColor
QColor comparisonColor
Definition: color_preview.hpp:37
color_widgets::ColorPreview::clicked
void clicked()
Emitted when the user clicks on the widget.
color_widgets::ColorPreview::Private
Definition: color_preview.cpp:33
color_widgets::ColorPreview::color
QColor color
Definition: color_preview.hpp:36
color_widgets::ColorPreview::colorChanged
void colorChanged(QColor)
Emitted on setColor.
color_widgets::ColorPreview
Definition: color_preview.hpp:33
color_widgets::ColorPreview::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *ev)
Definition: color_preview.cpp:162
color_widgets::ColorPreview::paint
void paint(QPainter &painter, QRect rect) const
Definition: color_preview.cpp:93
color_widgets::ColorPreview::p
Private *const p
Definition: color_preview.hpp:96
color_widgets::ColorPreview::DisplayMode
DisplayMode
Definition: color_preview.hpp:42
color_widgets::ColorPreview::sizeHint
QSize sizeHint() const
Definition: color_preview.cpp:88
color_widgets::ColorPreview::displayMode
DisplayMode displayMode() const
Get color display mode.
Definition: color_preview.cpp:67
color_widgets::ColorPreview::display_mode
DisplayMode display_mode
Definition: color_preview.hpp:38
color_widgets::ColorPreview::ColorPreview
ColorPreview(QWidget *parent=0)
Definition: color_preview.cpp:45
color_widgets::ColorPreview::~ColorPreview
~ColorPreview()
Definition: color_preview.cpp:51


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:43