void KeyframeEdit::slotAdjustKeyframeInfo(bool seek) { QTableWidgetItem *item = keyframe_list->currentItem(); if (!item) return; int min = m_min; int max = m_max; QTableWidgetItem *above = keyframe_list->item(item->row() - 1, item->column()); QTableWidgetItem *below = keyframe_list->item(item->row() + 1, item->column()); if (above) min = getPos(above->row()) + 1; if (below) max = getPos(below->row()) - 1; m_position->blockSignals(true); m_position->setRange(min, max, true); m_position->setPosition(getPos(item->row())); m_position->blockSignals(false); QLocale locale; for (int col = 0; col < keyframe_list->columnCount(); ++col) { DoubleParameterWidget *doubleparam = static_cast <DoubleParameterWidget*>(m_slidersLayout->itemAtPosition(col, 0)->widget()); if (!doubleparam) continue; doubleparam->blockSignals(true); if (keyframe_list->item(item->row(), col)) { doubleparam->setValue(locale.toDouble(keyframe_list->item(item->row(), col)->text())); } else { //qDebug() << "Null pointer exception caught: http://www.kdenlive.org/mantis/view.php?id=1771"; } doubleparam->blockSignals(false); } if (KdenliveSettings::keyframeseek() && seek) emit seekToPos(m_position->getPosition() - m_min); }
void KeyframeEdit::addParameter(const QDomElement &e, int activeKeyframe) { keyframe_list->blockSignals(true); m_params.append(e.cloneNode().toElement()); QDomElement na = e.firstChildElement(QStringLiteral("name")); QString paramName = i18n(na.text().toUtf8().data()); QDomElement commentElem = e.firstChildElement(QStringLiteral("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(QStringLiteral("min")).toDouble(), m_params.at(columnId).attribute(QStringLiteral("max")).toDouble(), m_params.at(columnId).attribute(QStringLiteral("default")).toDouble(), comment, columnId, m_params.at(columnId).attribute(QStringLiteral("suffix")), m_params.at(columnId).attribute(QStringLiteral("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(QStringLiteral("intimeline")) == QLatin1String("1")) { doubleparam->setInTimelineProperty(true); } QStringList frames = e.attribute(QStringLiteral("keyframes")).split(';', QString::SkipEmptyParts); for (int i = 0; i < frames.count(); ++i) { int frame = frames.at(i).section('=', 0, 0).toInt(); bool found = false; int j; for (j = 0; j < keyframe_list->rowCount(); ++j) { int currentPos = getPos(j); if (frame == currentPos) { keyframe_list->setItem(j, columnId, new QTableWidgetItem(frames.at(i).section('=', 1, 1))); found = true; break; } else if (currentPos > frame) { break; } } if (!found) { keyframe_list->insertRow(j); keyframe_list->setVerticalHeaderItem(j, new QTableWidgetItem(getPosString(frame))); keyframe_list->setItem(j, columnId, new QTableWidgetItem(frames.at(i).section('=', 1, 1))); keyframe_list->resizeRowToContents(j); } if ((activeKeyframe > -1) && (activeKeyframe == frame)) { keyframe_list->setCurrentCell(i, columnId); keyframe_list->selectRow(i); } } keyframe_list->resizeColumnsToContents(); keyframe_list->blockSignals(false); keyframe_list->horizontalHeader()->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); keyframe_list->verticalHeader()->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); slotAdjustKeyframeInfo(false); button_delete->setEnabled(keyframe_list->rowCount() > 1); }
void KeyframeEdit::slotResetKeyframe() { for (int col = 0; col < keyframe_list->columnCount(); ++col) { DoubleParameterWidget *doubleparam = static_cast<DoubleParameterWidget*>(m_slidersLayout->itemAtPosition(col, 0)->widget()); if (doubleparam) doubleparam->slotReset(); } }
void KeyframeEdit::slotUpdateVisibleParameter(int id, bool update) { for (int i = 0; i < m_params.count(); ++i) { m_params[i].setAttribute(QStringLiteral("intimeline"), (i == id ? "1" : "0")); } for (int col = 0; col < keyframe_list->columnCount(); ++col) { DoubleParameterWidget *doubleparam = static_cast <DoubleParameterWidget*>(m_slidersLayout->itemAtPosition(col, 0)->widget()); if (!doubleparam) continue; doubleparam->setInTimelineProperty(col == id); ////qDebug()<<"// PARAM: "<<col<<" Set TO: "<<(bool) (col == id); } if (update) emit parameterChanged(); }
void KeyframeEdit::slotAdjustKeyframeValue(double value) { Q_UNUSED(value) QTableWidgetItem *item = keyframe_list->currentItem(); for (int col = 0; col < keyframe_list->columnCount(); ++col) { DoubleParameterWidget *doubleparam = static_cast <DoubleParameterWidget*>(m_slidersLayout->itemAtPosition(col, 0)->widget()); if (!doubleparam) continue; double val = doubleparam->getValue(); QTableWidgetItem *nitem = keyframe_list->item(item->row(), col); if (nitem && nitem->text().toDouble() != val) nitem->setText(QString::number(val)); } //keyframe_list->item(item->row() - 1, item->column()); }