Warning, file /office/calligra/libs/widgets/KoSliderCombo.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 Copyright (c) 2007 C. Boemann <cbo@boemann.dk> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This library is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LIB. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 * Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #ifndef KOSLIDERCOMBO_H_ 0021 #define KOSLIDERCOMBO_H_ 0022 0023 #include <QComboBox> 0024 0025 #include "kowidgets_export.h" 0026 0027 /** 0028 * @short A widget for qreal values with a popup slider 0029 * 0030 * KoSliderCombo combines a numerical input and a dropdown slider in a way that takes up as 0031 * little screen space as possible. 0032 * 0033 * It allows the user to either enter a floating point value or quickly set the value using a slider 0034 * 0035 * One signal is emitted when the value changes. The signal is even emitted when the slider 0036 * is moving. The second argument of the signal however tells you if the value is final or not. A 0037 * final value is produced by entering a value numerically or by releasing the slider. 0038 * 0039 * The input of the numerical line edit is constrained to numbers and decimal signs. 0040 */ 0041 class KOWIDGETS_EXPORT KoSliderCombo : public QComboBox 0042 { 0043 0044 Q_OBJECT 0045 0046 public: 0047 0048 /** 0049 * Constructor for the widget, where value is set to 0 0050 * 0051 * @param parent parent QWidget 0052 */ 0053 explicit KoSliderCombo(QWidget *parent = nullptr); 0054 0055 /** 0056 * Destructor 0057 */ 0058 ~KoSliderCombo() override; 0059 0060 /** 0061 * The precision of values given as the number of digits after the period. 0062 * default is 2 0063 */ 0064 qreal decimals() const; 0065 0066 /** 0067 * The minimum value that can be entered. 0068 * default is 0 0069 */ 0070 qreal minimum() const; 0071 0072 /** 0073 * The maximum value that can be entered. 0074 * default is 100 0075 */ 0076 qreal maximum() const; 0077 0078 /** 0079 * Sets the precision of the entered values. 0080 * @param number the number of digits after the period 0081 */ 0082 0083 void setDecimals(int number); 0084 0085 /** 0086 * Sets the minimum value that can be entered. 0087 * @param min the minimum value 0088 */ 0089 void setMinimum(qreal min); 0090 0091 /** 0092 * Sets the maximum value that can be entered. 0093 * @param max the maximum value 0094 */ 0095 void setMaximum(qreal max); 0096 0097 /** 0098 * The value shown. 0099 */ 0100 qreal value() const; 0101 0102 QSize minimumSizeHint() const override; ///< reimplemented from QComboBox 0103 QSize sizeHint() const override; ///< reimplemented from QComboBox 0104 0105 public Q_SLOTS: 0106 0107 /** 0108 * Sets the value. 0109 * The value actually set is forced to be within the legal range: minimum <= value <= maximum 0110 * @param value the new value 0111 */ 0112 void setValue(qreal value); 0113 0114 Q_SIGNALS: 0115 0116 /** 0117 * Emitted every time the value changes (by calling setValue() or 0118 * by user interaction). 0119 * @param value the new value 0120 * @param final if the value is final ie not produced during sliding (on slider release it's final) 0121 */ 0122 void valueChanged(qreal value, bool final); 0123 0124 protected: 0125 void paintEvent(QPaintEvent *) override; ///< reimplemented from QComboBox 0126 void hideEvent(QHideEvent *) override; ///< reimplemented from QComboBox 0127 void changeEvent(QEvent *e) override; ///< reimplemented from QComboBox 0128 void mousePressEvent(QMouseEvent *e) override; ///< reimplemented from QComboBox 0129 void keyPressEvent(QKeyEvent *e) override; ///< reimplemented from QComboBox 0130 void wheelEvent(QWheelEvent *e) override; ///< reimplemented from QComboBox 0131 0132 private: 0133 Q_PRIVATE_SLOT(d, void sliderValueChanged(int value)) 0134 Q_PRIVATE_SLOT(d, void sliderReleased()) 0135 Q_PRIVATE_SLOT(d, void lineEditFinished()) 0136 0137 class KoSliderComboPrivate; 0138 KoSliderComboPrivate * const d; 0139 }; 0140 0141 #endif