]> git.sesse.net Git - kdenlive/blob - src/KoSliderCombo.h
Fix label
[kdenlive] / src / KoSliderCombo.h
1 /* This file is part of the KDE project
2    Copyright (c) 2007 Casper Boemann <cbr@boemann.dk>
3
4    This library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Library General Public
6    License as published by the Free Software Foundation; either
7    version 2 of the License, or (at your option) any later version.
8
9    This library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Library General Public License for more details.
13
14    You should have received a copy of the GNU Library General Public License
15    along with this library; see the file COPYING.LIB.  If not, write to
16    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18 */
19
20 #ifndef KOSLIDERCOMBO_H_
21 #define KOSLIDERCOMBO_H_
22
23 #include <QComboBox>
24
25
26 /**
27  * @short A widget for qreal values with a popup slider
28  *
29  * KoSliderCombo combines a numerical input and a dropdown slider in a way that takes up as
30  * little screen space as possible.
31  *
32  * It allows the user to either enter a floating point value or quickly set the value using a slider
33  *
34  * One signal is emitted when the value changes. The signal is even emitted when the slider
35  * is moving. The second argument of the signal however tells you if the value is final or not. A
36  * final value is produced by entering a value numerically or by releasing the slider.
37  *
38  * The input of the numerical line edit is constrained to numbers and decimal signs.
39  */
40 class KoSliderCombo : public QComboBox
41 {
42
43     Q_OBJECT
44
45 public:
46
47     /**
48      * Constructor for the widget, where value is set to 0
49      *
50      * @param parent parent QWidget
51      */
52     explicit KoSliderCombo(QWidget *parent = 0);
53
54     /**
55      * Destructor
56      */
57     virtual ~KoSliderCombo();
58
59     /**
60      * The precision of values given as the number of digits after the period.
61      * default is 2
62      */
63     qreal decimals() const;
64
65     /**
66      * The minimum value that can be entered.
67      * default is 0
68      */
69     qreal minimum() const;
70
71     /**
72      * The maximum value that can be entered.
73      * default is 100
74      */
75     qreal maximum() const;
76
77     /**
78      * Sets the precision of the entered values.
79      * @param number the number of digits after the period
80      */
81
82     void setDecimals(int number);
83
84     /**
85      * Sets the minimum value that can be entered.
86      * @param min the minimum value
87      */
88     void setMinimum(qreal min);
89
90     /**
91      * Sets the maximum value that can be entered.
92      * @param max the maximum value
93      */
94     void setMaximum(qreal max);
95
96     /**
97     * The value shown.
98     */
99     qreal value() const;
100
101     virtual QSize minimumSizeHint() const; ///< reimplemented from QComboBox
102     virtual QSize sizeHint() const; ///< reimplemented from QComboBox
103
104 public slots:
105
106     /**
107     * Sets the value.
108     * The value actually set is forced to be within the legal range: minimum <= value <= maximum
109     * @param value the new value
110     */
111     void setValue(qreal value);
112
113 signals:
114
115     /**
116      * Emitted every time the value changes (by calling setValue() or
117      * by user interaction).
118      * @param value the new value
119      * @param final if the value is final ie not produced during sliding (on slider release it's final)
120      */
121     void valueChanged(qreal value, bool final);
122
123 protected:
124     virtual void paintEvent(QPaintEvent *); ///< reimplemented from QComboBox
125     virtual void hideEvent(QHideEvent *); ///< reimplemented from QComboBox
126     virtual void changeEvent(QEvent *e); ///< reimplemented from QComboBox
127     virtual void mousePressEvent(QMouseEvent *e); ///< reimplemented from QComboBox
128     virtual void keyPressEvent(QKeyEvent *e); ///< reimplemented from QComboBox
129     virtual void wheelEvent(QWheelEvent *e); ///< reimplemented from QComboBox
130
131 private:
132     Q_PRIVATE_SLOT(d, void sliderValueChanged(int value))
133     Q_PRIVATE_SLOT(d, void sliderReleased())
134     Q_PRIVATE_SLOT(d, void lineEditFinished())
135
136     class KoSliderComboPrivate;
137     KoSliderComboPrivate * const d;
138 };
139
140 #endif