]> git.sesse.net Git - kdenlive/commitdiff
Fix dropping new effect in effect stack
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 26 Mar 2012 10:01:04 +0000 (12:01 +0200)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 26 Mar 2012 10:01:04 +0000 (12:01 +0200)
src/customtrackview.cpp
src/customtrackview.h
src/effectstack/collapsibleeffect.cpp
src/effectstack/collapsibleeffect.h
src/effectstack/effectstackview2.cpp
src/effectstack/effectstackview2.h
src/mainwindow.cpp

index c6abfabcd8616db1fd0fe62ca3433197f17ccd2a..58a2d1b1d1ac3ac7947c69f7eff40b1b73eedc79 100644 (file)
@@ -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<QGraphicsItem *> itemList;
index 85259b3631c3125297a0e7c1dfa8adcbcc0d1828..015a2fe15089b13bff84ec405a79ac9d9c1c08ba 100644 (file)
@@ -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 <GenTime> offsetList = QList <GenTime> (), bool skipSelectedItems = false);
+    
+    void slotAddEffect(ClipItem *clip, QDomElement effect);
 
 protected:
     virtual void drawBackground(QPainter * painter, const QRectF & rect);
index 49e303aa09c5373053b1d5515ff75c952adfb6b1..edc7421bfe1f57824a33fb5efe987514acf6a1c4 100644 (file)
@@ -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<QVBoxLayout *>(widgetFrame->layout());
index c4112d323b990cce24824c47ed67375b0628a315..5b7df1cb1e35ad7edec5e885c5d86ea2a80819e0 100644 (file)
@@ -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);
 };
 
 
index d910482853b1bb55a48f14a1ec5c0fbac1a7fc42..56a9b330736f6103d96c761e07e3a69bf1f95d72 100644 (file)
@@ -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<QVBoxLayout *>(m_ui.container->widget()->layout());
     CollapsibleEffect *effectToMove = getEffectByIndex(currentIndex);
     if (effectToMove == NULL) return;
 
index 1ab3f1b7ce93503901a8a3ae640c19fbbd85a1e3..2f7a6ba3aa349dff1e6b680a26faed498359fa6c 100644 (file)
@@ -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
index 2f51f975afdf291ba376b413b3f746c13244e111..5f6db6c71e9267762cc7ecfa60e49dcdb4890cd5 100644 (file)
@@ -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*)));