X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Feffectstack%2Feffectstackview2.cpp;h=c5f8ec8d5c3fd1358a5b0449b7ae7fdcfb752748;hb=5beaaab806a7678bc2046ce5e102e1a0193d2407;hp=9baa8435864364ad27202dec8110ef240215c3c4;hpb=ac5519967ca925d2cfec4c04fe05ef78459b40a1;p=kdenlive diff --git a/src/effectstack/effectstackview2.cpp b/src/effectstack/effectstackview2.cpp index 9baa8435..c5f8ec8d 100644 --- a/src/effectstack/effectstackview2.cpp +++ b/src/effectstack/effectstackview2.cpp @@ -89,26 +89,36 @@ void EffectStackView2::slotRenderPos(int pos) if (m_monitorSceneWanted) slotCheckMonitorPosition(pos); if (!m_effectMetaInfo.trackMode && m_clipref) pos = pos - m_clipref->startPos().frames(KdenliveSettings::project_fps()); - for (int i = 0; i< m_effects.count(); i++) + for (int i = 0; i< m_effects.count(); ++i) m_effects.at(i)->slotSyncEffectsPos(pos); } +void EffectStackView2::slotClipItemUpdate() +{ + int inPoint = m_clipref->cropStart().frames(KdenliveSettings::project_fps()); + int outPoint = m_clipref->cropDuration().frames(KdenliveSettings::project_fps()) + inPoint; + for (int i = 0; i < m_effects.count(); ++i) { + m_effects.at(i)->setRange(inPoint, outPoint); + } +} + void EffectStackView2::slotClipItemSelected(ClipItem* c) { if (c && !c->isEnabled()) return; if (c && c == m_clipref) { - } else { + if (m_clipref) disconnect(m_clipref, SIGNAL(updateRange()), this, SLOT(slotClipItemUpdate())); m_clipref = c; if (c) { + connect(m_clipref, SIGNAL(updateRange()), this, SLOT(slotClipItemUpdate())); QString cname = m_clipref->clipName(); if (cname.length() > 30) { - m_ui.checkAll->setToolTip(i18n("Effects for %1").arg(cname)); + m_ui.checkAll->setToolTip(i18n("Effects for %1", cname)); cname.truncate(27); - m_ui.checkAll->setText(i18n("Effects for %1").arg(cname) + "..."); + m_ui.checkAll->setText(i18n("Effects for %1", cname) + "..."); } else { m_ui.checkAll->setToolTip(QString()); - m_ui.checkAll->setText(i18n("Effects for %1").arg(cname)); + m_ui.checkAll->setText(i18n("Effects for %1", cname)); } m_ui.checkAll->setEnabled(true); QString size = c->baseClip()->getProperty("frame_size"); @@ -132,7 +142,7 @@ void EffectStackView2::slotClipItemSelected(ClipItem* c) setupListView(); } -void EffectStackView2::slotTrackItemSelected(int ix, const TrackInfo info) +void EffectStackView2::slotTrackItemSelected(int ix, const TrackInfo &info) { m_clipref = NULL; m_effectMetaInfo.trackMode = true; @@ -140,7 +150,7 @@ void EffectStackView2::slotTrackItemSelected(int ix, const TrackInfo info) m_trackInfo = info; setEnabled(true); m_ui.checkAll->setToolTip(QString()); - m_ui.checkAll->setText(i18n("Effects for track %1").arg(info.trackName.isEmpty() ? QString::number(ix) : info.trackName)); + m_ui.checkAll->setText(i18n("Effects for track %1", info.trackName.isEmpty() ? QString::number(ix) : info.trackName)); m_ui.checkAll->setEnabled(true); m_trackindex = ix; setupListView(); @@ -177,7 +187,7 @@ void EffectStackView2::setupListView() else if (selectedEffect > effectsCount) m_clipref->setSelectedEffect(effectsCount); } - for (int i = 0; i < effectsCount; i++) { + for (int i = 0; i < effectsCount; ++i) { QDomElement d = m_currentEffectList.at(i).cloneNode().toElement(); if (d.isNull()) { kDebug() << " . . . . WARNING, NULL EFFECT IN STACK!!!!!!!!!"; @@ -249,7 +259,7 @@ void EffectStackView2::setupListView() else { // Adjust group effects (up / down buttons) QList allGroups = m_ui.container->widget()->findChildren(); - for (int i = 0; i < allGroups.count(); i++) { + for (int i = 0; i < allGroups.count(); ++i) { allGroups.at(i)->adjustEffects(); } connect(m_effectMetaInfo.monitor, SIGNAL(renderPosition(int)), this, SLOT(slotRenderPos(int))); @@ -270,12 +280,12 @@ void EffectStackView2::connectEffect(CollapsibleEffect *currentEffect) { // Check drag & drop currentEffect->installEventFilter( this ); - connect(currentEffect, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int)), this , SLOT(slotUpdateEffectParams(const QDomElement, const QDomElement, int))); - connect(currentEffect, SIGNAL(startFilterJob(QString,QString,QString,QString,QString,QString)), this , SLOT(slotStartFilterJob(QString,QString,QString,QString,QString,QString))); - connect(currentEffect, SIGNAL(deleteEffect(const QDomElement)), this , SLOT(slotDeleteEffect(const QDomElement))); + connect(currentEffect, SIGNAL(parameterChanged(QDomElement,QDomElement,int)), this , SLOT(slotUpdateEffectParams(QDomElement,QDomElement,int))); + connect(currentEffect, SIGNAL(startFilterJob(QString,QString,QString,QString,QMap)), this , SLOT(slotStartFilterJob(QString,QString,QString,QString,QMap))); + connect(currentEffect, SIGNAL(deleteEffect(QDomElement)), this , SLOT(slotDeleteEffect(QDomElement))); connect(currentEffect, SIGNAL(reloadEffects()), this , SIGNAL(reloadEffects())); connect(currentEffect, SIGNAL(resetEffect(int)), this , SLOT(slotResetEffect(int))); - connect(currentEffect, SIGNAL(changeEffectPosition(QList ,bool)), this , SLOT(slotMoveEffectUp(QList ,bool))); + connect(currentEffect, SIGNAL(changeEffectPosition(QList,bool)), this , SLOT(slotMoveEffectUp(QList,bool))); connect(currentEffect, SIGNAL(effectStateChanged(bool,int,bool)), this, SLOT(slotUpdateEffectState(bool,int,bool))); connect(currentEffect, SIGNAL(activateEffect(int)), this, SLOT(slotSetCurrentEffect(int))); connect(currentEffect, SIGNAL(seekTimeline(int)), this , SLOT(slotSeekTimeline(int))); @@ -284,6 +294,7 @@ void EffectStackView2::connectEffect(CollapsibleEffect *currentEffect) connect(currentEffect, SIGNAL(addEffect(QDomElement)), this , SLOT(slotAddEffect(QDomElement))); connect(currentEffect, SIGNAL(createRegion(int,KUrl)), this, SLOT(slotCreateRegion(int,KUrl))); connect(currentEffect, SIGNAL(deleteGroup(QDomDocument)), this , SLOT(slotDeleteGroup(QDomDocument))); + connect(currentEffect, SIGNAL(importClipKeyframes()), this, SIGNAL(importClipKeyframes())); } void EffectStackView2::slotCheckWheelEventFilter() @@ -295,7 +306,7 @@ void EffectStackView2::slotCheckWheelEventFilter() // widget has scroll bar, filterWheelEvent = true; } - for (int i = 0; i < m_effects.count(); i++) { + for (int i = 0; i < m_effects.count(); ++i) { m_effects.at(i)->filterWheelEvent = filterWheelEvent; } } @@ -375,11 +386,25 @@ void EffectStackView2::startDrag() QPixmap pixmap; if (m_draggedEffect) { QDomElement effect = m_draggedEffect->effect().cloneNode().toElement(); + if (m_effectMetaInfo.trackMode) { + // Keep clip crop start in case we want to paste effect + effect.setAttribute("clipstart", 0); + } + else { + // Keep clip crop start in case we want to paste effect + effect.setAttribute("clipstart", m_clipref->cropStart().frames(KdenliveSettings::project_fps())); + } doc.appendChild(doc.importNode(effect, true)); pixmap = QPixmap::grabWidget(m_draggedEffect->title); } else if (m_draggedGroup) { doc = m_draggedGroup->effectsData(); + if (m_effectMetaInfo.trackMode) { + doc.documentElement().setAttribute("clipstart", 0); + } + else { + doc.documentElement().setAttribute("clipstart", m_clipref->cropStart().frames(KdenliveSettings::project_fps())); + } pixmap = QPixmap::grabWidget(m_draggedGroup->title()); } else return; @@ -486,13 +511,13 @@ void EffectStackView2::slotCheckAll(int state) bool disabled = state == Qt::Unchecked; // Disable all effects QList indexes; - for (int i = 0; i < m_effects.count(); i++) { - m_effects.at(i)->slotEnable(disabled, false); + for (int i = 0; i < m_effects.count(); ++i) { + m_effects.at(i)->slotDisable(disabled, false); indexes << m_effects.at(i)->effectIndex(); } // Take care of groups QList allGroups = m_ui.container->widget()->findChildren(); - for (int i = 0; i < allGroups.count(); i++) { + for (int i = 0; i < allGroups.count(); ++i) { allGroups.at(i)->slotEnable(disabled, false); } @@ -507,7 +532,7 @@ void EffectStackView2::slotUpdateCheckAllButton() bool hasEnabled = false; bool hasDisabled = false; - for (int i = 0; i < m_effects.count(); i++) { + for (int i = 0; i < m_effects.count(); ++i) { if (!m_effects.at(i)->enabledButton->isChecked()) hasEnabled = true; else hasDisabled = true; } @@ -524,7 +549,7 @@ void EffectStackView2::slotUpdateCheckAllButton() void EffectStackView2::deleteCurrentEffect() { - for (int i = 0; i < m_effects.count(); i++) { + for (int i = 0; i < m_effects.count(); ++i) { if (m_effects.at(i)->isActive()) { slotDeleteEffect(m_effects.at(i)->effect()); break; @@ -532,7 +557,7 @@ void EffectStackView2::deleteCurrentEffect() } } -void EffectStackView2::updateProjectFormat(MltVideoProfile profile, Timecode t) +void EffectStackView2::updateProjectFormat(const MltVideoProfile &profile, const Timecode &t) { m_effectMetaInfo.profile = profile; m_effectMetaInfo.timecode = t; @@ -540,13 +565,13 @@ void EffectStackView2::updateProjectFormat(MltVideoProfile profile, Timecode t) void EffectStackView2::updateTimecodeFormat() { - for (int i = 0; i< m_effects.count(); i++) + for (int i = 0; i< m_effects.count(); ++i) m_effects.at(i)->updateTimecodeFormat(); } CollapsibleEffect *EffectStackView2::getEffectByIndex(int ix) { - for (int i = 0; i< m_effects.count(); i++) { + for (int i = 0; i< m_effects.count(); ++i) { if (m_effects.at(i)->effectIndex() == ix) { return m_effects.at(i); } @@ -554,7 +579,7 @@ CollapsibleEffect *EffectStackView2::getEffectByIndex(int ix) return NULL; } -void EffectStackView2::slotUpdateEffectParams(const QDomElement old, const QDomElement e, int ix) +void EffectStackView2::slotUpdateEffectParams(const QDomElement &old, const QDomElement &e, int ix) { if (m_effectMetaInfo.trackMode) emit updateEffect(NULL, m_trackindex, old, e, ix,false); @@ -570,7 +595,7 @@ void EffectStackView2::slotSetCurrentEffect(int ix) { if (m_clipref && ix != m_clipref->selectedEffectIndex()) { m_clipref->setSelectedEffect(ix); - for (int i = 0; i < m_effects.count(); i++) { + for (int i = 0; i < m_effects.count(); ++i) { if (m_effects.at(i)->effectIndex() == ix) { if (m_effects.at(i)->isActive()) return; m_effects.at(i)->setActive(true); @@ -597,11 +622,11 @@ void EffectStackView2::slotDeleteGroup(QDomDocument doc) ix = -1; } - for (int i = 0; i < effects.count(); i++) + for (int i = 0; i < effects.count(); ++i) emit removeEffect(clip, ix, effects.at(i).toElement()); } -void EffectStackView2::slotDeleteEffect(const QDomElement effect) +void EffectStackView2::slotDeleteEffect(const QDomElement &effect) { if (m_effectMetaInfo.trackMode) emit removeEffect(NULL, m_trackindex, effect); @@ -609,12 +634,12 @@ void EffectStackView2::slotDeleteEffect(const QDomElement effect) emit removeEffect(m_clipref, -1, effect); } -void EffectStackView2::slotAddEffect(QDomElement effect) +void EffectStackView2::slotAddEffect(const QDomElement &effect) { emit addEffect(m_clipref, effect); } -void EffectStackView2::slotMoveEffectUp(QList indexes, bool up) +void EffectStackView2::slotMoveEffectUp(const QList &indexes, bool up) { if (up && indexes.first() <= 1) return; if (!up && indexes.last() >= m_currentEffectList.count()) return; @@ -629,10 +654,10 @@ void EffectStackView2::slotMoveEffectUp(QList indexes, bool up) else emit changeEffectPosition(m_clipref, -1, indexes, endPos); } -void EffectStackView2::slotStartFilterJob(const QString&filterName, const QString&filterParams, const QString&finalFilterName, const QString&consumer, const QString&consumerParams, const QString&properties) +void EffectStackView2::slotStartFilterJob(const QString&filterName, const QString&filterParams, const QString&consumer, const QString&consumerParams, const QMap &extraParams) { if (!m_clipref) return; - emit startFilterJob(m_clipref->info(), m_clipref->clipProducer(), filterName, filterParams, finalFilterName, consumer, consumerParams, properties); + emit startFilterJob(m_clipref->info(), m_clipref->clipProducer(), filterName, filterParams, consumer, consumerParams, extraParams); } void EffectStackView2::slotResetEffect(int ix) @@ -660,7 +685,7 @@ void EffectStackView2::slotResetEffect(int ix) info.cropStart = GenTime(0); info.startPos = GenTime(-1); info.track = 0; - for (int i = 0; i < m_effects.count(); i++) { + for (int i = 0; i < m_effects.count(); ++i) { if (m_effects.at(i)->effectIndex() == ix) { m_effects.at(i)->updateWidget(info, dom, &m_effectMetaInfo); break; @@ -669,7 +694,7 @@ void EffectStackView2::slotResetEffect(int ix) emit updateEffect(NULL, m_trackindex, old, dom, ix,false); } else { m_clipref->initEffect(dom); - for (int i = 0; i < m_effects.count(); i++) { + for (int i = 0; i < m_effects.count(); ++i) { if (m_effects.at(i)->effectIndex() == ix) { m_effects.at(i)->updateWidget(m_clipref->info(), dom, &m_effectMetaInfo); break; @@ -715,7 +740,7 @@ void EffectStackView2::slotCreateRegion(int ix, KUrl url) info.startPos = GenTime(-1); info.track = 0; } - else { + else if (m_clipref) { info = m_clipref->info(); } CollapsibleEffect *current = getEffectByIndex(ix); @@ -730,7 +755,7 @@ void EffectStackView2::slotCreateRegion(int ix, KUrl url) if (m_effectMetaInfo.trackMode) { isSelected = currentEffect->effectIndex() == 1; } - else { + else if (m_clipref) { isSelected = currentEffect->effectIndex() == m_clipref->selectedEffectIndex(); } if (isSelected) currentEffect->setActive(true); @@ -774,7 +799,7 @@ void EffectStackView2::slotCreateGroup(int ix) QVBoxLayout *l = static_cast(m_ui.container->widget()->layout()); int groupPos = 0; CollapsibleEffect *effectToMove = NULL; - for (int i = 0; i < m_effects.count(); i++) { + for (int i = 0; i < m_effects.count(); ++i) { if (m_effects.at(i)->effectIndex() == ix) { effectToMove = m_effects.at(i); groupPos = l->indexOf(effectToMove); @@ -788,7 +813,8 @@ void EffectStackView2::slotCreateGroup(int ix) connectGroup(group); l->insertWidget(groupPos, group); group->installEventFilter( this ); - group->addGroupEffect(effectToMove); + if (effectToMove) + group->addGroupEffect(effectToMove); } void EffectStackView2::connectGroup(CollapsibleGroup *group) @@ -796,10 +822,10 @@ void EffectStackView2::connectGroup(CollapsibleGroup *group) connect(group, SIGNAL(moveEffect(QList,int,int,QString)), this , SLOT(slotMoveEffect(QList,int,int,QString))); connect(group, SIGNAL(addEffect(QDomElement)), this , SLOT(slotAddEffect(QDomElement))); connect(group, SIGNAL(unGroup(CollapsibleGroup*)), this , SLOT(slotUnGroup(CollapsibleGroup*))); - connect(group, SIGNAL(groupRenamed(CollapsibleGroup *)), this , SLOT(slotRenameGroup(CollapsibleGroup*))); + connect(group, SIGNAL(groupRenamed(CollapsibleGroup*)), this , SLOT(slotRenameGroup(CollapsibleGroup*))); connect(group, SIGNAL(reloadEffects()), this , SIGNAL(reloadEffects())); connect(group, SIGNAL(deleteGroup(QDomDocument)), this , SLOT(slotDeleteGroup(QDomDocument))); - connect(group, SIGNAL(changeEffectPosition(QList ,bool)), this , SLOT(slotMoveEffectUp(QList ,bool))); + connect(group, SIGNAL(changeEffectPosition(QList,bool)), this , SLOT(slotMoveEffectUp(QList,bool))); } void EffectStackView2::slotMoveEffect(QList currentIndexes, int newIndex, int groupIndex, QString groupName) @@ -853,7 +879,7 @@ void EffectStackView2::slotUnGroup(CollapsibleGroup* group) void EffectStackView2::slotRenameGroup(CollapsibleGroup *group) { QList effects = group->effects(); - for (int i = 0; i < effects.count(); i++) { + for (int i = 0; i < effects.count(); ++i) { QDomElement origin = effects.at(i)->effect(); QDomElement changed = origin.cloneNode().toElement(); changed.setAttribute("kdenlive_info", effects.at(i)->infoString()); @@ -894,7 +920,7 @@ void EffectStackView2::processDroppedEffect(QDomElement e, QDropEvent *event) } // Moving group: delete all effects and re-add them QList indexes; - for (int i = 0; i < effects.count(); i++) { + for (int i = 0; i < effects.count(); ++i) { QDomElement effect = effects.at(i).cloneNode().toElement(); indexes << effect.attribute("kdenlive_ix").toInt(); } @@ -926,6 +952,16 @@ void EffectStackView2::dropEvent(QDropEvent *event) processDroppedEffect(doc.documentElement(), event); } +void EffectStackView2::setKeyframes(const QString &data, int maximum) +{ + for (int i = 0; i < m_effects.count(); ++i) { + if (m_effects.at(i)->isActive()) { + m_effects.at(i)->setKeyframes(data, maximum); + break; + } + } +} + //static const QString EffectStackView2::getStyleSheet() {