1 /***************************************************************************
2 * Copyright (C) 2011 by Till Theato (root@ttill.de) *
3 * This file is part of Kdenlive (www.kdenlive.org). *
5 * Kdenlive is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 2 of the License, or *
8 * (at your option) any later version. *
10 * Kdenlive is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with Kdenlive. If not, see <http://www.gnu.org/licenses/>. *
17 ***************************************************************************/
19 #include "simplekeyframes/simplekeyframewidget.h"
20 #include "simpletimelinewidget.h"
21 #include "timecodedisplay.h"
23 #include <QToolButton>
24 #include <QGridLayout>
29 SimpleKeyframeWidget::SimpleKeyframeWidget(Timecode t, int in, int out, QWidget *parent) :
32 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
34 QGridLayout *l = new QGridLayout(this);
36 m_timeline = new SimpleTimelineWidget(this);
37 m_timeline->setRange(in ,out);
39 m_buttonAddDelete = new QToolButton(this);
40 m_buttonAddDelete->setAutoRaise(true);
41 m_buttonAddDelete->setIcon(KIcon("document-new"));
42 m_buttonAddDelete->setToolTip(i18n("Add keyframe"));
44 m_buttonPrevious = new QToolButton(this);
45 m_buttonPrevious->setAutoRaise(true);
46 m_buttonPrevious->setIcon(KIcon("media-skip-backward"));
47 m_buttonPrevious->setToolTip(i18n("Go to previous keyframe"));
49 m_buttonNext = new QToolButton(this);
50 m_buttonNext->setAutoRaise(true);
51 m_buttonNext->setIcon(KIcon("media-skip-forward"));
52 m_buttonNext->setToolTip(i18n("Go to next keyframe"));
54 m_time = new TimecodeDisplay(t, this);
55 m_time->setRange(in, out);
57 l->addWidget(m_timeline, 0, 0, 1, -1);
58 l->addWidget(m_buttonPrevious, 1, 0);
59 l->addWidget(m_buttonAddDelete, 1, 1);
60 l->addWidget(m_buttonNext, 1, 2);
61 l->addWidget(m_time, 1, 3, Qt::AlignRight);
63 connect(m_time, SIGNAL(editingFinished()), this, SLOT(slotSetPosition()));
64 connect(m_timeline, SIGNAL(positionChanged(int)), this, SLOT(slotSetPosition(int)));
65 connect(m_timeline, SIGNAL(keyframeAdded(int)), this, SIGNAL(keyframeAdded(int)));
66 connect(m_timeline, SIGNAL(keyframeRemoved(int)), this, SIGNAL(keyframeRemoved(int)));
68 connect(m_buttonAddDelete, SIGNAL(pressed()), m_timeline, SLOT(slotAddRemove()));
69 connect(m_buttonPrevious, SIGNAL(pressed()), m_timeline, SLOT(slotGoToPrev()));
70 connect(m_buttonNext, SIGNAL(pressed()), m_timeline, SLOT(slotGoToNext()));
73 SimpleKeyframeWidget::~SimpleKeyframeWidget()
76 delete m_buttonAddDelete;
77 delete m_buttonPrevious;
79 //delete m_buttonSync;
83 void SimpleKeyframeWidget::slotSetPosition(int pos, bool update)
86 pos = m_time->getValue();
87 m_timeline->slotSetPosition(pos);
89 m_time->setValue(pos);
90 m_timeline->slotSetPosition(pos);
94 emit positionChanged(pos);
97 int SimpleKeyframeWidget::getPosition()
99 return m_time->getValue();
102 void SimpleKeyframeWidget::setKeyframes(const QList< int >& keyframes)
104 m_timeline->setKeyframes(keyframes);
107 void SimpleKeyframeWidget::addKeyframe(int pos)
110 m_timeline->slotAddKeyframe(pos);
115 #include "simplekeyframewidget.moc"