X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Feffectstackview.cpp;h=b5d80d0e004ae3b51e0f9bbdba3a182d722aba4a;hb=c199c097bfa84f1737b842f0bfeaff4b508e4513;hp=dccceb75eeedac082f8db5418083c7e05d2317fa;hpb=9b931c1ddfe43329d89ff6a55e5c6b73938f71e5;p=kdenlive diff --git a/src/effectstackview.cpp b/src/effectstackview.cpp index dccceb75..b5d80d0e 100644 --- a/src/effectstackview.cpp +++ b/src/effectstackview.cpp @@ -21,12 +21,15 @@ #include "clipitem.h" #include "mainwindow.h" #include "docclipbase.h" +#include "projectlist.h" +#include "kthumb.h" #include "kdenlivesettings.h" #include #include #include #include +#include #include #include @@ -34,16 +37,17 @@ #include -EffectStackView::EffectStackView(QWidget *parent) : +EffectStackView::EffectStackView(Monitor *monitor, QWidget *parent) : QWidget(parent) { 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.effectlist->horizontalHeader()->setVisible(false); //m_ui.effectlist->verticalHeader()->setVisible(false); m_clipref = NULL; @@ -60,10 +64,13 @@ EffectStackView::EffectStackView(QWidget *parent) : m_ui.buttonSave->setToolTip(i18n("Save effect")); m_ui.buttonReset->setIcon(KIcon("view-refresh")); m_ui.buttonReset->setToolTip(i18n("Reset effect")); + m_ui.checkAll->setToolTip(i18n("Enable/Disable all effects")); - m_ui.effectlist->setDragDropMode(QAbstractItemView::NoDragDrop);//use internal if drop is recognised right + 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.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())); @@ -71,8 +78,10 @@ EffectStackView::EffectStackView(QWidget *parent) : 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_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))); m_effectLists["audio"] = &MainWindow::audioEffects; m_effectLists["video"] = &MainWindow::videoEffects; m_effectLists["custom"] = &MainWindow::customEffects; @@ -87,6 +96,11 @@ EffectStackView::~EffectStackView() delete m_effectedit; } +void EffectStackView::updateTimecodeFormat() +{ + m_effectedit->updateTimecodeFormat(); +} + void EffectStackView::setMenu(QMenu *menu) { m_ui.buttonNew->setMenu(menu); @@ -123,7 +137,6 @@ void EffectStackView::slotSaveEffect() effectprops.setAttribute("id", name); effectprops.setAttribute("type", "custom"); - QFile file(path); if (file.open(QFile::WriteOnly | QFile::Truncate)) { QTextStream out(&file); @@ -144,6 +157,7 @@ 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) { @@ -158,7 +172,8 @@ void EffectStackView::slotClipItemSelected(ClipItem* c, int ix) if (m_clipref == NULL) { m_ui.effectlist->blockSignals(true); m_ui.effectlist->clear(); - m_effectedit->transferParamDesc(QDomElement(), 0, 0); + m_effectedit->transferParamDesc(QDomElement(), 0, 0, 0); + m_ui.region_url->clear(); m_ui.effectlist->blockSignals(false); setEnabled(false); return; @@ -171,13 +186,14 @@ void EffectStackView::slotItemChanged(QListWidgetItem *item) { bool disable = true; if (item->checkState() == Qt::Checked) disable = false; - m_ui.frame->setEnabled(!disable); + m_ui.frame_layout->setEnabled(!disable); m_ui.buttonReset->setEnabled(!disable); int activeRow = m_ui.effectlist->currentRow(); if (activeRow >= 0) { m_effectedit->updateParameter("disable", QString::number((int) disable)); emit changeEffectState(m_clipref, activeRow, disable); } + slotUpdateCheckAllButton(); } @@ -226,14 +242,19 @@ void EffectStackView::setupListView(int ix) m_ui.buttonReset->setEnabled(false); m_ui.buttonUp->setEnabled(false); m_ui.buttonDown->setEnabled(false); + m_ui.checkAll->setEnabled(false); } else { if (ix < 0) ix = 0; if (ix > m_ui.effectlist->count() - 1) 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) m_effectedit->transferParamDesc(QDomElement(), 0, 0); - else slotItemSelectionChanged(false); + if (m_ui.effectlist->count() == 0) { + m_effectedit->transferParamDesc(QDomElement(), 0, 0, 0); + m_ui.region_url->clear(); + } else slotItemSelectionChanged(false); + slotUpdateCheckAllButton(); } void EffectStackView::slotItemSelectionChanged(bool update) @@ -243,7 +264,12 @@ 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()) { - m_effectedit->transferParamDesc(m_clipref->effectAt(activeRow), m_clipref->cropStart().frames(KdenliveSettings::project_fps()), m_clipref->cropDuration().frames(KdenliveSettings::project_fps()));//minx max frame + 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->setUrl(KUrl(eff.attribute("region"))); } if (m_clipref && update) m_clipref->setSelectedEffect(activeRow); m_ui.buttonDel->setEnabled(hasItem); @@ -251,7 +277,7 @@ void EffectStackView::slotItemSelectionChanged(bool update) m_ui.buttonReset->setEnabled(hasItem && isChecked); m_ui.buttonUp->setEnabled(activeRow > 0); m_ui.buttonDown->setEnabled((activeRow < m_ui.effectlist->count() - 1) && hasItem); - m_ui.frame->setEnabled(isChecked); + m_ui.frame_layout->setEnabled(isChecked); } void EffectStackView::slotItemUp() @@ -273,6 +299,7 @@ void EffectStackView::slotItemDel() int activeRow = m_ui.effectlist->currentRow(); if (activeRow >= 0) { emit removeEffect(m_clipref, m_clipref->effectAt(activeRow)); + slotUpdateCheckAllButton(); } } @@ -293,7 +320,8 @@ void EffectStackView::slotResetEffect() if (!dom.isNull()) { dom.setAttribute("kdenlive_ix", old.attribute("kdenlive_ix")); m_clipref->initEffect(dom); - m_effectedit->transferParamDesc(dom, m_clipref->cropStart().frames(KdenliveSettings::project_fps()), m_clipref->cropDuration().frames(KdenliveSettings::project_fps()));//minx max frame + 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 updateClipEffect(m_clipref, old, dom, activeRow); } } @@ -314,15 +342,56 @@ void EffectStackView::clear() m_ui.buttonReset->setEnabled(false); m_ui.buttonUp->setEnabled(false); m_ui.buttonDown->setEnabled(false); - m_effectedit->transferParamDesc(QDomElement(), 0, 0); + m_ui.checkAll->setEnabled(false); + m_effectedit->transferParamDesc(QDomElement(), 0, 0, 0); + m_ui.region_url->clear(); m_ui.effectlist->blockSignals(false); } void EffectStackView::slotSeekTimeline(int pos) { - if (!m_clipref) return; - emit seekTimeline(m_clipref->startPos().frames(KdenliveSettings::project_fps()) + pos); + 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); + } + + for (int i = 0; i < m_ui.effectlist->count(); ++i) + m_ui.effectlist->item(i)->setCheckState((Qt::CheckState)state); +} + +void EffectStackView::slotRegionChanged() +{ + emit updateClipRegion(m_clipref, m_ui.effectlist->currentRow(), m_ui.region_url->text()); } #include "effectstackview.moc"