1 /* This file is part of the KDE project
2 Copyright (c) 2007 Casper Boemann <cbr@boemann.dk>
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.
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.
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.
20 #ifndef KOSLIDERCOMBO_H_
21 #define KOSLIDERCOMBO_H_
27 * @short A widget for qreal values with a popup slider
29 * KoSliderCombo combines a numerical input and a dropdown slider in a way that takes up as
30 * little screen space as possible.
32 * It allows the user to either enter a floating point value or quickly set the value using a slider
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.
38 * The input of the numerical line edit is constrained to numbers and decimal signs.
40 class KoSliderCombo : public QComboBox
48 * Constructor for the widget, where value is set to 0
50 * @param parent parent QWidget
52 KoSliderCombo(QWidget *parent=0);
57 virtual ~KoSliderCombo();
60 * The precision of values given as the number of digits after the period.
63 qreal decimals() const;
66 * The minimum value that can be entered.
69 qreal minimum() const;
72 * The maximum value that can be entered.
75 qreal maximum() const;
78 * Sets the precision of the entered values.
79 * @param number the number of digits after the period
82 void setDecimals(int number);
85 * Sets the minimum value that can be entered.
86 * @param min the minimum value
88 void setMinimum(qreal min);
91 * Sets the maximum value that can be entered.
92 * @param max the maximum value
94 void setMaximum(qreal max);
101 virtual QSize minimumSizeHint() const; ///< reimplemented from QComboBox
102 virtual QSize sizeHint() const; ///< reimplemented from QComboBox
108 * The value actually set is forced to be within the legal range: minimum <= value <= maximum
109 * @param value the new value
111 void setValue(qreal value);
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)
121 void valueChanged(qreal value, bool final);
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
132 Q_PRIVATE_SLOT(d, void sliderValueChanged(int value))
133 Q_PRIVATE_SLOT(d, void sliderReleased())
134 Q_PRIVATE_SLOT(d, void lineEditFinished())
136 class KoSliderComboPrivate;
137 KoSliderComboPrivate * const d;