]> git.sesse.net Git - kdenlive/blobdiff - src/keyframeedit.cpp
Auto-check first entry in Effect Stack for editing in timeline (regression):
[kdenlive] / src / keyframeedit.cpp
index 2ff857ad7e6505820e3ac73726eaf89ca6f28f4d..b93182911e2b01326f972d800643653003e78193 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "keyframeedit.h"
 #include "doubleparameterwidget.h"
+#include "positionedit.h"
 #include "kdenlivesettings.h"
 
 #include <KDebug>
@@ -51,6 +52,9 @@ KeyframeEdit::KeyframeEdit(QDomElement e, int minFrame, int maxFrame, Timecode t
     connect(keyframe_list, SIGNAL(itemSelectionChanged()), this, SLOT(slotAdjustKeyframeInfo()));
     connect(keyframe_list, SIGNAL(cellChanged(int, int)), this, SLOT(slotGenerateParams(int, int)));
 
+    m_position = new PositionEdit(i18n("Position"), 0, 0, 1, tc, widgetTable);
+    ((QGridLayout*)widgetTable->layout())->addWidget(m_position, 3, 0, 1, -1);
+
     m_showButtons = new QButtonGroup(this);
     m_slidersLayout = new QGridLayout(param_sliders);
     keyframe_list->setSelectionBehavior(QAbstractItemView::SelectRows);
@@ -63,12 +67,11 @@ KeyframeEdit::KeyframeEdit(QDomElement e, int minFrame, int maxFrame, Timecode t
     connect(button_add, SIGNAL(clicked()), this, SLOT(slotAddKeyframe()));
     connect(buttonKeyframes, SIGNAL(clicked()), this, SLOT(slotKeyframeMode()));
     connect(buttonResetKeyframe, SIGNAL(clicked()), this, SLOT(slotResetKeyframe()));
-    connect(keyframe_pos, SIGNAL(valueChanged(int)), this, SLOT(slotAdjustKeyframePos(int)));
+    connect(m_position, SIGNAL(parameterChanged(int)), this, SLOT(slotAdjustKeyframePos(int)));
     connect(m_showButtons, SIGNAL(buttonClicked(int)), this, SLOT(slotUpdateVisibleParameter(int)));
 
     //connect(keyframe_list, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(slotSaveCurrentParam(QTreeWidgetItem *, int)));
 
-    keyframe_pos->setPageStep(1);
     if (!keyframe_list->currentItem()) {
         keyframe_list->setCurrentCell(0, 0);
         keyframe_list->selectRow(0);
@@ -116,16 +119,16 @@ void KeyframeEdit::addParameter(QDomElement e, int activeKeyframe)
             m_params.at(columnId).attribute("min").toInt(), m_params.at(columnId).attribute("max").toInt(),
             m_params.at(columnId).attribute("default").toInt(), comment, m_params.at(columnId).attribute("suffix"), this);
     connect(doubleparam, SIGNAL(valueChanged(int)), this, SLOT(slotAdjustKeyframeValue(int)));
-    connect(this, SIGNAL(showComments()), doubleparam, SLOT(slotShowComment()));
+    connect(this, SIGNAL(showComments(bool)), doubleparam, SLOT(slotShowComment(bool)));
     m_slidersLayout->addWidget(doubleparam, columnId, 0);
 
     QRadioButton *radio = new QRadioButton(this);
+    radio->setToolTip(i18n("Show %1 in timeline").arg(paramName));
     m_showButtons->addButton(radio, columnId);
     if (e.attribute("intimeline") == "1")
         radio->setChecked(true);
 
-    // make the radiobutton stay at the top
-    QVBoxLayout *radioLayout = new QVBoxLayout(this);
+    QVBoxLayout *radioLayout = new QVBoxLayout;
     radioLayout->addWidget(radio, 0, Qt::AlignTop);
     m_slidersLayout->addLayout(radioLayout, columnId, 1);
 
@@ -201,8 +204,14 @@ void KeyframeEdit::slotAddKeyframe()
             result = m_min;
         }
     } else {
-        int pos2 = getPos(row - 1);
-        result = pos2 + (pos1 - pos2) / 2;
+        if (pos1 < m_max - 1) {
+            // last keyframe selected and it is not at end of clip -> add keyframe at the end
+            result = m_max - 1;
+            newrow++;
+        } else {
+            int pos2 = getPos(row - 1);
+            result = pos2 + (pos1 - pos2) / 2;
+        }
     }
 
     keyframe_list->insertRow(newrow);
@@ -329,10 +338,11 @@ void KeyframeEdit::slotAdjustKeyframeInfo(bool seek)
     if (below)
         max = getPos(below->row()) - 1;
 
-    keyframe_pos->blockSignals(true);
-    keyframe_pos->setRange(min, max);
-    keyframe_pos->setValue(getPos(item->row()));
-    keyframe_pos->blockSignals(false);
+    m_position->blockSignals(true);
+    m_position->setRange(min, max);
+    m_position->setPosition(getPos(item->row()));
+    m_position->blockSignals(false);
+
     for (int col = 0; col < keyframe_list->columnCount(); col++) {
         DoubleParameterWidget *doubleparam = static_cast <DoubleParameterWidget*>(m_slidersLayout->itemAtPosition(col, 0)->widget());
         if (!doubleparam)
@@ -346,7 +356,7 @@ void KeyframeEdit::slotAdjustKeyframeInfo(bool seek)
         doubleparam->blockSignals(false);
     }
     if (KdenliveSettings::keyframeseek() && seek)
-        emit seekToPos(keyframe_pos->value() - m_min);
+        emit seekToPos(m_position->getPosition() - m_min);
 }
 
 void KeyframeEdit::slotAdjustKeyframePos(int value)
@@ -369,7 +379,7 @@ void KeyframeEdit::slotAdjustKeyframeValue(int value)
             continue;
         int val = doubleparam->getValue();
         QTableWidgetItem *nitem = keyframe_list->item(item->row(), col);
-        if (nitem->text().toInt() != val)
+        if (nitem && nitem->text().toInt() != val)
             nitem->setText(QString::number(val));
     }
     //keyframe_list->item(item->row() - 1, item->column());
@@ -406,6 +416,8 @@ void KeyframeEdit::updateTimecodeFormat()
         else
             keyframe_list->verticalHeaderItem(row)->setText(m_timecode.getTimecodeFromFrames(pos.toInt()));
     }
+
+    m_position->updateTimecodeFormat();
 }
 
 void KeyframeEdit::slotKeyframeMode()
@@ -452,8 +464,8 @@ void KeyframeEdit::checkVisibleParam()
             return;
     }
 
-    slotUpdateVisibleParameter(0, false);
-    QRadioButton *radio = static_cast<QRadioButton*>(m_slidersLayout->itemAtPosition(0, 1)->widget());
+    slotUpdateVisibleParameter(0);
+    QRadioButton *radio = static_cast<QRadioButton*>(m_slidersLayout->itemAtPosition(0, 1)->layout()->itemAt(0)->widget());
     if (radio)
         radio->setChecked(true);
 }