]> git.sesse.net Git - kdenlive/commitdiff
paste effects from one clip to another
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 19 Jul 2008 18:33:59 +0000 (18:33 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 19 Jul 2008 18:33:59 +0000 (18:33 +0000)
svn path=/branches/KDE4/; revision=2324

src/addeffectcommand.cpp
src/addeffectcommand.h
src/customtrackview.cpp
src/customtrackview.h
src/kdenliveui.rc
src/mainwindow.cpp
src/mainwindow.h

index cceed84386343ce6572e9a948acd7242ee8e9698..e9e48c182c68bb00a68822efcb987529bf423b67 100644 (file)
@@ -22,8 +22,7 @@
 #include "addeffectcommand.h"
 #include "customtrackview.h"
 
-AddEffectCommand::AddEffectCommand(CustomTrackView *view, const int track, GenTime pos, QDomElement effect, bool doIt)
-        : m_view(view), m_track(track), m_pos(pos), m_effect(effect), m_doIt(doIt) {
+AddEffectCommand::AddEffectCommand(CustomTrackView *view, const int track, GenTime pos, QDomElement effect, bool doIt, QUndoCommand * parent) : QUndoCommand(parent), m_view(view), m_track(track), m_pos(pos), m_effect(effect), m_doIt(doIt) {
     QString effectName;
     QDomNode namenode = effect.elementsByTagName("name").item(0);
     if (!namenode.isNull()) effectName = i18n(namenode.toElement().text().toUtf8().data());
index 6f1fbfca24ef6f80dd0c06fd55bd3d4cb94709d2..d44b08b1ba824f13e468dc05b766281ec971d545 100644 (file)
@@ -30,7 +30,7 @@ class CustomTrackView;
 
 class AddEffectCommand : public QUndoCommand {
 public:
-    AddEffectCommand(CustomTrackView *view, const int track, GenTime pos, QDomElement effect, bool doIt);
+    AddEffectCommand(CustomTrackView *view, const int track, GenTime pos, QDomElement effect, bool doIt, QUndoCommand * parent = 0);
 
     virtual void undo();
     virtual void redo();
index be0a28f998356bd1c623b2d0949c4d95c0b305fc..dbbd4547f7a49ab56bcda5426b2f0c636c455db8 100644 (file)
@@ -2050,6 +2050,30 @@ void CustomTrackView::pasteClip() {
     m_commandStack->push(pasteClips);
 }
 
+void CustomTrackView::pasteClipEffects() {
+    if (m_copiedItems.count() != 1 || m_copiedItems.at(0)->type() != AVWIDGET) {
+        emit displayMessage(i18n("You must copy exactly one clip before pasting effects"), ErrorMessage);
+        return;
+    }
+    ClipItem *clip = static_cast < ClipItem *> (m_copiedItems.at(0));
+    EffectsList effects = clip->effectList();
+
+    QUndoCommand *paste = new QUndoCommand();
+    paste->setText("Paste effects");
+
+    QList<QGraphicsItem *> clips = scene()->selectedItems();
+    for (int i = 0; i < clips.count(); ++i) {
+       if (clips.at(i)->type() == AVWIDGET) {
+           ClipItem *item = static_cast < ClipItem *> (clips.at(i));
+           for (int i = 0; i < clip->effectsCount(); i++) {
+               new AddEffectCommand(this, m_tracksList.count() - item->track(), item->startPos(), clip->effectAt(i), true, paste);
+           }
+       }
+    }
+    m_commandStack->push(paste);
+}
+
+
 /*
 void CustomTrackView::drawForeground ( QPainter * painter, const QRectF & rect )
 {
index 991936f3ca16d670a018af1127089f57ef8e3289..ebb95d3cc3b1ef17a58e7731143ff70a257e3b27 100644 (file)
@@ -119,6 +119,7 @@ public slots:
     void editGuide(const GenTime oldPos, const GenTime pos, const QString &comment);
     void copyClip();
     void pasteClip();
+    void pasteClipEffects();
 
 protected:
     virtual void drawBackground(QPainter * painter, const QRectF & rect);
index a3d1799abee53a166e6e68febd54f5193f5d94a2..8da6a1101497456570e466452b7a82acb3402e88 100644 (file)
@@ -8,6 +8,7 @@
 
   <MenuBar>
     <Menu name="edit" >
+      <Action name="paste_effects" />
       <Action name="project_find" />
       <Action name="project_find_next" />
     </Menu>
index fc6955bca9b2b1277bcaeb5869e3a07d38757602..7899c653dafa4c378c9478baca26bbf58f47921a 100644 (file)
@@ -245,6 +245,7 @@ MainWindow::MainWindow(QWidget *parent)
     m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
     m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
     m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
+    m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
 
     QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
     m_timelineContextClipMenu->addMenu(markersMenu);
@@ -644,6 +645,10 @@ void MainWindow::setupActions() {
     actionCollection()->addAction("delete_all_guides", delAllGuides);
     connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
 
+    QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
+    actionCollection()->addAction("paste_effects", pasteEffects);
+    connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
+
     KStandardAction::quit(this, SLOT(queryQuit()),
                           actionCollection());
 
@@ -1326,6 +1331,11 @@ void MainWindow::slotPaste() {
     m_activeTimeline->projectView()->pasteClip();
 }
 
+void MainWindow::slotPasteEffects() {
+    if (!m_activeDocument || !m_activeTimeline) return;
+    m_activeTimeline->projectView()->pasteClipEffects();
+}
+
 void MainWindow::slotFind() {
     if (!m_activeDocument || !m_activeTimeline) return;
     m_projectSearch->setEnabled(false);
index 6fb14d9652a2cd8db93592b58e0785f87c09cc08..d26407083c88b2d1a93ffc90fd85097366d48f9e 100644 (file)
@@ -228,6 +228,7 @@ private slots:
 
     void slotCopy();
     void slotPaste();
+    void slotPasteEffects();
 };