digiKam
dcolorvalueselector.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 1997-02-20
7  * Description : color chooser widgets
8  *
9  * Copyright (C) 1997 by Martin Jones <mjones at kde dot org>
10  * Copyright (C) 2015-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_DCOLOR_VALUE_SELECTOR_H
26 #define DIGIKAM_DCOLOR_VALUE_SELECTOR_H
27 
28 // Qt includes
29 
30 #include <QPixmap>
31 #include <QAbstractSlider>
32 
33 // Local includes
34 
35 #include "dcolorchoosermode.h"
36 #include "digikam_export.h"
37 
38 namespace Digikam
39 {
40 
50 class DIGIKAM_EXPORT DSelector : public QAbstractSlider
51 {
52  Q_OBJECT
53  Q_PROPERTY(int value READ value WRITE setValue)
54  Q_PROPERTY(int minValue READ minimum WRITE setMinimum)
55  Q_PROPERTY(int maxValue READ maximum WRITE setMaximum)
56  Q_PROPERTY(bool indent READ indent WRITE setIndent)
57  Q_PROPERTY(Qt::ArrowType arrowDirection READ arrowDirection WRITE setArrowDirection)
58 
59 public:
60 
61  explicit DSelector(QWidget *parent = nullptr);
62  explicit DSelector(Qt::Orientation o, QWidget* const parent = nullptr);
63  ~DSelector() override;
64 
68  QRect contentsRect() const;
69 
74  void setIndent(bool i);
75 
79  bool indent() const;
80 
84  void setArrowDirection(Qt::ArrowType direction);
85 
89  Qt::ArrowType arrowDirection() const;
90 
91 protected:
92 
99  virtual void drawContents(QPainter*) {};
100 
105  virtual void drawArrow(QPainter* painter, const QPoint& pos);
106 
107  void paintEvent(QPaintEvent*) override;
108  void mousePressEvent(QMouseEvent* e) override;
109  void mouseMoveEvent(QMouseEvent* e) override;
110  void mouseReleaseEvent(QMouseEvent* e) override;
111  void wheelEvent(QWheelEvent*) override;
112 
113 private:
114 
115  QPoint calcArrowPos(int val);
116  void moveArrow(const QPoint& pos);
117 
118 private:
119 
120  class Private;
121  friend class Private;
122  Private* const d;
123 
124  Q_DISABLE_COPY(DSelector)
125 };
126 
127 // -----------------------------------------------------------------------------------
128 
129 class DIGIKAM_EXPORT DColorValueSelector : public DSelector
130 {
131  Q_OBJECT
132  Q_PROPERTY( int hue READ hue WRITE setHue)
133  Q_PROPERTY( int saturation READ saturation WRITE setSaturation)
134  Q_PROPERTY( int colorValue READ colorValue WRITE setColorValue)
135 
136 public:
137 
138  explicit DColorValueSelector(QWidget* const parent = nullptr);
139  explicit DColorValueSelector(Qt::Orientation o, QWidget* const parent = nullptr);
140  ~DColorValueSelector() override;
141 
145  void updateContents();
146 
152  int hue() const;
153 
160  void setHue(int hue);
161 
167  int saturation() const;
168 
175  void setSaturation(int saturation);
176 
182  int colorValue() const;
183 
190  void setColorValue(int colorValue);
191 
198  void setChooserMode(DColorChooserMode chooserMode);
199 
205  DColorChooserMode chooserMode() const;
206 
207 protected:
208 
213  virtual void drawPalette(QPixmap*);
214  void resizeEvent(QResizeEvent*) override;
215 
221  void drawContents(QPainter*) override;
222 
223 private:
224 
225  class Private;
226  friend class Private;
227  Private* const d;
228 
229  Q_DISABLE_COPY(DColorValueSelector)
230 };
231 
232 } // namespace Digikam
233 
234 #endif // DIGIKAM_DCOLOR_VALUE_SELECTOR_H
Definition: dcolorvalueselector.h:130
Definition: dcolorvalueselector.h:51
virtual void drawContents(QPainter *)
Definition: dcolorvalueselector.h:99
qulonglong value
Definition: itemviewutilities.cpp:592
@ Orientation
Definition: coredbfields.h:86
Definition: datefolderview.cpp:43
DColorChooserMode
Definition: dcolorchoosermode.h:32