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, EffectMetaInfo *metaInfo, bool lastEffect, QWidget * parent) :
122 AbstractCollapsibleWidget(parent),
125 m_original_effect(original_effect),
126 m_lastEffect(lastEffect)
129 filterWheelEvent = true;
130 m_info.fromString(effect.attribute("kdenlive_info"));
131 setFont(KGlobalSettings::smallestReadableFont());
133 buttonUp->setIcon(KIcon("kdenlive-up"));
134 buttonUp->setToolTip(i18n("Move effect up"));
136 buttonDown->setIcon(KIcon("kdenlive-down"));
137 buttonDown->setToolTip(i18n("Move effect down"));
139 buttonDel->setIcon(KIcon("kdenlive-deleffect"));
140 buttonDel->setToolTip(i18n("Delete effect"));
141 if (effectIndex() == 1) buttonUp->setVisible(false);
142 if (m_lastEffect) buttonDown->setVisible(false);
143 //buttonUp->setVisible(false);
144 //buttonDown->setVisible(false);
146 /*buttonReset->setIcon(KIcon("view-refresh"));
147 buttonReset->setToolTip(i18n("Reset effect"));*/
148 //checkAll->setToolTip(i18n("Enable/Disable all effects"));
149 //buttonShowComments->setIcon(KIcon("help-about"));
150 //buttonShowComments->setToolTip(i18n("Show additional information for the parameters"));
152 m_menu->addAction(KIcon("view-refresh"), i18n("Reset effect"), this, SLOT(slotResetEffect()));
153 m_menu->addAction(KIcon("document-save"), i18n("Save effect"), this, SLOT(slotSaveEffect()));
155 QDomElement namenode = m_effect.firstChildElement("name");
156 if (namenode.isNull()) return;
157 title->setText(i18n(namenode.text().toUtf8().data()));
158 QString type = m_effect.attribute("type", QString());
160 if (type == "audio") icon = KIcon("kdenlive-show-audio");
161 else if (m_effect.attribute("tag") == "region") icon = KIcon("kdenlive-mask-effect");
162 else if (type == "custom") icon = KIcon("kdenlive-custom-effect");
163 else icon = KIcon("kdenlive-show-video");
164 effecticon->setPixmap(icon.pixmap(16,16));
165 m_menu->addAction(KIcon("folder-new"), i18n("Create Group"), this, SLOT(slotCreateGroup()));
166 setupWidget(info, metaInfo);
168 setAcceptDrops(true);
169 menuButton->setIcon(KIcon("kdenlive-menu"));
170 menuButton->setMenu(m_menu);
172 if (m_effect.attribute("disable") == "1") {
173 title->setEnabled(false);
174 enabledBox->setChecked(false);
177 enabledBox->setChecked(true);
180 connect(collapseButton, SIGNAL(clicked()), this, SLOT(slotSwitch()));
181 connect(enabledBox, SIGNAL(toggled(bool)), this, SLOT(slotEnable(bool)));
182 connect(buttonUp, SIGNAL(clicked()), this, SLOT(slotEffectUp()));
183 connect(buttonDown, SIGNAL(clicked()), this, SLOT(slotEffectDown()));
184 connect(buttonDel, SIGNAL(clicked()), this, SLOT(slotDeleteEffect()));
186 Q_FOREACH( QSpinBox * sp, findChildren<QSpinBox*>() ) {
187 sp->installEventFilter( this );
188 sp->setFocusPolicy( Qt::StrongFocus );
190 Q_FOREACH( KComboBox * cb, findChildren<KComboBox*>() ) {
191 cb->installEventFilter( this );
192 cb->setFocusPolicy( Qt::StrongFocus );
194 Q_FOREACH( QProgressBar * cb, findChildren<QProgressBar*>() ) {
195 cb->installEventFilter( this );
196 cb->setFocusPolicy( Qt::StrongFocus );
200 CollapsibleEffect::~CollapsibleEffect()
202 if (m_paramWidget) delete m_paramWidget;
207 const QString CollapsibleEffect::getStyleSheet(QPalette p)
209 KColorScheme scheme(p.currentColorGroup(), KColorScheme::View, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
210 QColor dark_bg = scheme.shade(KColorScheme::DarkShade);
211 QColor selected_bg = scheme.decoration(KColorScheme::FocusColor).color();
212 QColor hover_bg = scheme.decoration(KColorScheme::HoverColor).color();
213 QColor light_bg = scheme.shade(KColorScheme::LightShade);
214 QColor midlight_bg = scheme.shade(KColorScheme::MidlightShade);
215 QColor normal_bg = scheme.background(KColorScheme::AlternateBackground).color();
216 QColor alt_bg = scheme.background(KColorScheme::NormalBackground).color();
218 KColorScheme scheme2(p.currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
219 QColor normal_bg2 = scheme2.background(KColorScheme::NormalBackground).color();
220 QColor normal_bg3 = scheme2.background(KColorScheme::AlternateBackground).color();
224 // group editable labels
225 stylesheet.append(QString("MyEditableLabel { background-color: transparent;} "));
228 stylesheet.append(QString("QFrame#decoframe {border-radius:5px;border:0px solid %1;background:%3;} QFrame:hover#decoframe {background:%4;} QFrame#decoframe[active=\"true\"] {background:%2;} ").arg(dark_bg.name()).arg(alt_bg.name()).arg(normal_bg2.name()).arg(normal_bg.name()));
230 // effect group background
231 stylesheet.append(QString("QFrame#decoframegroup {border-radius:5px;border:1px solid %1;background:%2;} QFrame#decoframegroup[active=\"true\"] {background:%3;} ").arg(dark_bg.name()).arg(normal_bg2.name()).arg(alt_bg.name()));
234 stylesheet.append(QString("QFrame#frame {border-radius: 5px;} QFrame#frame[active=\"true\"] {background:%1;}").arg(selected_bg.name()));
236 // group effect title bar
237 stylesheet.append(QString("QFrame#framegroup {border-radius: 5px; background: %2;} QFrame#framegroup[active=\"true\"] {background:%1;} ").arg(selected_bg.name()).arg(normal_bg3.name()));
239 // draggable effect content bar
240 stylesheet.append(QString("QProgressBar::chunk:horizontal {background: %1;border-top-left-radius: 4px;border-bottom-left-radius: 4px;} QProgressBar::chunk:horizontal#dragOnly {background: %2;border-top-left-radius: 4px;border-bottom-left-radius: 4px;} QProgressBar::chunk:horizontal:hover {background: %3;}").arg(normal_bg2.name()).arg(alt_bg.name()).arg(selected_bg.name()));
242 // draggable effect content bar
243 stylesheet.append(QString("QProgressBar:horizontal {border: 1px solid %1;border-top-left-radius: 4px;border-bottom-left-radius: 4px;border-right:0px;background:%4;padding: 0px;text-align:left center} QProgressBar:horizontal:disabled {border: 1px solid %5} QProgressBar:horizontal#dragOnly {background: %4} QProgressBar:horizontal[inTimeline=\"true\"] { border: 1px solid %2;border-right: 0px;background: %3;padding: 0px;text-align:left center } QProgressBar::chunk:horizontal[inTimeline=\"true\"] {background: %2;}").arg(dark_bg.name()).arg(hover_bg.name()).arg(light_bg.name()).arg(alt_bg.name()).arg(normal_bg2.name()));
246 // spin box for draggable widget
247 stylesheet.append(QString("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;} QAbstractSpinBox:disabled#dragBox {border: 1px solid %4;} QAbstractSpinBox::up-button#dragBox {width:0px;padding:0px;} QAbstractSpinBox[inTimeline=\"true\"]#dragBox { border: 1px solid %2;} QAbstractSpinBox:hover#dragBox {border: 1px solid %3;} ").arg(dark_bg.name()).arg(hover_bg.name()).arg(selected_bg.name()).arg(normal_bg2.name()));
252 void CollapsibleEffect::slotCreateGroup()
254 emit createGroup(effectIndex());
257 void CollapsibleEffect::slotUnGroup()
262 bool CollapsibleEffect::eventFilter( QObject * o, QEvent * e )
264 if (e->type() == QEvent::Wheel) {
265 QWheelEvent *we = static_cast<QWheelEvent *>(e);
266 if (!filterWheelEvent || we->modifiers() != Qt::NoModifier) {
270 if (qobject_cast<QAbstractSpinBox*>(o)) {
271 if(qobject_cast<QAbstractSpinBox*>(o)->focusPolicy() == Qt::WheelFocus)
282 if (qobject_cast<KComboBox*>(o)) {
283 if(qobject_cast<KComboBox*>(o)->focusPolicy() == Qt::WheelFocus)
294 if (qobject_cast<QProgressBar*>(o)) {
295 if(qobject_cast<QProgressBar*>(o)->focusPolicy() == Qt::WheelFocus)
307 return QWidget::eventFilter(o, e);
310 QDomElement CollapsibleEffect::effect() const
315 bool CollapsibleEffect::isActive() const
317 return decoframe->property("active").toBool();
320 void CollapsibleEffect::setActive(bool activate)
322 decoframe->setProperty("active", activate);
323 decoframe->setStyleSheet(decoframe->styleSheet());
326 void CollapsibleEffect::mouseDoubleClickEvent ( QMouseEvent * event )
328 if (frame->underMouse() && collapseButton->isEnabled()) slotSwitch();
329 QWidget::mouseDoubleClickEvent(event);
332 void CollapsibleEffect::mousePressEvent ( QMouseEvent *event )
335 if (!decoframe->property("active").toBool() && !isGroup()) emit activateEffect(effectIndex());
336 QWidget::mousePressEvent(event);
340 void CollapsibleEffect::slotEnable(bool enable)
342 title->setEnabled(enable);
343 enabledBox->blockSignals(true);
344 enabledBox->setChecked(enable);
345 enabledBox->blockSignals(false);
346 m_effect.setAttribute("disable", enable ? 0 : 1);
347 if (enable || KdenliveSettings::disable_effect_parameters()) {
348 widgetFrame->setEnabled(enable);
350 emit effectStateChanged(!enable, effectIndex());
353 void CollapsibleEffect::slotDeleteEffect()
355 emit deleteEffect(m_effect);
358 void CollapsibleEffect::slotEffectUp()
360 emit changeEffectPosition(effectIndex(), true);
363 void CollapsibleEffect::slotEffectDown()
365 emit changeEffectPosition(effectIndex(), false);
368 void CollapsibleEffect::slotSaveEffect()
370 QString name = QInputDialog::getText(this, i18n("Save Effect"), i18n("Name for saved effect: "));
371 if (name.isEmpty()) return;
372 QString path = KStandardDirs::locateLocal("appdata", "effects/", true);
373 path = path + name + ".xml";
374 if (QFile::exists(path)) if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", path)) == KMessageBox::No) return;
377 QDomElement effect = m_effect.cloneNode().toElement();
378 doc.appendChild(doc.importNode(effect, true));
379 effect = doc.firstChild().toElement();
380 effect.removeAttribute("kdenlive_ix");
381 effect.setAttribute("id", name);
382 effect.setAttribute("type", "custom");
383 QDomElement effectname = effect.firstChildElement("name");
384 effect.removeChild(effectname);
385 effectname = doc.createElement("name");
386 QDomText nametext = doc.createTextNode(name);
387 effectname.appendChild(nametext);
388 effect.insertBefore(effectname, QDomNode());
389 QDomElement effectprops = effect.firstChildElement("properties");
390 effectprops.setAttribute("id", name);
391 effectprops.setAttribute("type", "custom");
394 if (file.open(QFile::WriteOnly | QFile::Truncate)) {
395 QTextStream out(&file);
396 out << doc.toString();
399 emit reloadEffects();
402 void CollapsibleEffect::slotResetEffect()
404 emit resetEffect(effectIndex());
407 void CollapsibleEffect::slotSwitch()
409 bool enable = !widgetFrame->isVisible();
413 void CollapsibleEffect::slotShow(bool show)
415 widgetFrame->setVisible(show);
417 collapseButton->setArrowType(Qt::DownArrow);
418 m_info.isCollapsed = false;
421 collapseButton->setArrowType(Qt::RightArrow);
422 m_info.isCollapsed = true;
424 m_effect.setAttribute("kdenlive_info", m_info.toString());
425 emit parameterChanged(m_original_effect, m_effect, effectIndex());
428 void CollapsibleEffect::updateGroupIndex(int groupIndex)
430 m_info.groupIndex = groupIndex;
431 if (groupIndex == -1) m_info.groupName.clear();
432 m_effect.setAttribute("kdenlive_info", m_info.toString());
433 emit parameterChanged(m_original_effect, m_effect, effectIndex());
436 void CollapsibleEffect::setGroupIndex(int ix)
438 m_info.groupIndex = ix;
441 void CollapsibleEffect::setGroupName(const QString &groupName)
443 m_info.groupName = groupName;
446 QString CollapsibleEffect::infoString() const
448 return m_info.toString();
451 void CollapsibleEffect::removeGroup(int ix, QVBoxLayout *layout)
453 QVBoxLayout *vbox = static_cast<QVBoxLayout *>(widgetFrame->layout());
454 if (vbox == NULL) return;
456 for (int j = vbox->count() - 1; j >= 0; j--) {
457 QLayoutItem *child = vbox->takeAt(j);
458 CollapsibleEffect *e = static_cast<CollapsibleEffect *>(child->widget());
459 layout->insertWidget(ix, e);
460 e->updateGroupIndex(-1);
465 int CollapsibleEffect::groupIndex() const
467 return m_info.groupIndex;
470 int CollapsibleEffect::effectIndex() const
472 if (m_effect.isNull()) return -1;
473 return m_effect.attribute("kdenlive_ix").toInt();
476 void CollapsibleEffect::updateWidget(ItemInfo info, QDomElement effect, EffectMetaInfo *metaInfo)
480 delete m_paramWidget;
481 m_paramWidget = NULL;
484 setupWidget(info, metaInfo);
487 void CollapsibleEffect::setupWidget(ItemInfo info, EffectMetaInfo *metaInfo)
489 if (m_effect.isNull()) {
490 // kDebug() << "// EMPTY EFFECT STACK";
494 if (m_effect.attribute("tag") == "region") {
495 QVBoxLayout *vbox = new QVBoxLayout(widgetFrame);
496 vbox->setContentsMargins(2, 0, 2, 0);
498 QDomNodeList effects = m_effect.elementsByTagName("effect");
499 QDomNodeList origin_effects = m_original_effect.elementsByTagName("effect");
500 QWidget *container = new QWidget(widgetFrame);
501 vbox->addWidget(container);
502 m_paramWidget = new ParameterContainer(m_effect.toElement(), info, metaInfo, container);
503 for (int i = 0; i < effects.count(); i++) {
504 CollapsibleEffect *coll = new CollapsibleEffect(effects.at(i).toElement(), origin_effects.at(i).toElement(), info, metaInfo, container);
505 m_subParamWidgets.append(coll);
506 //container = new QWidget(widgetFrame);
507 vbox->addWidget(coll);
508 //p = new ParameterContainer(effects.at(i).toElement(), info, isEffect, container);
513 m_paramWidget = new ParameterContainer(m_effect, info, metaInfo, widgetFrame);
514 if (m_effect.firstChildElement("parameter").isNull()) {
515 // Effect has no parameter, don't allow expand
516 collapseButton->setEnabled(false);
517 collapseButton->setVisible(false);
518 widgetFrame->setVisible(false);
521 if (collapseButton->isEnabled() && m_info.isCollapsed) {
522 widgetFrame->setVisible(false);
523 collapseButton->setArrowType(Qt::RightArrow);
526 connect (m_paramWidget, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int)), this, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int)));
528 connect(m_paramWidget, SIGNAL(startFilterJob(QString,QString,QString,QString,QString,QString)), this, SIGNAL(startFilterJob(QString,QString,QString,QString,QString,QString)));
530 connect (this, SIGNAL(syncEffectsPos(int)), m_paramWidget, SIGNAL(syncEffectsPos(int)));
531 connect (this, SIGNAL(effectStateChanged(bool)), m_paramWidget, SIGNAL(effectStateChanged(bool)));
532 connect (m_paramWidget, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
533 connect (m_paramWidget, SIGNAL(seekTimeline(int)), this, SIGNAL(seekTimeline(int)));
538 bool CollapsibleEffect::isGroup() const
543 void CollapsibleEffect::updateTimecodeFormat()
545 m_paramWidget->updateTimecodeFormat();
546 if (!m_subParamWidgets.isEmpty()) {
548 for (int i = 0; i < m_subParamWidgets.count(); i++)
549 m_subParamWidgets.at(i)->updateTimecodeFormat();
553 void CollapsibleEffect::slotSyncEffectsPos(int pos)
555 emit syncEffectsPos(pos);
558 void CollapsibleEffect::dragEnterEvent(QDragEnterEvent *event)
560 if (event->mimeData()->hasFormat("kdenlive/effectslist")) {
561 frame->setProperty("active", true);
562 frame->setStyleSheet(frame->styleSheet());
563 event->acceptProposedAction();
567 void CollapsibleEffect::dragLeaveEvent(QDragLeaveEvent */*event*/)
569 frame->setProperty("active", false);
570 frame->setStyleSheet(frame->styleSheet());
573 void CollapsibleEffect::dropEvent(QDropEvent *event)
575 frame->setProperty("active", false);
576 frame->setStyleSheet(frame->styleSheet());
577 const QString effects = QString::fromUtf8(event->mimeData()->data("kdenlive/effectslist"));
578 //event->acceptProposedAction();
580 doc.setContent(effects, true);
581 QDomElement e = doc.documentElement();
582 int ix = e.attribute("kdenlive_ix").toInt();
583 if (ix == effectIndex()) {
584 // effect dropped on itself, reject
589 // effect dropped from effects list, add it
590 e.setAttribute("kdenlive_ix", ix);
591 event->setDropAction(Qt::CopyAction);
596 emit moveEffect(ix, effectIndex(), m_info.groupIndex, m_info.groupName);
597 event->setDropAction(Qt::MoveAction);
601 ParameterContainer::ParameterContainer(QDomElement effect, ItemInfo info, EffectMetaInfo *metaInfo, QWidget * parent) :
602 m_keyframeEditor(NULL),
603 m_geometryWidget(NULL),
604 m_metaInfo(metaInfo),
607 m_in = info.cropStart.frames(KdenliveSettings::project_fps());
608 m_out = (info.cropStart + info.cropDuration).frames(KdenliveSettings::project_fps()) - 1;
610 QDomNodeList namenode = effect.childNodes(); //elementsByTagName("parameter");
612 QDomElement e = effect.toElement();
613 int minFrame = e.attribute("start").toInt();
614 int maxFrame = e.attribute("end").toInt();
615 // In transitions, maxFrame is in fact one frame after the end of transition
616 if (maxFrame > 0) maxFrame --;
618 bool disable = effect.attribute("disable") == "1" && KdenliveSettings::disable_effect_parameters();
619 parent->setEnabled(!disable);
622 m_vbox = new QVBoxLayout(parent);
623 m_vbox->setContentsMargins(2, 0, 2, 0);
624 m_vbox->setSpacing(2);
626 for (int i = 0; i < namenode.count() ; i++) {
627 QDomElement pa = namenode.item(i).toElement();
628 if (pa.tagName() != "parameter") continue;
629 QDomElement na = pa.firstChildElement("name");
630 QDomElement commentElem = pa.firstChildElement("comment");
631 QString type = pa.attribute("type");
632 QString paramName = na.isNull() ? pa.attribute("name") : i18n(na.text().toUtf8().data());
634 if (!commentElem.isNull())
635 comment = i18n(commentElem.text().toUtf8().data());
636 QWidget * toFillin = new QWidget(parent);
637 QString value = pa.attribute("value").isNull() ?
638 pa.attribute("default") : pa.attribute("value");
641 /** See effects/README for info on the different types */
643 if (type == "double" || type == "constant") {
646 if (pa.attribute("min").contains('%'))
647 min = ProfilesDialog::getStringEval(m_metaInfo->profile, pa.attribute("min"), m_metaInfo->frameSize);
649 min = pa.attribute("min").toDouble();
650 if (pa.attribute("max").contains('%'))
651 max = ProfilesDialog::getStringEval(m_metaInfo->profile, pa.attribute("max"), m_metaInfo->frameSize);
653 max = pa.attribute("max").toDouble();
655 DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, value.toDouble(), min, max,
656 pa.attribute("default").toDouble(), comment, -1, pa.attribute("suffix"), pa.attribute("decimals").toInt(), parent);
657 doubleparam->setFocusPolicy(Qt::StrongFocus);
658 m_vbox->addWidget(doubleparam);
659 m_valueItems[paramName] = doubleparam;
660 connect(doubleparam, SIGNAL(valueChanged(double)), this, SLOT(slotCollectAllParameters()));
661 connect(this, SIGNAL(showComments(bool)), doubleparam, SLOT(slotShowComment(bool)));
662 } else if (type == "list") {
663 Listval *lsval = new Listval;
664 lsval->setupUi(toFillin);
665 lsval->list->setFocusPolicy(Qt::StrongFocus);
666 QStringList listitems = pa.attribute("paramlist").split(';');
667 if (listitems.count() == 1) {
668 // probably custom effect created before change to ';' as separator
669 listitems = pa.attribute("paramlist").split(",");
671 QDomElement list = pa.firstChildElement("paramlistdisplay");
672 QStringList listitemsdisplay;
673 if (!list.isNull()) {
674 listitemsdisplay = i18n(list.text().toUtf8().data()).split(',');
676 listitemsdisplay = i18n(pa.attribute("paramlistdisplay").toUtf8().data()).split(',');
678 if (listitemsdisplay.count() != listitems.count())
679 listitemsdisplay = listitems;
680 lsval->list->setIconSize(QSize(30, 30));
681 for (int i = 0; i < listitems.count(); i++) {
682 lsval->list->addItem(listitemsdisplay.at(i), listitems.at(i));
683 QString entry = listitems.at(i);
684 if (!entry.isEmpty() && (entry.endsWith(".png") || entry.endsWith(".pgm"))) {
685 if (!CollapsibleEffect::iconCache.contains(entry)) {
687 CollapsibleEffect::iconCache[entry] = pix.scaled(30, 30);
689 lsval->list->setItemIcon(i, QPixmap::fromImage(CollapsibleEffect::iconCache[entry]));
692 if (!value.isEmpty()) lsval->list->setCurrentIndex(listitems.indexOf(value));
693 lsval->name->setText(paramName);
694 lsval->labelComment->setText(comment);
695 lsval->widgetComment->setHidden(true);
696 m_valueItems[paramName] = lsval;
697 connect(lsval->list, SIGNAL(currentIndexChanged(int)) , this, SLOT(slotCollectAllParameters()));
698 if (!comment.isEmpty())
699 connect(this, SIGNAL(showComments(bool)), lsval->widgetComment, SLOT(setVisible(bool)));
700 m_uiItems.append(lsval);
701 } else if (type == "bool") {
702 Boolval *bval = new Boolval;
703 bval->setupUi(toFillin);
704 bval->checkBox->setCheckState(value == "0" ? Qt::Unchecked : Qt::Checked);
705 bval->name->setText(paramName);
706 bval->labelComment->setText(comment);
707 bval->widgetComment->setHidden(true);
708 m_valueItems[paramName] = bval;
709 connect(bval->checkBox, SIGNAL(stateChanged(int)) , this, SLOT(slotCollectAllParameters()));
710 if (!comment.isEmpty())
711 connect(this, SIGNAL(showComments(bool)), bval->widgetComment, SLOT(setVisible(bool)));
712 m_uiItems.append(bval);
713 } else if (type == "complex") {
714 ComplexParameter *pl = new ComplexParameter;
715 pl->setupParam(effect, pa.attribute("name"), 0, 100);
716 m_vbox->addWidget(pl);
717 m_valueItems[paramName+"complex"] = pl;
718 connect(pl, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
719 } else if (type == "geometry") {
720 if (KdenliveSettings::on_monitor_effects()) {
721 m_geometryWidget = new GeometryWidget(m_metaInfo->monitor, m_metaInfo->timecode, 0, true, effect.hasAttribute("showrotation"), parent);
722 m_geometryWidget->setFrameSize(m_metaInfo->frameSize);
723 m_geometryWidget->slotShowScene(!disable);
724 // connect this before setupParam to make sure the monitor scene shows up at startup
725 connect(m_geometryWidget, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
726 connect(m_geometryWidget, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
727 if (minFrame == maxFrame)
728 m_geometryWidget->setupParam(pa, m_in, m_out);
730 m_geometryWidget->setupParam(pa, minFrame, maxFrame);
731 m_vbox->addWidget(m_geometryWidget);
732 m_valueItems[paramName+"geometry"] = m_geometryWidget;
733 connect(m_geometryWidget, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
734 connect(this, SIGNAL(syncEffectsPos(int)), m_geometryWidget, SLOT(slotSyncPosition(int)));
735 connect(this, SIGNAL(effectStateChanged(bool)), m_geometryWidget, SLOT(slotShowScene(bool)));
737 Geometryval *geo = new Geometryval(m_metaInfo->profile, m_metaInfo->timecode, m_metaInfo->frameSize, 0);
738 if (minFrame == maxFrame)
739 geo->setupParam(pa, m_in, m_out);
741 geo->setupParam(pa, minFrame, maxFrame);
742 m_vbox->addWidget(geo);
743 m_valueItems[paramName+"geometry"] = geo;
744 connect(geo, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
745 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
746 connect(this, SIGNAL(syncEffectsPos(int)), geo, SLOT(slotSyncPosition(int)));
748 } else if (type == "addedgeometry") {
749 // this is a parameter that should be linked to the geometry widget, for example rotation, shear, ...
750 if (m_geometryWidget) m_geometryWidget->addParameter(pa);
751 } else if (type == "keyframe" || type == "simplekeyframe") {
752 // keyframe editor widget
753 if (m_keyframeEditor == NULL) {
755 if (pa.attribute("widget") == "corners") {
756 // we want a corners-keyframe-widget
757 CornersWidget *corners = new CornersWidget(m_metaInfo->monitor, pa, m_in, m_out, m_metaInfo->timecode, e.attribute("active_keyframe", "-1").toInt(), parent);
758 corners->slotShowScene(!disable);
759 connect(corners, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
760 connect(this, SIGNAL(effectStateChanged(bool)), corners, SLOT(slotShowScene(bool)));
761 connect(this, SIGNAL(syncEffectsPos(int)), corners, SLOT(slotSyncPosition(int)));
762 geo = static_cast<KeyframeEdit *>(corners);
764 geo = new KeyframeEdit(pa, m_in, m_out, m_metaInfo->timecode, e.attribute("active_keyframe", "-1").toInt());
766 m_vbox->addWidget(geo);
767 m_valueItems[paramName+"keyframe"] = geo;
768 m_keyframeEditor = geo;
769 connect(geo, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
770 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
771 connect(this, SIGNAL(showComments(bool)), geo, SIGNAL(showComments(bool)));
773 // we already have a keyframe editor, so just add another column for the new param
774 m_keyframeEditor->addParameter(pa);
776 } else if (type == "color") {
777 if (value.startsWith('#'))
778 value = value.replace('#', "0x");
779 ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, value, parent);
780 m_vbox->addWidget(choosecolor);
781 m_valueItems[paramName] = choosecolor;
782 connect(choosecolor, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int)));
783 connect(choosecolor, SIGNAL(modified()) , this, SLOT(slotCollectAllParameters()));
784 } else if (type == "position") {
785 int pos = value.toInt();
786 if (effect.attribute("id") == "fadein" || effect.attribute("id") == "fade_from_black") {
788 } else if (effect.attribute("id") == "fadeout" || effect.attribute("id") == "fade_to_black") {
789 // fadeout position starts from clip end
792 PositionEdit *posedit = new PositionEdit(paramName, pos, 0, m_out - m_in, m_metaInfo->timecode);
793 m_vbox->addWidget(posedit);
794 m_valueItems[paramName+"position"] = posedit;
795 connect(posedit, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
796 } else if (type == "curve") {
797 KisCurveWidget *curve = new KisCurveWidget(parent);
798 curve->setMaxPoints(pa.attribute("max").toInt());
799 QList<QPointF> points;
800 int number = EffectsList::parameter(e, pa.attribute("number")).toInt();
801 QString inName = pa.attribute("inpoints");
802 QString outName = pa.attribute("outpoints");
803 int start = pa.attribute("min").toInt();
804 for (int j = start; j <= number; j++) {
806 in.replace("%i", QString::number(j));
807 QString out = outName;
808 out.replace("%i", QString::number(j));
809 points << QPointF(EffectsList::parameter(e, in).toDouble(), EffectsList::parameter(e, out).toDouble());
811 if (!points.isEmpty())
812 curve->setCurve(KisCubicCurve(points));
813 MySpinBox *spinin = new MySpinBox();
814 spinin->setRange(0, 1000);
815 MySpinBox *spinout = new MySpinBox();
816 spinout->setRange(0, 1000);
817 curve->setupInOutControls(spinin, spinout, 0, 1000);
818 m_vbox->addWidget(curve);
819 m_vbox->addWidget(spinin);
820 m_vbox->addWidget(spinout);
822 connect(curve, SIGNAL(modified()), this, SLOT(slotCollectAllParameters()));
823 m_valueItems[paramName] = curve;
825 QString depends = pa.attribute("depends");
826 if (!depends.isEmpty())
827 meetDependency(paramName, type, EffectsList::parameter(e, depends));
828 } else if (type == "bezier_spline") {
829 BezierSplineWidget *widget = new BezierSplineWidget(value, parent);
831 m_vbox->addWidget(widget);
832 m_valueItems[paramName] = widget;
833 connect(widget, SIGNAL(modified()), this, SLOT(slotCollectAllParameters()));
834 QString depends = pa.attribute("depends");
835 if (!depends.isEmpty())
836 meetDependency(paramName, type, EffectsList::parameter(e, depends));
838 } else if (type == "roto-spline") {
839 RotoWidget *roto = new RotoWidget(value, m_metaInfo->monitor, info, m_metaInfo->timecode, parent);
840 roto->slotShowScene(!disable);
841 connect(roto, SIGNAL(valueChanged()), this, SLOT(slotCollectAllParameters()));
842 connect(roto, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
843 connect(roto, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
844 connect(this, SIGNAL(syncEffectsPos(int)), roto, SLOT(slotSyncPosition(int)));
845 connect(this, SIGNAL(effectStateChanged(bool)), roto, SLOT(slotShowScene(bool)));
846 m_vbox->addWidget(roto);
847 m_valueItems[paramName] = roto;
849 } else if (type == "wipe") {
850 Wipeval *wpval = new Wipeval;
851 wpval->setupUi(toFillin);
852 wipeInfo w = getWipeInfo(value);
855 wpval->start_up->setChecked(true);
858 wpval->start_down->setChecked(true);
861 wpval->start_right->setChecked(true);
864 wpval->start_left->setChecked(true);
867 wpval->start_center->setChecked(true);
872 wpval->end_up->setChecked(true);
875 wpval->end_down->setChecked(true);
878 wpval->end_right->setChecked(true);
881 wpval->end_left->setChecked(true);
884 wpval->end_center->setChecked(true);
887 wpval->start_transp->setValue(w.startTransparency);
888 wpval->end_transp->setValue(w.endTransparency);
889 m_valueItems[paramName] = wpval;
890 connect(wpval->end_up, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
891 connect(wpval->end_down, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
892 connect(wpval->end_left, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
893 connect(wpval->end_right, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
894 connect(wpval->end_center, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
895 connect(wpval->start_up, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
896 connect(wpval->start_down, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
897 connect(wpval->start_left, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
898 connect(wpval->start_right, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
899 connect(wpval->start_center, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
900 connect(wpval->start_transp, SIGNAL(valueChanged(int)), this, SLOT(slotCollectAllParameters()));
901 connect(wpval->end_transp, SIGNAL(valueChanged(int)), this, SLOT(slotCollectAllParameters()));
902 //wpval->title->setTitle(na.toElement().text());
903 m_uiItems.append(wpval);
904 } else if (type == "url") {
905 Urlval *cval = new Urlval;
906 cval->setupUi(toFillin);
907 cval->label->setText(paramName);
908 cval->urlwidget->fileDialog()->setFilter(ProjectList::getExtensions());
909 m_valueItems[paramName] = cval;
910 cval->urlwidget->setUrl(KUrl(value));
911 connect(cval->urlwidget, SIGNAL(returnPressed()) , this, SLOT(slotCollectAllParameters()));
912 connect(cval->urlwidget, SIGNAL(urlSelected(const KUrl&)) , this, SLOT(slotCollectAllParameters()));
913 m_uiItems.append(cval);
914 } else if (type == "keywords") {
915 Keywordval* kval = new Keywordval;
916 kval->setupUi(toFillin);
917 kval->label->setText(paramName);
918 kval->lineeditwidget->setText(value);
919 QDomElement klistelem = pa.firstChildElement("keywords");
920 QDomElement kdisplaylistelem = pa.firstChildElement("keywordsdisplay");
921 QStringList keywordlist;
922 QStringList keyworddisplaylist;
923 if (!klistelem.isNull()) {
924 keywordlist = klistelem.text().split(';');
925 keyworddisplaylist = i18n(kdisplaylistelem.text().toUtf8().data()).split(';');
927 if (keyworddisplaylist.count() != keywordlist.count()) {
928 keyworddisplaylist = keywordlist;
930 for (int i = 0; i < keywordlist.count(); i++) {
931 kval->comboboxwidget->addItem(keyworddisplaylist.at(i), keywordlist.at(i));
933 // Add disabled user prompt at index 0
934 kval->comboboxwidget->insertItem(0, i18n("<select a keyword>"), "");
935 kval->comboboxwidget->model()->setData( kval->comboboxwidget->model()->index(0,0), QVariant(Qt::NoItemFlags), Qt::UserRole -1);
936 kval->comboboxwidget->setCurrentIndex(0);
937 m_valueItems[paramName] = kval;
938 connect(kval->lineeditwidget, SIGNAL(editingFinished()) , this, SLOT(collectAllParameters()));
939 connect(kval->comboboxwidget, SIGNAL(activated (const QString&)), this, SLOT(collectAllParameters()));
940 m_uiItems.append(kval);
941 } else if (type == "fontfamily") {
942 Fontval* fval = new Fontval;
943 fval->setupUi(toFillin);
944 fval->name->setText(paramName);
945 fval->fontfamilywidget->setCurrentFont(QFont(value));
946 m_valueItems[paramName] = fval;
947 connect(fval->fontfamilywidget, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(collectAllParameters())) ;
948 m_uiItems.append(fval);
949 } else if (type == "filterjob") {
950 QVBoxLayout *l= new QVBoxLayout(toFillin);
951 QPushButton *button = new QPushButton(paramName, toFillin);
952 l->addWidget(button);
953 m_valueItems[paramName] = button;
954 connect(button, SIGNAL(pressed()), this, SLOT(slotStartFilterJobAction()));
961 m_vbox->addWidget(toFillin);
965 m_vbox->addStretch();
967 if (m_keyframeEditor)
968 m_keyframeEditor->checkVisibleParam();
970 // Make sure all doubleparam spinboxes have the same width, looks much better
971 QList<DoubleParameterWidget *> allWidgets = findChildren<DoubleParameterWidget *>();
973 for (int i = 0; i < allWidgets.count(); i++) {
974 if (minSize < allWidgets.at(i)->spinSize()) minSize = allWidgets.at(i)->spinSize();
976 for (int i = 0; i < allWidgets.count(); i++) {
977 allWidgets.at(i)->setSpinSize(minSize);
981 ParameterContainer::~ParameterContainer()
987 void ParameterContainer::meetDependency(const QString& name, QString type, QString value)
989 if (type == "curve") {
990 KisCurveWidget *curve = (KisCurveWidget*)m_valueItems[name];
992 int color = value.toInt();
993 curve->setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(curve->size(), (ColorTools::ColorsRGB)(color == 3 ? 4 : color), 0.8)));
995 } else if (type == "bezier_spline") {
996 BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems[name];
998 widget->setMode((BezierSplineWidget::CurveModes)((int)(value.toDouble() * 10)));
1003 wipeInfo ParameterContainer::getWipeInfo(QString value)
1006 // Convert old geometry values that used a comma as separator
1007 if (value.contains(',')) value.replace(',','/');
1008 QString start = value.section(';', 0, 0);
1009 QString end = value.section(';', 1, 1).section('=', 1, 1);
1010 if (start.startsWith("-100%/0"))
1012 else if (start.startsWith("100%/0"))
1014 else if (start.startsWith("0%/100%"))
1016 else if (start.startsWith("0%/-100%"))
1019 info.start = CENTER;
1021 if (start.count(':') == 2)
1022 info.startTransparency = start.section(':', -1).toInt();
1024 info.startTransparency = 100;
1026 if (end.startsWith("-100%/0"))
1028 else if (end.startsWith("100%/0"))
1030 else if (end.startsWith("0%/100%"))
1032 else if (end.startsWith("0%/-100%"))
1037 if (end.count(':') == 2)
1038 info.endTransparency = end.section(':', -1).toInt();
1040 info.endTransparency = 100;
1045 void ParameterContainer::updateTimecodeFormat()
1047 if (m_keyframeEditor)
1048 m_keyframeEditor->updateTimecodeFormat();
1050 QDomNodeList namenode = m_effect.elementsByTagName("parameter");
1051 for (int i = 0; i < namenode.count() ; i++) {
1052 QDomNode pa = namenode.item(i);
1053 QDomElement na = pa.firstChildElement("name");
1054 QString type = pa.attributes().namedItem("type").nodeValue();
1055 QString paramName = na.isNull() ? pa.attributes().namedItem("name").nodeValue() : i18n(na.text().toUtf8().data());
1057 if (type == "geometry") {
1058 if (KdenliveSettings::on_monitor_effects()) {
1059 if (m_geometryWidget) m_geometryWidget->updateTimecodeFormat();
1061 Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
1062 geom->updateTimecodeFormat();
1065 } else if (type == "position") {
1066 PositionEdit *posi = ((PositionEdit*)m_valueItems[paramName+"position"]);
1067 posi->updateTimecodeFormat();
1070 } else if (type == "roto-spline") {
1071 RotoWidget *widget = static_cast<RotoWidget *>(m_valueItems[paramName]);
1072 widget->updateTimecodeFormat();
1078 void ParameterContainer::slotCollectAllParameters()
1080 if (m_valueItems.isEmpty() || m_effect.isNull()) return;
1082 locale.setNumberOptions(QLocale::OmitGroupSeparator);
1083 const QDomElement oldparam = m_effect.cloneNode().toElement();
1084 //QDomElement newparam = oldparam.cloneNode().toElement();
1085 QDomNodeList namenode = m_effect.elementsByTagName("parameter");
1087 for (int i = 0; i < namenode.count() ; i++) {
1088 QDomNode pa = namenode.item(i);
1089 QDomElement na = pa.firstChildElement("name");
1090 QString type = pa.attributes().namedItem("type").nodeValue();
1091 QString paramName = na.isNull() ? pa.attributes().namedItem("name").nodeValue() : i18n(na.text().toUtf8().data());
1092 if (type == "complex")
1093 paramName.append("complex");
1094 else if (type == "position")
1095 paramName.append("position");
1096 else if (type == "geometry")
1097 paramName.append("geometry");
1098 else if (type == "keyframe")
1099 paramName.append("keyframe");
1100 if (type != "simplekeyframe" && type != "fixed" && type != "addedgeometry" && !m_valueItems.contains(paramName)) {
1101 kDebug() << "// Param: " << paramName << " NOT FOUND";
1106 if (type == "double" || type == "constant") {
1107 DoubleParameterWidget *doubleparam = (DoubleParameterWidget*)m_valueItems.value(paramName);
1108 setValue = locale.toString(doubleparam->getValue());
1109 } else if (type == "list") {
1110 KComboBox *box = ((Listval*)m_valueItems.value(paramName))->list;
1111 setValue = box->itemData(box->currentIndex()).toString();
1112 } else if (type == "bool") {
1113 QCheckBox *box = ((Boolval*)m_valueItems.value(paramName))->checkBox;
1114 setValue = box->checkState() == Qt::Checked ? "1" : "0" ;
1115 } else if (type == "color") {
1116 ChooseColorWidget *choosecolor = ((ChooseColorWidget*)m_valueItems.value(paramName));
1117 setValue = choosecolor->getColor();
1118 } else if (type == "complex") {
1119 ComplexParameter *complex = ((ComplexParameter*)m_valueItems.value(paramName));
1120 namenode.item(i) = complex->getParamDesc();
1121 } else if (type == "geometry") {
1122 if (KdenliveSettings::on_monitor_effects()) {
1123 if (m_geometryWidget) namenode.item(i).toElement().setAttribute("value", m_geometryWidget->getValue());
1125 Geometryval *geom = ((Geometryval*)m_valueItems.value(paramName));
1126 namenode.item(i).toElement().setAttribute("value", geom->getValue());
1128 } else if (type == "addedgeometry") {
1129 namenode.item(i).toElement().setAttribute("value", m_geometryWidget->getExtraValue(namenode.item(i).toElement().attribute("name")));
1130 } else if (type == "position") {
1131 PositionEdit *pedit = ((PositionEdit*)m_valueItems.value(paramName));
1132 int pos = pedit->getPosition();
1133 setValue = QString::number(pos);
1134 if (m_effect.attribute("id") == "fadein" || m_effect.attribute("id") == "fade_from_black") {
1135 // Make sure duration is not longer than clip
1136 /*if (pos > m_out) {
1138 pedit->setPosition(pos);
1140 EffectsList::setParameter(m_effect, "in", QString::number(m_in));
1141 EffectsList::setParameter(m_effect, "out", QString::number(m_in + pos));
1143 } else if (m_effect.attribute("id") == "fadeout" || m_effect.attribute("id") == "fade_to_black") {
1144 // Make sure duration is not longer than clip
1145 /*if (pos > m_out) {
1147 pedit->setPosition(pos);
1149 EffectsList::setParameter(m_effect, "in", QString::number(m_out - pos));
1150 EffectsList::setParameter(m_effect, "out", QString::number(m_out));
1153 } else if (type == "curve") {
1154 KisCurveWidget *curve = ((KisCurveWidget*)m_valueItems.value(paramName));
1155 QList<QPointF> points = curve->curve().points();
1156 QString number = pa.attributes().namedItem("number").nodeValue();
1157 QString inName = pa.attributes().namedItem("inpoints").nodeValue();
1158 QString outName = pa.attributes().namedItem("outpoints").nodeValue();
1159 int off = pa.attributes().namedItem("min").nodeValue().toInt();
1160 int end = pa.attributes().namedItem("max").nodeValue().toInt();
1161 EffectsList::setParameter(m_effect, number, QString::number(points.count()));
1162 for (int j = 0; (j < points.count() && j + off <= end); j++) {
1163 QString in = inName;
1164 in.replace("%i", QString::number(j + off));
1165 QString out = outName;
1166 out.replace("%i", QString::number(j + off));
1167 EffectsList::setParameter(m_effect, in, locale.toString(points.at(j).x()));
1168 EffectsList::setParameter(m_effect, out, locale.toString(points.at(j).y()));
1170 QString depends = pa.attributes().namedItem("depends").nodeValue();
1171 if (!depends.isEmpty())
1172 meetDependency(paramName, type, EffectsList::parameter(m_effect, depends));
1173 } else if (type == "bezier_spline") {
1174 BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems.value(paramName);
1175 setValue = widget->spline();
1176 QString depends = pa.attributes().namedItem("depends").nodeValue();
1177 if (!depends.isEmpty())
1178 meetDependency(paramName, type, EffectsList::parameter(m_effect, depends));
1180 } else if (type == "roto-spline") {
1181 RotoWidget *widget = static_cast<RotoWidget *>(m_valueItems.value(paramName));
1182 setValue = widget->getSpline();
1184 } else if (type == "wipe") {
1185 Wipeval *wp = (Wipeval*)m_valueItems.value(paramName);
1187 if (wp->start_left->isChecked())
1189 else if (wp->start_right->isChecked())
1191 else if (wp->start_up->isChecked())
1193 else if (wp->start_down->isChecked())
1195 else if (wp->start_center->isChecked())
1196 info.start = CENTER;
1199 info.startTransparency = wp->start_transp->value();
1201 if (wp->end_left->isChecked())
1203 else if (wp->end_right->isChecked())
1205 else if (wp->end_up->isChecked())
1207 else if (wp->end_down->isChecked())
1209 else if (wp->end_center->isChecked())
1213 info.endTransparency = wp->end_transp->value();
1215 setValue = getWipeString(info);
1216 } else if ((type == "simplekeyframe" || type == "keyframe") && m_keyframeEditor) {
1217 QDomElement elem = pa.toElement();
1218 QString realName = i18n(na.toElement().text().toUtf8().data());
1219 QString val = m_keyframeEditor->getValue(realName);
1220 elem.setAttribute("keyframes", val);
1222 if (m_keyframeEditor->isVisibleParam(realName))
1223 elem.setAttribute("intimeline", "1");
1224 else if (elem.hasAttribute("intimeline"))
1225 elem.removeAttribute("intimeline");
1226 } else if (type == "url") {
1227 KUrlRequester *req = ((Urlval*)m_valueItems.value(paramName))->urlwidget;
1228 setValue = req->url().path();
1229 } else if (type == "keywords"){
1230 QLineEdit *line = ((Keywordval*)m_valueItems.value(paramName))->lineeditwidget;
1231 QComboBox *combo = ((Keywordval*)m_valueItems.value(paramName))->comboboxwidget;
1232 if(combo->currentIndex())
1234 QString comboval = combo->itemData(combo->currentIndex()).toString();
1235 line->insert(comboval);
1236 combo->setCurrentIndex(0);
1238 setValue = line->text();
1239 } else if (type == "fontfamily") {
1240 QFontComboBox* fontfamily = ((Fontval*)m_valueItems.value(paramName))->fontfamilywidget;
1241 setValue = fontfamily->currentFont().family();
1243 if (!setValue.isNull())
1244 pa.attributes().namedItem("value").setNodeValue(setValue);
1247 emit parameterChanged(oldparam, m_effect, m_effect.attribute("kdenlive_ix").toInt());
1250 QString ParameterContainer::getWipeString(wipeInfo info)
1255 switch (info.start) {
1257 start = "-100%/0%:100%x100%";
1260 start = "100%/0%:100%x100%";
1263 start = "0%/100%:100%x100%";
1266 start = "0%/-100%:100%x100%";
1269 start = "0%/0%:100%x100%";
1272 start.append(':' + QString::number(info.startTransparency));
1276 end = "-100%/0%:100%x100%";
1279 end = "100%/0%:100%x100%";
1282 end = "0%/100%:100%x100%";
1285 end = "0%/-100%:100%x100%";
1288 end = "0%/0%:100%x100%";
1291 end.append(':' + QString::number(info.endTransparency));
1292 return QString(start + ";-1=" + end);
1295 void ParameterContainer::slotStartFilterJobAction()
1297 QDomNodeList namenode = m_effect.elementsByTagName("parameter");
1298 for (int i = 0; i < namenode.count() ; i++) {
1299 QDomElement pa = namenode.item(i).toElement();
1300 QString type = pa.attribute("type");
1301 if (type == "filterjob") {
1302 emit startFilterJob(pa.attribute("filtertag"), pa.attribute("filterparams"), pa.attribute("finalfilter"), pa.attribute("consumer"), pa.attribute("consumerparams"), pa.attribute("wantedproperties"));
1303 kDebug()<<" - - -PROPS:\n"<<pa.attribute("filtertag")<<"-"<< pa.attribute("filterparams")<<"-"<< pa.attribute("consumer")<<"-"<< pa.attribute("consumerparams")<<"-"<< pa.attribute("wantedproperties");