1 /***************************************************************************
2 * Copyright (C) 2011 by Till Theato (root@ttill.de) *
3 * This file is part of Kdenlive (www.kdenlive.org). *
5 * Kdenlive is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 2 of the License, or *
8 * (at your option) any later version. *
10 * Kdenlive is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with Kdenlive. If not, see <http://www.gnu.org/licenses/>. *
17 ***************************************************************************/
29 * @brief A widget for modifing numbers by dragging, using the mouse wheel or entering them with the keyboard.
32 class DragValue : public QWidget
37 DragValue(QWidget* parent = 0);
40 /** @brief Returns the precision = number of decimals */
41 int precision() const;
42 /** @brief Returns the maximum value */
43 qreal minimum() const;
44 /** @brief Returns the minimum value */
45 qreal maximum() const;
47 /** @brief Sets the precision (number of decimals) to @param precision. */
48 void setPrecision(int precision);
49 /** @brief Sets the minimum value. */
50 void setMinimum(qreal min);
51 /** @brief Sets the maximum value. */
52 void setMaximum(qreal max);
53 /** @brief Sets minimum and maximum value. */
54 void setRange(qreal min, qreal max);
55 /** @brief Sets the size of a step (when dragging or using the mouse wheel). */
56 void setStep(qreal step);
58 /** @brief Returns the current value */
62 /** @brief Sets the value (forced to be in the valid range) and emits valueChanged. */
63 void setValue(qreal value, bool final = true);
66 void valueChanged(qreal value, bool final);
76 virtual void mousePressEvent(QMouseEvent *e);
77 virtual void mouseMoveEvent(QMouseEvent *e);
78 virtual void mouseReleaseEvent(QMouseEvent *e);
79 /** @brief Forwards tab focus to lineedit since it is disabled. */
80 virtual void focusInEvent(QFocusEvent *e);
81 //virtual void keyPressEvent(QKeyEvent *e);
82 virtual void wheelEvent(QWheelEvent *e);
87 void slotEditingFinished();
95 /*QToolButton *m_buttonInc;
96 QToolButton *m_buttonDec;*/
97 QPoint m_dragStartPosition;
98 QPoint m_dragLastPosition;
102 /** @brief Sets the maximum width of the widget so that there is enough space for the widest possible value. */
103 void updateMaxWidth();