X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Feffectstackview.cpp;h=d6d79719ef1b861a68cf06ffac50fda5ac03c4c5;hb=6a33521fe12af44ab9abe8e09c6e007f4093b2da;hp=f9b8012333fa3f763d0a88c9aab6139d1521ca2d;hpb=e7dcc38423c07ce3f0538263e809da00bb849ff5;p=kdenlive diff --git a/src/effectstackview.cpp b/src/effectstackview.cpp index f9b80123..d6d79719 100644 --- a/src/effectstackview.cpp +++ b/src/effectstackview.cpp @@ -23,6 +23,7 @@ #include "docclipbase.h" #include "projectlist.h" #include "kthumb.h" +#include "monitorscene.h" #include "kdenlivesettings.h" #include @@ -37,20 +38,23 @@ #include -EffectStackView::EffectStackView(QWidget *parent) : - QWidget(parent) +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(m_ui.frame); + m_effectedit = new EffectStackEdit(monitor, m_ui.frame); vbox1->setContentsMargins(0, 0, 0, 0); vbox1->setSpacing(0); vbox1->addWidget(m_effectedit); m_ui.frame->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum)); - m_ui.region_url->fileDialog()->setFilter(ProjectList::getExtensions()); + //m_ui.region_url->fileDialog()->setFilter(ProjectList::getExtensions()); //m_ui.effectlist->horizontalHeader()->setVisible(false); //m_ui.effectlist->verticalHeader()->setVisible(false); - m_clipref = NULL; m_ui.buttonNew->setIcon(KIcon("document-new")); m_ui.buttonNew->setToolTip(i18n("Add new effect")); @@ -69,8 +73,8 @@ EffectStackView::EffectStackView(QWidget *parent) : m_ui.effectlist->setDragDropMode(QAbstractItemView::NoDragDrop); //use internal if drop is recognised right - 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.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())); @@ -81,6 +85,9 @@ EffectStackView::EffectStackView(QWidget *parent) : connect(m_ui.checkAll, SIGNAL(stateChanged(int)), this, SLOT(slotCheckAll(int))); connect(m_effectedit, SIGNAL(parameterChanged(const QDomElement, const QDomElement)), this , SLOT(slotUpdateEffectParams(const QDomElement, const QDomElement))); 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))); m_effectLists["audio"] = &MainWindow::audioEffects; m_effectLists["video"] = &MainWindow::videoEffects; m_effectLists["custom"] = &MainWindow::customEffects; @@ -116,11 +123,11 @@ void EffectStackView::slotSaveEffect() 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 already exists.\nDo you want to overwrite it?")) == KMessageBox::No) return; + 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_clipref->effectAt(i).cloneNode().toElement(); + QDomElement effect = m_currentEffectList.at(i).cloneNode().toElement(); doc.appendChild(doc.importNode(effect, true)); effect = doc.firstChild().toElement(); effect.removeAttribute("kdenlive_ix"); @@ -147,8 +154,10 @@ void EffectStackView::slotSaveEffect() void EffectStackView::slotUpdateEffectParams(const QDomElement old, const QDomElement e) { - if (m_clipref) - emit updateClipEffect(m_clipref, old, e, m_ui.effectlist->currentRow()); + 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) @@ -160,6 +169,15 @@ void EffectStackView::slotClipItemSelected(ClipItem* c, int ix) } else { m_clipref = c; if (c) { + QString cname = m_clipref->clipName(); + if (cname.length() > 20) { + m_ui.checkAll->setToolTip(i18n("Effects for %1").arg(cname)); + cname.truncate(17); + 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(); @@ -172,15 +190,32 @@ void EffectStackView::slotClipItemSelected(ClipItem* c, int ix) m_ui.effectlist->blockSignals(true); m_ui.effectlist->clear(); m_effectedit->transferParamDesc(QDomElement(), 0, 0, 0); - m_ui.region_url->clear(); + //m_ui.region_url->clear(); m_ui.effectlist->blockSignals(false); + m_ui.checkAll->setToolTip(QString()); + m_ui.checkAll->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; + 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 = true; @@ -190,7 +225,10 @@ void EffectStackView::slotItemChanged(QListWidgetItem *item) int activeRow = m_ui.effectlist->currentRow(); if (activeRow >= 0) { m_effectedit->updateParameter("disable", QString::number((int) disable)); - emit changeEffectState(m_clipref, activeRow, disable); + if (m_trackMode) + emit changeEffectState(NULL, m_trackindex, activeRow, disable); + else + emit changeEffectState(m_clipref, -1, activeRow, disable); } slotUpdateCheckAllButton(); } @@ -207,8 +245,8 @@ void EffectStackView::setupListView(int ix) KIcon customIcon("kdenlive-custom-effect"); QListWidgetItem* item; - for (int i = 0; i < m_clipref->effectsCount(); i++) { - const QDomElement d = m_clipref->effectAt(i); + 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; @@ -231,8 +269,10 @@ void EffectStackView::setupListView(int ix) item = new QListWidgetItem(videoIcon, i18n(namenode.toElement().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 (d.attribute("disable") == "1") + item->setCheckState(Qt::Unchecked); + else + item->setCheckState(Qt::Checked); } } if (m_ui.effectlist->count() == 0) { @@ -250,10 +290,9 @@ void EffectStackView::setupListView(int ix) } m_ui.effectlist->blockSignals(false); if (m_ui.effectlist->count() == 0) { - m_effectedit->transferParamDesc(QDomElement(), 0, 0, 0); - m_ui.region_url->clear(); - } - else slotItemSelectionChanged(false); + m_effectedit->transferParamDesc(QDomElement(), 0, 0, 0); + //m_ui.region_url->clear(); + } else slotItemSelectionChanged(false); slotUpdateCheckAllButton(); } @@ -264,14 +303,17 @@ void EffectStackView::slotItemSelectionChanged(bool update) bool isChecked = false; if (hasItem && m_ui.effectlist->currentItem()->checkState() == Qt::Checked) isChecked = true; if (hasItem && m_ui.effectlist->currentItem()->isSelected()) { - QDomElement eff = m_clipref->effectAt(activeRow); - m_effectedit->transferParamDesc(eff, - 0, - m_clipref->cropStart().frames(KdenliveSettings::project_fps()), - (m_clipref->cropStart() + m_clipref->cropDuration()).frames(KdenliveSettings::project_fps())); //minx max frame - m_ui.region_url->setText(eff.attribute("region")); + QDomElement eff = m_currentEffectList.at(activeRow); + if (m_trackMode) { + // showing track effects + m_effectedit->transferParamDesc(eff, 0, 0, -1); + } else m_effectedit->transferParamDesc(eff, + 0, + m_clipref->cropStart().frames(KdenliveSettings::project_fps()), + (m_clipref->cropStart() + m_clipref->cropDuration()).frames(KdenliveSettings::project_fps()) - 1); //minx max frame + //m_ui.region_url->setUrl(KUrl(eff.attribute("region"))); } - if (m_clipref && update) m_clipref->setSelectedEffect(activeRow); + 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); @@ -284,21 +326,24 @@ void EffectStackView::slotItemUp() { int activeRow = m_ui.effectlist->currentRow(); if (activeRow <= 0) return; - emit changeEffectPosition(m_clipref, activeRow + 1, activeRow); + 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; - emit changeEffectPosition(m_clipref, activeRow + 1, activeRow + 2); + 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) { - emit removeEffect(m_clipref, m_clipref->effectAt(activeRow)); + 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(); } } @@ -307,7 +352,7 @@ void EffectStackView::slotResetEffect() { int activeRow = m_ui.effectlist->currentRow(); if (activeRow < 0) return; - QDomElement old = m_clipref->effectAt(activeRow).cloneNode().toElement(); + QDomElement old = m_currentEffectList.at(activeRow).cloneNode().toElement(); QDomElement dom; QString effectName = m_ui.effectlist->currentItem()->text(); foreach(const QString &type, m_effectLists.keys()) { @@ -319,17 +364,24 @@ void EffectStackView::slotResetEffect() } if (!dom.isNull()) { dom.setAttribute("kdenlive_ix", old.attribute("kdenlive_ix")); - m_clipref->initEffect(dom); - m_effectedit->transferParamDesc(dom, 0, m_clipref->cropStart().frames(KdenliveSettings::project_fps()), (m_clipref->cropStart() + m_clipref->cropDuration()).frames(KdenliveSettings::project_fps()));//minx max frame - m_ui.region_url->setText(dom.attribute("region")); - emit updateClipEffect(m_clipref, old, dom, activeRow); + if (m_trackMode) { + EffectsList::setParameter(dom, "in", QString::number(0)); + EffectsList::setParameter(dom, "out", QString::number(0)); + m_effectedit->transferParamDesc(dom, 0, 0, 0);//minx max frame + emit updateEffect(NULL, m_trackindex, old, dom, activeRow); + } else { + m_clipref->initEffect(dom); + m_effectedit->transferParamDesc(dom, 0, m_clipref->cropStart().frames(KdenliveSettings::project_fps()), (m_clipref->cropStart() + m_clipref->cropDuration()).frames(KdenliveSettings::project_fps()));//minx max frame + //m_ui.region_url->setUrl(KUrl(dom.attribute("region"))); + emit updateEffect(m_clipref, -1, old, dom, activeRow); + } } } void EffectStackView::raiseWindow(QWidget* dock) { - if (m_clipref && dock) + if ((m_clipref || m_trackMode) && dock) dock->raise(); } @@ -344,14 +396,14 @@ void EffectStackView::clear() m_ui.buttonDown->setEnabled(false); m_ui.checkAll->setEnabled(false); m_effectedit->transferParamDesc(QDomElement(), 0, 0, 0); - m_ui.region_url->clear(); + //m_ui.region_url->clear(); m_ui.effectlist->blockSignals(false); } void EffectStackView::slotSeekTimeline(int pos) { - if (m_clipref) + if (!m_trackMode && m_clipref) emit seekTimeline(m_clipref->startPos().frames(KdenliveSettings::project_fps()) + pos); } @@ -385,13 +437,44 @@ void EffectStackView::slotCheckAll(int state) m_ui.checkAll->blockSignals(false); } - for (int i = 0; i < m_ui.effectlist->count(); ++i) - m_ui.effectlist->item(i)->setCheckState((Qt::CheckState)state); + 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 || (renderPos >= m_clipref->startPos().frames(KdenliveSettings::project_fps()) && renderPos <= m_clipref->endPos().frames(KdenliveSettings::project_fps()))) { + if (!m_monitor->getEffectScene()->views().at(0)->isVisible()) + m_monitor->slotEffectScene(true); + } else { + m_monitor->slotEffectScene(false); + } +} + +void EffectStackView::slotRenderPos(int pos) +{ + if (m_clipref && m_effectedit && !m_trackMode) + m_effectedit->slotSyncEffectsPos(pos - m_clipref->startPos().frames(KdenliveSettings::project_fps())); } -void EffectStackView::slotRegionChanged() +int EffectStackView::isTrackMode(bool *ok) const { - emit updateClipRegion(m_clipref, m_ui.effectlist->currentRow(), m_ui.region_url->text()); + *ok = m_trackMode; + return m_trackindex; } #include "effectstackview.moc"