]> git.sesse.net Git - kdenlive/blob - src/timecodedisplay.h
Use new timecode widget for position parameter in effects
[kdenlive] / src / timecodedisplay.h
1 /* This file is part of the KDE project
2    Copyright (c) 2010 Jean-Baptiste Mardelle <jb@kdenlive.org>
3
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.
8
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.
13
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.
18 */
19
20 #ifndef TIMECODEDISPLAY_H_
21 #define TIMECODEDISPLAY_H_
22
23 #include "ui_timecodedisplay_ui.h"
24 #include "timecode.h"
25
26 #include <KRestrictedLine>
27
28
29 /**
30  * @short A widget for qreal values with a popup slider
31  *
32  * TimecodeDisplay combines a numerical input and a dropdown slider in a way that takes up as
33  * little screen space as possible.
34  *
35  * It allows the user to either enter a floating point value or quickly set the value using a slider
36  *
37  * One signal is emitted when the value changes. The signal is even emitted when the slider
38  * is moving. The second argument of the signal however tells you if the value is final or not. A
39  * final value is produced by entering a value numerically or by releasing the slider.
40  *
41  * The input of the numerical line edit is constrained to numbers and decimal signs.
42  */
43 class TimecodeDisplay : public QWidget, public Ui::TimecodeDisplay_UI
44 {
45
46     Q_OBJECT
47
48 public:
49
50     /**
51      * Constructor for the widget, where value is set to 0
52      *
53      * @param parent parent QWidget
54      */
55     TimecodeDisplay(Timecode t, QWidget *parent = 0);
56
57     /**
58      * Destructor
59      */
60     virtual ~TimecodeDisplay();
61
62     /**
63      * The minimum value that can be entered.
64      * default is 0
65      */
66     int minimum() const;
67
68     /**
69      * The maximum value that can be entered.
70      * default is 100
71      */
72     int maximum() const;
73
74     /**
75      * Sets the minimum maximum value that can be entered.
76      * @param min the minimum value
77      * @param max the maximum value
78      */
79     void setRange(int min, int max);
80
81     /**
82     * The value shown.
83     */
84     int value() const;
85
86     Timecode timecode() const;
87
88     //virtual QSize minimumSizeHint() const; ///< reimplemented from QComboBox
89     //virtual QSize sizeHint() const; ///< reimplemented from QComboBox
90
91 private:
92     /** timecode for widget */
93     Timecode m_timecode;
94     /** Should we display the timecode in frames or in format hh:mm:ss:ff */
95     bool m_frametimecode;
96     int m_minimum;
97     int m_maximum;
98
99 public slots:
100
101     /**
102     * Sets the value.
103     * The value actually set is forced to be within the legal range: minimum <= value <= maximum
104     * @param value the new value
105     */
106     void setValue(int value);
107     void setValue(const QString &value);
108     void slotPrepareTimeCodeFormat(Timecode t);
109
110 private slots:
111     void slotValueUp();
112     void slotValueDown();
113
114 signals:
115
116     /**
117      * Emitted every time the value changes (by calling setValue() or
118      * by user interaction).
119      * @param value the new value
120      * @param final if the value is final ie not produced during sliding (on slider release it's final)
121      */
122     void valueChanged(int value, bool final);
123     void editingFinished();
124
125 protected:
126     virtual void keyPressEvent(QKeyEvent *e);
127     virtual void wheelEvent(QWheelEvent *e);
128
129 };
130
131 #endif