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 ***************************************************************************/
23 #include <kselectaction.h>
25 #include <QDoubleSpinBox>
27 #include <QProgressBar>
37 class CustomLabel : public QProgressBar
41 CustomLabel(const QString &label, bool showSlider = true, int range = 1000, QWidget *parent = 0);
42 void setProgressValue(double value);
43 void setStep(double step);
46 //virtual void mouseDoubleClickEvent(QMouseEvent * event);
47 virtual void mousePressEvent(QMouseEvent * event);
48 virtual void mouseReleaseEvent(QMouseEvent *event);
49 virtual void mouseMoveEvent(QMouseEvent *event);
50 //virtual void paintEvent(QPaintEvent *event);
51 virtual void wheelEvent(QWheelEvent * event);
54 QPoint m_dragStartPosition;
55 QPoint m_dragLastPosition;
59 void slotValueInc(double factor = 1);
60 void slotValueDec(double factor = 1);
61 void setNewValue(double, bool);
64 void valueChanged(double, bool);
70 * @brief A widget for modifing numbers by dragging, using the mouse wheel or entering them with the keyboard.
73 class DragValue : public QWidget
79 * @brief Default constructor.
80 * @param label The label that will be displayed in the progress bar
81 * @param defaultValue The default value
82 * @param decimals The number of decimals for the parameter. 0 means it is an integer
83 * @param min The minimum value
84 * @param max The maximum value
85 * @param id Used to identify this widget. If this parameter is set, "Show in Timeline" will be available in context menu.
86 * @param suffix The suffix that will be displayed in the spinbox (for example '%')
87 * @param showSlider If disabled, user can still drag on the label but no progress bar is shown
89 DragValue(const QString &label, double defaultValue, int decimals, double min = 0, double max = 100, int id = -1, const QString suffix = QString(), bool showSlider = true, QWidget* parent = 0);
92 /** @brief Returns the precision = number of decimals */
93 int precision() const;
94 /** @brief Returns the maximum value */
95 qreal minimum() const;
96 /** @brief Returns the minimum value */
97 qreal maximum() const;
99 /** @brief Sets the precision (number of decimals) to @param precision. */
100 void setPrecision(int precision);
101 /** @brief Sets the minimum value. */
102 void setMinimum(qreal min);
103 /** @brief Sets the maximum value. */
104 void setMaximum(qreal max);
105 /** @brief Sets minimum and maximum value. */
106 void setRange(qreal min, qreal max);
107 /** @brief Sets the size of a step (when dragging or using the mouse wheel). */
108 void setStep(qreal step);
110 /** @brief Returns the current value */
112 /** @brief Change the "inTimeline" property to paint the intimeline widget differently. */
113 void setInTimelineProperty(bool intimeline);
114 /** @brief Returns minimum size for QSpinBox, used to set all spinboxes to the same width. */
116 /** @brief Sets the minimum size for QSpinBox, used to set all spinboxes to the same width. */
117 void setSpinSize(int width);
120 /** @brief Sets the value (forced to be in the valid range) and emits valueChanged. */
121 void setValue(double value, bool final = true);
122 void setValueFromProgress(double value, bool final);
123 /** @brief Resets to default value */
127 void valueChanged(double value, bool final = true);
128 void inTimeline(int);
137 /*virtual void mousePressEvent(QMouseEvent *e);
138 virtual void mouseMoveEvent(QMouseEvent *e);
139 virtual void mouseReleaseEvent(QMouseEvent *e);*/
140 /** @brief Forwards tab focus to lineedit since it is disabled. */
141 virtual void focusInEvent(QFocusEvent *e);
142 //virtual void keyPressEvent(QKeyEvent *e);
143 //virtual void wheelEvent(QWheelEvent *e);
144 //virtual void paintEvent( QPaintEvent * event );
148 void slotEditingFinished();
150 void slotSetScaleMode(int mode);
151 void slotSetDirectUpdate(bool directUpdate);
152 void slotShowContextMenu(const QPoint &pos);
153 void slotSetValue(int value);
154 void slotSetValue(double value);
155 void slotSetInTimeline();
164 QDoubleSpinBox *m_doubleEdit;
167 KSelectAction *m_scale;
168 QAction *m_directUpdate;
169 CustomLabel *m_label;