]> git.sesse.net Git - kdenlive/blob - src/clipdurationdialog.cpp
double click a clip in timeline to edit position & duration, several clip move/resize...
[kdenlive] / src / clipdurationdialog.cpp
1 /***************************************************************************
2  *   Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
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 2 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, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
18  ***************************************************************************/
19
20
21 #include <KDebug>
22
23 #include "clipdurationdialog.h"
24 #include "kdenlivesettings.h"
25
26 ClipDurationDialog::ClipDurationDialog(AbstractClipItem *clip, Timecode tc, QWidget * parent): QDialog(parent), m_tc(tc), m_clip(clip) {
27     setFont(KGlobalSettings::toolBarFont());
28     m_fps = m_tc.fps();
29     m_view.setupUi(this);
30
31     if (clip->type() == TRANSITIONWIDGET) {
32         m_view.crop_up->hide();
33         m_view.crop_down->hide();
34         m_view.crop_position->hide();
35         m_view.crop_label->hide();
36     }
37
38     m_view.clip_position->setText(tc.getTimecode(m_clip->startPos(), m_fps));
39     m_view.crop_position->setText(tc.getTimecode(m_clip->cropStart(), m_fps));
40     m_view.clip_duration->setText(tc.getTimecode(m_clip->duration(), m_fps));
41     connect(m_view.position_up, SIGNAL(clicked()), this, SLOT(slotPosUp()));
42     connect(m_view.position_down, SIGNAL(clicked()), this, SLOT(slotPosDown()));
43     connect(m_view.crop_up, SIGNAL(clicked()), this, SLOT(slotCropUp()));
44     connect(m_view.crop_down, SIGNAL(clicked()), this, SLOT(slotCropDown()));
45     connect(m_view.duration_up, SIGNAL(clicked()), this, SLOT(slotDurUp()));
46     connect(m_view.duration_down, SIGNAL(clicked()), this, SLOT(slotDurDown()));
47
48     adjustSize();
49 }
50
51 ClipDurationDialog::~ClipDurationDialog() {
52 }
53
54 void ClipDurationDialog::slotPosUp() {
55     int position = m_tc.getFrameCount(m_view.clip_position->text(), m_fps);
56     //if (duration >= m_clip->duration().frames(m_fps)) return;
57     position ++;
58     m_view.clip_position->setText(m_tc.getTimecode(GenTime(position, m_fps), m_fps));
59 }
60
61 void ClipDurationDialog::slotPosDown() {
62     int position = m_tc.getFrameCount(m_view.clip_position->text(), m_fps);
63     //if (duration >= m_clip->duration().frames(m_fps)) return;
64     position --;
65     m_view.clip_position->setText(m_tc.getTimecode(GenTime(position, m_fps), m_fps));
66 }
67
68 void ClipDurationDialog::slotDurUp() {
69     int duration = m_tc.getFrameCount(m_view.clip_duration->text(), m_fps);
70     int crop = m_tc.getFrameCount(m_view.crop_position->text(), m_fps);
71     if (duration + crop > m_clip->maxDuration().frames(m_fps)) return;
72     duration ++;
73     m_view.clip_duration->setText(m_tc.getTimecode(GenTime(duration, m_fps), m_fps));
74 }
75
76 void ClipDurationDialog::slotDurDown() {
77     int duration = m_tc.getFrameCount(m_view.clip_duration->text(), m_fps);
78     if (duration <= 0) return;
79     duration --;
80     m_view.clip_duration->setText(m_tc.getTimecode(GenTime(duration, m_fps), m_fps));
81 }
82
83 void ClipDurationDialog::slotCropUp() {
84     int crop = m_tc.getFrameCount(m_view.crop_position->text(), m_fps);
85     int duration = m_tc.getFrameCount(m_view.clip_duration->text(), m_fps);
86     if (duration + crop > m_clip->maxDuration().frames(m_fps)) return;
87     crop ++;
88     m_view.crop_position->setText(m_tc.getTimecode(GenTime(crop, m_fps), m_fps));
89 }
90
91 void ClipDurationDialog::slotCropDown() {
92     int crop = m_tc.getFrameCount(m_view.crop_position->text(), m_fps);
93     if (crop <= 0) return;
94     crop --;
95     m_view.crop_position->setText(m_tc.getTimecode(GenTime(crop, m_fps), m_fps));
96 }
97
98 GenTime ClipDurationDialog::startPos() const {
99     int pos = m_tc.getFrameCount(m_view.clip_position->text(), m_fps);
100     return GenTime(pos, m_fps);
101 }
102
103 GenTime ClipDurationDialog::cropStart() const {
104     int pos = m_tc.getFrameCount(m_view.crop_position->text(), m_fps);
105     return GenTime(pos, m_fps);
106 }
107
108 GenTime ClipDurationDialog::duration() const {
109     int pos = m_tc.getFrameCount(m_view.clip_duration->text(), m_fps);
110     return GenTime(pos, m_fps);
111 }
112
113 #include "clipdurationdialog.moc"
114
115