1 /**
2  * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB.  All rights reserved.
3  *
4  * This file is part of the KD Chart library.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef COLORSLIDER_H
21 #define COLORSLIDER_H
22 
23 #include <QAbstractSlider>
24 
25 class ColorSlider : public QAbstractSlider
26 {
27     Q_OBJECT
28     Q_PROPERTY( QColor startColor READ startColor WRITE setStartColor NOTIFY startColorChanged )
29     Q_PROPERTY( QColor endColor READ endColor WRITE setStartColor NOTIFY endColorChanged )
30 public:
31     explicit ColorSlider( QWidget *parent = nullptr );
32     ~ColorSlider();
33     QColor startColor() const;
34     void setStartColor( const QColor &color );
35     QColor endColor() const;
36     void setEndColor( const QColor &color );
37     QSize sizeHint() const override;
38 
39 protected:
40     void paintEvent( QPaintEvent *event ) override;
41     void mousePressEvent(QMouseEvent *event ) override;
42     void mouseReleaseEvent(QMouseEvent *event ) override;
43     void mouseMoveEvent( QMouseEvent *event ) override;
44 
45 Q_SIGNALS:
46     void startColorChanged();
47     void endColorChanged();
48 
49 public Q_SLOTS:
50 private:
51     class Private;
52     Private *d;
53 
54 };
55 
56 #endif // COLORSLIDER_H
57