1 /***************************************************************************
2 * Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include "collapsibleeffect.h"
23 #include "ui_listval_ui.h"
24 #include "ui_boolval_ui.h"
25 #include "ui_wipeval_ui.h"
26 #include "ui_urlval_ui.h"
27 #include "ui_keywordval_ui.h"
28 #include "ui_fontval_ui.h"
29 #include "complexparameter.h"
30 #include "geometryval.h"
31 #include "positionedit.h"
32 #include "projectlist.h"
33 #include "effectslist.h"
34 #include "kdenlivesettings.h"
35 #include "profilesdialog.h"
36 #include "kis_curve_widget.h"
37 #include "kis_cubic_curve.h"
38 #include "choosecolorwidget.h"
39 #include "geometrywidget.h"
40 #include "colortools.h"
41 #include "doubleparameterwidget.h"
42 #include "cornerswidget.h"
43 #include "dragvalue.h"
44 #include "beziercurve/beziersplinewidget.h"
46 #include "rotoscoping/rotowidget.h"
49 #include <QInputDialog>
52 #include <QVBoxLayout>
55 #include <KGlobalSettings>
57 #include <KMessageBox>
58 #include <KStandardDirs>
59 #include <KFileDialog>
60 #include <KUrlRequester>
61 #include <KColorScheme>
63 class Boolval: public QWidget, public Ui::Boolval_UI
67 class Listval: public QWidget, public Ui::Listval_UI
71 class Wipeval: public QWidget, public Ui::Wipeval_UI
75 class Urlval: public QWidget, public Ui::Urlval_UI
79 class Keywordval: public QWidget, public Ui::Keywordval_UI
83 class Fontval: public QWidget, public Ui::Fontval_UI
87 QMap<QString, QImage> CollapsibleEffect::iconCache;
89 void clearLayout(QLayout *layout)
92 while((item = layout->takeAt(0))) {
94 clearLayout(item->layout());
95 delete item->layout();
98 delete item->widget();
104 MySpinBox::MySpinBox(QWidget * parent):
107 setFocusPolicy(Qt::StrongFocus);
110 void MySpinBox::focusInEvent(QFocusEvent*)
112 setFocusPolicy(Qt::WheelFocus);
115 void MySpinBox::focusOutEvent(QFocusEvent*)
117 setFocusPolicy(Qt::StrongFocus);
121 CollapsibleEffect::CollapsibleEffect(QDomElement effect, QDomElement original_effect, ItemInfo info, int ix, EffectMetaInfo *metaInfo, bool lastEffect, bool isGroup, QWidget * parent) :
125 m_original_effect(original_effect),
126 m_lastEffect(lastEffect),
131 //setMouseTracking(true);
133 filterWheelEvent = true;
134 m_info.fromString(effect.attribute("kdenlive_info"));
135 //frame->setBackgroundRole(QPalette::Midlight);
136 //frame->setAutoFillBackground(true);
137 setFont(KGlobalSettings::smallestReadableFont());
139 buttonUp->setIcon(KIcon("kdenlive-up"));
140 buttonUp->setToolTip(i18n("Move effect up"));
142 buttonDown->setIcon(KIcon("kdenlive-down"));
143 buttonDown->setToolTip(i18n("Move effect down"));
145 buttonDel->setIcon(KIcon("kdenlive-deleffect"));
146 buttonDel->setToolTip(i18n("Delete effect"));
147 if (effectIndex() == 1) buttonUp->setVisible(false);
148 if (m_lastEffect) buttonDown->setVisible(false);
149 //buttonUp->setVisible(false);
150 //buttonDown->setVisible(false);
152 /*buttonReset->setIcon(KIcon("view-refresh"));
153 buttonReset->setToolTip(i18n("Reset effect"));*/
154 //checkAll->setToolTip(i18n("Enable/Disable all effects"));
155 //buttonShowComments->setIcon(KIcon("help-about"));
156 //buttonShowComments->setToolTip(i18n("Show additional information for the parameters"));
158 m_menu->addAction(KIcon("view-refresh"), i18n("Reset effect"), this, SLOT(slotResetEffect()));
159 m_menu->addAction(KIcon("document-save"), i18n("Save effect"), this, SLOT(slotSaveEffect()));
162 QDomElement namenode = m_effect.firstChildElement("name");
163 if (namenode.isNull()) return;
164 title->setText(i18n(namenode.text().toUtf8().data()));
165 QString type = m_effect.attribute("type", QString());
167 if (type == "audio") icon = KIcon("kdenlive-show-audio");
168 else if (m_effect.attribute("tag") == "region") icon = KIcon("kdenlive-mask-effect");
169 else if (type == "custom") icon = KIcon("kdenlive-custom-effect");
170 else icon = KIcon("kdenlive-show-video");
171 effecticon->setPixmap(icon.pixmap(16,16));
172 m_menu->addAction(KIcon("folder-new"), i18n("Create Group"), this, SLOT(slotCreateGroup()));
173 setupWidget(info, ix, metaInfo);
176 title->setText(i18n("Effect Group"));
177 effecticon->setPixmap(KIcon("folder").pixmap(16,16));
178 m_menu->addAction(KIcon("list-remove"), i18n("Ungroup"), this, SLOT(slotUnGroup()));
180 setAcceptDrops(true);
181 menuButton->setIcon(KIcon("kdenlive-menu"));
182 menuButton->setMenu(m_menu);
184 if (m_effect.attribute("disable") == "1") {
185 title->setEnabled(false);
186 enabledBox->setChecked(false);
189 enabledBox->setChecked(true);
192 connect(collapseButton, SIGNAL(clicked()), this, SLOT(slotSwitch()));
193 connect(enabledBox, SIGNAL(toggled(bool)), this, SLOT(slotEnable(bool)));
194 connect(buttonUp, SIGNAL(clicked()), this, SLOT(slotEffectUp()));
195 connect(buttonDown, SIGNAL(clicked()), this, SLOT(slotEffectDown()));
196 connect(buttonDel, SIGNAL(clicked()), this, SLOT(slotDeleteEffect()));
198 Q_FOREACH( QSpinBox * sp, findChildren<QSpinBox*>() ) {
199 sp->installEventFilter( this );
200 sp->setFocusPolicy( Qt::StrongFocus );
202 Q_FOREACH( KComboBox * cb, findChildren<KComboBox*>() ) {
203 cb->installEventFilter( this );
204 cb->setFocusPolicy( Qt::StrongFocus );
206 Q_FOREACH( QProgressBar * cb, findChildren<QProgressBar*>() ) {
207 cb->installEventFilter( this );
208 cb->setFocusPolicy( Qt::StrongFocus );
212 CollapsibleEffect::~CollapsibleEffect()
214 if (m_paramWidget) delete m_paramWidget;
219 const QString CollapsibleEffect::getStyleSheet(QPalette p)
221 KColorScheme scheme(p.currentColorGroup(), KColorScheme::View, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
222 QColor dark_bg = scheme.shade(KColorScheme::DarkShade);
223 QColor selected_bg = scheme.decoration(KColorScheme::FocusColor).color();
224 QColor hover_bg = scheme.decoration(KColorScheme::HoverColor).color();
225 QColor light_bg = scheme.shade(KColorScheme::LightShade);
226 QColor normal_bg = scheme.background(KColorScheme::NormalBackground).color();
228 KColorScheme scheme2(p.currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
229 QColor normal_bg2 = scheme2.background(KColorScheme::NormalBackground).color();
231 QString stylesheet(QString("QProgressBar::chunk:horizontal {background: %6;border-top-left-radius: 4px;border-bottom-left-radius: 4px;} QProgressBar::chunk:horizontal#dragOnly {background: %5;border-top-left-radius: 4px;border-bottom-left-radius: 4px;} QProgressBar::chunk:horizontal:hover {background: %3;}\
232 QProgressBar:horizontal {border: 1px solid %1;border-top-left-radius: 4px;border-bottom-left-radius: 4px;border-right:0px;background:%5;padding: 0px;text-align:left center}\
233 QProgressBar:horizontal:disabled {border: 1px solid %6} QProgressBar:horizontal#dragOnly {background: %5}\
234 QProgressBar:horizontal[inTimeline=\"true\"] { border: 1px solid %2;border-right: 0px;background: %4;padding: 0px;text-align:left center } QProgressBar::chunk:horizontal[inTimeline=\"true\"] {background: %2;}\
235 QAbstractSpinBox#dragBox {border: 1px solid %1;border-top-right-radius: 4px;border-bottom-right-radius: 4px;padding-right:0px;} QAbstractSpinBox::down-button#dragBox {width:0px;padding:0px;}\
236 QAbstractSpinBox:disabled#dragBox {border: 1px solid %6;}\
237 QAbstractSpinBox::up-button#dragBox {width:0px;padding:0px;} QAbstractSpinBox[inTimeline=\"true\"]#dragBox { border: 1px solid %2;} QAbstractSpinBox:hover#dragBox {border: 1px solid %3;} ")
238 .arg(dark_bg.name()).arg(hover_bg.name()).arg(selected_bg.name()).arg(light_bg.name()).arg(normal_bg.name()).arg(normal_bg2.name()));
240 QPalette p = QApplication::palette();
241 KColorScheme scheme(p.currentColorGroup(), KColorScheme::View, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
242 QColor dark_bg = scheme.shade(KColorScheme::DarkShade);
243 QColor selected_bg = scheme.decoration(KColorScheme::FocusColor).color();
244 QColor hover_bg = scheme.decoration(KColorScheme::HoverColor).color();
245 QColor light_bg = scheme.shade(KColorScheme::LightShade);
246 QColor normal_bg = scheme.background(KColorScheme::NormalBackground).color();
248 KColorScheme scheme2(p.currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
249 QColor normal_bg2 = scheme2.background(KColorScheme::NormalBackground).color();
251 QString stylesheet(QString("QProgressBar::chunk:horizontal {background: %6;border-top-left-radius: 4px;border-bottom-left-radius: 4px;} QProgressBar::chunk:horizontal#dragOnly {background: %5;border-top-left-radius: 4px;border-bottom-left-radius: 4px;} QProgressBar::chunk:horizontal:hover {background: %3;}\
252 QProgressBar:horizontal {border: 1px solid %1;border-top-left-radius: 4px;border-bottom-left-radius: 4px;border-right:0px;background:%5;padding: 0px;text-align:left center}\
253 QProgressBar:horizontal:disabled {border: 1px solid %6} QProgressBar:horizontal#dragOnly {background: %5}\
254 QProgressBar:horizontal[inTimeline=\"true\"] { border: 1px solid %2;border-right: 0px;background: %4;padding: 0px;text-align:left center } QProgressBar::chunk:horizontal[inTimeline=\"true\"] {background: %2;}\
255 QAbstractSpinBox#dragBox {border: 1px solid %1;border-top-right-radius: 4px;border-bottom-right-radius: 4px;padding-right:0px;} QAbstractSpinBox::down-button#dragBox {width:0px;padding:0px;}\
256 QAbstractSpinBox:disabled#dragBox {border: 1px solid %6;}\
257 QAbstractSpinBox::up-button#dragBox {width:0px;padding:0px;} QAbstractSpinBox[inTimeline=\"true\"]#dragBox { border: 1px solid %2;} QAbstractSpinBox:hover#dragBox {border: 1px solid %3;} ")
258 .arg(dark_bg.name()).arg(hover_bg.name()).arg(selected_bg.name()).arg(light_bg.name()).arg(normal_bg.name()).arg(normal_bg2.name()));
262 void CollapsibleEffect::slotCreateGroup()
264 emit createGroup(effectIndex());
267 void CollapsibleEffect::slotUnGroup()
272 bool CollapsibleEffect::eventFilter( QObject * o, QEvent * e )
274 if (e->type() == QEvent::Wheel) {
275 QWheelEvent *we = static_cast<QWheelEvent *>(e);
276 if (!filterWheelEvent || we->modifiers() != Qt::NoModifier) {
280 if (qobject_cast<QAbstractSpinBox*>(o)) {
281 if(qobject_cast<QAbstractSpinBox*>(o)->focusPolicy() == Qt::WheelFocus)
292 if (qobject_cast<KComboBox*>(o)) {
293 if(qobject_cast<KComboBox*>(o)->focusPolicy() == Qt::WheelFocus)
304 if (qobject_cast<QProgressBar*>(o)) {
305 if(qobject_cast<QProgressBar*>(o)->focusPolicy() == Qt::WheelFocus)
317 return QWidget::eventFilter(o, e);
320 QDomElement CollapsibleEffect::effect() const
325 bool CollapsibleEffect::isActive() const
330 void CollapsibleEffect::setActive(bool activate, bool focused)
334 frame->setBackgroundRole(QPalette::Highlight);
335 frame->setAutoFillBackground(true);
338 frame->setBackgroundRole(QPalette::Window);
339 frame->setAutoFillBackground(false);
341 setBackgroundRole(QPalette::Mid);
342 setAutoFillBackground(true);
344 else setAutoFillBackground(false);
345 //title->setDown(m_active);
346 //frame->setBackgroundRole(m_active ? QPalette::Mid : QPalette::Midlight);
350 void CollapsibleEffect::mouseDoubleClickEvent ( QMouseEvent * event )
352 if (frame->underMouse() && collapseButton->isEnabled()) slotSwitch();
353 QWidget::mouseDoubleClickEvent(event);
356 void CollapsibleEffect::mousePressEvent ( QMouseEvent *event )
358 if (!m_active && !isGroup()) emit activateEffect(effectIndex());
359 QWidget::mousePressEvent(event);
362 void CollapsibleEffect::enterEvent ( QEvent * event )
364 //buttonDel->setVisible(true);
365 //menuButton->setVisible(true);
366 QWidget::enterEvent(event);
369 void CollapsibleEffect::leaveEvent ( QEvent * event )
371 QWidget::leaveEvent(event);
374 void CollapsibleEffect::slotEnable(bool enable)
376 title->setEnabled(enable);
377 enabledBox->blockSignals(true);
378 enabledBox->setChecked(enable);
379 enabledBox->blockSignals(false);
381 QVBoxLayout *vbox = static_cast<QVBoxLayout *>(widgetFrame->layout());
382 if (vbox == NULL) return;
383 for (int i = 0; i < vbox->count(); i++) {
384 CollapsibleEffect *e = static_cast<CollapsibleEffect *>(vbox->itemAt(i)->widget());
385 if (e) e->enabledBox->setChecked(enable);// slotEnable(enable);
388 m_effect.setAttribute("disable", enable ? 0 : 1);
389 if (enable || KdenliveSettings::disable_effect_parameters()) {
390 widgetFrame->setEnabled(enable);
392 emit effectStateChanged(!enable, effectIndex());
396 void CollapsibleEffect::slotDeleteEffect()
398 if (!m_isGroup) emit deleteEffect(m_effect);
401 void CollapsibleEffect::slotEffectUp()
403 if (!m_isGroup) emit changeEffectPosition(effectIndex(), true);
406 void CollapsibleEffect::slotEffectDown()
408 if (!m_isGroup) emit changeEffectPosition(effectIndex(), false);
411 void CollapsibleEffect::slotSaveEffect()
413 QString name = QInputDialog::getText(this, i18n("Save Effect"), i18n("Name for saved effect: "));
414 if (name.isEmpty()) return;
415 QString path = KStandardDirs::locateLocal("appdata", "effects/", true);
416 path = path + name + ".xml";
417 if (QFile::exists(path)) if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", path)) == KMessageBox::No) return;
420 QDomElement effect = m_effect.cloneNode().toElement();
421 doc.appendChild(doc.importNode(effect, true));
422 effect = doc.firstChild().toElement();
423 effect.removeAttribute("kdenlive_ix");
424 effect.setAttribute("id", name);
425 effect.setAttribute("type", "custom");
426 QDomElement effectname = effect.firstChildElement("name");
427 effect.removeChild(effectname);
428 effectname = doc.createElement("name");
429 QDomText nametext = doc.createTextNode(name);
430 effectname.appendChild(nametext);
431 effect.insertBefore(effectname, QDomNode());
432 QDomElement effectprops = effect.firstChildElement("properties");
433 effectprops.setAttribute("id", name);
434 effectprops.setAttribute("type", "custom");
437 if (file.open(QFile::WriteOnly | QFile::Truncate)) {
438 QTextStream out(&file);
439 out << doc.toString();
442 emit reloadEffects();
445 void CollapsibleEffect::slotResetEffect()
447 emit resetEffect(effectIndex());
450 void CollapsibleEffect::slotSwitch()
452 bool enable = !widgetFrame->isVisible();
456 void CollapsibleEffect::slotShow(bool show)
458 widgetFrame->setVisible(show);
460 collapseButton->setArrowType(Qt::DownArrow);
461 m_info.isCollapsed = false;
464 collapseButton->setArrowType(Qt::RightArrow);
465 m_info.isCollapsed = true;
467 m_effect.setAttribute("kdenlive_info", m_info.toString());
468 emit parameterChanged(m_original_effect, m_effect, effectIndex());
471 void CollapsibleEffect::updateGroupIndex(int groupIndex)
473 m_info.groupIndex = groupIndex;
474 m_effect.setAttribute("kdenlive_info", m_info.toString());
475 emit parameterChanged(m_original_effect, m_effect, effectIndex());
478 void CollapsibleEffect::setGroupIndex(int ix)
480 m_info.groupIndex = ix;
483 void CollapsibleEffect::addGroupEffect(CollapsibleEffect *effect)
485 QVBoxLayout *vbox = static_cast<QVBoxLayout *>(widgetFrame->layout());
487 vbox = new QVBoxLayout();
488 vbox->setContentsMargins(10, 0, 0, 0);
490 widgetFrame->setLayout(vbox);
492 effect->setGroupIndex(groupIndex());
493 vbox->addWidget(effect);
496 QString CollapsibleEffect::infoString() const
498 return m_info.toString();
501 void CollapsibleEffect::removeGroup(int ix, QVBoxLayout *layout)
503 QVBoxLayout *vbox = static_cast<QVBoxLayout *>(widgetFrame->layout());
504 if (vbox == NULL) return;
506 for (int j = vbox->count() - 1; j >= 0; j--) {
507 QLayoutItem *child = vbox->takeAt(j);
508 CollapsibleEffect *e = static_cast<CollapsibleEffect *>(child->widget());
509 layout->insertWidget(ix, e);
510 e->updateGroupIndex(-1);
515 int CollapsibleEffect::index() const
520 int CollapsibleEffect::groupIndex() const
522 if (m_isGroup) return m_index;
526 bool CollapsibleEffect::isGroup() const
531 int CollapsibleEffect::effectIndex() const
533 if (m_effect.isNull()) return -1;
534 return m_effect.attribute("kdenlive_ix").toInt();
537 void CollapsibleEffect::updateWidget(ItemInfo info, int index, QDomElement effect, EffectMetaInfo *metaInfo)
541 delete m_paramWidget;
542 m_paramWidget = NULL;
545 setupWidget(info, index, metaInfo);
548 void CollapsibleEffect::setupWidget(ItemInfo info, int index, EffectMetaInfo *metaInfo)
550 if (m_effect.isNull()) {
551 // kDebug() << "// EMPTY EFFECT STACK";
555 if (m_effect.attribute("tag") == "region") {
556 QVBoxLayout *vbox = new QVBoxLayout(widgetFrame);
557 vbox->setContentsMargins(2, 0, 2, 0);
559 QDomNodeList effects = m_effect.elementsByTagName("effect");
560 QDomNodeList origin_effects = m_original_effect.elementsByTagName("effect");
561 QWidget *container = new QWidget(widgetFrame);
562 vbox->addWidget(container);
563 m_paramWidget = new ParameterContainer(m_effect.toElement(), info, metaInfo, index, container);
564 for (int i = 0; i < effects.count(); i++) {
565 CollapsibleEffect *coll = new CollapsibleEffect(effects.at(i).toElement(), origin_effects.at(i).toElement(), info, i, metaInfo, container);
566 m_subParamWidgets.append(coll);
567 //container = new QWidget(widgetFrame);
568 vbox->addWidget(coll);
569 //p = new ParameterContainer(effects.at(i).toElement(), info, isEffect, container);
574 m_paramWidget = new ParameterContainer(m_effect, info, metaInfo, index, widgetFrame);
575 if (m_effect.firstChildElement("parameter").isNull()) {
576 // Effect has no parameter, don't allow expand
577 collapseButton->setEnabled(false);
578 collapseButton->setVisible(false);
579 widgetFrame->setVisible(false);
582 if (collapseButton->isEnabled() && m_info.isCollapsed) {
583 widgetFrame->setVisible(false);
584 collapseButton->setArrowType(Qt::RightArrow);
587 connect (m_paramWidget, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int)), this, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int)));
589 connect(m_paramWidget, SIGNAL(startFilterJob(QString,QString,QString,QString,QString,QString)), this, SIGNAL(startFilterJob(QString,QString,QString,QString,QString,QString)));
591 connect (this, SIGNAL(syncEffectsPos(int)), m_paramWidget, SIGNAL(syncEffectsPos(int)));
592 connect (this, SIGNAL(effectStateChanged(bool)), m_paramWidget, SIGNAL(effectStateChanged(bool)));
593 connect (m_paramWidget, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
594 connect (m_paramWidget, SIGNAL(seekTimeline(int)), this, SIGNAL(seekTimeline(int)));
599 void CollapsibleEffect::updateTimecodeFormat()
601 m_paramWidget->updateTimecodeFormat();
602 if (!m_subParamWidgets.isEmpty()) {
604 for (int i = 0; i < m_subParamWidgets.count(); i++)
605 m_subParamWidgets.at(i)->updateTimecodeFormat();
609 void CollapsibleEffect::slotSyncEffectsPos(int pos)
611 emit syncEffectsPos(pos);
614 void CollapsibleEffect::dragEnterEvent(QDragEnterEvent *event)
616 if (event->mimeData()->hasFormat("kdenlive/effectslist")) {
617 setActive(m_active, true);
618 event->acceptProposedAction();
622 void CollapsibleEffect::dragLeaveEvent(QDragLeaveEvent */*event*/)
624 setActive(m_active, false);
627 void CollapsibleEffect::dropEvent(QDropEvent *event)
629 setActive(m_active, false);
630 const QString effects = QString::fromUtf8(event->mimeData()->data("kdenlive/effectslist"));
631 //event->acceptProposedAction();
633 doc.setContent(effects, true);
634 QDomElement e = doc.documentElement();
635 int ix = e.attribute("kdenlive_ix").toInt();
636 if (ix == effectIndex()) {
637 // effect dropped on itself, reject
642 // effect dropped from effects list, add it
643 e.setAttribute("kdenlive_ix", ix);
644 event->setDropAction(Qt::CopyAction);
651 QVBoxLayout *vbox = static_cast<QVBoxLayout *>(widgetFrame->layout());
652 if (vbox == NULL) return;
653 CollapsibleEffect *e = static_cast<CollapsibleEffect *>(vbox->itemAt(vbox->count() -1)->widget());
654 new_index = e->effectIndex();
657 new_index = effectIndex();
659 emit moveEffect(ix, new_index, this);
660 event->setDropAction(Qt::MoveAction);
664 ParameterContainer::ParameterContainer(QDomElement effect, ItemInfo info, EffectMetaInfo *metaInfo, int index, QWidget * parent) :
666 m_keyframeEditor(NULL),
667 m_geometryWidget(NULL),
668 m_metaInfo(metaInfo),
671 m_in = info.cropStart.frames(KdenliveSettings::project_fps());
672 m_out = (info.cropStart + info.cropDuration).frames(KdenliveSettings::project_fps()) - 1;
674 QDomNodeList namenode = effect.childNodes(); //elementsByTagName("parameter");
676 QDomElement e = effect.toElement();
677 int minFrame = e.attribute("start").toInt();
678 int maxFrame = e.attribute("end").toInt();
679 // In transitions, maxFrame is in fact one frame after the end of transition
680 if (maxFrame > 0) maxFrame --;
682 bool disable = effect.attribute("disable") == "1" && KdenliveSettings::disable_effect_parameters();
683 parent->setEnabled(!disable);
686 m_vbox = new QVBoxLayout(parent);
687 m_vbox->setContentsMargins(2, 0, 2, 0);
688 m_vbox->setSpacing(2);
690 for (int i = 0; i < namenode.count() ; i++) {
691 QDomElement pa = namenode.item(i).toElement();
692 if (pa.tagName() != "parameter") continue;
693 QDomElement na = pa.firstChildElement("name");
694 QDomElement commentElem = pa.firstChildElement("comment");
695 QString type = pa.attribute("type");
696 QString paramName = na.isNull() ? pa.attribute("name") : i18n(na.text().toUtf8().data());
698 if (!commentElem.isNull())
699 comment = i18n(commentElem.text().toUtf8().data());
700 QWidget * toFillin = new QWidget(parent);
701 QString value = pa.attribute("value").isNull() ?
702 pa.attribute("default") : pa.attribute("value");
705 /** See effects/README for info on the different types */
707 if (type == "double" || type == "constant") {
710 if (pa.attribute("min").contains('%'))
711 min = ProfilesDialog::getStringEval(m_metaInfo->profile, pa.attribute("min"), m_metaInfo->frameSize);
713 min = pa.attribute("min").toDouble();
714 if (pa.attribute("max").contains('%'))
715 max = ProfilesDialog::getStringEval(m_metaInfo->profile, pa.attribute("max"), m_metaInfo->frameSize);
717 max = pa.attribute("max").toDouble();
719 DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, value.toDouble(), min, max,
720 pa.attribute("default").toDouble(), comment, -1, pa.attribute("suffix"), pa.attribute("decimals").toInt(), parent);
721 doubleparam->setFocusPolicy(Qt::StrongFocus);
722 m_vbox->addWidget(doubleparam);
723 m_valueItems[paramName] = doubleparam;
724 connect(doubleparam, SIGNAL(valueChanged(double)), this, SLOT(slotCollectAllParameters()));
725 connect(this, SIGNAL(showComments(bool)), doubleparam, SLOT(slotShowComment(bool)));
726 } else if (type == "list") {
727 Listval *lsval = new Listval;
728 lsval->setupUi(toFillin);
729 lsval->list->setFocusPolicy(Qt::StrongFocus);
730 QStringList listitems = pa.attribute("paramlist").split(';');
731 if (listitems.count() == 1) {
732 // probably custom effect created before change to ';' as separator
733 listitems = pa.attribute("paramlist").split(",");
735 QDomElement list = pa.firstChildElement("paramlistdisplay");
736 QStringList listitemsdisplay;
737 if (!list.isNull()) {
738 listitemsdisplay = i18n(list.text().toUtf8().data()).split(',');
740 listitemsdisplay = i18n(pa.attribute("paramlistdisplay").toUtf8().data()).split(',');
742 if (listitemsdisplay.count() != listitems.count())
743 listitemsdisplay = listitems;
744 lsval->list->setIconSize(QSize(30, 30));
745 for (int i = 0; i < listitems.count(); i++) {
746 lsval->list->addItem(listitemsdisplay.at(i), listitems.at(i));
747 QString entry = listitems.at(i);
748 if (!entry.isEmpty() && (entry.endsWith(".png") || entry.endsWith(".pgm"))) {
749 if (!CollapsibleEffect::iconCache.contains(entry)) {
751 CollapsibleEffect::iconCache[entry] = pix.scaled(30, 30);
753 lsval->list->setItemIcon(i, QPixmap::fromImage(CollapsibleEffect::iconCache[entry]));
756 if (!value.isEmpty()) lsval->list->setCurrentIndex(listitems.indexOf(value));
757 lsval->name->setText(paramName);
758 lsval->labelComment->setText(comment);
759 lsval->widgetComment->setHidden(true);
760 m_valueItems[paramName] = lsval;
761 connect(lsval->list, SIGNAL(currentIndexChanged(int)) , this, SLOT(slotCollectAllParameters()));
762 if (!comment.isEmpty())
763 connect(this, SIGNAL(showComments(bool)), lsval->widgetComment, SLOT(setVisible(bool)));
764 m_uiItems.append(lsval);
765 } else if (type == "bool") {
766 Boolval *bval = new Boolval;
767 bval->setupUi(toFillin);
768 bval->checkBox->setCheckState(value == "0" ? Qt::Unchecked : Qt::Checked);
769 bval->name->setText(paramName);
770 bval->labelComment->setText(comment);
771 bval->widgetComment->setHidden(true);
772 m_valueItems[paramName] = bval;
773 connect(bval->checkBox, SIGNAL(stateChanged(int)) , this, SLOT(slotCollectAllParameters()));
774 if (!comment.isEmpty())
775 connect(this, SIGNAL(showComments(bool)), bval->widgetComment, SLOT(setVisible(bool)));
776 m_uiItems.append(bval);
777 } else if (type == "complex") {
778 ComplexParameter *pl = new ComplexParameter;
779 pl->setupParam(effect, pa.attribute("name"), 0, 100);
780 m_vbox->addWidget(pl);
781 m_valueItems[paramName+"complex"] = pl;
782 connect(pl, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
783 } else if (type == "geometry") {
784 if (KdenliveSettings::on_monitor_effects()) {
785 m_geometryWidget = new GeometryWidget(m_metaInfo->monitor, m_metaInfo->timecode, 0, true, effect.hasAttribute("showrotation"), parent);
786 m_geometryWidget->setFrameSize(m_metaInfo->frameSize);
787 m_geometryWidget->slotShowScene(!disable);
788 // connect this before setupParam to make sure the monitor scene shows up at startup
789 connect(m_geometryWidget, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
790 connect(m_geometryWidget, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
791 if (minFrame == maxFrame)
792 m_geometryWidget->setupParam(pa, m_in, m_out);
794 m_geometryWidget->setupParam(pa, minFrame, maxFrame);
795 m_vbox->addWidget(m_geometryWidget);
796 m_valueItems[paramName+"geometry"] = m_geometryWidget;
797 connect(m_geometryWidget, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
798 connect(this, SIGNAL(syncEffectsPos(int)), m_geometryWidget, SLOT(slotSyncPosition(int)));
799 connect(this, SIGNAL(effectStateChanged(bool)), m_geometryWidget, SLOT(slotShowScene(bool)));
801 Geometryval *geo = new Geometryval(m_metaInfo->profile, m_metaInfo->timecode, m_metaInfo->frameSize, 0);
802 if (minFrame == maxFrame)
803 geo->setupParam(pa, m_in, m_out);
805 geo->setupParam(pa, minFrame, maxFrame);
806 m_vbox->addWidget(geo);
807 m_valueItems[paramName+"geometry"] = geo;
808 connect(geo, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
809 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
810 connect(this, SIGNAL(syncEffectsPos(int)), geo, SLOT(slotSyncPosition(int)));
812 } else if (type == "addedgeometry") {
813 // this is a parameter that should be linked to the geometry widget, for example rotation, shear, ...
814 if (m_geometryWidget) m_geometryWidget->addParameter(pa);
815 } else if (type == "keyframe" || type == "simplekeyframe") {
816 // keyframe editor widget
817 if (m_keyframeEditor == NULL) {
819 if (pa.attribute("widget") == "corners") {
820 // we want a corners-keyframe-widget
821 CornersWidget *corners = new CornersWidget(m_metaInfo->monitor, pa, m_in, m_out, m_metaInfo->timecode, e.attribute("active_keyframe", "-1").toInt(), parent);
822 corners->slotShowScene(!disable);
823 connect(corners, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
824 connect(this, SIGNAL(effectStateChanged(bool)), corners, SLOT(slotShowScene(bool)));
825 connect(this, SIGNAL(syncEffectsPos(int)), corners, SLOT(slotSyncPosition(int)));
826 geo = static_cast<KeyframeEdit *>(corners);
828 geo = new KeyframeEdit(pa, m_in, m_out, m_metaInfo->timecode, e.attribute("active_keyframe", "-1").toInt());
830 m_vbox->addWidget(geo);
831 m_valueItems[paramName+"keyframe"] = geo;
832 m_keyframeEditor = geo;
833 connect(geo, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
834 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
835 connect(this, SIGNAL(showComments(bool)), geo, SIGNAL(showComments(bool)));
837 // we already have a keyframe editor, so just add another column for the new param
838 m_keyframeEditor->addParameter(pa);
840 } else if (type == "color") {
841 if (value.startsWith('#'))
842 value = value.replace('#', "0x");
843 ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, value, parent);
844 m_vbox->addWidget(choosecolor);
845 m_valueItems[paramName] = choosecolor;
846 connect(choosecolor, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int)));
847 connect(choosecolor, SIGNAL(modified()) , this, SLOT(slotCollectAllParameters()));
848 } else if (type == "position") {
849 int pos = value.toInt();
850 if (effect.attribute("id") == "fadein" || effect.attribute("id") == "fade_from_black") {
852 } else if (effect.attribute("id") == "fadeout" || effect.attribute("id") == "fade_to_black") {
853 // fadeout position starts from clip end
856 PositionEdit *posedit = new PositionEdit(paramName, pos, 0, m_out - m_in, m_metaInfo->timecode);
857 m_vbox->addWidget(posedit);
858 m_valueItems[paramName+"position"] = posedit;
859 connect(posedit, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
860 } else if (type == "curve") {
861 KisCurveWidget *curve = new KisCurveWidget(parent);
862 curve->setMaxPoints(pa.attribute("max").toInt());
863 QList<QPointF> points;
864 int number = EffectsList::parameter(e, pa.attribute("number")).toInt();
865 QString inName = pa.attribute("inpoints");
866 QString outName = pa.attribute("outpoints");
867 int start = pa.attribute("min").toInt();
868 for (int j = start; j <= number; j++) {
870 in.replace("%i", QString::number(j));
871 QString out = outName;
872 out.replace("%i", QString::number(j));
873 points << QPointF(EffectsList::parameter(e, in).toDouble(), EffectsList::parameter(e, out).toDouble());
875 if (!points.isEmpty())
876 curve->setCurve(KisCubicCurve(points));
877 MySpinBox *spinin = new MySpinBox();
878 spinin->setRange(0, 1000);
879 MySpinBox *spinout = new MySpinBox();
880 spinout->setRange(0, 1000);
881 curve->setupInOutControls(spinin, spinout, 0, 1000);
882 m_vbox->addWidget(curve);
883 m_vbox->addWidget(spinin);
884 m_vbox->addWidget(spinout);
886 connect(curve, SIGNAL(modified()), this, SLOT(slotCollectAllParameters()));
887 m_valueItems[paramName] = curve;
889 QString depends = pa.attribute("depends");
890 if (!depends.isEmpty())
891 meetDependency(paramName, type, EffectsList::parameter(e, depends));
892 } else if (type == "bezier_spline") {
893 BezierSplineWidget *widget = new BezierSplineWidget(value, parent);
895 m_vbox->addWidget(widget);
896 m_valueItems[paramName] = widget;
897 connect(widget, SIGNAL(modified()), this, SLOT(slotCollectAllParameters()));
898 QString depends = pa.attribute("depends");
899 if (!depends.isEmpty())
900 meetDependency(paramName, type, EffectsList::parameter(e, depends));
902 } else if (type == "roto-spline") {
903 RotoWidget *roto = new RotoWidget(value, m_metaInfo->monitor, info, m_metaInfo->timecode, parent);
904 roto->slotShowScene(!disable);
905 connect(roto, SIGNAL(valueChanged()), this, SLOT(slotCollectAllParameters()));
906 connect(roto, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
907 connect(roto, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
908 connect(this, SIGNAL(syncEffectsPos(int)), roto, SLOT(slotSyncPosition(int)));
909 connect(this, SIGNAL(effectStateChanged(bool)), roto, SLOT(slotShowScene(bool)));
910 m_vbox->addWidget(roto);
911 m_valueItems[paramName] = roto;
913 } else if (type == "wipe") {
914 Wipeval *wpval = new Wipeval;
915 wpval->setupUi(toFillin);
916 wipeInfo w = getWipeInfo(value);
919 wpval->start_up->setChecked(true);
922 wpval->start_down->setChecked(true);
925 wpval->start_right->setChecked(true);
928 wpval->start_left->setChecked(true);
931 wpval->start_center->setChecked(true);
936 wpval->end_up->setChecked(true);
939 wpval->end_down->setChecked(true);
942 wpval->end_right->setChecked(true);
945 wpval->end_left->setChecked(true);
948 wpval->end_center->setChecked(true);
951 wpval->start_transp->setValue(w.startTransparency);
952 wpval->end_transp->setValue(w.endTransparency);
953 m_valueItems[paramName] = wpval;
954 connect(wpval->end_up, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
955 connect(wpval->end_down, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
956 connect(wpval->end_left, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
957 connect(wpval->end_right, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
958 connect(wpval->end_center, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
959 connect(wpval->start_up, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
960 connect(wpval->start_down, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
961 connect(wpval->start_left, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
962 connect(wpval->start_right, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
963 connect(wpval->start_center, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
964 connect(wpval->start_transp, SIGNAL(valueChanged(int)), this, SLOT(slotCollectAllParameters()));
965 connect(wpval->end_transp, SIGNAL(valueChanged(int)), this, SLOT(slotCollectAllParameters()));
966 //wpval->title->setTitle(na.toElement().text());
967 m_uiItems.append(wpval);
968 } else if (type == "url") {
969 Urlval *cval = new Urlval;
970 cval->setupUi(toFillin);
971 cval->label->setText(paramName);
972 cval->urlwidget->fileDialog()->setFilter(ProjectList::getExtensions());
973 m_valueItems[paramName] = cval;
974 cval->urlwidget->setUrl(KUrl(value));
975 connect(cval->urlwidget, SIGNAL(returnPressed()) , this, SLOT(slotCollectAllParameters()));
976 connect(cval->urlwidget, SIGNAL(urlSelected(const KUrl&)) , this, SLOT(slotCollectAllParameters()));
977 m_uiItems.append(cval);
978 } else if (type == "keywords") {
979 Keywordval* kval = new Keywordval;
980 kval->setupUi(toFillin);
981 kval->label->setText(paramName);
982 kval->lineeditwidget->setText(value);
983 QDomElement klistelem = pa.firstChildElement("keywords");
984 QDomElement kdisplaylistelem = pa.firstChildElement("keywordsdisplay");
985 QStringList keywordlist;
986 QStringList keyworddisplaylist;
987 if (!klistelem.isNull()) {
988 keywordlist = klistelem.text().split(';');
989 keyworddisplaylist = i18n(kdisplaylistelem.text().toUtf8().data()).split(';');
991 if (keyworddisplaylist.count() != keywordlist.count()) {
992 keyworddisplaylist = keywordlist;
994 for (int i = 0; i < keywordlist.count(); i++) {
995 kval->comboboxwidget->addItem(keyworddisplaylist.at(i), keywordlist.at(i));
997 // Add disabled user prompt at index 0
998 kval->comboboxwidget->insertItem(0, i18n("<select a keyword>"), "");
999 kval->comboboxwidget->model()->setData( kval->comboboxwidget->model()->index(0,0), QVariant(Qt::NoItemFlags), Qt::UserRole -1);
1000 kval->comboboxwidget->setCurrentIndex(0);
1001 m_valueItems[paramName] = kval;
1002 connect(kval->lineeditwidget, SIGNAL(editingFinished()) , this, SLOT(collectAllParameters()));
1003 connect(kval->comboboxwidget, SIGNAL(activated (const QString&)), this, SLOT(collectAllParameters()));
1004 m_uiItems.append(kval);
1005 } else if (type == "fontfamily") {
1006 Fontval* fval = new Fontval;
1007 fval->setupUi(toFillin);
1008 fval->name->setText(paramName);
1009 fval->fontfamilywidget->setCurrentFont(QFont(value));
1010 m_valueItems[paramName] = fval;
1011 connect(fval->fontfamilywidget, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(collectAllParameters())) ;
1012 m_uiItems.append(fval);
1013 } else if (type == "filterjob") {
1014 QVBoxLayout *l= new QVBoxLayout(toFillin);
1015 QPushButton *button = new QPushButton(paramName, toFillin);
1016 l->addWidget(button);
1017 m_valueItems[paramName] = button;
1018 connect(button, SIGNAL(pressed()), this, SLOT(slotStartFilterJobAction()));
1025 m_vbox->addWidget(toFillin);
1029 m_vbox->addStretch();
1031 if (m_keyframeEditor)
1032 m_keyframeEditor->checkVisibleParam();
1034 // Make sure all doubleparam spinboxes have the same width, looks much better
1035 QList<DoubleParameterWidget *> allWidgets = findChildren<DoubleParameterWidget *>();
1037 for (int i = 0; i < allWidgets.count(); i++) {
1038 if (minSize < allWidgets.at(i)->spinSize()) minSize = allWidgets.at(i)->spinSize();
1040 for (int i = 0; i < allWidgets.count(); i++) {
1041 allWidgets.at(i)->setSpinSize(minSize);
1045 ParameterContainer::~ParameterContainer()
1047 clearLayout(m_vbox);
1051 void ParameterContainer::meetDependency(const QString& name, QString type, QString value)
1053 if (type == "curve") {
1054 KisCurveWidget *curve = (KisCurveWidget*)m_valueItems[name];
1056 int color = value.toInt();
1057 curve->setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(curve->size(), (ColorTools::ColorsRGB)(color == 3 ? 4 : color), 0.8)));
1059 } else if (type == "bezier_spline") {
1060 BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems[name];
1062 widget->setMode((BezierSplineWidget::CurveModes)((int)(value.toDouble() * 10)));
1067 wipeInfo ParameterContainer::getWipeInfo(QString value)
1070 // Convert old geometry values that used a comma as separator
1071 if (value.contains(',')) value.replace(',','/');
1072 QString start = value.section(';', 0, 0);
1073 QString end = value.section(';', 1, 1).section('=', 1, 1);
1074 if (start.startsWith("-100%/0"))
1076 else if (start.startsWith("100%/0"))
1078 else if (start.startsWith("0%/100%"))
1080 else if (start.startsWith("0%/-100%"))
1083 info.start = CENTER;
1085 if (start.count(':') == 2)
1086 info.startTransparency = start.section(':', -1).toInt();
1088 info.startTransparency = 100;
1090 if (end.startsWith("-100%/0"))
1092 else if (end.startsWith("100%/0"))
1094 else if (end.startsWith("0%/100%"))
1096 else if (end.startsWith("0%/-100%"))
1101 if (end.count(':') == 2)
1102 info.endTransparency = end.section(':', -1).toInt();
1104 info.endTransparency = 100;
1109 void ParameterContainer::updateTimecodeFormat()
1111 if (m_keyframeEditor)
1112 m_keyframeEditor->updateTimecodeFormat();
1114 QDomNodeList namenode = m_effect.elementsByTagName("parameter");
1115 for (int i = 0; i < namenode.count() ; i++) {
1116 QDomNode pa = namenode.item(i);
1117 QDomElement na = pa.firstChildElement("name");
1118 QString type = pa.attributes().namedItem("type").nodeValue();
1119 QString paramName = na.isNull() ? pa.attributes().namedItem("name").nodeValue() : i18n(na.text().toUtf8().data());
1121 if (type == "geometry") {
1122 if (KdenliveSettings::on_monitor_effects()) {
1123 if (m_geometryWidget) m_geometryWidget->updateTimecodeFormat();
1125 Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
1126 geom->updateTimecodeFormat();
1129 } else if (type == "position") {
1130 PositionEdit *posi = ((PositionEdit*)m_valueItems[paramName+"position"]);
1131 posi->updateTimecodeFormat();
1134 } else if (type == "roto-spline") {
1135 RotoWidget *widget = static_cast<RotoWidget *>(m_valueItems[paramName]);
1136 widget->updateTimecodeFormat();
1142 void ParameterContainer::slotCollectAllParameters()
1144 if (m_valueItems.isEmpty() || m_effect.isNull()) return;
1146 locale.setNumberOptions(QLocale::OmitGroupSeparator);
1147 const QDomElement oldparam = m_effect.cloneNode().toElement();
1148 //QDomElement newparam = oldparam.cloneNode().toElement();
1149 QDomNodeList namenode = m_effect.elementsByTagName("parameter");
1151 for (int i = 0; i < namenode.count() ; i++) {
1152 QDomNode pa = namenode.item(i);
1153 QDomElement na = pa.firstChildElement("name");
1154 QString type = pa.attributes().namedItem("type").nodeValue();
1155 QString paramName = na.isNull() ? pa.attributes().namedItem("name").nodeValue() : i18n(na.text().toUtf8().data());
1156 if (type == "complex")
1157 paramName.append("complex");
1158 else if (type == "position")
1159 paramName.append("position");
1160 else if (type == "geometry")
1161 paramName.append("geometry");
1162 else if (type == "keyframe")
1163 paramName.append("keyframe");
1164 if (type != "simplekeyframe" && type != "fixed" && type != "addedgeometry" && !m_valueItems.contains(paramName)) {
1165 kDebug() << "// Param: " << paramName << " NOT FOUND";
1170 if (type == "double" || type == "constant") {
1171 DoubleParameterWidget *doubleparam = (DoubleParameterWidget*)m_valueItems.value(paramName);
1172 setValue = locale.toString(doubleparam->getValue());
1173 } else if (type == "list") {
1174 KComboBox *box = ((Listval*)m_valueItems.value(paramName))->list;
1175 setValue = box->itemData(box->currentIndex()).toString();
1176 } else if (type == "bool") {
1177 QCheckBox *box = ((Boolval*)m_valueItems.value(paramName))->checkBox;
1178 setValue = box->checkState() == Qt::Checked ? "1" : "0" ;
1179 } else if (type == "color") {
1180 ChooseColorWidget *choosecolor = ((ChooseColorWidget*)m_valueItems.value(paramName));
1181 setValue = choosecolor->getColor();
1182 } else if (type == "complex") {
1183 ComplexParameter *complex = ((ComplexParameter*)m_valueItems.value(paramName));
1184 namenode.item(i) = complex->getParamDesc();
1185 } else if (type == "geometry") {
1186 if (KdenliveSettings::on_monitor_effects()) {
1187 if (m_geometryWidget) namenode.item(i).toElement().setAttribute("value", m_geometryWidget->getValue());
1189 Geometryval *geom = ((Geometryval*)m_valueItems.value(paramName));
1190 namenode.item(i).toElement().setAttribute("value", geom->getValue());
1192 } else if (type == "addedgeometry") {
1193 namenode.item(i).toElement().setAttribute("value", m_geometryWidget->getExtraValue(namenode.item(i).toElement().attribute("name")));
1194 } else if (type == "position") {
1195 PositionEdit *pedit = ((PositionEdit*)m_valueItems.value(paramName));
1196 int pos = pedit->getPosition();
1197 setValue = QString::number(pos);
1198 if (m_effect.attribute("id") == "fadein" || m_effect.attribute("id") == "fade_from_black") {
1199 // Make sure duration is not longer than clip
1200 /*if (pos > m_out) {
1202 pedit->setPosition(pos);
1204 EffectsList::setParameter(m_effect, "in", QString::number(m_in));
1205 EffectsList::setParameter(m_effect, "out", QString::number(m_in + pos));
1207 } else if (m_effect.attribute("id") == "fadeout" || m_effect.attribute("id") == "fade_to_black") {
1208 // Make sure duration is not longer than clip
1209 /*if (pos > m_out) {
1211 pedit->setPosition(pos);
1213 EffectsList::setParameter(m_effect, "in", QString::number(m_out - pos));
1214 EffectsList::setParameter(m_effect, "out", QString::number(m_out));
1217 } else if (type == "curve") {
1218 KisCurveWidget *curve = ((KisCurveWidget*)m_valueItems.value(paramName));
1219 QList<QPointF> points = curve->curve().points();
1220 QString number = pa.attributes().namedItem("number").nodeValue();
1221 QString inName = pa.attributes().namedItem("inpoints").nodeValue();
1222 QString outName = pa.attributes().namedItem("outpoints").nodeValue();
1223 int off = pa.attributes().namedItem("min").nodeValue().toInt();
1224 int end = pa.attributes().namedItem("max").nodeValue().toInt();
1225 EffectsList::setParameter(m_effect, number, QString::number(points.count()));
1226 for (int j = 0; (j < points.count() && j + off <= end); j++) {
1227 QString in = inName;
1228 in.replace("%i", QString::number(j + off));
1229 QString out = outName;
1230 out.replace("%i", QString::number(j + off));
1231 EffectsList::setParameter(m_effect, in, locale.toString(points.at(j).x()));
1232 EffectsList::setParameter(m_effect, out, locale.toString(points.at(j).y()));
1234 QString depends = pa.attributes().namedItem("depends").nodeValue();
1235 if (!depends.isEmpty())
1236 meetDependency(paramName, type, EffectsList::parameter(m_effect, depends));
1237 } else if (type == "bezier_spline") {
1238 BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems.value(paramName);
1239 setValue = widget->spline();
1240 QString depends = pa.attributes().namedItem("depends").nodeValue();
1241 if (!depends.isEmpty())
1242 meetDependency(paramName, type, EffectsList::parameter(m_effect, depends));
1244 } else if (type == "roto-spline") {
1245 RotoWidget *widget = static_cast<RotoWidget *>(m_valueItems.value(paramName));
1246 setValue = widget->getSpline();
1248 } else if (type == "wipe") {
1249 Wipeval *wp = (Wipeval*)m_valueItems.value(paramName);
1251 if (wp->start_left->isChecked())
1253 else if (wp->start_right->isChecked())
1255 else if (wp->start_up->isChecked())
1257 else if (wp->start_down->isChecked())
1259 else if (wp->start_center->isChecked())
1260 info.start = CENTER;
1263 info.startTransparency = wp->start_transp->value();
1265 if (wp->end_left->isChecked())
1267 else if (wp->end_right->isChecked())
1269 else if (wp->end_up->isChecked())
1271 else if (wp->end_down->isChecked())
1273 else if (wp->end_center->isChecked())
1277 info.endTransparency = wp->end_transp->value();
1279 setValue = getWipeString(info);
1280 } else if ((type == "simplekeyframe" || type == "keyframe") && m_keyframeEditor) {
1281 QDomElement elem = pa.toElement();
1282 QString realName = i18n(na.toElement().text().toUtf8().data());
1283 QString val = m_keyframeEditor->getValue(realName);
1284 elem.setAttribute("keyframes", val);
1286 if (m_keyframeEditor->isVisibleParam(realName))
1287 elem.setAttribute("intimeline", "1");
1288 else if (elem.hasAttribute("intimeline"))
1289 elem.removeAttribute("intimeline");
1290 } else if (type == "url") {
1291 KUrlRequester *req = ((Urlval*)m_valueItems.value(paramName))->urlwidget;
1292 setValue = req->url().path();
1293 } else if (type == "keywords"){
1294 QLineEdit *line = ((Keywordval*)m_valueItems.value(paramName))->lineeditwidget;
1295 QComboBox *combo = ((Keywordval*)m_valueItems.value(paramName))->comboboxwidget;
1296 if(combo->currentIndex())
1298 QString comboval = combo->itemData(combo->currentIndex()).toString();
1299 line->insert(comboval);
1300 combo->setCurrentIndex(0);
1302 setValue = line->text();
1303 } else if (type == "fontfamily") {
1304 QFontComboBox* fontfamily = ((Fontval*)m_valueItems.value(paramName))->fontfamilywidget;
1305 setValue = fontfamily->currentFont().family();
1307 if (!setValue.isNull())
1308 pa.attributes().namedItem("value").setNodeValue(setValue);
1311 emit parameterChanged(oldparam, m_effect, m_effect.attribute("kdenlive_ix").toInt());
1314 QString ParameterContainer::getWipeString(wipeInfo info)
1319 switch (info.start) {
1321 start = "-100%/0%:100%x100%";
1324 start = "100%/0%:100%x100%";
1327 start = "0%/100%:100%x100%";
1330 start = "0%/-100%:100%x100%";
1333 start = "0%/0%:100%x100%";
1336 start.append(':' + QString::number(info.startTransparency));
1340 end = "-100%/0%:100%x100%";
1343 end = "100%/0%:100%x100%";
1346 end = "0%/100%:100%x100%";
1349 end = "0%/-100%:100%x100%";
1352 end = "0%/0%:100%x100%";
1355 end.append(':' + QString::number(info.endTransparency));
1356 return QString(start + ";-1=" + end);
1359 int ParameterContainer::index() const
1364 void ParameterContainer::slotStartFilterJobAction()
1366 QDomNodeList namenode = m_effect.elementsByTagName("parameter");
1367 for (int i = 0; i < namenode.count() ; i++) {
1368 QDomElement pa = namenode.item(i).toElement();
1369 QString type = pa.attribute("type");
1370 if (type == "filterjob") {
1371 emit startFilterJob(pa.attribute("filtertag"), pa.attribute("filterparams"), pa.attribute("finalfilter"), pa.attribute("consumer"), pa.attribute("consumerparams"), pa.attribute("wantedproperties"));
1372 kDebug()<<" - - -PROPS:\n"<<pa.attribute("filtertag")<<"-"<< pa.attribute("filterparams")<<"-"<< pa.attribute("consumer")<<"-"<< pa.attribute("consumerparams")<<"-"<< pa.attribute("wantedproperties");