]> git.sesse.net Git - kdenlive/blob - src/timecodedisplay.h
Fix label
[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 "timecode.h"
24 #include "gentime.h"
25
26 #include <QAbstractSpinBox>
27
28 /**
29  * @class TimecodeDisplay
30  * @brief A widget for inserting a timecode value.
31  * @author Jean-Baptiste Mardelle
32  *
33  * TimecodeDisplay can be used to insert eigther frames
34  * or a timecode in the format HH:MM:SS:FF
35  */
36 class TimecodeDisplay : public QAbstractSpinBox
37 {
38     Q_OBJECT
39
40 public:
41     /** @brief Constructor for the widget, sets value to 0.
42     * @param t Timecode object used to setup correct input (frames or HH:MM:SS:FF)
43     * @param parent parent Widget */
44     explicit TimecodeDisplay(const Timecode& t, QWidget *parent = 0);
45
46     /** @brief Returns the minimum value, which can be entered.
47     * default is 0 */
48     int minimum() const;
49
50     /** @brief Returns the maximum value, which can be entered.
51     * default is no maximum (-1) */
52     int maximum() const;
53
54     /** @brief Sets the minimum maximum value that can be entered.
55     * @param min the minimum value
56     * @param max the maximum value */
57     void setRange(int min, int max);
58
59     /** @brief Returns the current input in frames. */
60     int getValue() const;
61
62     /** @brief Returns the current input as a GenTime object. */
63     GenTime gentime() const;
64
65     /** @brief Returs the widget's timecode object. */
66     Timecode timecode() const;
67
68     /** @brief Sets value's format to frames or HH:MM:SS:FF according to @param frametimecode.
69     * @param frametimecode true = frames, false = HH:MM:SS:FF
70     * @param init true = force the change, false = update only if the frametimecode param changed */
71     void setTimeCodeFormat(bool frametimecode, bool init = false);
72
73     /** @brief Sets timecode for current project.
74      * @param t the new timecode */
75     void updateTimeCode(const Timecode &t);
76
77     virtual void stepBy(int steps);
78
79 private:
80     /** timecode for widget */
81     Timecode m_timecode;
82     /** Should we display the timecode in frames or in format hh:mm:ss:ff */
83     bool m_frametimecode;
84     int m_minimum;
85     int m_maximum;
86     int m_value;
87
88 public slots:
89     /** @brief Sets the value.
90     * @param value the new value
91     * The value actually set is forced to be within the legal range: minimum <= value <= maximum */
92     void setValue(int value);
93     void setValue(const QString &value);
94     void setValue(const GenTime &value);
95
96     /** @brief Sets value's format according to Kdenlive's settings.
97     * @param t (optional, if already existing) Timecode object to use */
98     void slotUpdateTimeCodeFormat();
99
100 private slots:
101     void slotEditingFinished();
102
103 signals:
104     /**
105      * Emitted every time the value changes (by calling setValue() or
106      * by user interaction).
107      * @param value the new value
108      * @param final if the value is final ie not produced during sliding (on slider release it's final)
109      */
110     void valueChanged(int value, bool final);
111     void timeCodeEditingFinished();
112
113 protected:
114     virtual void keyPressEvent(QKeyEvent *e);
115     virtual void mouseReleaseEvent(QMouseEvent *);
116     virtual void wheelEvent(QWheelEvent *e);
117     virtual QAbstractSpinBox::StepEnabled stepEnabled () const;
118
119 };
120
121 #endif