From 2cd321d36c5d172057c5095cc5f23ea92dedd11c Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Sun, 6 May 2012 15:50:41 +0200 Subject: [PATCH] Fix effect regressions introduced by recent cleanup --- src/CMakeLists.txt | 1 - src/clipitem.cpp | 16 +- src/clipitem.h | 13 +- src/customtrackview.cpp | 68 ++--- src/effectstackview.cpp | 550 ---------------------------------------- src/effectstackview.h | 170 ------------- 6 files changed, 54 insertions(+), 764 deletions(-) delete mode 100644 src/effectstackview.cpp delete mode 100644 src/effectstackview.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8585bcb3..b93993a6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -134,7 +134,6 @@ list(APPEND kdenlive_SRCS effectslistview.cpp effectslistwidget.cpp effectstackedit.cpp - effectstackview.cpp encodingprofilesdialog.cpp folderprojectitem.cpp gentime.cpp diff --git a/src/clipitem.cpp b/src/clipitem.cpp index bf001308..7570202b 100644 --- a/src/clipitem.cpp +++ b/src/clipitem.cpp @@ -433,7 +433,7 @@ void ClipItem::setSelectedEffect(const int ix) { m_selectedEffect = ix; QLocale locale; - QDomElement effect = effectAt(m_selectedEffect); + QDomElement effect = effectAtIndex(m_selectedEffect); if (!effect.isNull() && effect.attribute("disable") != "1") { QDomNodeList params = effect.elementsByTagName("parameter"); for (int i = 0; i < params.count(); i++) { @@ -487,7 +487,7 @@ QStringList ClipItem::keyframes(const int index) void ClipItem::updateKeyframeEffect() { // regenerate xml parameter from the clip keyframes - QDomElement effect = getEffectAt(m_selectedEffect); + QDomElement effect = getEffectAtIndex(m_selectedEffect); if (effect.attribute("disable") == "1") return; QDomNodeList params = effect.elementsByTagName("parameter"); QDomElement e = params.item(m_visibleParam).toElement(); @@ -509,7 +509,7 @@ void ClipItem::updateKeyframeEffect() QDomElement ClipItem::selectedEffect() { if (m_selectedEffect == -1 || m_effectList.isEmpty()) return QDomElement(); - return effectAt(m_selectedEffect); + return effectAtIndex(m_selectedEffect); } void ClipItem::resetThumbs(bool clearExistingThumbs) @@ -1359,13 +1359,19 @@ QStringList ClipItem::effectNames() return m_effectList.effectNames(); } -QDomElement ClipItem::effectAt(int ix) const +QDomElement ClipItem::effect(int ix) const +{ + if (ix >= m_effectList.count() || ix < 0) return QDomElement(); + return m_effectList.at(ix).cloneNode().toElement(); +} + +QDomElement ClipItem::effectAtIndex(int ix) const { if (ix > m_effectList.count() || ix <= 0) return QDomElement(); return m_effectList.itemFromIndex(ix).cloneNode().toElement(); } -QDomElement ClipItem::getEffectAt(int ix) const +QDomElement ClipItem::getEffectAtIndex(int ix) const { if (ix > m_effectList.count() || ix <= 0) return QDomElement(); return m_effectList.itemFromIndex(ix); diff --git a/src/clipitem.h b/src/clipitem.h index 088f49bc..59d0ce6d 100644 --- a/src/clipitem.h +++ b/src/clipitem.h @@ -85,16 +85,21 @@ public: /** @brief Gets a unique (?) effect id. */ int effectsCounter(); + + /** @brief Gets a copy of the xml of an effect. + * @param ix The effect's list index (starting from 0) + * @return A copy of the effect's xml */ + QDomElement effect(int ix) const; /** @brief Gets a copy of the xml of an effect. - * @param ix The effect's index in effectlist + * @param ix The effect's index in effectlist (starting from 1) * @return A copy of the effect's xml */ - QDomElement effectAt(int ix) const; + QDomElement effectAtIndex(int ix) const; /** @brief Gets the xml of an effect. - * @param ix The effect's index in effectlist + * @param ix The effect's index in effectlist (starting from 1) * @return The effect's xml */ - QDomElement getEffectAt(int ix) const; + QDomElement getEffectAtIndex(int ix) const; /** @brief Replaces an effect. * @param ix The effect's index in effectlist diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index 208d48f7..1538e679 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -1292,7 +1292,7 @@ void CustomTrackView::mouseDoubleClickEvent(QMouseEvent *event) ClipItem * item = static_cast (m_dragItem); //QString previous = item->keyframes(item->selectedEffectIndex()); QDomElement oldEffect = item->selectedEffect().cloneNode().toElement(); - item->insertKeyframe(item->getEffectAt(item->selectedEffectIndex()), keyFramePos.frames(m_document->fps()), val); + item->insertKeyframe(item->getEffectAtIndex(item->selectedEffectIndex()), keyFramePos.frames(m_document->fps()), val); //item->updateKeyframeEffect(); //QString next = item->keyframes(item->selectedEffectIndex()); QDomElement newEffect = item->selectedEffect().cloneNode().toElement(); @@ -1645,7 +1645,7 @@ void CustomTrackView::slotRefreshEffects(ClipItem *clip) } bool success = true; for (int i = 0; i < clip->effectsCount(); i++) { - if (!m_document->renderer()->mltAddEffect(track, pos, getEffectArgs(clip->effectAt(i)), false)) success = false; + if (!m_document->renderer()->mltAddEffect(track, pos, getEffectArgs(clip->effect(i)), false)) success = false; } if (!success) emit displayMessage(i18n("Problem adding effect to clip"), ErrorMessage); m_document->renderer()->doRefresh(); @@ -1919,7 +1919,7 @@ void CustomTrackView::slotDeleteEffect(ClipItem *clip, int track, QDomElement ef ClipItem *item = static_cast (items.at(i)); int ix = item->hasEffect(effect.attribute("tag"), effect.attribute("id")); if (ix != -1) { - QDomElement eff = item->effectAt(ix); + QDomElement eff = item->effectAtIndex(ix); new AddEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), eff, false, delCommand); } } @@ -2089,13 +2089,13 @@ void CustomTrackView::moveEffect(int track, GenTime pos, QList oldPos, QLi } int old_position = oldPos.at(0); for (int i = 0; i < newPos.count(); i++) { - QDomElement act = clip->effectAt(new_position); + QDomElement act = clip->effectAtIndex(new_position); if (old_position > new_position) { // Moving up, we need to adjust index old_position = oldPos.at(i); new_position = newPos.at(i); } - QDomElement before = clip->effectAt(old_position); + QDomElement before = clip->effectAtIndex(old_position); if (act.isNull() || before.isNull()) { emit displayMessage(i18n("Cannot move effect"), ErrorMessage); return; @@ -2124,7 +2124,7 @@ void CustomTrackView::slotChangeEffectState(ClipItem *clip, int track, QList speedEffectIndexes; for (int i = 0; i < effectIndexes.count(); i++) { - QDomElement effect = clip->effectAt(effectIndexes.at(i)); + QDomElement effect = clip->effectAtIndex(effectIndexes.at(i)); if (effect.attribute("id") == "speed") { // speed effect speedEffectIndexes << effectIndexes.at(i); @@ -2164,7 +2164,7 @@ void CustomTrackView::slotUpdateClipEffect(ClipItem *clip, int track, QDomElemen void CustomTrackView::slotUpdateClipRegion(ClipItem *clip, int ix, QString region) { - QDomElement effect = clip->getEffectAt(ix); + QDomElement effect = clip->getEffectAtIndex(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, true); @@ -2203,23 +2203,23 @@ ClipItem *CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut, boo // fade in from 2nd part of the clip int ix = dup->hasEffect(QString(), "fadein"); if (ix != -1) { - QDomElement oldeffect = dup->effectAt(ix); + QDomElement oldeffect = dup->effectAtIndex(ix); dup->deleteEffect(oldeffect.attribute("kdenlive_ix")); } ix = dup->hasEffect(QString(), "fade_from_black"); if (ix != -1) { - QDomElement oldeffect = dup->effectAt(ix); + QDomElement oldeffect = dup->effectAtIndex(ix); dup->deleteEffect(oldeffect.attribute("kdenlive_ix")); } // fade out from 1st part of the clip ix = item->hasEffect(QString(), "fadeout"); if (ix != -1) { - QDomElement oldeffect = item->effectAt(ix); + QDomElement oldeffect = item->effectAtIndex(ix); item->deleteEffect(oldeffect.attribute("kdenlive_ix")); } ix = item->hasEffect(QString(), "fade_to_black"); if (ix != -1) { - QDomElement oldeffect = item->effectAt(ix); + QDomElement oldeffect = item->effectAtIndex(ix); item->deleteEffect(oldeffect.attribute("kdenlive_ix")); } @@ -2260,12 +2260,12 @@ ClipItem *CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut, boo // join fade effects again int ix = dup->hasEffect(QString(), "fadeout"); if (ix != -1) { - QDomElement effect = dup->effectAt(ix); + QDomElement effect = dup->effectAtIndex(ix); item->addEffect(effect); } ix = dup->hasEffect(QString(), "fade_to_black"); if (ix != -1) { - QDomElement effect = dup->effectAt(ix); + QDomElement effect = dup->effectAtIndex(ix); item->addEffect(effect); } @@ -3581,7 +3581,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) KdenliveSettings::setSnaptopoints(false); item->setPos((int) m_dragItemInfo.startPos.frames(m_document->fps()), (int)(m_dragItemInfo.track * m_tracksHeight + 1)); KdenliveSettings::setSnaptopoints(snap); - emit displayMessage(i18n("Cannot move clip to position %1", m_document->timecode().getTimecodeFromFrames(m_dragItemInfo.startPos.frames(m_document->fps()))), ErrorMessage); + emit displayMessage(i18n("Cannot move clip to position %1", m_document->timecode().getTimecodeFromFrames(info.startPos.frames(m_document->fps()))), ErrorMessage); } setDocumentModified(); } else if (m_dragItem->type() == TRANSITIONWIDGET && (m_dragItemInfo.startPos != info.startPos || m_dragItemInfo.track != info.track)) { @@ -3670,7 +3670,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) adjustTimelineClips(m_scene->editMode(), clip, ItemInfo(), moveGroup); m_document->renderer()->mltInsertClip(info, clip->xml(), clip->getProducer(trackProducer), m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT); for (int i = 0; i < clip->effectsCount(); i++) { - m_document->renderer()->mltAddEffect(info.track, info.startPos, getEffectArgs(clip->effectAt(i)), false); + m_document->renderer()->mltAddEffect(info.track, info.startPos, getEffectArgs(clip->effect(i)), false); } } else { Transition *tr = static_cast (item); @@ -3774,7 +3774,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) int ix = item->hasEffect("volume", "fadein"); int ix2 = item->hasEffect("", "fade_from_black"); if (ix != -1) { - QDomElement oldeffect = item->effectAt(ix); + QDomElement oldeffect = item->effectAtIndex(ix); int start = item->cropStart().frames(m_document->fps()); int end = item->fadeIn(); if (end == 0) { @@ -3797,7 +3797,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) slotAddEffect(effect, m_dragItem->startPos(), m_dragItem->track()); } if (ix2 != -1) { - QDomElement oldeffect = item->effectAt(ix2); + QDomElement oldeffect = item->effectAtIndex(ix2); int start = item->cropStart().frames(m_document->fps()); int end = item->fadeIn(); if (end == 0) { @@ -3817,7 +3817,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) int ix = item->hasEffect("volume", "fadeout"); int ix2 = item->hasEffect("", "fade_to_black"); if (ix != -1) { - QDomElement oldeffect = item->effectAt(ix); + QDomElement oldeffect = item->effectAtIndex(ix); int end = (item->cropDuration() + item->cropStart()).frames(m_document->fps()); int start = item->fadeOut(); if (start == 0) { @@ -3842,7 +3842,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) slotAddEffect(effect, m_dragItem->startPos(), m_dragItem->track()); } if (ix2 != -1) { - QDomElement oldeffect = item->effectAt(ix2); + QDomElement oldeffect = item->effectAtIndex(ix2); int end = (item->cropDuration() + item->cropStart()).frames(m_document->fps()); int start = item->fadeOut(); if (start == 0) { @@ -3872,9 +3872,9 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) if ((val < -50 || val > 150) && item->editedKeyFramePos() != start && item->editedKeyFramePos() != end && item->keyFrameNumber() > 1) { //delete keyframe - item->movedKeyframe(item->getEffectAt(item->selectedEffectIndex()), item->selectedKeyFramePos(), -1, 0); + item->movedKeyframe(item->getEffectAtIndex(item->selectedEffectIndex()), item->selectedKeyFramePos(), -1, 0); } else { - item->movedKeyframe(item->getEffectAt(item->selectedEffectIndex()), item->selectedKeyFramePos(), item->editedKeyFramePos(), item->editedKeyFrameValue()); + item->movedKeyframe(item->getEffectAtIndex(item->selectedEffectIndex()), item->selectedKeyFramePos(), item->editedKeyFramePos(), item->editedKeyFrameValue()); } QDomElement newEffect = item->selectedEffect().cloneNode().toElement(); @@ -4274,7 +4274,7 @@ void CustomTrackView::addClip(QDomElement xml, const QString &clipId, ItemInfo i info.track = m_document->tracksCount() - info.track; m_document->renderer()->mltInsertClip(info, xml, item->getProducer(producerTrack), overwrite, push); for (int i = 0; i < item->effectsCount(); i++) { - m_document->renderer()->mltAddEffect(info.track, info.startPos, getEffectArgs(item->effectAt(i)), false); + m_document->renderer()->mltAddEffect(info.track, info.startPos, getEffectArgs(item->effect(i)), false); } setDocumentModified(); if (refresh) @@ -4578,7 +4578,7 @@ void CustomTrackView::moveGroup(QList startClip, QList sta info.track = m_document->tracksCount() - info.track; m_document->renderer()->mltInsertClip(info, clip->xml(), clip->getProducer(trackProducer)); for (int i = 0; i < clip->effectsCount(); i++) { - m_document->renderer()->mltAddEffect(info.track, info.startPos, getEffectArgs(clip->effectAt(i)), false); + m_document->renderer()->mltAddEffect(info.track, info.startPos, getEffectArgs(clip->effect(i)), false); } } else if (item->type() == TRANSITIONWIDGET) { Transition *tr = static_cast (item); @@ -4907,7 +4907,7 @@ void CustomTrackView::updatePositionEffects(ClipItem* item, ItemInfo info, bool // there is a fade in effect int effectPos = item->hasEffect("volume", "fadein"); if (effectPos != -1) { - QDomElement effect = item->getEffectAt(effectPos); + QDomElement effect = item->getEffectAtIndex(effectPos); int start = item->cropStart().frames(m_document->fps()); int max = item->cropDuration().frames(m_document->fps()); if (end > max) { @@ -4928,7 +4928,7 @@ void CustomTrackView::updatePositionEffects(ClipItem* item, ItemInfo info, bool } effectPos = item->hasEffect("brightness", "fade_from_black"); if (effectPos != -1) { - QDomElement effect = item->getEffectAt(effectPos); + QDomElement effect = item->getEffectAtIndex(effectPos); int start = item->cropStart().frames(m_document->fps()); int max = item->cropDuration().frames(m_document->fps()); if (end > max) { @@ -4954,7 +4954,7 @@ void CustomTrackView::updatePositionEffects(ClipItem* item, ItemInfo info, bool // there is a fade out effect int effectPos = item->hasEffect("volume", "fadeout"); if (effectPos != -1) { - QDomElement effect = item->getEffectAt(effectPos); + QDomElement effect = item->getEffectAtIndex(effectPos); int max = item->cropDuration().frames(m_document->fps()); int end = max + item->cropStart().frames(m_document->fps()); if (start > max) { @@ -4975,7 +4975,7 @@ void CustomTrackView::updatePositionEffects(ClipItem* item, ItemInfo info, bool } effectPos = item->hasEffect("brightness", "fade_to_black"); if (effectPos != -1) { - QDomElement effect = item->getEffectAt(effectPos); + QDomElement effect = item->getEffectAtIndex(effectPos); int max = item->cropDuration().frames(m_document->fps()); int end = max + item->cropStart().frames(m_document->fps()); if (start > max) { @@ -5000,7 +5000,7 @@ void CustomTrackView::updatePositionEffects(ClipItem* item, ItemInfo info, bool if (effectPos != -1) { // Freeze effect needs to be adjusted with clip resize int diff = (info.startPos - item->startPos()).frames(m_document->fps()); - QDomElement eff = item->getEffectAt(effectPos); + QDomElement eff = item->getEffectAtIndex(effectPos); if (!eff.isNull() && diff != 0) { int freeze_pos = EffectsList::parameter(eff, "frame").toInt() + diff; EffectsList::setParameter(eff, "frame", QString::number(freeze_pos)); @@ -5690,8 +5690,8 @@ void CustomTrackView::pasteClipEffects() for (int i = 0; i < clips.count(); ++i) { if (clips.at(i)->type() == AVWIDGET) { ClipItem *item = static_cast < ClipItem *>(clips.at(i)); - for (int j = 1; j <= clip->effectsCount(); j++) { - QDomElement eff = clip->effectAt(j); + for (int j = 0; j < clip->effectsCount(); j++) { + QDomElement eff = clip->effect(j); if (eff.attribute("unique", "0") == "0" || item->hasEffect(eff.attribute("tag"), eff.attribute("id")) == -1) { adjustKeyfames(clip->cropStart(), item->cropStart(), item->cropDuration(), eff); new AddEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), eff, true, paste); @@ -6301,10 +6301,10 @@ void CustomTrackView::doSplitAudio(const GenTime &pos, int track, EffectsList ef int audioIx = 0; for (int i = 0; i < effects.count(); ++i) { if (effects.at(i).attribute("type") == "audio") { - deleteEffect(m_document->tracksCount() - track, pos, clip->effectAt(videoIx)); + deleteEffect(m_document->tracksCount() - track, pos, clip->effect(videoIx)); audioIx++; } else { - deleteEffect(freetrack, pos, audioClip->effectAt(audioIx)); + deleteEffect(freetrack, pos, audioClip->effect(audioIx)); videoIx++; } } @@ -7135,7 +7135,7 @@ void CustomTrackView::adjustEffects(ClipItem* item, ItemInfo oldInfo, QUndoComma if (effects.count()) { QMap::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, false, command); + new EditEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), i.value(), item->effect(i.key()), i.key(), false, false, command); ++i; } } @@ -7150,7 +7150,7 @@ void CustomTrackView::slotGotFilterJobResults(const QString &/*id*/, int startPo return; } QDomElement newEffect; - QDomElement effect = clip->getEffectAt(clip->selectedEffectIndex()); + QDomElement effect = clip->getEffectAtIndex(clip->selectedEffectIndex()); if (effect.attribute("id") == filter) { newEffect = effect.cloneNode().toElement(); QMap::const_iterator i = filterParams.constBegin(); diff --git a/src/effectstackview.cpp b/src/effectstackview.cpp deleted file mode 100644 index 57c97da9..00000000 --- a/src/effectstackview.cpp +++ /dev/null @@ -1,550 +0,0 @@ -/*************************************************************************** - effecstackview.cpp - description - ------------------- - begin : Feb 15 2008 - copyright : (C) 2008 by Marco Gittler - email : g.marco@freenet.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - - -#include "effectstackview.h" -#include "effectslist.h" -#include "clipitem.h" -#include "mainwindow.h" -#include "docclipbase.h" -#include "projectlist.h" -#include "kthumb.h" -#include "monitoreditwidget.h" -#include "monitorscene.h" -#include "kdenlivesettings.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - - -EffectStackView::EffectStackView(Monitor *monitor, QWidget *parent) : - QWidget(parent), - m_monitor(monitor), - m_clipref(NULL), - m_trackMode(false), - m_trackindex(-1) -{ - m_ui.setupUi(this); - QVBoxLayout *vbox1 = new QVBoxLayout(m_ui.frame); - //m_effectedit = new EffectStackEdit(monitor, m_ui.frame); - m_ui.frame->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); - vbox1->setContentsMargins(2, 0, 2, 0); - vbox1->setSpacing(0); - vbox1->addWidget(m_effectedit); - m_ui.splitter->setStretchFactor(0, 1); - m_ui.splitter->setStretchFactor(1, 20); - - //m_ui.region_url->fileDialog()->setFilter(ProjectList::getExtensions()); - //m_ui.effectlist->horizontalHeader()->setVisible(false); - //m_ui.effectlist->verticalHeader()->setVisible(false); - int size = style()->pixelMetric(QStyle::PM_SmallIconSize); - QSize iconSize(size, size); - - m_ui.buttonNew->setIcon(KIcon("document-new")); - m_ui.buttonNew->setToolTip(i18n("Add new effect")); - m_ui.buttonNew->setIconSize(iconSize); - m_ui.buttonUp->setIcon(KIcon("go-up")); - m_ui.buttonUp->setToolTip(i18n("Move effect up")); - m_ui.buttonUp->setIconSize(iconSize); - m_ui.buttonDown->setIcon(KIcon("go-down")); - m_ui.buttonDown->setToolTip(i18n("Move effect down")); - m_ui.buttonDown->setIconSize(iconSize); - m_ui.buttonDel->setIcon(KIcon("edit-delete")); - m_ui.buttonDel->setToolTip(i18n("Delete effect")); - m_ui.buttonDel->setIconSize(iconSize); - m_ui.buttonSave->setIcon(KIcon("document-save")); - m_ui.buttonSave->setToolTip(i18n("Save effect")); - m_ui.buttonSave->setIconSize(iconSize); - m_ui.buttonReset->setIcon(KIcon("view-refresh")); - m_ui.buttonReset->setToolTip(i18n("Reset effect")); - m_ui.buttonReset->setIconSize(iconSize); - m_ui.checkAll->setToolTip(i18n("Enable/Disable all effects")); - m_ui.buttonShowComments->setIcon(KIcon("help-about")); - m_ui.buttonShowComments->setToolTip(i18n("Show additional information for the parameters")); - - m_ui.effectlist->setDragDropMode(QAbstractItemView::NoDragDrop); //use internal if drop is recognised right - - m_ui.labelComment->setHidden(true); - - //connect(m_ui.region_url, SIGNAL(urlSelected(const KUrl &)), this , SLOT(slotRegionChanged())); - //connect(m_ui.region_url, SIGNAL(returnPressed()), this , SLOT(slotRegionChanged())); - connect(m_ui.effectlist, SIGNAL(itemSelectionChanged()), this , SLOT(slotItemSelectionChanged())); - connect(m_ui.effectlist, SIGNAL(itemChanged(QListWidgetItem *)), this , SLOT(slotItemChanged(QListWidgetItem *))); - connect(m_ui.buttonUp, SIGNAL(clicked()), this, SLOT(slotItemUp())); - connect(m_ui.buttonDown, SIGNAL(clicked()), this, SLOT(slotItemDown())); - connect(m_ui.buttonDel, SIGNAL(clicked()), this, SLOT(slotItemDel())); - connect(m_ui.buttonSave, SIGNAL(clicked()), this, SLOT(slotSaveEffect())); - connect(m_ui.buttonReset, SIGNAL(clicked()), this, SLOT(slotResetEffect())); - connect(m_ui.checkAll, SIGNAL(stateChanged(int)), this, SLOT(slotCheckAll(int))); - connect(m_ui.buttonShowComments, SIGNAL(clicked()), this, SLOT(slotShowComments())); - connect(m_effectedit, SIGNAL(parameterChanged(const QDomElement &, const QDomElement &)), this , SLOT(slotUpdateEffectParams(const QDomElement &, const QDomElement &))); - connect(m_effectedit, SIGNAL(startFilterJob(QString,QString,QString,QString,QString,QString)), this , SLOT(slotStartFilterJob(QString,QString,QString,QString,QString,QString))); - connect(m_effectedit, SIGNAL(seekTimeline(int)), this , SLOT(slotSeekTimeline(int))); - connect(m_effectedit, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int))); - connect(m_effectedit, SIGNAL(checkMonitorPosition(int)), this, SLOT(slotCheckMonitorPosition(int))); - - connect(monitor, SIGNAL(renderPosition(int)), this, SLOT(slotRenderPos(int))); - connect(this, SIGNAL(showComments(bool)), m_effectedit, SIGNAL(showComments(bool))); - m_effectLists["audio"] = &MainWindow::audioEffects; - m_effectLists["video"] = &MainWindow::videoEffects; - m_effectLists["custom"] = &MainWindow::customEffects; - setEnabled(false); -} - -EffectStackView::~EffectStackView() -{ - m_effectLists.clear(); - delete m_effectedit; -} - -void EffectStackView::updateTimecodeFormat() -{ - m_effectedit->updateTimecodeFormat(); -} - -void EffectStackView::setMenu(QMenu *menu) -{ - m_ui.buttonNew->setMenu(menu); -} - -void EffectStackView::updateProjectFormat(MltVideoProfile profile, Timecode t) -{ - m_effectedit->updateProjectFormat(profile, t); -} - -void EffectStackView::slotSaveEffect() -{ - QString name = QInputDialog::getText(this, i18n("Save Effect"), i18n("Name for saved effect: ")); - if (name.isEmpty()) return; - QString path = KStandardDirs::locateLocal("appdata", "effects/", true); - path = path + name + ".xml"; - if (QFile::exists(path)) if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", path)) == KMessageBox::No) return; - - int i = m_ui.effectlist->currentRow(); - QDomDocument doc; - QDomElement effect = m_currentEffectList.at(i).cloneNode().toElement(); - doc.appendChild(doc.importNode(effect, true)); - effect = doc.firstChild().toElement(); - effect.removeAttribute("kdenlive_ix"); - effect.setAttribute("id", name); - effect.setAttribute("type", "custom"); - QDomElement effectname = effect.firstChildElement("name"); - effect.removeChild(effectname); - effectname = doc.createElement("name"); - QDomText nametext = doc.createTextNode(name); - effectname.appendChild(nametext); - effect.insertBefore(effectname, QDomNode()); - QDomElement effectprops = effect.firstChildElement("properties"); - effectprops.setAttribute("id", name); - effectprops.setAttribute("type", "custom"); - - QFile file(path); - if (file.open(QFile::WriteOnly | QFile::Truncate)) { - QTextStream out(&file); - out << doc.toString(); - } - file.close(); - emit reloadEffects(); -} - -void EffectStackView::slotUpdateEffectParams(const QDomElement &old, const QDomElement &e) -{ - if (m_trackMode) - emit updateEffect(NULL, m_trackindex, old, e, m_ui.effectlist->currentRow()); - else if (m_clipref) - emit updateEffect(m_clipref, -1, old, e, m_ui.effectlist->currentRow()); -} - -void EffectStackView::slotClipItemSelected(ClipItem* c, int ix) -{ - if (c && !c->isEnabled()) return; - if (c && c == m_clipref) { - if (ix == -1) ix = m_ui.effectlist->currentRow(); - //if (ix == -1 || ix == m_ui.effectlist->currentRow()) return; - } else { - m_clipref = c; - if (c) { - QString cname = m_clipref->clipName(); - if (cname.length() > 30) { - m_ui.checkAll->setToolTip(i18n("Effects for %1").arg(cname)); - cname.truncate(27); - m_ui.checkAll->setText(i18n("Effects for %1").arg(cname) + "..."); - } else { - m_ui.checkAll->setToolTip(QString()); - m_ui.checkAll->setText(i18n("Effects for %1").arg(cname)); - } - ix = c->selectedEffectIndex(); - QString size = c->baseClip()->getProperty("frame_size"); - double factor = c->baseClip()->getProperty("aspect_ratio").toDouble(); - QPoint p((int)(size.section('x', 0, 0).toInt() * factor + 0.5), size.section('x', 1, 1).toInt()); - m_effectedit->setFrameSize(p); - } else { - ix = 0; - } - } - if (m_clipref == NULL) { - m_ui.effectlist->blockSignals(true); - m_ui.effectlist->clear(); - ItemInfo info; - m_effectedit->transferParamDesc(QDomElement(), info); - //m_ui.region_url->clear(); - m_ui.effectlist->blockSignals(false); - m_ui.checkAll->setToolTip(QString()); - m_ui.checkAll->setText(QString()); - m_ui.labelComment->setText(QString()); - setEnabled(false); - return; - } - setEnabled(true); - m_trackMode = false; - m_currentEffectList = m_clipref->effectList(); - setupListView(ix); -} - -void EffectStackView::slotTrackItemSelected(int ix, const TrackInfo info) -{ - m_clipref = NULL; - m_trackMode = true; - m_currentEffectList = info.effectsList; - m_trackInfo = info; - kDebug() << "// TRACK; " << ix << ", EFFECTS: " << m_currentEffectList.count(); - setEnabled(true); - m_ui.checkAll->setToolTip(QString()); - m_ui.checkAll->setText(i18n("Effects for track %1").arg(info.trackName.isEmpty() ? QString::number(ix) : info.trackName)); - m_trackindex = ix; - setupListView(0); -} - -void EffectStackView::slotItemChanged(QListWidgetItem *item) -{ - bool disable = item->checkState() == Qt::Unchecked; - int row = m_ui.effectlist->row(item); - int activeRow = m_ui.effectlist->currentRow(); - - if (row == activeRow) { - m_ui.buttonReset->setEnabled(!disable || !KdenliveSettings::disable_effect_parameters()); - m_effectedit->updateParameter("disable", QString::number((int) disable)); - } - - if (m_trackMode) - emit changeEffectState(NULL, m_trackindex, row, disable); - else - emit changeEffectState(m_clipref, -1, row, disable); - - slotUpdateCheckAllButton(); -} - - -void EffectStackView::setupListView(int ix) -{ - m_ui.effectlist->blockSignals(true); - m_ui.effectlist->clear(); - - // Issue 238: Add icons for effect type in effectstack. - KIcon videoIcon("kdenlive-show-video"); - KIcon audioIcon("kdenlive-show-audio"); - KIcon customIcon("kdenlive-custom-effect"); - QListWidgetItem* item; - - for (int i = 0; i < m_currentEffectList.count(); i++) { - const QDomElement d = m_currentEffectList.at(i).cloneNode().toElement(); - if (d.isNull()) { - kDebug() << " . . . . WARNING, NULL EFFECT IN STACK!!!!!!!!!"; - continue; - } - - /*QDomDocument doc; - doc.appendChild(doc.importNode(d, true)); - kDebug() << "IMPORTED STK: " << doc.toString();*/ - - QDomElement namenode = d.firstChildElement("name"); - if (!namenode.isNull()) { - // Issue 238: Add icons for effect type in effectstack. - // Logic more or less copied from initeffects.cpp - QString type = d.attribute("type", QString()); - if ("audio" == type) { - item = new QListWidgetItem(audioIcon, i18n(namenode.text().toUtf8().data()), m_ui.effectlist); - } else if ("custom" == type) { - item = new QListWidgetItem(customIcon, i18n(namenode.text().toUtf8().data()), m_ui.effectlist); - } else { - item = new QListWidgetItem(videoIcon, i18n(namenode.text().toUtf8().data()), m_ui.effectlist); - } - item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); - if (d.attribute("disable") == "1") - item->setCheckState(Qt::Unchecked); - else - item->setCheckState(Qt::Checked); - } - } - if (m_ui.effectlist->count() == 0) { - m_ui.buttonDel->setEnabled(false); - m_ui.buttonSave->setEnabled(false); - m_ui.buttonReset->setEnabled(false); - m_ui.buttonUp->setEnabled(false); - m_ui.buttonDown->setEnabled(false); - m_ui.checkAll->setEnabled(false); - m_ui.buttonShowComments->setEnabled(false); - m_ui.labelComment->setHidden(true); - } else { - ix = qBound(0, ix, m_ui.effectlist->count() - 1); - m_ui.effectlist->setCurrentRow(ix); - m_ui.checkAll->setEnabled(true); - } - m_ui.effectlist->blockSignals(false); - if (m_ui.effectlist->count() == 0) { - ItemInfo info; - m_effectedit->transferParamDesc(QDomElement(), info); - //m_ui.region_url->clear(); - } else slotItemSelectionChanged(false); - slotUpdateCheckAllButton(); -} - -void EffectStackView::slotItemSelectionChanged(bool update) -{ - bool hasItem = m_ui.effectlist->currentItem(); - int activeRow = m_ui.effectlist->currentRow(); - bool isChecked = false; - if (hasItem && m_ui.effectlist->currentItem()->checkState() == Qt::Checked) isChecked = true; - QDomElement eff; - if (hasItem && m_ui.effectlist->currentItem()->isSelected()) { - eff = m_currentEffectList.at(activeRow); - if (m_trackMode) { - // showing track effects - ItemInfo info; - info.track = m_trackInfo.type; - info.cropDuration = GenTime(m_trackInfo.duration, KdenliveSettings::project_fps()); - info.cropStart = GenTime(0); - info.startPos = GenTime(-1); - info.track = 0; - m_effectedit->transferParamDesc(eff, info); - } else { - m_effectedit->transferParamDesc(eff, m_clipref->info()); - } - //m_ui.region_url->setUrl(KUrl(eff.attribute("region"))); - m_ui.labelComment->setText(i18n(eff.firstChildElement("description").firstChildElement("full").text().toUtf8().data())); - } - if (!m_trackMode && m_clipref && update) m_clipref->setSelectedEffect(activeRow); - m_ui.buttonDel->setEnabled(hasItem); - m_ui.buttonSave->setEnabled(hasItem); - m_ui.buttonReset->setEnabled(hasItem && (isChecked || !KdenliveSettings::disable_effect_parameters())); - m_ui.buttonUp->setEnabled(activeRow > 0); - m_ui.buttonDown->setEnabled((activeRow < m_ui.effectlist->count() - 1) && hasItem); - m_ui.buttonShowComments->setEnabled(hasItem); - - emit showComments(m_ui.buttonShowComments->isChecked()); - m_ui.labelComment->setVisible(hasItem && m_ui.labelComment->text().count() && (m_ui.buttonShowComments->isChecked() || !eff.elementsByTagName("parameter").count())); -} - -void EffectStackView::slotItemUp() -{ - int activeRow = m_ui.effectlist->currentRow(); - if (activeRow <= 0) return; - if (m_trackMode) emit changeEffectPosition(NULL, m_trackindex, activeRow + 1, activeRow); - else emit changeEffectPosition(m_clipref, -1, activeRow + 1, activeRow); -} - -void EffectStackView::slotItemDown() -{ - int activeRow = m_ui.effectlist->currentRow(); - if (activeRow >= m_ui.effectlist->count() - 1) return; - if (m_trackMode) emit changeEffectPosition(NULL, m_trackindex, activeRow + 1, activeRow + 2); - else emit changeEffectPosition(m_clipref, -1, activeRow + 1, activeRow + 2); -} - -void EffectStackView::slotItemDel() -{ - int activeRow = m_ui.effectlist->currentRow(); - if (activeRow >= 0) { - if (m_trackMode) - emit removeEffect(NULL, m_trackindex, m_currentEffectList.at(activeRow).cloneNode().toElement()); - else - emit removeEffect(m_clipref, -1, m_clipref->effectAt(activeRow)); - slotUpdateCheckAllButton(); - } -} - -void EffectStackView::slotResetEffect() -{ - int activeRow = m_ui.effectlist->currentRow(); - if (activeRow < 0) return; - QDomElement old = m_currentEffectList.at(activeRow).cloneNode().toElement(); - QDomElement dom; - QString effectName = m_ui.effectlist->currentItem()->text(); - foreach(const QString &type, m_effectLists.keys()) { - EffectsList *list = m_effectLists[type]; - if (list->effectNames().contains(effectName)) { - dom = list->getEffectByName(effectName).cloneNode().toElement(); - break; - } - } - if (!dom.isNull()) { - dom.setAttribute("kdenlive_ix", old.attribute("kdenlive_ix")); - if (m_trackMode) { - EffectsList::setParameter(dom, "in", QString::number(0)); - EffectsList::setParameter(dom, "out", QString::number(m_trackInfo.duration)); - ItemInfo info; - info.track = m_trackInfo.type; - info.cropDuration = GenTime(m_trackInfo.duration, KdenliveSettings::project_fps()); - info.cropStart = GenTime(0); - info.startPos = GenTime(-1); - info.track = 0; - m_effectedit->transferParamDesc(dom, info); - emit updateEffect(NULL, m_trackindex, old, dom, activeRow); - } else { - m_clipref->initEffect(dom); - m_effectedit->transferParamDesc(dom, m_clipref->info()); - //m_ui.region_url->setUrl(KUrl(dom.attribute("region"))); - emit updateEffect(m_clipref, -1, old, dom, activeRow); - } - } - - emit showComments(m_ui.buttonShowComments->isChecked()); - m_ui.labelComment->setHidden(!m_ui.buttonShowComments->isChecked() || !m_ui.labelComment->text().count()); -} - - -void EffectStackView::raiseWindow(QWidget* dock) -{ - if ((m_clipref || m_trackMode) && dock) - dock->raise(); -} - -void EffectStackView::clear() -{ - m_ui.effectlist->blockSignals(true); - m_ui.effectlist->clear(); - m_ui.buttonDel->setEnabled(false); - m_ui.buttonSave->setEnabled(false); - m_ui.buttonReset->setEnabled(false); - m_ui.buttonUp->setEnabled(false); - m_ui.buttonDown->setEnabled(false); - m_ui.checkAll->setEnabled(false); - ItemInfo info; - m_effectedit->transferParamDesc(QDomElement(), info); - //m_ui.region_url->clear(); - m_clipref = NULL; - m_ui.buttonShowComments->setEnabled(false); - m_ui.labelComment->setText(QString()); - m_ui.effectlist->blockSignals(false); -} - - -void EffectStackView::slotSeekTimeline(int pos) -{ - if (m_trackMode) { - emit seekTimeline(pos); - } else if (m_clipref) { - emit seekTimeline(m_clipref->startPos().frames(KdenliveSettings::project_fps()) + pos); - } -} - -void EffectStackView::slotUpdateCheckAllButton() -{ - bool hasEnabled = false; - bool hasDisabled = false; - for (int i = 0; i < m_ui.effectlist->count(); ++i) { - if (m_ui.effectlist->item(i)->checkState() == Qt::Checked) - hasEnabled = true; - else - hasDisabled = true; - } - - m_ui.checkAll->blockSignals(true); - if (hasEnabled && hasDisabled) - m_ui.checkAll->setCheckState(Qt::PartiallyChecked); - else if (hasEnabled) - m_ui.checkAll->setCheckState(Qt::Checked); - else - m_ui.checkAll->setCheckState(Qt::Unchecked); - m_ui.checkAll->blockSignals(false); -} - -void EffectStackView::slotCheckAll(int state) -{ - if (state == 1) { - state = 2; - m_ui.checkAll->blockSignals(true); - m_ui.checkAll->setCheckState(Qt::Checked); - m_ui.checkAll->blockSignals(false); - } - - bool disabled = (state != 2); - m_effectedit->updateParameter("disable", QString::number((int) disabled)); - for (int i = 0; i < m_ui.effectlist->count(); ++i) { - if (m_ui.effectlist->item(i)->checkState() != (Qt::CheckState)state) { - m_ui.effectlist->item(i)->setCheckState((Qt::CheckState)state); - if (m_trackMode) - emit changeEffectState(NULL, m_trackindex, i, disabled); - else - emit changeEffectState(m_clipref, -1, i, disabled); - } - } -} - -/*void EffectStackView::slotRegionChanged() -{ - if (!m_trackMode) emit updateClipRegion(m_clipref, m_ui.effectlist->currentRow(), m_ui.region_url->text()); -}*/ - -void EffectStackView::slotCheckMonitorPosition(int renderPos) -{ - if (m_trackMode || (m_clipref && renderPos >= m_clipref->startPos().frames(KdenliveSettings::project_fps()) && renderPos <= m_clipref->endPos().frames(KdenliveSettings::project_fps()))) { - if (!m_monitor->getEffectEdit()->getScene()->views().at(0)->isVisible()) - m_monitor->slotShowEffectScene(true); - } else { - m_monitor->slotShowEffectScene(false); - } -} - -void EffectStackView::slotRenderPos(int pos) -{ - if (m_effectedit) { - if (m_trackMode) { - m_effectedit->slotSyncEffectsPos(pos); - } else if (m_clipref) { - m_effectedit->slotSyncEffectsPos(pos - m_clipref->startPos().frames(KdenliveSettings::project_fps())); - } - } -} - -int EffectStackView::isTrackMode(bool *ok) const -{ - *ok = m_trackMode; - return m_trackindex; -} - -void EffectStackView::slotShowComments() -{ - m_ui.labelComment->setHidden(!m_ui.buttonShowComments->isChecked() || !m_ui.labelComment->text().count()); - emit showComments(m_ui.buttonShowComments->isChecked()); -} - -void EffectStackView::slotStartFilterJob(const QString&filterName, const QString&filterParams, const QString&finalFilterName, const QString&consumer, const QString&consumerParams, const QString&properties) -{ - if (!m_clipref) return; - emit startFilterJob(m_clipref->info(), m_clipref->clipProducer(), filterName, filterParams, finalFilterName, consumer, consumerParams, properties); -} - -#include "effectstackview.moc" diff --git a/src/effectstackview.h b/src/effectstackview.h deleted file mode 100644 index c2a4e2bd..00000000 --- a/src/effectstackview.h +++ /dev/null @@ -1,170 +0,0 @@ -/*************************************************************************** - effecstackview.h - description - ------------------- - begin : Feb 15 2008 - copyright : (C) 2008 by Marco Gittler - email : g.marco@freenet.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -/** - * @class EffectStackView - * @brief View part of the EffectStack - * @author Marco Gittler - */ - -#ifndef EFFECTSTACKVIEW_H -#define EFFECTSTACKVIEW_H - -#include "ui_effectstack_ui.h" -#include "effectstackedit.h" - -class EffectsList; -class ClipItem; -class MltVideoProfile; -class Monitor; - -class EffectStackView : public QWidget -{ - Q_OBJECT - -public: - EffectStackView(Monitor *monitor, QWidget *parent = 0); - virtual ~EffectStackView(); - - /** @brief Raises @param dock if a clip is loaded. */ - void raiseWindow(QWidget* dock); - - /** @brief Clears the list of effects and updates the buttons accordingly. */ - void clear(); - - /** @brief Sets the add effect button's menu to @param menu. */ - void setMenu(QMenu *menu); - - /** @brief Passes updates on @param profile and @param t on to the effect editor. */ - void updateProjectFormat(MltVideoProfile profile, Timecode t); - - /** @brief Tells the effect editor to update its timecode format. */ - void updateTimecodeFormat(); - - /** @brief return the index of the track displayed in effect stack - ** @param ok set to true if we are looking at a track's effects, otherwise false. */ - int isTrackMode(bool *ok) const; - -private: - Ui::EffectStack_UI m_ui; - Monitor *m_monitor; - ClipItem* m_clipref; - QMap m_effectLists; - EffectsList m_currentEffectList; - EffectStackEdit* m_effectedit; - - /** @brief Effectstackview can show the effects of a clip or the effects of a track. - * true if showing track effects. */ - bool m_trackMode; - - /** @brief The track index of currently edited track. */ - int m_trackindex; - - /** If in track mode: Info of the edited track to be able to access its duration. */ - TrackInfo m_trackInfo; - - /** @brief Sets the list of effects according to the clip's effect list. - * @param ix Number of the effect to preselect */ - void setupListView(int ix); - -public slots: - /** @brief Sets the clip whose effect list should be managed. - * @param c Clip whose effect list should be managed - * @param ix Effect to preselect */ - void slotClipItemSelected(ClipItem* c, int ix); - - void slotTrackItemSelected(int ix, const TrackInfo info); - - /** @brief Emits updateClipEffect. - * @param old Old effect information - * @param e New effect information - * - * Connected to a parameter change in the editor */ - void slotUpdateEffectParams(const QDomElement &old, const QDomElement &e); - - /** @brief Removes the selected effect. */ - void slotItemDel(); - -private slots: - /** @brief Updates buttons and the editor according to selected effect. - * @param update (optional) Set the clip's selected effect (display keyframes in timeline) */ - void slotItemSelectionChanged(bool update = true); - - /** @brief Moves the selected effect upwards. */ - void slotItemUp(); - - /** @brief Moves the selected effect downwards. */ - void slotItemDown(); - - /** @brief Resets the selected effect to its default values. */ - void slotResetEffect(); - - /** @brief Updates effect @param item if it was enabled or disabled. */ - void slotItemChanged(QListWidgetItem *item); - - /** @brief Saves the selected effect's values to a custom effect. - * - * TODO: save all effects into one custom effect */ - void slotSaveEffect(); - - /** @brief Emits seekTimeline with position = clipstart + @param pos. */ - void slotSeekTimeline(int pos); - - /** @brief Makes the check all checkbox represent the check state of the effects. */ - void slotUpdateCheckAllButton(); - - /** @brief Sets the check state of all effects according to @param state. */ - void slotCheckAll(int state); - - /* @brief Define the region filter for current effect. - void slotRegionChanged();*/ - - /** @brief Checks whether the monitor scene has to be displayed. */ - void slotCheckMonitorPosition(int renderPos); - - /** @brief Pass position changes of the timeline cursor to the effects to keep their local timelines in sync. */ - void slotRenderPos(int pos); - - /** @brief Shows/Hides the comment box and emits showComments to notify the parameter widgets to do the same. */ - void slotShowComments(); - - /** @brief Triggers a filter job on this clip. */ - void slotStartFilterJob(const QString&filterName, const QString&filterParams, const QString&finalFilterName, const QString&consumer, const QString&consumerParams, const QString&properties); - -signals: - void removeEffect(ClipItem*, int, QDomElement); - /** Parameters for an effect changed, update the filter in playlist */ - void updateEffect(ClipItem*, int, QDomElement, QDomElement, int); - /** An effect in stack was moved, we need to regenerate - all effects for this clip in the playlist */ - void refreshEffectStack(ClipItem *); - /** Enable or disable an effect */ - void changeEffectState(ClipItem*, int, int, bool); - /** An effect in stack was moved */ - void changeEffectPosition(ClipItem*, int, int, int); - /** an effect was saved, reload list */ - void reloadEffects(); - /** An effect with position parameter was changed, seek */ - void seekTimeline(int); - /** The region effect for current effect was changed */ - void updateClipRegion(ClipItem*, int, QString); - 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); -}; - -#endif -- 2.39.2