- m_param(e),
- m_max(max),
- m_timecode(tc),
- m_previousPos(0)
-{
- m_ui.setupUi(this);
- m_ui.keyframe_list->setHeaderLabels(QStringList() << i18n("Position") << i18n("Value"));
- //setResizeMode(1, QHeaderView::Interactive);
- m_ui.button_add->setIcon(KIcon("document-new"));
- m_ui.button_delete->setIcon(KIcon("edit-delete"));
- connect(m_ui.keyframe_list, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(slotAdjustKeyframeInfo()));
- setupParam();
- m_ui.keyframe_list->header()->resizeSections(QHeaderView::ResizeToContents);
- connect(m_ui.button_delete, SIGNAL(clicked()), this, SLOT(slotDeleteKeyframe()));
- connect(m_ui.button_add, SIGNAL(clicked()), this, SLOT(slotAddKeyframe()));
- connect(m_ui.keyframe_list, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotGenerateParams(QTreeWidgetItem *, int)));
- connect(m_ui.keyframe_list, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(slotSaveCurrentParam(QTreeWidgetItem *, int)));
- connect(m_ui.keyframe_pos, SIGNAL(valueChanged(int)), this, SLOT(slotAdjustKeyframeValue(int)));
- m_ui.keyframe_pos->setPageStep(1);
-}
-
-void KeyframeEdit::setupParam(QDomElement e)
-{
- if (!e.isNull()) m_param = e;
- m_ui.keyframe_list->clear();
- QStringList frames = m_param.attribute("keyframes").split(";", QString::SkipEmptyParts);
+ m_min(minFrame),
+ m_max(maxFrame),
+ m_timecode(tc)
+{
+ setupUi(this);
+ if (m_max == -1) {
+ // special case: keyframe for tracks, do not allow keyframes
+ widgetTable->setHidden(true);
+ }
+ keyframe_list->setFont(KGlobalSettings::generalFont());
+ buttonSeek->setChecked(KdenliveSettings::keyframeseek());
+ connect(buttonSeek, SIGNAL(toggled(bool)), this, SLOT(slotSetSeeking(bool)));
+
+ buttonKeyframes->setIcon(KIcon("chronometer"));
+ button_add->setIcon(KIcon("list-add"));
+ button_add->setToolTip(i18n("Add keyframe"));
+ button_delete->setIcon(KIcon("list-remove"));
+ button_delete->setToolTip(i18n("Delete keyframe"));
+ buttonResetKeyframe->setIcon(KIcon("edit-undo"));
+ buttonSeek->setIcon(KIcon("insert-link"));
+ 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_slidersLayout = new QGridLayout(param_sliders);
+ //m_slidersLayout->setSpacing(0);
+
+ m_slidersLayout->setContentsMargins(0, 0, 0, 0);
+ m_slidersLayout->setVerticalSpacing(2);
+ keyframe_list->setSelectionBehavior(QAbstractItemView::SelectRows);
+ keyframe_list->setSelectionMode(QAbstractItemView::SingleSelection);
+ addParameter(e, activeKeyframe);
+ keyframe_list->resizeRowsToContents();
+
+ //keyframe_list->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents);
+ connect(button_delete, SIGNAL(clicked()), this, SLOT(slotDeleteKeyframe()));
+ connect(button_add, SIGNAL(clicked()), this, SLOT(slotAddKeyframe()));
+ connect(buttonKeyframes, SIGNAL(clicked()), this, SLOT(slotKeyframeMode()));
+ connect(buttonResetKeyframe, SIGNAL(clicked()), this, SLOT(slotResetKeyframe()));
+ connect(m_position, SIGNAL(parameterChanged(int)), this, SLOT(slotAdjustKeyframePos(int)));
+
+ //connect(keyframe_list, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(slotSaveCurrentParam(QTreeWidgetItem *, int)));
+
+ if (!keyframe_list->currentItem()) {
+ keyframe_list->setCurrentCell(0, 0);
+ keyframe_list->selectRow(0);
+ }
+ // ensure the keyframe list shows at least 3 lines
+ keyframe_list->setMinimumHeight(QFontInfo(keyframe_list->font()).pixelSize() * 9);
+
+ // Do not show keyframe table if only one keyframe exists at the beginning
+ if (keyframe_list->rowCount() < 2 && getPos(0) == m_min && m_max != -1)
+ widgetTable->setHidden(true);
+ else
+ buttonKeyframes->setHidden(true);
+}
+
+KeyframeEdit::~KeyframeEdit()
+{
+ keyframe_list->blockSignals(true);
+ keyframe_list->clear();
+ QLayoutItem *child;
+ while ((child = m_slidersLayout->takeAt(0)) != 0) {
+ QWidget *wid = child->widget();
+ delete child;
+ if (wid)
+ delete wid;
+ }
+}
+
+void KeyframeEdit::addParameter(QDomElement e, int activeKeyframe)
+{
+ keyframe_list->blockSignals(true);
+ m_params.append(e.cloneNode().toElement());
+
+ QDomElement na = e.firstChildElement("name");
+ QString paramName = i18n(na.text().toUtf8().data());
+ QDomElement commentElem = e.firstChildElement("comment");
+ QString comment;
+ if (!commentElem.isNull())
+ comment = i18n(commentElem.text().toUtf8().data());
+
+ int columnId = keyframe_list->columnCount();
+ keyframe_list->insertColumn(columnId);
+ keyframe_list->setHorizontalHeaderItem(columnId, new QTableWidgetItem(paramName));
+
+ DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, 0,
+ m_params.at(columnId).attribute("min").toDouble(), m_params.at(columnId).attribute("max").toDouble(),
+ m_params.at(columnId).attribute("default").toDouble(), comment, columnId, m_params.at(columnId).attribute("suffix"), m_params.at(columnId).attribute("decimals").toInt(), this);
+ connect(doubleparam, SIGNAL(valueChanged(double)), this, SLOT(slotAdjustKeyframeValue(double)));
+ connect(this, SIGNAL(showComments(bool)), doubleparam, SLOT(slotShowComment(bool)));
+ connect(doubleparam, SIGNAL(setInTimeline(int)), this, SLOT(slotUpdateVisibleParameter(int)));
+ m_slidersLayout->addWidget(doubleparam, columnId, 0);
+ if (e.attribute("intimeline") == "1") {
+ doubleparam->setInTimelineProperty(true);
+ }
+
+ QStringList frames = e.attribute("keyframes").split(';', QString::SkipEmptyParts);