]> git.sesse.net Git - kdenlive/blob - src/spacerdialog.cpp
Reindent the codebase using 'linux' bracket placement.
[kdenlive] / src / spacerdialog.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 "spacerdialog.h"
22 #include "kthumb.h"
23 #include "kdenlivesettings.h"
24
25 #include <QWheelEvent>
26 #include <KDebug>
27
28
29 SpacerDialog::SpacerDialog(const GenTime duration, Timecode tc, int track, int trackNumber, QWidget * parent): QDialog(parent), m_tc(tc)
30 {
31     setFont(KGlobalSettings::toolBarFont());
32     m_fps = m_tc.fps();
33     m_view.setupUi(this);
34     m_view.space_duration->setText(tc.getTimecode(duration, m_fps));
35     QStringList tracks;
36     tracks << i18n("All tracks");
37     for (int i = 0; i < trackNumber - 1; i++) {
38         tracks << QString::number(i);
39     }
40     m_view.track_number->addItems(tracks);
41     m_view.track_number->setCurrentIndex(track);
42
43     connect(m_view.position_up, SIGNAL(clicked()), this, SLOT(slotTimeUp()));
44     connect(m_view.position_down, SIGNAL(clicked()), this, SLOT(slotTimeDown()));
45
46     adjustSize();
47 }
48
49 SpacerDialog::~SpacerDialog()
50 {
51 }
52
53 void SpacerDialog::slotTimeUp()
54 {
55     int duration = m_tc.getFrameCount(m_view.space_duration->text(), m_fps);
56     duration ++;
57     m_view.space_duration->setText(m_tc.getTimecode(GenTime(duration, m_fps), m_fps));
58 }
59
60 void SpacerDialog::slotTimeDown()
61 {
62     int duration = m_tc.getFrameCount(m_view.space_duration->text(), m_fps);
63     if (duration <= 0) return;
64     duration --;
65     m_view.space_duration->setText(m_tc.getTimecode(GenTime(duration, m_fps), m_fps));
66 }
67
68 GenTime SpacerDialog::selectedDuration()
69 {
70     return GenTime(m_tc.getFrameCount(m_view.space_duration->text(), m_fps), m_fps);
71 }
72
73 void SpacerDialog::wheelEvent(QWheelEvent * event)
74 {
75     if (m_view.space_duration->underMouse()) {
76         if (event->delta() > 0)
77             slotTimeUp();
78         else
79             slotTimeDown();
80     }
81 }
82
83 int SpacerDialog::selectedTrack()
84 {
85     return m_view.track_number->currentIndex() - 1;
86 }
87
88 #include "spacerdialog.moc"
89
90