From: Jean-Baptiste Mardelle Date: Mon, 26 Mar 2012 10:01:04 +0000 (+0200) Subject: Fix dropping new effect in effect stack X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=b1d2b276bea14afb4720b00b7b546c2b9272d516;p=kdenlive Fix dropping new effect in effect stack --- diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index c6abfabc..58a2d1b1 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -1758,6 +1758,11 @@ void CustomTrackView::slotAddGroupEffect(QDomElement effect, AbstractGroupItem * } else delete effectCommand; } +void CustomTrackView::slotAddEffect(ClipItem *clip, QDomElement effect) +{ + if (clip) slotAddEffect(effect, clip->startPos(), clip->track()); +} + void CustomTrackView::slotAddEffect(QDomElement effect, GenTime pos, int track) { QList itemList; diff --git a/src/customtrackview.h b/src/customtrackview.h index 85259b36..015a2fe1 100644 --- a/src/customtrackview.h +++ b/src/customtrackview.h @@ -272,6 +272,8 @@ public slots: * @param offsetList The list of points that should also snap (for example when movin a clip, start and end points should snap * @param skipSelectedItems if true, the selected item start and end points will not be added to snap list */ void updateSnapPoints(AbstractClipItem *selected, QList offsetList = QList (), bool skipSelectedItems = false); + + void slotAddEffect(ClipItem *clip, QDomElement effect); protected: virtual void drawBackground(QPainter * painter, const QRectF & rect); diff --git a/src/effectstack/collapsibleeffect.cpp b/src/effectstack/collapsibleeffect.cpp index 49e303aa..edc7421b 100644 --- a/src/effectstack/collapsibleeffect.cpp +++ b/src/effectstack/collapsibleeffect.cpp @@ -561,13 +561,21 @@ void CollapsibleEffect::dropEvent(QDropEvent *event) //event->acceptProposedAction(); QDomDocument doc; doc.setContent(effects, true); - const QDomElement e = doc.documentElement(); + QDomElement e = doc.documentElement(); int ix = e.attribute("kdenlive_ix").toInt(); if (ix == effectIndex()) { // effect dropped on itself, reject event->ignore(); return; } + if (ix == 0) { + // effect dropped from effects list, add it + e.setAttribute("kdenlive_ix", ix); + event->setDropAction(Qt::CopyAction); + event->accept(); + emit addEffect(e); + return; + } int new_index = -1; if (m_isGroup) { QVBoxLayout *vbox = static_cast(widgetFrame->layout()); diff --git a/src/effectstack/collapsibleeffect.h b/src/effectstack/collapsibleeffect.h index c4112d32..5b7df1cb 100644 --- a/src/effectstack/collapsibleeffect.h +++ b/src/effectstack/collapsibleeffect.h @@ -193,6 +193,7 @@ signals: void createGroup(int ix); void moveEffect(int current_pos, int new_pos, CollapsibleEffect *target); void unGroup(CollapsibleEffect *); + void addEffect(QDomElement e); }; diff --git a/src/effectstack/effectstackview2.cpp b/src/effectstack/effectstackview2.cpp index d9104828..56a9b330 100644 --- a/src/effectstack/effectstackview2.cpp +++ b/src/effectstack/effectstackview2.cpp @@ -235,6 +235,7 @@ void EffectStackView2::setupListView(int ix) connect(currentEffect, SIGNAL(seekTimeline(int)), this , SLOT(slotSeekTimeline(int))); connect(currentEffect, SIGNAL(createGroup(int)), this , SLOT(slotCreateGroup(int))); connect(currentEffect, SIGNAL(moveEffect(int,int,CollapsibleEffect*)), this , SLOT(slotMoveEffect(int,int,CollapsibleEffect*))); + connect(currentEffect, SIGNAL(addEffect(QDomElement)), this , SLOT(slotAddEffect(QDomElement))); //ui.title->setPixmap(icon.pixmap(QSize(12, 12))); } @@ -423,6 +424,11 @@ void EffectStackView2::slotDeleteEffect(const QDomElement effect) emit removeEffect(m_clipref, -1, effect); } +void EffectStackView2::slotAddEffect(QDomElement effect) +{ + emit addEffect(m_clipref, effect); +} + void EffectStackView2::slotMoveEffectUp(int index, bool up) { if (up && index <= 1) return; @@ -530,7 +536,6 @@ void EffectStackView2::slotCreateGroup(int ix) void EffectStackView2::slotMoveEffect(int currentIndex, int newIndex, CollapsibleEffect* target) { - QVBoxLayout *l = static_cast(m_ui.container->widget()->layout()); CollapsibleEffect *effectToMove = getEffectByIndex(currentIndex); if (effectToMove == NULL) return; diff --git a/src/effectstack/effectstackview2.h b/src/effectstack/effectstackview2.h index 1ab3f1b7..2f7a6ba3 100644 --- a/src/effectstack/effectstackview2.h +++ b/src/effectstack/effectstackview2.h @@ -158,8 +158,11 @@ private slots: ** @param lastEffectIndex the last effect index in the group, effect will be inserted after that index */ void slotMoveEffect(int currentIndex, int newIndex, CollapsibleEffect* target); + /** @brief Remove effects from a group */ void slotUnGroup(CollapsibleEffect* group); + + void slotAddEffect(QDomElement effect); signals: void removeEffect(ClipItem*, int, QDomElement); @@ -181,6 +184,7 @@ signals: void displayMessage(const QString&, int); void showComments(bool show); void startFilterJob(ItemInfo info, const QString &clipId, const QString &filterName, const QString &filterParams, const QString&finalFilterName, const QString &consumer, const QString &consumerParams, const QString &properties); + void addEffect(ClipItem*,QDomElement); }; #endif diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2f51f975..5f6db6c7 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2475,6 +2475,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //cha 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(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))); disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int))); disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*))); @@ -2552,6 +2553,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //cha connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int))); 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))); connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool))); connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int))); connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));