#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());
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();
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 )
{
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);
<MenuBar>
<Menu name="edit" >
+ <Action name="paste_effects" />
<Action name="project_find" />
<Action name="project_find_next" />
</Menu>
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);
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());
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);
void slotCopy();
void slotPaste();
+ void slotPasteEffects();
};