* along with Kdenlive. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
-#include "simplekeyframes/simplekeyframewidget.h"
+#include "simplekeyframewidget.h"
#include "simpletimelinewidget.h"
#include "timecodedisplay.h"
#include <KIcon>
#include <KLocale>
-SimpleKeyframeWidget::SimpleKeyframeWidget(Timecode t, int in, int out, QWidget *parent) :
+SimpleKeyframeWidget::SimpleKeyframeWidget(const Timecode &t, int duration, QWidget *parent) :
QWidget(parent)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
QGridLayout *l = new QGridLayout(this);
m_timeline = new SimpleTimelineWidget(this);
- m_timeline->setRange(in ,out);
+ m_timeline->setDuration(duration);
m_buttonAddDelete = new QToolButton(this);
m_buttonAddDelete->setAutoRaise(true);
m_buttonNext->setToolTip(i18n("Go to next keyframe"));
m_time = new TimecodeDisplay(t, this);
- m_time->setRange(in, out);
+ m_time->setRange(0, duration);
l->addWidget(m_timeline, 0, 0, 1, -1);
l->addWidget(m_buttonPrevious, 1, 0);
l->addWidget(m_buttonNext, 1, 2);
l->addWidget(m_time, 1, 3, Qt::AlignRight);
- connect(m_time, SIGNAL(editingFinished()), this, SLOT(slotSetPosition()));
+ connect(m_time, SIGNAL(timeCodeEditingFinished()), this, SLOT(slotSetPosition()));
connect(m_timeline, SIGNAL(positionChanged(int)), this, SLOT(slotSetPosition(int)));
+ connect(m_timeline, SIGNAL(atKeyframe(bool)), this, SLOT(slotAtKeyframe(bool)));
connect(m_timeline, SIGNAL(keyframeAdded(int)), this, SIGNAL(keyframeAdded(int)));
connect(m_timeline, SIGNAL(keyframeRemoved(int)), this, SIGNAL(keyframeRemoved(int)));
+ connect(m_timeline, SIGNAL(keyframeMoved(int,int)), this, SIGNAL(keyframeMoved(int,int)));
connect(m_buttonAddDelete, SIGNAL(pressed()), m_timeline, SLOT(slotAddRemove()));
connect(m_buttonPrevious, SIGNAL(pressed()), m_timeline, SLOT(slotGoToPrev()));
connect(m_buttonNext, SIGNAL(pressed()), m_timeline, SLOT(slotGoToNext()));
+
+ // no keyframes yet
+ setEnabled(false);
}
SimpleKeyframeWidget::~SimpleKeyframeWidget()
delete m_buttonAddDelete;
delete m_buttonPrevious;
delete m_buttonNext;
- //delete m_buttonSync;
delete m_time;
}
emit positionChanged(pos);
}
-int SimpleKeyframeWidget::getPosition()
+int SimpleKeyframeWidget::getPosition() const
{
return m_time->getValue();
}
void SimpleKeyframeWidget::setKeyframes(const QList< int >& keyframes)
{
m_timeline->setKeyframes(keyframes);
+ setEnabled(true);
}
void SimpleKeyframeWidget::addKeyframe(int pos)
blockSignals(true);
m_timeline->slotAddKeyframe(pos);
blockSignals(false);
+ setEnabled(true);
+}
+
+void SimpleKeyframeWidget::updateTimecodeFormat()
+{
+ m_time->slotUpdateTimeCodeFormat();
}
+void SimpleKeyframeWidget::slotAtKeyframe(bool atKeyframe)
+{
+ if (atKeyframe) {
+ m_buttonAddDelete->setIcon(KIcon("edit-delete"));
+ m_buttonAddDelete->setToolTip(i18n("Delete keyframe"));
+ } else {
+ m_buttonAddDelete->setIcon(KIcon("document-new"));
+ m_buttonAddDelete->setToolTip(i18n("Add keyframe"));
+ }
+}
#include "simplekeyframewidget.moc"