1 /*  QWinFF - a qt4 gui frontend for ffmpeg
2  *  Copyright (C) 2011-2013 Timothy Lin <lzh9102@gmail.com>
3  *
4  *  This program is free software: you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation, either version 3 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program 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
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef TIMERANGEEDIT_H
19 #define TIMERANGEEDIT_H
20 
21 #include <QWidget>
22 
23 QT_BEGIN_NAMESPACE
24 class QTimeEdit;
25 class QCheckBox;
26 QT_END_NAMESPACE
27 
28 class TimeRangeEdit : public QWidget
29 {
30     Q_OBJECT
31 public:
32     explicit TimeRangeEdit(QWidget *parent = 0);
33 
34     int maxTime() const;
35 
36     /**
37      * @brief begin time
38      * @return If fromBegin() is false, this function returns the begin time.
39      *       If fromBegin() is true, the return value is 0.
40      */
41     int beginTime() const;
42 
43     /**
44      * @brief endTime
45      * @return If toEnd() is false, this fuction returns the end time.
46      *       If toEnd() is true, the return value is the same as maxTime().
47      */
48     int endTime() const;
49 
50     /**
51      * @brief whether the "from begin" checkbox is checked
52      */
53     bool fromBegin() const;
54 
55     /**
56      * @brief whether the "to end" checkbox is checked
57      */
58     bool toEnd() const;
59 
60 public slots:
61 
62     /**
63      * @brief Set the maximum duration to @a sec
64      * @param sec the maximum duration in seconds
65      */
66     void setMaxTime(int sec);
67 
68     /**
69      * @brief Set the begin time to @a sec
70      */
71     void setBeginTime(int sec);
72 
73     /**
74      * @brief Set the end time to @a sec
75      */
76     void setEndTime(int sec);
77 
78     void setFromBegin(bool);
79 
80     void setToEnd(bool);
81 
82 signals:
83     void valueChanged();
84 
85 private slots:
86     void time_changed();
87 
88 private:
89     QTimeEdit *m_timeBegin;
90     QTimeEdit *m_timeEnd;
91     QCheckBox *m_chkFromBegin;
92     QCheckBox *m_chkToEnd;
93 };
94 
95 #endif // TIMERANGEEDIT_H
96