pqColorChooserButton.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3 // SPDX-License-Identifier: BSD-3-Clause
4 #ifndef pqColorChooserButton_h
5 #define pqColorChooserButton_h
6 
7 #include "pqWidgetsModule.h"
8 
9 #include <QColor>
10 #include <QToolButton>
11 #include <QVariant>
12 
18 class PQWIDGETS_EXPORT pqColorChooserButton : public QToolButton
19 {
20  Q_OBJECT
21  Q_PROPERTY(QColor chosenColor READ chosenColor WRITE setChosenColor USER true);
22  Q_PROPERTY(QVariantList chosenColorRgbF READ chosenColorRgbF WRITE setChosenColorRgbF);
23  Q_PROPERTY(QVariantList chosenColorRgbaF READ chosenColorRgbaF WRITE setChosenColorRgbaF);
24  Q_PROPERTY(bool showAlphaChannel READ showAlphaChannel WRITE setShowAlphaChannel);
25 
26 public:
30  pqColorChooserButton(QWidget* p);
31 
35  QColor chosenColor() const;
36 
41  QVariantList chosenColorRgbF() const;
42 
47  QVariantList chosenColorRgbaF() const;
48 
52  void setIconRadiusHeightRatio(double val) { this->IconRadiusHeightRatio = val; }
53  double iconRadiusHeightRatio() const { return this->IconRadiusHeightRatio; }
54 
58  bool showAlphaChannel() const { return this->ShowAlphaChannel; }
59  void setShowAlphaChannel(bool val) { this->ShowAlphaChannel = val; }
60 
61 Q_SIGNALS:
66  void chosenColorChanged(const QColor&);
67 
72  void validColorChosen(const QColor&);
73 
74 public Q_SLOTS:
78  virtual void setChosenColor(const QColor&);
79 
84  void setChosenColorRgbF(const QVariantList&);
85 
90  void setChosenColorRgbaF(const QVariantList&);
91 
95  virtual void chooseColor();
96 
97 protected:
101  void resizeEvent(QResizeEvent* rEvent) override;
102 
106  QIcon renderColorSwatch(const QColor&);
107 
111  double Color[4];
112 
117 
119 };
120 
121 #endif
pqColorChooserButton is a QToolButton subclass suitable for showing a a button that allows the use to...
double IconRadiusHeightRatio
the ratio of icon radius to button height
double iconRadiusHeightRatio() const
void setIconRadiusHeightRatio(double val)
Set/Get the ratio of icon radius to button height.
#define PQWIDGETS_EXPORT
Color
void setShowAlphaChannel(bool val)
bool showAlphaChannel() const
When true, the widget will allow users to choose the alpha channel.