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 filterWheelEvent = true;
132 m_info.fromString(effect.attribute("kdenlive_info"));
133 setFont(KGlobalSettings::smallestReadableFont());
135 buttonUp->setIcon(KIcon("kdenlive-up"));
136 buttonUp->setToolTip(i18n("Move effect up"));
138 buttonDown->setIcon(KIcon("kdenlive-down"));
139 buttonDown->setToolTip(i18n("Move effect down"));
141 buttonDel->setIcon(KIcon("kdenlive-deleffect"));
142 buttonDel->setToolTip(i18n("Delete effect"));
143 if (effectIndex() == 1) buttonUp->setVisible(false);
144 if (m_lastEffect) buttonDown->setVisible(false);
145 //buttonUp->setVisible(false);
146 //buttonDown->setVisible(false);
148 /*buttonReset->setIcon(KIcon("view-refresh"));
149 buttonReset->setToolTip(i18n("Reset effect"));*/
150 //checkAll->setToolTip(i18n("Enable/Disable all effects"));
151 //buttonShowComments->setIcon(KIcon("help-about"));
152 //buttonShowComments->setToolTip(i18n("Show additional information for the parameters"));
154 m_menu->addAction(KIcon("view-refresh"), i18n("Reset effect"), this, SLOT(slotResetEffect()));
155 m_menu->addAction(KIcon("document-save"), i18n("Save effect"), this, SLOT(slotSaveEffect()));
158 QDomElement namenode = m_effect.firstChildElement("name");
159 if (namenode.isNull()) return;
160 title->setText(i18n(namenode.text().toUtf8().data()));
161 QString type = m_effect.attribute("type", QString());
163 if (type == "audio") icon = KIcon("kdenlive-show-audio");
164 else if (m_effect.attribute("tag") == "region") icon = KIcon("kdenlive-mask-effect");
165 else if (type == "custom") icon = KIcon("kdenlive-custom-effect");
166 else icon = KIcon("kdenlive-show-video");
167 effecticon->setPixmap(icon.pixmap(16,16));
168 m_menu->addAction(KIcon("folder-new"), i18n("Create Group"), this, SLOT(slotCreateGroup()));
169 setupWidget(info, ix, metaInfo);
172 title->setText(i18n("Effect Group"));
173 effecticon->setPixmap(KIcon("folder").pixmap(16,16));
174 m_menu->addAction(KIcon("list-remove"), i18n("Ungroup"), this, SLOT(slotUnGroup()));
176 setAcceptDrops(true);
177 menuButton->setIcon(KIcon("kdenlive-menu"));
178 menuButton->setMenu(m_menu);
180 if (m_effect.attribute("disable") == "1") {
181 title->setEnabled(false);
182 enabledBox->setChecked(false);
185 enabledBox->setChecked(true);
188 connect(collapseButton, SIGNAL(clicked()), this, SLOT(slotSwitch()));
189 connect(enabledBox, SIGNAL(toggled(bool)), this, SLOT(slotEnable(bool)));
190 connect(buttonUp, SIGNAL(clicked()), this, SLOT(slotEffectUp()));
191 connect(buttonDown, SIGNAL(clicked()), this, SLOT(slotEffectDown()));
192 connect(buttonDel, SIGNAL(clicked()), this, SLOT(slotDeleteEffect()));
194 Q_FOREACH( QSpinBox * sp, findChildren<QSpinBox*>() ) {
195 sp->installEventFilter( this );
196 sp->setFocusPolicy( Qt::StrongFocus );
198 Q_FOREACH( KComboBox * cb, findChildren<KComboBox*>() ) {
199 cb->installEventFilter( this );
200 cb->setFocusPolicy( Qt::StrongFocus );
202 Q_FOREACH( QProgressBar * cb, findChildren<QProgressBar*>() ) {
203 cb->installEventFilter( this );
204 cb->setFocusPolicy( Qt::StrongFocus );
208 CollapsibleEffect::~CollapsibleEffect()
210 if (m_paramWidget) delete m_paramWidget;
215 const QString CollapsibleEffect::getStyleSheet(QPalette p)
217 KColorScheme scheme(p.currentColorGroup(), KColorScheme::View, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
218 QColor dark_bg = scheme.shade(KColorScheme::DarkShade);
219 QColor selected_bg = scheme.decoration(KColorScheme::FocusColor).color();
220 QColor hover_bg = scheme.decoration(KColorScheme::HoverColor).color();
221 QColor light_bg = scheme.shade(KColorScheme::LightShade);
222 QColor normal_bg = scheme.background(KColorScheme::AlternateBackground).color();
223 QColor alt_bg = scheme.background(KColorScheme::NormalBackground).color();
225 KColorScheme scheme2(p.currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
226 QColor normal_bg2 = scheme2.background(KColorScheme::NormalBackground).color();
228 QString stylesheet(QString("QFrame#decoframe {border-radius:5px;border:0px solid %1;border-top:0px;background:%6;} QFrame:hover#decoframe {background:%7;} QFrame#decoframe[active=\"true\"] {background:%5;} QFrame#frame[active=\"true\"] {background:%3;} 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;}\
229 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}\
230 QProgressBar:horizontal:disabled {border: 1px solid %6} QProgressBar:horizontal#dragOnly {background: %5}\
231 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;}\
232 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;}\
233 QAbstractSpinBox:disabled#dragBox {border: 1px solid %6;}\
234 QAbstractSpinBox::up-button#dragBox {width:0px;padding:0px;} QAbstractSpinBox[inTimeline=\"true\"]#dragBox { border: 1px solid %2;} QAbstractSpinBox:hover#dragBox {border: 1px solid %3;} ")
235 .arg(dark_bg.name()).arg(hover_bg.name()).arg(selected_bg.name()).arg(light_bg.name()).arg(alt_bg.name()).arg(normal_bg2.name()).arg(normal_bg.name()));
237 QPalette p = QApplication::palette();
238 KColorScheme scheme(p.currentColorGroup(), KColorScheme::View, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
239 QColor dark_bg = scheme.shade(KColorScheme::DarkShade);
240 QColor selected_bg = scheme.decoration(KColorScheme::FocusColor).color();
241 QColor hover_bg = scheme.decoration(KColorScheme::HoverColor).color();
242 QColor light_bg = scheme.shade(KColorScheme::LightShade);
243 QColor normal_bg = scheme.background(KColorScheme::NormalBackground).color();
245 KColorScheme scheme2(p.currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
246 QColor normal_bg2 = scheme2.background(KColorScheme::NormalBackground).color();
248 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;}\
249 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}\
250 QProgressBar:horizontal:disabled {border: 1px solid %6} QProgressBar:horizontal#dragOnly {background: %5}\
251 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;}\
252 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;}\
253 QAbstractSpinBox:disabled#dragBox {border: 1px solid %6;}\
254 QAbstractSpinBox::up-button#dragBox {width:0px;padding:0px;} QAbstractSpinBox[inTimeline=\"true\"]#dragBox { border: 1px solid %2;} QAbstractSpinBox:hover#dragBox {border: 1px solid %3;} ")
255 .arg(dark_bg.name()).arg(hover_bg.name()).arg(selected_bg.name()).arg(light_bg.name()).arg(normal_bg.name()).arg(normal_bg2.name()));
259 void CollapsibleEffect::slotCreateGroup()
261 emit createGroup(effectIndex());
264 void CollapsibleEffect::slotUnGroup()
269 bool CollapsibleEffect::eventFilter( QObject * o, QEvent * e )
271 if (e->type() == QEvent::Wheel) {
272 QWheelEvent *we = static_cast<QWheelEvent *>(e);
273 if (!filterWheelEvent || we->modifiers() != Qt::NoModifier) {
277 if (qobject_cast<QAbstractSpinBox*>(o)) {
278 if(qobject_cast<QAbstractSpinBox*>(o)->focusPolicy() == Qt::WheelFocus)
289 if (qobject_cast<KComboBox*>(o)) {
290 if(qobject_cast<KComboBox*>(o)->focusPolicy() == Qt::WheelFocus)
301 if (qobject_cast<QProgressBar*>(o)) {
302 if(qobject_cast<QProgressBar*>(o)->focusPolicy() == Qt::WheelFocus)
314 return QWidget::eventFilter(o, e);
317 QDomElement CollapsibleEffect::effect() const
322 bool CollapsibleEffect::isActive() const
324 return decoframe->property("active").toBool();
327 void CollapsibleEffect::setActive(bool activate)
329 decoframe->setProperty("active", activate);
330 decoframe->setStyleSheet(decoframe->styleSheet());
333 void CollapsibleEffect::mouseDoubleClickEvent ( QMouseEvent * event )
335 if (frame->underMouse() && collapseButton->isEnabled()) slotSwitch();
336 QWidget::mouseDoubleClickEvent(event);
339 void CollapsibleEffect::mousePressEvent ( QMouseEvent *event )
342 if (!decoframe->property("active").toBool() && !isGroup()) emit activateEffect(effectIndex());
343 QWidget::mousePressEvent(event);
347 void CollapsibleEffect::slotEnable(bool enable)
349 title->setEnabled(enable);
350 enabledBox->blockSignals(true);
351 enabledBox->setChecked(enable);
352 enabledBox->blockSignals(false);
354 QVBoxLayout *vbox = static_cast<QVBoxLayout *>(widgetFrame->layout());
355 if (vbox == NULL) return;
356 for (int i = 0; i < vbox->count(); i++) {
357 CollapsibleEffect *e = static_cast<CollapsibleEffect *>(vbox->itemAt(i)->widget());
358 if (e) e->enabledBox->setChecked(enable);// slotEnable(enable);
361 m_effect.setAttribute("disable", enable ? 0 : 1);
362 if (enable || KdenliveSettings::disable_effect_parameters()) {
363 widgetFrame->setEnabled(enable);
365 emit effectStateChanged(!enable, effectIndex());
369 void CollapsibleEffect::slotDeleteEffect()
371 if (!m_isGroup) emit deleteEffect(m_effect);
374 void CollapsibleEffect::slotEffectUp()
376 if (!m_isGroup) emit changeEffectPosition(effectIndex(), true);
379 void CollapsibleEffect::slotEffectDown()
381 if (!m_isGroup) emit changeEffectPosition(effectIndex(), false);
384 void CollapsibleEffect::slotSaveEffect()
386 QString name = QInputDialog::getText(this, i18n("Save Effect"), i18n("Name for saved effect: "));
387 if (name.isEmpty()) return;
388 QString path = KStandardDirs::locateLocal("appdata", "effects/", true);
389 path = path + name + ".xml";
390 if (QFile::exists(path)) if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", path)) == KMessageBox::No) return;
393 QDomElement effect = m_effect.cloneNode().toElement();
394 doc.appendChild(doc.importNode(effect, true));
395 effect = doc.firstChild().toElement();
396 effect.removeAttribute("kdenlive_ix");
397 effect.setAttribute("id", name);
398 effect.setAttribute("type", "custom");
399 QDomElement effectname = effect.firstChildElement("name");
400 effect.removeChild(effectname);
401 effectname = doc.createElement("name");
402 QDomText nametext = doc.createTextNode(name);
403 effectname.appendChild(nametext);
404 effect.insertBefore(effectname, QDomNode());
405 QDomElement effectprops = effect.firstChildElement("properties");
406 effectprops.setAttribute("id", name);
407 effectprops.setAttribute("type", "custom");
410 if (file.open(QFile::WriteOnly | QFile::Truncate)) {
411 QTextStream out(&file);
412 out << doc.toString();
415 emit reloadEffects();
418 void CollapsibleEffect::slotResetEffect()
420 emit resetEffect(effectIndex());
423 void CollapsibleEffect::slotSwitch()
425 bool enable = !widgetFrame->isVisible();
429 void CollapsibleEffect::slotShow(bool show)
431 widgetFrame->setVisible(show);
433 collapseButton->setArrowType(Qt::DownArrow);
434 m_info.isCollapsed = false;
437 collapseButton->setArrowType(Qt::RightArrow);
438 m_info.isCollapsed = true;
440 m_effect.setAttribute("kdenlive_info", m_info.toString());
441 emit parameterChanged(m_original_effect, m_effect, effectIndex());
444 void CollapsibleEffect::updateGroupIndex(int groupIndex)
446 m_info.groupIndex = groupIndex;
447 m_effect.setAttribute("kdenlive_info", m_info.toString());
448 emit parameterChanged(m_original_effect, m_effect, effectIndex());
451 void CollapsibleEffect::setGroupIndex(int ix)
453 m_info.groupIndex = ix;
456 void CollapsibleEffect::addGroupEffect(CollapsibleEffect *effect)
458 QVBoxLayout *vbox = static_cast<QVBoxLayout *>(widgetFrame->layout());
460 vbox = new QVBoxLayout();
461 vbox->setContentsMargins(10, 0, 0, 0);
463 widgetFrame->setLayout(vbox);
465 effect->setGroupIndex(groupIndex());
466 vbox->addWidget(effect);
469 QString CollapsibleEffect::infoString() const
471 return m_info.toString();
474 void CollapsibleEffect::removeGroup(int ix, QVBoxLayout *layout)
476 QVBoxLayout *vbox = static_cast<QVBoxLayout *>(widgetFrame->layout());
477 if (vbox == NULL) return;
479 for (int j = vbox->count() - 1; j >= 0; j--) {
480 QLayoutItem *child = vbox->takeAt(j);
481 CollapsibleEffect *e = static_cast<CollapsibleEffect *>(child->widget());
482 layout->insertWidget(ix, e);
483 e->updateGroupIndex(-1);
488 int CollapsibleEffect::index() const
493 int CollapsibleEffect::groupIndex() const
495 if (m_isGroup) return m_index;
499 bool CollapsibleEffect::isGroup() const
504 int CollapsibleEffect::effectIndex() const
506 if (m_effect.isNull()) return -1;
507 return m_effect.attribute("kdenlive_ix").toInt();
510 void CollapsibleEffect::updateWidget(ItemInfo info, int index, QDomElement effect, EffectMetaInfo *metaInfo)
514 delete m_paramWidget;
515 m_paramWidget = NULL;
518 setupWidget(info, index, metaInfo);
521 void CollapsibleEffect::setupWidget(ItemInfo info, int index, EffectMetaInfo *metaInfo)
523 if (m_effect.isNull()) {
524 // kDebug() << "// EMPTY EFFECT STACK";
528 if (m_effect.attribute("tag") == "region") {
529 QVBoxLayout *vbox = new QVBoxLayout(widgetFrame);
530 vbox->setContentsMargins(2, 0, 2, 0);
532 QDomNodeList effects = m_effect.elementsByTagName("effect");
533 QDomNodeList origin_effects = m_original_effect.elementsByTagName("effect");
534 QWidget *container = new QWidget(widgetFrame);
535 vbox->addWidget(container);
536 m_paramWidget = new ParameterContainer(m_effect.toElement(), info, metaInfo, index, container);
537 for (int i = 0; i < effects.count(); i++) {
538 CollapsibleEffect *coll = new CollapsibleEffect(effects.at(i).toElement(), origin_effects.at(i).toElement(), info, i, metaInfo, container);
539 m_subParamWidgets.append(coll);
540 //container = new QWidget(widgetFrame);
541 vbox->addWidget(coll);
542 //p = new ParameterContainer(effects.at(i).toElement(), info, isEffect, container);
547 m_paramWidget = new ParameterContainer(m_effect, info, metaInfo, index, widgetFrame);
548 if (m_effect.firstChildElement("parameter").isNull()) {
549 // Effect has no parameter, don't allow expand
550 collapseButton->setEnabled(false);
551 collapseButton->setVisible(false);
552 widgetFrame->setVisible(false);
555 if (collapseButton->isEnabled() && m_info.isCollapsed) {
556 widgetFrame->setVisible(false);
557 collapseButton->setArrowType(Qt::RightArrow);
560 connect (m_paramWidget, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int)), this, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int)));
562 connect(m_paramWidget, SIGNAL(startFilterJob(QString,QString,QString,QString,QString,QString)), this, SIGNAL(startFilterJob(QString,QString,QString,QString,QString,QString)));
564 connect (this, SIGNAL(syncEffectsPos(int)), m_paramWidget, SIGNAL(syncEffectsPos(int)));
565 connect (this, SIGNAL(effectStateChanged(bool)), m_paramWidget, SIGNAL(effectStateChanged(bool)));
566 connect (m_paramWidget, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
567 connect (m_paramWidget, SIGNAL(seekTimeline(int)), this, SIGNAL(seekTimeline(int)));
572 void CollapsibleEffect::updateTimecodeFormat()
574 m_paramWidget->updateTimecodeFormat();
575 if (!m_subParamWidgets.isEmpty()) {
577 for (int i = 0; i < m_subParamWidgets.count(); i++)
578 m_subParamWidgets.at(i)->updateTimecodeFormat();
582 void CollapsibleEffect::slotSyncEffectsPos(int pos)
584 emit syncEffectsPos(pos);
587 void CollapsibleEffect::dragEnterEvent(QDragEnterEvent *event)
589 if (event->mimeData()->hasFormat("kdenlive/effectslist")) {
590 frame->setProperty("active", true);
591 frame->setStyleSheet(frame->styleSheet());
592 event->acceptProposedAction();
596 void CollapsibleEffect::dragLeaveEvent(QDragLeaveEvent */*event*/)
598 frame->setProperty("active", false);
599 frame->setStyleSheet(frame->styleSheet());
602 void CollapsibleEffect::dropEvent(QDropEvent *event)
604 frame->setProperty("active", false);
605 frame->setStyleSheet(frame->styleSheet());
606 const QString effects = QString::fromUtf8(event->mimeData()->data("kdenlive/effectslist"));
607 //event->acceptProposedAction();
609 doc.setContent(effects, true);
610 QDomElement e = doc.documentElement();
611 int ix = e.attribute("kdenlive_ix").toInt();
612 if (ix == effectIndex()) {
613 // effect dropped on itself, reject
618 // effect dropped from effects list, add it
619 e.setAttribute("kdenlive_ix", ix);
620 event->setDropAction(Qt::CopyAction);
627 QVBoxLayout *vbox = static_cast<QVBoxLayout *>(widgetFrame->layout());
628 if (vbox == NULL) return;
629 CollapsibleEffect *e = static_cast<CollapsibleEffect *>(vbox->itemAt(vbox->count() -1)->widget());
630 new_index = e->effectIndex();
633 new_index = effectIndex();
635 emit moveEffect(ix, new_index, this);
636 event->setDropAction(Qt::MoveAction);
640 ParameterContainer::ParameterContainer(QDomElement effect, ItemInfo info, EffectMetaInfo *metaInfo, int index, QWidget * parent) :
642 m_keyframeEditor(NULL),
643 m_geometryWidget(NULL),
644 m_metaInfo(metaInfo),
647 m_in = info.cropStart.frames(KdenliveSettings::project_fps());
648 m_out = (info.cropStart + info.cropDuration).frames(KdenliveSettings::project_fps()) - 1;
650 QDomNodeList namenode = effect.childNodes(); //elementsByTagName("parameter");
652 QDomElement e = effect.toElement();
653 int minFrame = e.attribute("start").toInt();
654 int maxFrame = e.attribute("end").toInt();
655 // In transitions, maxFrame is in fact one frame after the end of transition
656 if (maxFrame > 0) maxFrame --;
658 bool disable = effect.attribute("disable") == "1" && KdenliveSettings::disable_effect_parameters();
659 parent->setEnabled(!disable);
662 m_vbox = new QVBoxLayout(parent);
663 m_vbox->setContentsMargins(2, 0, 2, 0);
664 m_vbox->setSpacing(2);
666 for (int i = 0; i < namenode.count() ; i++) {
667 QDomElement pa = namenode.item(i).toElement();
668 if (pa.tagName() != "parameter") continue;
669 QDomElement na = pa.firstChildElement("name");
670 QDomElement commentElem = pa.firstChildElement("comment");
671 QString type = pa.attribute("type");
672 QString paramName = na.isNull() ? pa.attribute("name") : i18n(na.text().toUtf8().data());
674 if (!commentElem.isNull())
675 comment = i18n(commentElem.text().toUtf8().data());
676 QWidget * toFillin = new QWidget(parent);
677 QString value = pa.attribute("value").isNull() ?
678 pa.attribute("default") : pa.attribute("value");
681 /** See effects/README for info on the different types */
683 if (type == "double" || type == "constant") {
686 if (pa.attribute("min").contains('%'))
687 min = ProfilesDialog::getStringEval(m_metaInfo->profile, pa.attribute("min"), m_metaInfo->frameSize);
689 min = pa.attribute("min").toDouble();
690 if (pa.attribute("max").contains('%'))
691 max = ProfilesDialog::getStringEval(m_metaInfo->profile, pa.attribute("max"), m_metaInfo->frameSize);
693 max = pa.attribute("max").toDouble();
695 DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, value.toDouble(), min, max,
696 pa.attribute("default").toDouble(), comment, -1, pa.attribute("suffix"), pa.attribute("decimals").toInt(), parent);
697 doubleparam->setFocusPolicy(Qt::StrongFocus);
698 m_vbox->addWidget(doubleparam);
699 m_valueItems[paramName] = doubleparam;
700 connect(doubleparam, SIGNAL(valueChanged(double)), this, SLOT(slotCollectAllParameters()));
701 connect(this, SIGNAL(showComments(bool)), doubleparam, SLOT(slotShowComment(bool)));
702 } else if (type == "list") {
703 Listval *lsval = new Listval;
704 lsval->setupUi(toFillin);
705 lsval->list->setFocusPolicy(Qt::StrongFocus);
706 QStringList listitems = pa.attribute("paramlist").split(';');
707 if (listitems.count() == 1) {
708 // probably custom effect created before change to ';' as separator
709 listitems = pa.attribute("paramlist").split(",");
711 QDomElement list = pa.firstChildElement("paramlistdisplay");
712 QStringList listitemsdisplay;
713 if (!list.isNull()) {
714 listitemsdisplay = i18n(list.text().toUtf8().data()).split(',');
716 listitemsdisplay = i18n(pa.attribute("paramlistdisplay").toUtf8().data()).split(',');
718 if (listitemsdisplay.count() != listitems.count())
719 listitemsdisplay = listitems;
720 lsval->list->setIconSize(QSize(30, 30));
721 for (int i = 0; i < listitems.count(); i++) {
722 lsval->list->addItem(listitemsdisplay.at(i), listitems.at(i));
723 QString entry = listitems.at(i);
724 if (!entry.isEmpty() && (entry.endsWith(".png") || entry.endsWith(".pgm"))) {
725 if (!CollapsibleEffect::iconCache.contains(entry)) {
727 CollapsibleEffect::iconCache[entry] = pix.scaled(30, 30);
729 lsval->list->setItemIcon(i, QPixmap::fromImage(CollapsibleEffect::iconCache[entry]));
732 if (!value.isEmpty()) lsval->list->setCurrentIndex(listitems.indexOf(value));
733 lsval->name->setText(paramName);
734 lsval->labelComment->setText(comment);
735 lsval->widgetComment->setHidden(true);
736 m_valueItems[paramName] = lsval;
737 connect(lsval->list, SIGNAL(currentIndexChanged(int)) , this, SLOT(slotCollectAllParameters()));
738 if (!comment.isEmpty())
739 connect(this, SIGNAL(showComments(bool)), lsval->widgetComment, SLOT(setVisible(bool)));
740 m_uiItems.append(lsval);
741 } else if (type == "bool") {
742 Boolval *bval = new Boolval;
743 bval->setupUi(toFillin);
744 bval->checkBox->setCheckState(value == "0" ? Qt::Unchecked : Qt::Checked);
745 bval->name->setText(paramName);
746 bval->labelComment->setText(comment);
747 bval->widgetComment->setHidden(true);
748 m_valueItems[paramName] = bval;
749 connect(bval->checkBox, SIGNAL(stateChanged(int)) , this, SLOT(slotCollectAllParameters()));
750 if (!comment.isEmpty())
751 connect(this, SIGNAL(showComments(bool)), bval->widgetComment, SLOT(setVisible(bool)));
752 m_uiItems.append(bval);
753 } else if (type == "complex") {
754 ComplexParameter *pl = new ComplexParameter;
755 pl->setupParam(effect, pa.attribute("name"), 0, 100);
756 m_vbox->addWidget(pl);
757 m_valueItems[paramName+"complex"] = pl;
758 connect(pl, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
759 } else if (type == "geometry") {
760 if (KdenliveSettings::on_monitor_effects()) {
761 m_geometryWidget = new GeometryWidget(m_metaInfo->monitor, m_metaInfo->timecode, 0, true, effect.hasAttribute("showrotation"), parent);
762 m_geometryWidget->setFrameSize(m_metaInfo->frameSize);
763 m_geometryWidget->slotShowScene(!disable);
764 // connect this before setupParam to make sure the monitor scene shows up at startup
765 connect(m_geometryWidget, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
766 connect(m_geometryWidget, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
767 if (minFrame == maxFrame)
768 m_geometryWidget->setupParam(pa, m_in, m_out);
770 m_geometryWidget->setupParam(pa, minFrame, maxFrame);
771 m_vbox->addWidget(m_geometryWidget);
772 m_valueItems[paramName+"geometry"] = m_geometryWidget;
773 connect(m_geometryWidget, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
774 connect(this, SIGNAL(syncEffectsPos(int)), m_geometryWidget, SLOT(slotSyncPosition(int)));
775 connect(this, SIGNAL(effectStateChanged(bool)), m_geometryWidget, SLOT(slotShowScene(bool)));
777 Geometryval *geo = new Geometryval(m_metaInfo->profile, m_metaInfo->timecode, m_metaInfo->frameSize, 0);
778 if (minFrame == maxFrame)
779 geo->setupParam(pa, m_in, m_out);
781 geo->setupParam(pa, minFrame, maxFrame);
782 m_vbox->addWidget(geo);
783 m_valueItems[paramName+"geometry"] = geo;
784 connect(geo, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
785 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
786 connect(this, SIGNAL(syncEffectsPos(int)), geo, SLOT(slotSyncPosition(int)));
788 } else if (type == "addedgeometry") {
789 // this is a parameter that should be linked to the geometry widget, for example rotation, shear, ...
790 if (m_geometryWidget) m_geometryWidget->addParameter(pa);
791 } else if (type == "keyframe" || type == "simplekeyframe") {
792 // keyframe editor widget
793 if (m_keyframeEditor == NULL) {
795 if (pa.attribute("widget") == "corners") {
796 // we want a corners-keyframe-widget
797 CornersWidget *corners = new CornersWidget(m_metaInfo->monitor, pa, m_in, m_out, m_metaInfo->timecode, e.attribute("active_keyframe", "-1").toInt(), parent);
798 corners->slotShowScene(!disable);
799 connect(corners, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
800 connect(this, SIGNAL(effectStateChanged(bool)), corners, SLOT(slotShowScene(bool)));
801 connect(this, SIGNAL(syncEffectsPos(int)), corners, SLOT(slotSyncPosition(int)));
802 geo = static_cast<KeyframeEdit *>(corners);
804 geo = new KeyframeEdit(pa, m_in, m_out, m_metaInfo->timecode, e.attribute("active_keyframe", "-1").toInt());
806 m_vbox->addWidget(geo);
807 m_valueItems[paramName+"keyframe"] = geo;
808 m_keyframeEditor = geo;
809 connect(geo, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
810 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
811 connect(this, SIGNAL(showComments(bool)), geo, SIGNAL(showComments(bool)));
813 // we already have a keyframe editor, so just add another column for the new param
814 m_keyframeEditor->addParameter(pa);
816 } else if (type == "color") {
817 if (value.startsWith('#'))
818 value = value.replace('#', "0x");
819 ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, value, parent);
820 m_vbox->addWidget(choosecolor);
821 m_valueItems[paramName] = choosecolor;
822 connect(choosecolor, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int)));
823 connect(choosecolor, SIGNAL(modified()) , this, SLOT(slotCollectAllParameters()));
824 } else if (type == "position") {
825 int pos = value.toInt();
826 if (effect.attribute("id") == "fadein" || effect.attribute("id") == "fade_from_black") {
828 } else if (effect.attribute("id") == "fadeout" || effect.attribute("id") == "fade_to_black") {
829 // fadeout position starts from clip end
832 PositionEdit *posedit = new PositionEdit(paramName, pos, 0, m_out - m_in, m_metaInfo->timecode);
833 m_vbox->addWidget(posedit);
834 m_valueItems[paramName+"position"] = posedit;
835 connect(posedit, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
836 } else if (type == "curve") {
837 KisCurveWidget *curve = new KisCurveWidget(parent);
838 curve->setMaxPoints(pa.attribute("max").toInt());
839 QList<QPointF> points;
840 int number = EffectsList::parameter(e, pa.attribute("number")).toInt();
841 QString inName = pa.attribute("inpoints");
842 QString outName = pa.attribute("outpoints");
843 int start = pa.attribute("min").toInt();
844 for (int j = start; j <= number; j++) {
846 in.replace("%i", QString::number(j));
847 QString out = outName;
848 out.replace("%i", QString::number(j));
849 points << QPointF(EffectsList::parameter(e, in).toDouble(), EffectsList::parameter(e, out).toDouble());
851 if (!points.isEmpty())
852 curve->setCurve(KisCubicCurve(points));
853 MySpinBox *spinin = new MySpinBox();
854 spinin->setRange(0, 1000);
855 MySpinBox *spinout = new MySpinBox();
856 spinout->setRange(0, 1000);
857 curve->setupInOutControls(spinin, spinout, 0, 1000);
858 m_vbox->addWidget(curve);
859 m_vbox->addWidget(spinin);
860 m_vbox->addWidget(spinout);
862 connect(curve, SIGNAL(modified()), this, SLOT(slotCollectAllParameters()));
863 m_valueItems[paramName] = curve;
865 QString depends = pa.attribute("depends");
866 if (!depends.isEmpty())
867 meetDependency(paramName, type, EffectsList::parameter(e, depends));
868 } else if (type == "bezier_spline") {
869 BezierSplineWidget *widget = new BezierSplineWidget(value, parent);
871 m_vbox->addWidget(widget);
872 m_valueItems[paramName] = widget;
873 connect(widget, SIGNAL(modified()), this, SLOT(slotCollectAllParameters()));
874 QString depends = pa.attribute("depends");
875 if (!depends.isEmpty())
876 meetDependency(paramName, type, EffectsList::parameter(e, depends));
878 } else if (type == "roto-spline") {
879 RotoWidget *roto = new RotoWidget(value, m_metaInfo->monitor, info, m_metaInfo->timecode, parent);
880 roto->slotShowScene(!disable);
881 connect(roto, SIGNAL(valueChanged()), this, SLOT(slotCollectAllParameters()));
882 connect(roto, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
883 connect(roto, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
884 connect(this, SIGNAL(syncEffectsPos(int)), roto, SLOT(slotSyncPosition(int)));
885 connect(this, SIGNAL(effectStateChanged(bool)), roto, SLOT(slotShowScene(bool)));
886 m_vbox->addWidget(roto);
887 m_valueItems[paramName] = roto;
889 } else if (type == "wipe") {
890 Wipeval *wpval = new Wipeval;
891 wpval->setupUi(toFillin);
892 wipeInfo w = getWipeInfo(value);
895 wpval->start_up->setChecked(true);
898 wpval->start_down->setChecked(true);
901 wpval->start_right->setChecked(true);
904 wpval->start_left->setChecked(true);
907 wpval->start_center->setChecked(true);
912 wpval->end_up->setChecked(true);
915 wpval->end_down->setChecked(true);
918 wpval->end_right->setChecked(true);
921 wpval->end_left->setChecked(true);
924 wpval->end_center->setChecked(true);
927 wpval->start_transp->setValue(w.startTransparency);
928 wpval->end_transp->setValue(w.endTransparency);
929 m_valueItems[paramName] = wpval;
930 connect(wpval->end_up, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
931 connect(wpval->end_down, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
932 connect(wpval->end_left, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
933 connect(wpval->end_right, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
934 connect(wpval->end_center, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
935 connect(wpval->start_up, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
936 connect(wpval->start_down, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
937 connect(wpval->start_left, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
938 connect(wpval->start_right, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
939 connect(wpval->start_center, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
940 connect(wpval->start_transp, SIGNAL(valueChanged(int)), this, SLOT(slotCollectAllParameters()));
941 connect(wpval->end_transp, SIGNAL(valueChanged(int)), this, SLOT(slotCollectAllParameters()));
942 //wpval->title->setTitle(na.toElement().text());
943 m_uiItems.append(wpval);
944 } else if (type == "url") {
945 Urlval *cval = new Urlval;
946 cval->setupUi(toFillin);
947 cval->label->setText(paramName);
948 cval->urlwidget->fileDialog()->setFilter(ProjectList::getExtensions());
949 m_valueItems[paramName] = cval;
950 cval->urlwidget->setUrl(KUrl(value));
951 connect(cval->urlwidget, SIGNAL(returnPressed()) , this, SLOT(slotCollectAllParameters()));
952 connect(cval->urlwidget, SIGNAL(urlSelected(const KUrl&)) , this, SLOT(slotCollectAllParameters()));
953 m_uiItems.append(cval);
954 } else if (type == "keywords") {
955 Keywordval* kval = new Keywordval;
956 kval->setupUi(toFillin);
957 kval->label->setText(paramName);
958 kval->lineeditwidget->setText(value);
959 QDomElement klistelem = pa.firstChildElement("keywords");
960 QDomElement kdisplaylistelem = pa.firstChildElement("keywordsdisplay");
961 QStringList keywordlist;
962 QStringList keyworddisplaylist;
963 if (!klistelem.isNull()) {
964 keywordlist = klistelem.text().split(';');
965 keyworddisplaylist = i18n(kdisplaylistelem.text().toUtf8().data()).split(';');
967 if (keyworddisplaylist.count() != keywordlist.count()) {
968 keyworddisplaylist = keywordlist;
970 for (int i = 0; i < keywordlist.count(); i++) {
971 kval->comboboxwidget->addItem(keyworddisplaylist.at(i), keywordlist.at(i));
973 // Add disabled user prompt at index 0
974 kval->comboboxwidget->insertItem(0, i18n("<select a keyword>"), "");
975 kval->comboboxwidget->model()->setData( kval->comboboxwidget->model()->index(0,0), QVariant(Qt::NoItemFlags), Qt::UserRole -1);
976 kval->comboboxwidget->setCurrentIndex(0);
977 m_valueItems[paramName] = kval;
978 connect(kval->lineeditwidget, SIGNAL(editingFinished()) , this, SLOT(collectAllParameters()));
979 connect(kval->comboboxwidget, SIGNAL(activated (const QString&)), this, SLOT(collectAllParameters()));
980 m_uiItems.append(kval);
981 } else if (type == "fontfamily") {
982 Fontval* fval = new Fontval;
983 fval->setupUi(toFillin);
984 fval->name->setText(paramName);
985 fval->fontfamilywidget->setCurrentFont(QFont(value));
986 m_valueItems[paramName] = fval;
987 connect(fval->fontfamilywidget, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(collectAllParameters())) ;
988 m_uiItems.append(fval);
989 } else if (type == "filterjob") {
990 QVBoxLayout *l= new QVBoxLayout(toFillin);
991 QPushButton *button = new QPushButton(paramName, toFillin);
992 l->addWidget(button);
993 m_valueItems[paramName] = button;
994 connect(button, SIGNAL(pressed()), this, SLOT(slotStartFilterJobAction()));
1001 m_vbox->addWidget(toFillin);
1005 m_vbox->addStretch();
1007 if (m_keyframeEditor)
1008 m_keyframeEditor->checkVisibleParam();
1010 // Make sure all doubleparam spinboxes have the same width, looks much better
1011 QList<DoubleParameterWidget *> allWidgets = findChildren<DoubleParameterWidget *>();
1013 for (int i = 0; i < allWidgets.count(); i++) {
1014 if (minSize < allWidgets.at(i)->spinSize()) minSize = allWidgets.at(i)->spinSize();
1016 for (int i = 0; i < allWidgets.count(); i++) {
1017 allWidgets.at(i)->setSpinSize(minSize);
1021 ParameterContainer::~ParameterContainer()
1023 clearLayout(m_vbox);
1027 void ParameterContainer::meetDependency(const QString& name, QString type, QString value)
1029 if (type == "curve") {
1030 KisCurveWidget *curve = (KisCurveWidget*)m_valueItems[name];
1032 int color = value.toInt();
1033 curve->setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(curve->size(), (ColorTools::ColorsRGB)(color == 3 ? 4 : color), 0.8)));
1035 } else if (type == "bezier_spline") {
1036 BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems[name];
1038 widget->setMode((BezierSplineWidget::CurveModes)((int)(value.toDouble() * 10)));
1043 wipeInfo ParameterContainer::getWipeInfo(QString value)
1046 // Convert old geometry values that used a comma as separator
1047 if (value.contains(',')) value.replace(',','/');
1048 QString start = value.section(';', 0, 0);
1049 QString end = value.section(';', 1, 1).section('=', 1, 1);
1050 if (start.startsWith("-100%/0"))
1052 else if (start.startsWith("100%/0"))
1054 else if (start.startsWith("0%/100%"))
1056 else if (start.startsWith("0%/-100%"))
1059 info.start = CENTER;
1061 if (start.count(':') == 2)
1062 info.startTransparency = start.section(':', -1).toInt();
1064 info.startTransparency = 100;
1066 if (end.startsWith("-100%/0"))
1068 else if (end.startsWith("100%/0"))
1070 else if (end.startsWith("0%/100%"))
1072 else if (end.startsWith("0%/-100%"))
1077 if (end.count(':') == 2)
1078 info.endTransparency = end.section(':', -1).toInt();
1080 info.endTransparency = 100;
1085 void ParameterContainer::updateTimecodeFormat()
1087 if (m_keyframeEditor)
1088 m_keyframeEditor->updateTimecodeFormat();
1090 QDomNodeList namenode = m_effect.elementsByTagName("parameter");
1091 for (int i = 0; i < namenode.count() ; i++) {
1092 QDomNode pa = namenode.item(i);
1093 QDomElement na = pa.firstChildElement("name");
1094 QString type = pa.attributes().namedItem("type").nodeValue();
1095 QString paramName = na.isNull() ? pa.attributes().namedItem("name").nodeValue() : i18n(na.text().toUtf8().data());
1097 if (type == "geometry") {
1098 if (KdenliveSettings::on_monitor_effects()) {
1099 if (m_geometryWidget) m_geometryWidget->updateTimecodeFormat();
1101 Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
1102 geom->updateTimecodeFormat();
1105 } else if (type == "position") {
1106 PositionEdit *posi = ((PositionEdit*)m_valueItems[paramName+"position"]);
1107 posi->updateTimecodeFormat();
1110 } else if (type == "roto-spline") {
1111 RotoWidget *widget = static_cast<RotoWidget *>(m_valueItems[paramName]);
1112 widget->updateTimecodeFormat();
1118 void ParameterContainer::slotCollectAllParameters()
1120 if (m_valueItems.isEmpty() || m_effect.isNull()) return;
1122 locale.setNumberOptions(QLocale::OmitGroupSeparator);
1123 const QDomElement oldparam = m_effect.cloneNode().toElement();
1124 //QDomElement newparam = oldparam.cloneNode().toElement();
1125 QDomNodeList namenode = m_effect.elementsByTagName("parameter");
1127 for (int i = 0; i < namenode.count() ; i++) {
1128 QDomNode pa = namenode.item(i);
1129 QDomElement na = pa.firstChildElement("name");
1130 QString type = pa.attributes().namedItem("type").nodeValue();
1131 QString paramName = na.isNull() ? pa.attributes().namedItem("name").nodeValue() : i18n(na.text().toUtf8().data());
1132 if (type == "complex")
1133 paramName.append("complex");
1134 else if (type == "position")
1135 paramName.append("position");
1136 else if (type == "geometry")
1137 paramName.append("geometry");
1138 else if (type == "keyframe")
1139 paramName.append("keyframe");
1140 if (type != "simplekeyframe" && type != "fixed" && type != "addedgeometry" && !m_valueItems.contains(paramName)) {
1141 kDebug() << "// Param: " << paramName << " NOT FOUND";
1146 if (type == "double" || type == "constant") {
1147 DoubleParameterWidget *doubleparam = (DoubleParameterWidget*)m_valueItems.value(paramName);
1148 setValue = locale.toString(doubleparam->getValue());
1149 } else if (type == "list") {
1150 KComboBox *box = ((Listval*)m_valueItems.value(paramName))->list;
1151 setValue = box->itemData(box->currentIndex()).toString();
1152 } else if (type == "bool") {
1153 QCheckBox *box = ((Boolval*)m_valueItems.value(paramName))->checkBox;
1154 setValue = box->checkState() == Qt::Checked ? "1" : "0" ;
1155 } else if (type == "color") {
1156 ChooseColorWidget *choosecolor = ((ChooseColorWidget*)m_valueItems.value(paramName));
1157 setValue = choosecolor->getColor();
1158 } else if (type == "complex") {
1159 ComplexParameter *complex = ((ComplexParameter*)m_valueItems.value(paramName));
1160 namenode.item(i) = complex->getParamDesc();
1161 } else if (type == "geometry") {
1162 if (KdenliveSettings::on_monitor_effects()) {
1163 if (m_geometryWidget) namenode.item(i).toElement().setAttribute("value", m_geometryWidget->getValue());
1165 Geometryval *geom = ((Geometryval*)m_valueItems.value(paramName));
1166 namenode.item(i).toElement().setAttribute("value", geom->getValue());
1168 } else if (type == "addedgeometry") {
1169 namenode.item(i).toElement().setAttribute("value", m_geometryWidget->getExtraValue(namenode.item(i).toElement().attribute("name")));
1170 } else if (type == "position") {
1171 PositionEdit *pedit = ((PositionEdit*)m_valueItems.value(paramName));
1172 int pos = pedit->getPosition();
1173 setValue = QString::number(pos);
1174 if (m_effect.attribute("id") == "fadein" || m_effect.attribute("id") == "fade_from_black") {
1175 // Make sure duration is not longer than clip
1176 /*if (pos > m_out) {
1178 pedit->setPosition(pos);
1180 EffectsList::setParameter(m_effect, "in", QString::number(m_in));
1181 EffectsList::setParameter(m_effect, "out", QString::number(m_in + pos));
1183 } else if (m_effect.attribute("id") == "fadeout" || m_effect.attribute("id") == "fade_to_black") {
1184 // Make sure duration is not longer than clip
1185 /*if (pos > m_out) {
1187 pedit->setPosition(pos);
1189 EffectsList::setParameter(m_effect, "in", QString::number(m_out - pos));
1190 EffectsList::setParameter(m_effect, "out", QString::number(m_out));
1193 } else if (type == "curve") {
1194 KisCurveWidget *curve = ((KisCurveWidget*)m_valueItems.value(paramName));
1195 QList<QPointF> points = curve->curve().points();
1196 QString number = pa.attributes().namedItem("number").nodeValue();
1197 QString inName = pa.attributes().namedItem("inpoints").nodeValue();
1198 QString outName = pa.attributes().namedItem("outpoints").nodeValue();
1199 int off = pa.attributes().namedItem("min").nodeValue().toInt();
1200 int end = pa.attributes().namedItem("max").nodeValue().toInt();
1201 EffectsList::setParameter(m_effect, number, QString::number(points.count()));
1202 for (int j = 0; (j < points.count() && j + off <= end); j++) {
1203 QString in = inName;
1204 in.replace("%i", QString::number(j + off));
1205 QString out = outName;
1206 out.replace("%i", QString::number(j + off));
1207 EffectsList::setParameter(m_effect, in, locale.toString(points.at(j).x()));
1208 EffectsList::setParameter(m_effect, out, locale.toString(points.at(j).y()));
1210 QString depends = pa.attributes().namedItem("depends").nodeValue();
1211 if (!depends.isEmpty())
1212 meetDependency(paramName, type, EffectsList::parameter(m_effect, depends));
1213 } else if (type == "bezier_spline") {
1214 BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems.value(paramName);
1215 setValue = widget->spline();
1216 QString depends = pa.attributes().namedItem("depends").nodeValue();
1217 if (!depends.isEmpty())
1218 meetDependency(paramName, type, EffectsList::parameter(m_effect, depends));
1220 } else if (type == "roto-spline") {
1221 RotoWidget *widget = static_cast<RotoWidget *>(m_valueItems.value(paramName));
1222 setValue = widget->getSpline();
1224 } else if (type == "wipe") {
1225 Wipeval *wp = (Wipeval*)m_valueItems.value(paramName);
1227 if (wp->start_left->isChecked())
1229 else if (wp->start_right->isChecked())
1231 else if (wp->start_up->isChecked())
1233 else if (wp->start_down->isChecked())
1235 else if (wp->start_center->isChecked())
1236 info.start = CENTER;
1239 info.startTransparency = wp->start_transp->value();
1241 if (wp->end_left->isChecked())
1243 else if (wp->end_right->isChecked())
1245 else if (wp->end_up->isChecked())
1247 else if (wp->end_down->isChecked())
1249 else if (wp->end_center->isChecked())
1253 info.endTransparency = wp->end_transp->value();
1255 setValue = getWipeString(info);
1256 } else if ((type == "simplekeyframe" || type == "keyframe") && m_keyframeEditor) {
1257 QDomElement elem = pa.toElement();
1258 QString realName = i18n(na.toElement().text().toUtf8().data());
1259 QString val = m_keyframeEditor->getValue(realName);
1260 elem.setAttribute("keyframes", val);
1262 if (m_keyframeEditor->isVisibleParam(realName))
1263 elem.setAttribute("intimeline", "1");
1264 else if (elem.hasAttribute("intimeline"))
1265 elem.removeAttribute("intimeline");
1266 } else if (type == "url") {
1267 KUrlRequester *req = ((Urlval*)m_valueItems.value(paramName))->urlwidget;
1268 setValue = req->url().path();
1269 } else if (type == "keywords"){
1270 QLineEdit *line = ((Keywordval*)m_valueItems.value(paramName))->lineeditwidget;
1271 QComboBox *combo = ((Keywordval*)m_valueItems.value(paramName))->comboboxwidget;
1272 if(combo->currentIndex())
1274 QString comboval = combo->itemData(combo->currentIndex()).toString();
1275 line->insert(comboval);
1276 combo->setCurrentIndex(0);
1278 setValue = line->text();
1279 } else if (type == "fontfamily") {
1280 QFontComboBox* fontfamily = ((Fontval*)m_valueItems.value(paramName))->fontfamilywidget;
1281 setValue = fontfamily->currentFont().family();
1283 if (!setValue.isNull())
1284 pa.attributes().namedItem("value").setNodeValue(setValue);
1287 emit parameterChanged(oldparam, m_effect, m_effect.attribute("kdenlive_ix").toInt());
1290 QString ParameterContainer::getWipeString(wipeInfo info)
1295 switch (info.start) {
1297 start = "-100%/0%:100%x100%";
1300 start = "100%/0%:100%x100%";
1303 start = "0%/100%:100%x100%";
1306 start = "0%/-100%:100%x100%";
1309 start = "0%/0%:100%x100%";
1312 start.append(':' + QString::number(info.startTransparency));
1316 end = "-100%/0%:100%x100%";
1319 end = "100%/0%:100%x100%";
1322 end = "0%/100%:100%x100%";
1325 end = "0%/-100%:100%x100%";
1328 end = "0%/0%:100%x100%";
1331 end.append(':' + QString::number(info.endTransparency));
1332 return QString(start + ";-1=" + end);
1335 int ParameterContainer::index() const
1340 void ParameterContainer::slotStartFilterJobAction()
1342 QDomNodeList namenode = m_effect.elementsByTagName("parameter");
1343 for (int i = 0; i < namenode.count() ; i++) {
1344 QDomElement pa = namenode.item(i).toElement();
1345 QString type = pa.attribute("type");
1346 if (type == "filterjob") {
1347 emit startFilterJob(pa.attribute("filtertag"), pa.attribute("filterparams"), pa.attribute("finalfilter"), pa.attribute("consumer"), pa.attribute("consumerparams"), pa.attribute("wantedproperties"));
1348 kDebug()<<" - - -PROPS:\n"<<pa.attribute("filtertag")<<"-"<< pa.attribute("filterparams")<<"-"<< pa.attribute("consumer")<<"-"<< pa.attribute("consumerparams")<<"-"<< pa.attribute("wantedproperties");