#include <KLocale>
-EditEffectCommand::EditEffectCommand(CustomTrackView *view, const int track, GenTime pos, QDomElement oldeffect, QDomElement effect, int stackPos, bool doIt, QUndoCommand *parent) :
+EditEffectCommand::EditEffectCommand(CustomTrackView *view, const int track, GenTime pos, QDomElement oldeffect, QDomElement effect, int stackPos, bool refreshEffectStack, bool doIt, QUndoCommand *parent) :
QUndoCommand(parent),
m_view(view),
m_track(track),
m_effect(effect),
m_pos(pos),
m_stackPos(stackPos),
- m_doIt(doIt)
+ m_doIt(doIt),
+ m_refreshEffectStack(refreshEffectStack)
{
QString effectName;
QDomElement namenode = effect.firstChildElement("name");
{
if (other->id() != id()) return false;
if (m_track != static_cast<const EditEffectCommand*>(other)->m_track) return false;
+ if (m_stackPos != static_cast<const EditEffectCommand*>(other)->m_stackPos) return false;
if (m_pos != static_cast<const EditEffectCommand*>(other)->m_pos) return false;
m_effect = static_cast<const EditEffectCommand*>(other)->m_effect.cloneNode().toElement();
return true;
// virtual
void EditEffectCommand::undo()
{
- m_view->updateEffect(m_track, m_pos, m_oldeffect, m_stackPos, false);
+ m_view->updateEffect(m_track, m_pos, m_oldeffect, m_stackPos, true);
}
// virtual
void EditEffectCommand::redo()
{
- m_view->updateEffect(m_track, m_pos, m_effect, m_stackPos, m_doIt);
- m_doIt = false;
+ if (m_doIt) m_view->updateEffect(m_track, m_pos, m_effect, m_stackPos, m_refreshEffectStack);
+ m_doIt = true;
+ m_refreshEffectStack = true;
}
class EditEffectCommand : public QUndoCommand
{
public:
- EditEffectCommand(CustomTrackView *view, const int track, GenTime pos, QDomElement oldeffect, QDomElement effect, int stackPos, bool doIt, QUndoCommand *parent = 0);
+ EditEffectCommand(CustomTrackView *view, const int track, GenTime pos, QDomElement oldeffect, QDomElement effect, int stackPos, bool refreshEffectStack, bool doIt, QUndoCommand *parent = 0);
virtual int id() const;
virtual bool mergeWith(const QUndoCommand * command);
const GenTime m_pos;
int m_stackPos;
bool m_doIt;
+ bool m_refreshEffectStack;
};
#endif
//item->updateKeyframeEffect();
//QString next = item->keyframes(item->selectedEffectIndex());
QDomElement newEffect = item->selectedEffect().cloneNode().toElement();
- EditEffectCommand *command = new EditEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), oldEffect, newEffect, item->selectedEffectIndex(), false);
+ EditEffectCommand *command = new EditEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), oldEffect, newEffect, item->selectedEffectIndex(), false, false);
//EditKeyFrameCommand *command = new EditKeyFrameCommand(this, m_dragItem->track(), m_dragItem->startPos(), item->selectedEffectIndex(), previous, next, false);
m_commandStack->push(command);
updateEffect(m_document->tracksCount() - item->track(), item->startPos(), item->selectedEffect(), item->selectedEffectIndex());
setDocumentModified();
}
-void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedEffect, int ix, bool triggeredByUser)
+void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedEffect, int ix, bool updateEffectStack)
{
if (insertedEffect.isNull()) {
emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), speed, clip->speed(), strobe, clip->baseClip()->getId());
}
if (clip->updateEffect(effect)) {
- if (ix == clip->selectedEffectIndex()) {
- clip->setSelectedEffect(ix);
- if (!triggeredByUser)
+ if (updateEffectStack && clip->isSelected())
emit clipItemSelected(clip, ix);
- }
+ /*if (ix == clip->selectedEffectIndex()) {
+ clip->setSelectedEffect(ix);
+
+ }*/
} else emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
return;
}
clip->setFadeOut(pos);
}
}
- bool success = true;
- if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - clip->track(), clip->startPos(), effectParams)) success = false;
+ bool success = m_document->renderer()->mltEditEffect(m_document->tracksCount() - clip->track(), clip->startPos(), effectParams);
if (success && clip->updateEffect(effect)) {
- if (ix == clip->selectedEffectIndex()) {
- clip->setSelectedEffect(ix);
- if (!triggeredByUser)
- emit clipItemSelected(clip, ix);
+ if (updateEffectStack && clip->isSelected()) {
+ emit clipItemSelected(clip, ix);
}
+ /*if (ix == clip->selectedEffectIndex()) {
+ clip->setSelectedEffect(ix);
+ }*/
}
else emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
}
if (clip == NULL) {
// editing track effect
- command = new EditEffectCommand(this, m_document->tracksCount() - track, GenTime(-1), oldEffect, effect, effectPos, true);
+ command = new EditEffectCommand(this, m_document->tracksCount() - track, GenTime(-1), oldEffect, effect, effectPos, true, true);
} else {
- command = new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), oldEffect, effect, effectPos, true);
+ command = new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), oldEffect, effect, effectPos, true, true);
}
m_commandStack->push(command);
setDocumentModified();;
setDocumentModified();
}
-void CustomTrackView::slotUpdateClipEffect(ClipItem *clip, int track, QDomElement oldeffect, QDomElement effect, int ix)
+void CustomTrackView::slotUpdateClipEffect(ClipItem *clip, int track, QDomElement oldeffect, QDomElement effect, int ix, bool refreshEffectStack)
{
EditEffectCommand *command;
- if (clip) command = new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), oldeffect, effect, ix, true);
- else command = new EditEffectCommand(this, m_document->tracksCount() - track, GenTime(-1), oldeffect, effect, ix, true);
+ if (clip) command = new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), oldeffect, effect, ix, refreshEffectStack, true);
+ else command = new EditEffectCommand(this, m_document->tracksCount() - track, GenTime(-1), oldeffect, effect, ix, refreshEffectStack, true);
m_commandStack->push(command);
}
QDomElement effect = clip->getEffectAt(ix);
QDomElement oldeffect = effect.cloneNode().toElement();
effect.setAttribute("region", region);
- EditEffectCommand *command = new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), oldeffect, effect, ix, true);
+ EditEffectCommand *command = new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), oldeffect, effect, ix, true, true);
m_commandStack->push(command);
}
//item->updateKeyframeEffect();
//QString next = item->keyframes(item->selectedEffectIndex());
//EditKeyFrameCommand *command = new EditKeyFrameCommand(this, item->track(), item->startPos(), item->selectedEffectIndex(), previous, next, false);
- EditEffectCommand *command = new EditEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), oldEffect, newEffect, item->selectedEffectIndex(), false);
+ EditEffectCommand *command = new EditEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), oldEffect, newEffect, item->selectedEffectIndex(), false, false);
m_commandStack->push(command);
updateEffect(m_document->tracksCount() - item->track(), item->startPos(), item->selectedEffect(), item->selectedEffectIndex());
if (effects.count()) {
QMap<int, QDomElement>::const_iterator i = effects.constBegin();
while (i != effects.constEnd()) {
- new EditEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), i.value(), item->effectAt(i.key()), i.key(), false, command);
+ new EditEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), i.value(), item->effectAt(i.key()), i.key(), false, false, command);
++i;
}
}
kDebug()<<"// RESULT FILTER: "<<i.key()<<"="<< i.value();
++i;
}
- EditEffectCommand *command = new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), effect, newEffect, clip->selectedEffectIndex(), true);
+ EditEffectCommand *command = new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), effect, newEffect, clip->selectedEffectIndex(), true, true);
m_commandStack->push(command);
emit clipItemSelected(clip, clip->selectedEffectIndex());
}
void slotAddGroupEffect(QDomElement effect, AbstractGroupItem *group);
void addEffect(int track, GenTime pos, QDomElement effect);
void deleteEffect(int track, GenTime pos, QDomElement effect);
- void updateEffect(int track, GenTime pos, QDomElement insertedEffect, int ix, bool triggeredByUser = true);
+ void updateEffect(int track, GenTime pos, QDomElement insertedEffect, int ix, bool refreshEffectStack = false);
void moveEffect(int track, GenTime pos, int oldPos, int newPos);
void addTransition(ItemInfo transitionInfo, int endTrack, QDomElement params, bool refresh);
void deleteTransition(ItemInfo transitionInfo, int endTrack, QDomElement params, bool refresh);
void slotDeleteEffect(ClipItem *clip, int track, QDomElement effect, bool affectGroup = true);
void slotChangeEffectState(ClipItem *clip, int track, int effectPos, bool disable);
void slotChangeEffectPosition(ClipItem *clip, int track, int currentPos, int newPos);
- void slotUpdateClipEffect(ClipItem *clip, int track, QDomElement oldeffect, QDomElement effect, int ix);
+ void slotUpdateClipEffect(ClipItem *clip, int track, QDomElement oldeffect, QDomElement effect, int ix, bool refreshEffectStack = true);
void slotUpdateClipRegion(ClipItem *clip, int ix, QString region);
void slotRefreshEffects(ClipItem *clip);
void setDuration(int duration);
if (!e.isNull()) {
result = m_baseElement.appendChild(importNode(e, true)).toElement();
if (m_useIndex) {
- updateIndexes(m_baseElement.childNodes());
+ updateIndexes(m_baseElement.childNodes(), m_baseElement.childNodes().count() - 1);
}
}
return result;
QDomNodeList effects = m_baseElement.childNodes();
if (ix <= 0 || ix > effects.count()) return;
m_baseElement.removeChild(effects.at(ix - 1));
- if (m_useIndex) updateIndexes(effects);
+ if (m_useIndex) updateIndexes(effects, ix - 1);
}
QDomElement EffectsList::itemFromIndex(int ix) const
QDomNodeList effects = m_baseElement.childNodes();
int ix = effect.attribute("kdenlive_ix").toInt();
QDomElement result;
- if (effect.hasAttribute("kdenlive_ix") && ix > effects.count()) result = m_baseElement.appendChild(importNode(effect, true)).toElement();
+ if (effect.hasAttribute("kdenlive_ix") && ix > effects.count()) {
+ ix = effects.count();
+ result = m_baseElement.appendChild(importNode(effect, true)).toElement();
+ }
else {
QDomElement listeffect = effects.at(ix - 1).toElement();
result = m_baseElement.insertBefore(importNode(effect, true), listeffect).toElement();
}
- if (m_useIndex) updateIndexes(effects);
+ if (m_useIndex) updateIndexes(effects, ix - 1);
return result;
}
-void EffectsList::updateIndexes(QDomNodeList effects)
+void EffectsList::updateIndexes(QDomNodeList effects, int startIndex)
{
- for (int i = 0; i < effects.count(); i++) {
+ for (int i = startIndex; i < effects.count(); i++) {
QDomElement listeffect = effects.at(i).toElement();
listeffect.setAttribute("kdenlive_ix", i + 1);
}
/** @brief Get am effect with effect index equal to ix. */
QDomElement effectFromIndex(QDomNodeList effects, int ix);
/** @brief Update all effects indexes to make sure they are 1, 2, 3, ... */
- void updateIndexes(QDomNodeList effects);
+ void updateIndexes(QDomNodeList effects, int startIndex);
private:
QDomElement m_baseElement;
#include <QInputDialog>
#include <QDragEnterEvent>
#include <QDropEvent>
-
+#include <QMutexLocker>
#include <KDebug>
#include <KGlobalSettings>
void CollapsibleGroup::addGroupEffect(CollapsibleEffect *effect)
{
+ QMutexLocker lock(&m_mutex);
QVBoxLayout *vbox = static_cast<QVBoxLayout *>(widgetFrame->layout());
if (vbox == NULL) {
vbox = new QVBoxLayout();
void CollapsibleGroup::removeGroup(int ix, QVBoxLayout *layout)
{
+ QMutexLocker lock(&m_mutex);
QVBoxLayout *vbox = static_cast<QVBoxLayout *>(widgetFrame->layout());
if (vbox == NULL) return;
for (int i = m_subWidgets.count() - 1; i >= 0 ; i--) {
vbox->removeWidget(m_subWidgets.at(i));
layout->insertWidget(ix, m_subWidgets.at(i));
m_subWidgets.at(i)->removeFromGroup();
+ kDebug()<<"// Removing effect at: "<<i;
}
m_subWidgets.clear();
}
void CollapsibleGroup::dropEvent(QDropEvent *event)
{
+ QMutexLocker lock(&m_mutex);
framegroup->setProperty("active", false);
framegroup->setStyleSheet(framegroup->styleSheet());
const QString effects = QString::fromUtf8(event->mimeData()->data("kdenlive/effectslist"));
void CollapsibleGroup::slotRenameGroup()
{
+ QMutexLocker lock(&m_mutex);
m_title->setReadOnly(true);
if (m_title->text().isEmpty()) m_title->setText(i18n("Effect Group"));
for (int j = 0; j < m_subWidgets.count(); j++) {
QList <CollapsibleEffect*> CollapsibleGroup::effects()
{
+ QMutexLocker lock(&m_mutex);
return m_subWidgets;
}
QDomDocument CollapsibleGroup::effectsData()
{
+ QMutexLocker lock(&m_mutex);
QDomDocument doc;
QDomElement list = doc.createElement("list");
list.setAttribute("name", m_title->text());
#include <QDomElement>
#include <QToolButton>
#include <QLineEdit>
+#include <QMutex>
class QFrame;
EffectInfo m_info;
int m_index;
MyEditableLabel *m_title;
+ QMutex m_mutex;
protected:
virtual void mouseDoubleClickEvent ( QMouseEvent * event );
void EffectStackView2::slotUpdateEffectParams(const QDomElement old, const QDomElement e, int ix)
{
if (m_effectMetaInfo.trackMode)
- emit updateEffect(NULL, m_trackindex, old, e, ix);
+ emit updateEffect(NULL, m_trackindex, old, e, ix,false);
else if (m_clipref) {
- emit updateEffect(m_clipref, -1, old, e, ix);
+ emit updateEffect(m_clipref, -1, old, e, ix, false);
// Make sure the changed effect is currently displayed
slotSetCurrentEffect(ix);
}
info.startPos = GenTime(-1);
info.track = 0;
m_effects.at(ix)->updateWidget(info, dom, &m_effectMetaInfo);
- emit updateEffect(NULL, m_trackindex, old, dom, ix);
+ emit updateEffect(NULL, m_trackindex, old, dom, ix,false);
} else {
m_clipref->initEffect(dom);
m_effects.at(ix)->updateWidget(m_clipref->info(), dom, &m_effectMetaInfo);
//m_ui.region_url->setUrl(KUrl(dom.attribute("region")));
- emit updateEffect(m_clipref, -1, old, dom, ix);
+ emit updateEffect(m_clipref, -1, old, dom, ix,false);
}
}
info.cropStart = GenTime(0);
info.startPos = GenTime(-1);
info.track = 0;
- emit updateEffect(NULL, m_trackindex, oldeffect, neweffect, ix);
+ emit updateEffect(NULL, m_trackindex, oldeffect, neweffect, ix, false);
} else {
- emit updateEffect(m_clipref, -1, oldeffect, neweffect, ix);
+ emit updateEffect(m_clipref, -1, oldeffect, neweffect, ix, false);
}
QVBoxLayout *l = static_cast<QVBoxLayout *>(m_ui.container->widget()->layout());
info.cropStart = GenTime(0);
info.startPos = GenTime(-1);
info.track = 0;
- emit updateEffect(NULL, m_trackindex, oldeffect, neweffect, effectToMove->effectIndex());
+ emit updateEffect(NULL, m_trackindex, oldeffect, neweffect, effectToMove->effectIndex(),false);
} else {
- emit updateEffect(m_clipref, -1, oldeffect, neweffect, effectToMove->effectIndex());
+ emit updateEffect(m_clipref, -1, oldeffect, neweffect, effectToMove->effectIndex(),false);
}
//if (currentIndex == newIndex) return;
QDomElement changed = origin.cloneNode().toElement();
changed.setAttribute("kdenlive_info", effects.at(i)->infoString());
if (m_effectMetaInfo.trackMode) {
- emit updateEffect(NULL, m_trackindex, origin, changed, effects.at(i)->effectIndex());
+ emit updateEffect(NULL, m_trackindex, origin, changed, effects.at(i)->effectIndex(),false);
} else {
- emit updateEffect(m_clipref, -1, origin, changed, effects.at(i)->effectIndex());
+ emit updateEffect(m_clipref, -1, origin, changed, effects.at(i)->effectIndex(),false);
}
}
}
signals:
void removeEffect(ClipItem*, int, QDomElement);
/** Parameters for an effect changed, update the filter in playlist */
- void updateEffect(ClipItem*, int, QDomElement, QDomElement, int);
+ void updateEffect(ClipItem*, int, QDomElement, QDomElement, int,bool);
/** An effect in stack was moved, we need to regenerate
all effects for this clip in the playlist */
void refreshEffectStack(ClipItem *);
disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(slotActivateMonitor()));
disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
- disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
+ disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int,bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int,bool)));
disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
disconnect(m_effectStack, SIGNAL(addEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotAddEffect(ClipItem*, QDomElement)));
disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
connect(m_projectList, SIGNAL(gotFilterJobResults(const QString &, int, int, const QString &, stringMap)), trackView->projectView(), SLOT(slotGotFilterJobResults(const QString &, int, int, const QString &, stringMap)));
- connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
+ connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int,bool)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int,bool)));
connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
connect(m_effectStack, SIGNAL(addEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotAddEffect(ClipItem*, QDomElement)));