X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Feffectstack%2Feffectstackview2.cpp;h=27f77f42722e6bd7bd9551b30cc9ad9871640ed6;hb=af20dd7143d1889c1424349b666bd51353cc6924;hp=8d64110e61fb409b7ca0f7051d87c6d53a57adcf;hpb=5acf9f110c445c43cf02ad392b58b502dba5f0bd;p=kdenlive diff --git a/src/effectstack/effectstackview2.cpp b/src/effectstack/effectstackview2.cpp index 8d64110e..27f77f42 100644 --- a/src/effectstack/effectstackview2.cpp +++ b/src/effectstack/effectstackview2.cpp @@ -89,7 +89,7 @@ void EffectStackView2::slotRenderPos(int pos) m_effects.at(i)->slotSyncEffectsPos(pos); } -void EffectStackView2::slotClipItemSelected(ClipItem* c, int ix) +void EffectStackView2::slotClipItemSelected(ClipItem* c) { if (c && !c->isEnabled()) return; if (c && c == m_clipref) { @@ -107,12 +107,9 @@ void EffectStackView2::slotClipItemSelected(ClipItem* c, int ix) m_ui.checkAll->setText(i18n("Effects for %1").arg(cname)); } m_ui.checkAll->setEnabled(true); - ix = c->selectedEffectIndex(); QString size = c->baseClip()->getProperty("frame_size"); double factor = c->baseClip()->getProperty("aspect_ratio").toDouble(); m_effectMetaInfo.frameSize = QPoint((int)(size.section('x', 0, 0).toInt() * factor + 0.5), size.section('x', 1, 1).toInt()); - } else { - ix = 0; } } if (m_clipref == NULL) { @@ -125,7 +122,7 @@ void EffectStackView2::slotClipItemSelected(ClipItem* c, int ix) setEnabled(true); m_effectMetaInfo.trackMode = false; m_currentEffectList = m_clipref->effectList(); - setupListView(ix); + setupListView(); } void EffectStackView2::slotTrackItemSelected(int ix, const TrackInfo info) @@ -138,11 +135,11 @@ void EffectStackView2::slotTrackItemSelected(int ix, const TrackInfo info) m_ui.checkAll->setToolTip(QString()); m_ui.checkAll->setText(i18n("Effects for track %1").arg(info.trackName.isEmpty() ? QString::number(ix) : info.trackName)); m_trackindex = ix; - setupListView(0); + setupListView(); } -void EffectStackView2::setupListView(int ix) +void EffectStackView2::setupListView() { blockSignals(true); m_draggedEffect = NULL; @@ -175,8 +172,7 @@ void EffectStackView2::setupListView(int ix) EffectInfo effectInfo; effectInfo.fromString(d.attribute("kdenlive_info")); if (effectInfo.groupIndex >= 0) { - // effect is in a group - + // effect is in a group for (int j = 0; j < vbox1->count(); j++) { CollapsibleGroup *eff = static_cast(vbox1->itemAt(j)->widget()); if (eff->isGroup() && eff->groupIndex() == effectInfo.groupIndex) { @@ -191,7 +187,7 @@ void EffectStackView2::setupListView(int ix) connect(group, SIGNAL(unGroup(CollapsibleGroup*)), this , SLOT(slotUnGroup(CollapsibleGroup*))); connect(group, SIGNAL(groupRenamed(CollapsibleGroup *)), this, SLOT(slotRenameGroup(CollapsibleGroup*))); connect(group, SIGNAL(reloadEffects()), this , SIGNAL(reloadEffects())); - connect(group, SIGNAL(deleteGroup(int, QDomDocument)), this , SLOT(slotDeleteGroup(int,QDomDocument))); + connect(group, SIGNAL(deleteGroup(QDomDocument)), this , SLOT(slotDeleteGroup(QDomDocument))); vbox1->addWidget(group); group->installEventFilter( this ); } @@ -203,6 +199,7 @@ void EffectStackView2::setupListView(int ix) kDebug() << "IMPORTED STK: " << doc.toString();*/ ItemInfo info; + bool isSelected = false; if (m_effectMetaInfo.trackMode) { info.track = m_trackInfo.type; info.cropDuration = GenTime(m_trackInfo.duration, KdenliveSettings::project_fps()); @@ -210,35 +207,25 @@ void EffectStackView2::setupListView(int ix) info.startPos = GenTime(-1); info.track = 0; } - else info = m_clipref->info(); + else { + info = m_clipref->info(); + } CollapsibleEffect *currentEffect = new CollapsibleEffect(d, m_currentEffectList.at(i), info, &m_effectMetaInfo, i == m_currentEffectList.count() - 1, view); + if (m_effectMetaInfo.trackMode) { + isSelected = currentEffect->effectIndex() == 1; + } + else { + isSelected = currentEffect->effectIndex() == m_clipref->selectedEffectIndex(); + } + if (isSelected) currentEffect->setActive(true); m_effects.append(currentEffect); if (group) { group->addGroupEffect(currentEffect); } else { vbox1->addWidget(currentEffect); } - if (currentEffect->effectIndex() == ix) currentEffect->setActive(true); - - // 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(reloadEffects()), this , SIGNAL(reloadEffects())); - connect(currentEffect, SIGNAL(resetEffect(int)), this , SLOT(slotResetEffect(int))); - connect(currentEffect, SIGNAL(changeEffectPosition(int,bool)), this , SLOT(slotMoveEffectUp(int , bool))); - connect(currentEffect, SIGNAL(effectStateChanged(bool, int)), this, SLOT(slotUpdateEffectState(bool, int))); - connect(currentEffect, SIGNAL(activateEffect(int)), this, SLOT(slotSetCurrentEffect(int))); - connect(currentEffect, SIGNAL(checkMonitorPosition(int)), this, SLOT(slotCheckMonitorPosition(int))); - connect(currentEffect, SIGNAL(seekTimeline(int)), this , SLOT(slotSeekTimeline(int))); - connect(currentEffect, SIGNAL(createGroup(int)), this , SLOT(slotCreateGroup(int))); - connect(currentEffect, SIGNAL(moveEffect(int,int,int,QString)), this , SLOT(slotMoveEffect(int,int,int,QString))); - connect(currentEffect, SIGNAL(addEffect(QDomElement)), this , SLOT(slotAddEffect(QDomElement))); - - //ui.title->setPixmap(icon.pixmap(QSize(12, 12))); + connectEffect(currentEffect); } vbox1->addStretch(10); slotUpdateCheckAllButton(); @@ -248,6 +235,25 @@ void EffectStackView2::setupListView(int ix) QTimer::singleShot(200, this, SLOT(slotCheckWheelEventFilter())); } +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(reloadEffects()), this , SIGNAL(reloadEffects())); + connect(currentEffect, SIGNAL(resetEffect(int)), this , SLOT(slotResetEffect(int))); + connect(currentEffect, SIGNAL(changeEffectPosition(int,bool)), this , SLOT(slotMoveEffectUp(int , 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(checkMonitorPosition(int)), this, SLOT(slotCheckMonitorPosition(int))); + connect(currentEffect, SIGNAL(seekTimeline(int)), this , SLOT(slotSeekTimeline(int))); + connect(currentEffect, SIGNAL(createGroup(int)), this , SLOT(slotCreateGroup(int))); + connect(currentEffect, SIGNAL(moveEffect(int,int,int,QString)), this , SLOT(slotMoveEffect(int,int,int,QString))); + connect(currentEffect, SIGNAL(addEffect(QDomElement)), this , SLOT(slotAddEffect(QDomElement))); + connect(currentEffect, SIGNAL(createRegion(int,KUrl)), this, SLOT(slotCreateRegion(int,KUrl))); +} void EffectStackView2::slotCheckWheelEventFilter() { @@ -360,13 +366,13 @@ void EffectStackView2::startDrag() } -void EffectStackView2::slotUpdateEffectState(bool disable, int index) +void EffectStackView2::slotUpdateEffectState(bool disable, int index, bool updateMainStatus) { if (m_effectMetaInfo.trackMode) emit changeEffectState(NULL, m_trackindex, index, disable); else emit changeEffectState(m_clipref, -1, index, disable); - slotUpdateCheckAllButton(); + if (updateMainStatus) slotUpdateCheckAllButton(); } @@ -424,17 +430,17 @@ void EffectStackView2::clear() void EffectStackView2::slotCheckAll(int state) { - if (state == 1) { - state = 2; + if (state == Qt::PartiallyChecked) { + state = Qt::Checked; m_ui.checkAll->blockSignals(true); m_ui.checkAll->setCheckState(Qt::Checked); m_ui.checkAll->blockSignals(false); } - bool disabled = (state != 2); + bool disabled = state == Qt::Unchecked; for (int i = 0; i < m_effects.count(); i++) { if (!m_effects.at(i)->isGroup()) { - m_effects.at(i)->slotEnable(!disabled); + m_effects.at(i)->slotEnable(disabled, false); } } } @@ -518,7 +524,7 @@ void EffectStackView2::slotSetCurrentEffect(int ix) } } -void EffectStackView2::slotDeleteGroup(int groupIndex, QDomDocument doc) +void EffectStackView2::slotDeleteGroup(QDomDocument doc) { QDomNodeList effects = doc.elementsByTagName("effect"); ClipItem * clip = NULL; @@ -619,6 +625,66 @@ void EffectStackView2::slotShowComments() emit showComments(m_ui.buttonShowComments->isChecked()); } +void EffectStackView2::slotCreateRegion(int ix, KUrl url) +{ + QDomElement oldeffect = m_currentEffectList.itemFromIndex(ix); + QDomElement neweffect = oldeffect.cloneNode().toElement(); + QDomElement region = MainWindow::videoEffects.getEffectByTag("region", "region").cloneNode().toElement(); + region.appendChild(region.ownerDocument().importNode(neweffect, true)); + region.setAttribute("kdenlive_ix", ix); + EffectsList::setParameter(region, "resource", url.path()); + if (m_effectMetaInfo.trackMode) + emit updateEffect(NULL, m_trackindex, oldeffect, region, ix,false); + else if (m_clipref) { + emit updateEffect(m_clipref, -1, oldeffect, region, ix, false); + // Make sure the changed effect is currently displayed + //slotSetCurrentEffect(ix); + } + // refresh effect stack + ItemInfo info; + bool isSelected = false; + if (m_effectMetaInfo.trackMode) { + info.track = m_trackInfo.type; + info.cropDuration = GenTime(m_trackInfo.duration, KdenliveSettings::project_fps()); + info.cropStart = GenTime(0); + info.startPos = GenTime(-1); + info.track = 0; + } + else { + info = m_clipref->info(); + } + CollapsibleEffect *current = getEffectByIndex(ix); + m_effects.removeAll(current); + current->setEnabled(false); + m_currentEffectList.removeAt(ix); + m_currentEffectList.insert(region); + current->deleteLater(); + CollapsibleEffect *currentEffect = new CollapsibleEffect(region, m_currentEffectList.itemFromIndex(ix), info, &m_effectMetaInfo, ix == m_currentEffectList.count() - 1, m_ui.container->widget()); + connectEffect(currentEffect); + + if (m_effectMetaInfo.trackMode) { + isSelected = currentEffect->effectIndex() == 1; + } + else { + isSelected = currentEffect->effectIndex() == m_clipref->selectedEffectIndex(); + } + if (isSelected) currentEffect->setActive(true); + m_effects.append(currentEffect); + // TODO: region in group? + //if (group) { + // group->addGroupEffect(currentEffect); + //} else { + QVBoxLayout *vbox = static_cast (m_ui.container->widget()->layout()); + vbox->insertWidget(ix, currentEffect); + //} + + // Check drag & drop + currentEffect->installEventFilter( this ); + + QTimer::singleShot(200, this, SLOT(slotCheckWheelEventFilter())); + +} + void EffectStackView2::slotCreateGroup(int ix) { QDomElement oldeffect = m_currentEffectList.itemFromIndex(ix); @@ -658,7 +724,7 @@ void EffectStackView2::slotCreateGroup(int ix) connect(group, SIGNAL(unGroup(CollapsibleGroup*)), this , SLOT(slotUnGroup(CollapsibleGroup*))); connect(group, SIGNAL(groupRenamed(CollapsibleGroup *)), this , SLOT(slotRenameGroup(CollapsibleGroup*))); connect(group, SIGNAL(reloadEffects()), this , SIGNAL(reloadEffects())); - connect(group, SIGNAL(deleteGroup(int, QDomDocument)), this , SLOT(slotDeleteGroup(int,QDomDocument))); + connect(group, SIGNAL(deleteGroup(QDomDocument)), this , SLOT(slotDeleteGroup(QDomDocument))); l->insertWidget(groupPos, group); group->installEventFilter( this ); group->addGroupEffect(effectToMove);