KWidgetsAddons

kselector.h
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 1997 Martin Jones <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 //-----------------------------------------------------------------------------
8 // Selector widgets for KDE Color Selector, but probably useful for other
9 // stuff also.
10 
11 #ifndef KSELECTOR_H
12 #define KSELECTOR_H
13 
14 #include <kwidgetsaddons_export.h>
15 
16 #include <QAbstractSlider>
17 #include <QGradient>
18 #include <QWidget>
19 
31 class KWIDGETSADDONS_EXPORT KSelector : public QAbstractSlider
32 {
33  Q_OBJECT
34  Q_PROPERTY(int value READ value WRITE setValue)
35  Q_PROPERTY(int minValue READ minimum WRITE setMinimum)
36  Q_PROPERTY(int maxValue READ maximum WRITE setMaximum)
37  Q_PROPERTY(bool indent READ indent WRITE setIndent)
38  Q_PROPERTY(Qt::ArrowType arrowDirection READ arrowDirection WRITE setArrowDirection)
39 public:
40 
44  explicit KSelector(QWidget *parent = nullptr);
49  explicit KSelector(Qt::Orientation o, QWidget *parent = nullptr);
50  /*
51  * Destructs the widget.
52  */
53  ~KSelector() override;
54 
58  QRect contentsRect() const;
59 
64  void setIndent(bool i);
65 
69  bool indent() const;
70 
74  void setArrowDirection(Qt::ArrowType direction);
75 
79  Qt::ArrowType arrowDirection() const;
80 
81 protected:
88  virtual void drawContents(QPainter *);
93  virtual void drawArrow(QPainter *painter, const QPoint &pos);
94 
95  void paintEvent(QPaintEvent *) override;
96  void mousePressEvent(QMouseEvent *e) override;
97  void mouseMoveEvent(QMouseEvent *e) override;
98  void mouseReleaseEvent(QMouseEvent *e) override;
99  void wheelEvent(QWheelEvent *) override;
100 
101 private:
102  QPoint calcArrowPos(int val);
103  void moveArrow(const QPoint &pos);
104 
105 private:
106  class Private;
107  friend class Private;
108  Private *const d;
109 
111 };
112 
123 class KWIDGETSADDONS_EXPORT KGradientSelector : public KSelector
124 {
125  Q_OBJECT
126 
127  Q_PROPERTY(QColor firstColor READ firstColor WRITE setFirstColor)
128  Q_PROPERTY(QColor secondColor READ secondColor WRITE setSecondColor)
129  Q_PROPERTY(QString firstText READ firstText WRITE setFirstText)
130  Q_PROPERTY(QString secondText READ secondText WRITE setSecondText)
131 
132 public:
137  explicit KGradientSelector(QWidget *parent = nullptr);
142  explicit KGradientSelector(Qt::Orientation o, QWidget *parent = nullptr);
146  ~KGradientSelector() override;
147 
153  void setStops(const QGradientStops &stops);
154 
159  QGradientStops stops() const;
160 
164  void setColors(const QColor &col1, const QColor &col2);
165  void setText(const QString &t1, const QString &t2);
166 
170  void setFirstColor(const QColor &col);
171  void setSecondColor(const QColor &col);
172 
176  void setFirstText(const QString &t);
177  void setSecondText(const QString &t);
178 
179  QColor firstColor() const;
180  QColor secondColor() const;
181 
182  QString firstText() const;
183  QString secondText() const;
184 
185 protected:
186 
187  void drawContents(QPainter *) override;
188  virtual QSize minimumSize() const;
189 
190 private:
191  class KGradientSelectorPrivate;
192  friend class KGradientSelectorPrivate;
193  KGradientSelectorPrivate *const d;
194 
196 };
197 
198 #endif // KSELECTOR_H
ArrowType
QRect contentsRect() const const
virtual void mouseReleaseEvent(QMouseEvent *event)
QSize minimumSize() const const
virtual void paintEvent(QPaintEvent *event)
virtual void mousePressEvent(QMouseEvent *event)
virtual void mouseMoveEvent(QMouseEvent *event)
The KGradientSelector widget allows the user to choose from a one-dimensional range of colors which i...
Definition: kselector.h:123
virtual void wheelEvent(QWheelEvent *e) override
Q_PROPERTY(...)
virtual void drawContents(QPainter *)
Override this function to draw the contents of the control.
Definition: kselector.cpp:261
Q_DISABLE_COPY(Class)
Orientation
KSelector is the base class for other widgets which provides the ability to choose from a one-dimensi...
Definition: kselector.h:31
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Jul 9 2020 22:43:31 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.