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 ***************************************************************************/
31 * @brief A widget for modifing numbers by dragging, using the mouse wheel or entering them with the keyboard.
34 class DragValue : public QWidget
39 DragValue(QWidget* parent = 0);
42 /** @brief Returns the precision = number of decimals */
43 int precision() const;
44 /** @brief Returns the maximum value */
45 qreal minimum() const;
46 /** @brief Returns the minimum value */
47 qreal maximum() const;
49 /** @brief Sets the precision (number of decimals) to @param precision. */
50 void setPrecision(int precision);
51 /** @brief Sets the minimum value. */
52 void setMinimum(qreal min);
53 /** @brief Sets the maximum value. */
54 void setMaximum(qreal max);
55 /** @brief Sets minimum and maximum value. */
56 void setRange(qreal min, qreal max);
57 /** @brief Sets the size of a step (when dragging or using the mouse wheel). */
58 void setStep(qreal step);
60 /** @brief Returns the current value */
64 /** @brief Sets the value (forced to be in the valid range) and emits valueChanged. */
65 void setValue(qreal value, bool final = true);
68 void valueChanged(qreal value, bool final);
78 virtual void mousePressEvent(QMouseEvent *e);
79 virtual void mouseMoveEvent(QMouseEvent *e);
80 virtual void mouseReleaseEvent(QMouseEvent *e);
81 /** @brief Forwards tab focus to lineedit since it is disabled. */
82 virtual void focusInEvent(QFocusEvent *e);
83 //virtual void keyPressEvent(QKeyEvent *e);
84 virtual void wheelEvent(QWheelEvent *e);
89 void slotEditingFinished();
91 void slotSetNonlinearScale(bool nonlinear);
92 void slotSetDirectUpdate(bool directUpdate);
93 void slotShowContextMenu(const QPoint &pos);
101 QPoint m_dragStartPosition;
102 QPoint m_dragLastPosition;
106 QAction *m_nonlinearScale;
107 QAction *m_directUpdate;
109 /** @brief Sets the maximum width of the widget so that there is enough space for the widest possible value. */
110 void updateMaxWidth();