]> git.sesse.net Git - kdenlive/blob - src/effectstack/collapsibleeffect.cpp
ace7e2843e578fee1574e7fb8a27d323f8d73450
[kdenlive] / src / effectstack / collapsibleeffect.cpp
1 /***************************************************************************
2  *   Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
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.                                   *
8  *                                                                         *
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.                          *
13  *                                                                         *
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  ***************************************************************************/
19
20
21 #include "collapsibleeffect.h"
22
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"
45 #ifdef USE_QJSON
46 #include "rotoscoping/rotowidget.h"
47 #endif
48
49 #include <QInputDialog>
50 #include <QDialog>
51 #include <QMenu>
52 #include <QVBoxLayout>
53 #include <KDebug>
54 #include <KGlobalSettings>
55 #include <KLocale>
56 #include <KMessageBox>
57 #include <KStandardDirs>
58 #include <KFileDialog>
59 #include <KUrlRequester>
60
61 class Boolval: public QWidget, public Ui::Boolval_UI
62 {
63 };
64
65 class Listval: public QWidget, public Ui::Listval_UI
66 {
67 };
68
69 class Wipeval: public QWidget, public Ui::Wipeval_UI
70 {
71 };
72
73 class Urlval: public QWidget, public Ui::Urlval_UI
74 {
75 };
76
77 class Keywordval: public QWidget, public Ui::Keywordval_UI
78 {
79 };
80
81 class Fontval: public QWidget, public Ui::Fontval_UI
82 {
83 };
84
85 QMap<QString, QImage> CollapsibleEffect::iconCache;
86
87 void clearLayout(QLayout *layout)
88 {
89     QLayoutItem *item;
90     while((item = layout->takeAt(0))) {
91         if (item->layout()) {
92             clearLayout(item->layout());
93             delete item->layout();
94         }
95         if (item->widget()) {
96             delete item->widget();
97         }
98         delete item;
99     }
100 }
101
102 MySpinBox::MySpinBox(QWidget * parent):
103     QSpinBox(parent)
104 {
105     setFocusPolicy(Qt::StrongFocus);
106 }
107
108 void MySpinBox::focusInEvent(QFocusEvent*)
109 {
110      setFocusPolicy(Qt::WheelFocus);
111 }
112
113 void MySpinBox::focusOutEvent(QFocusEvent*)
114 {
115      setFocusPolicy(Qt::StrongFocus);
116 }
117
118
119 CollapsibleEffect::CollapsibleEffect(QDomElement effect, QDomElement original_effect, ItemInfo info, int ix, EffectMetaInfo *metaInfo, bool lastEffect, QWidget * parent) :
120         QWidget(parent),
121         m_paramWidget(NULL),
122         m_effect(effect),
123         m_original_effect(original_effect),
124         m_lastEffect(lastEffect),
125         m_active(false)
126 {
127     //setMouseTracking(true);
128     setupUi(this);
129     frame->setBackgroundRole(QPalette::Midlight);
130     frame->setAutoFillBackground(true);
131     setFont(KGlobalSettings::smallestReadableFont());
132    
133     buttonUp->setIcon(KIcon("go-up"));
134     buttonUp->setToolTip(i18n("Move effect up"));
135     if (!lastEffect) {
136         buttonDown->setIcon(KIcon("go-down"));
137         buttonDown->setToolTip(i18n("Move effect down"));
138     }
139     buttonDel->setIcon(KIcon("edit-delete"));
140     buttonDel->setToolTip(i18n("Delete effect"));
141
142     buttonUp->setVisible(false);
143     buttonDown->setVisible(false);
144     buttonDel->setVisible(false);
145     
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"));
151     QDomElement namenode = m_effect.firstChildElement("name");
152     if (namenode.isNull()) return;
153     title->setText(i18n(namenode.text().toUtf8().data()));
154     QString type = m_effect.attribute("type", QString());
155     KIcon icon;
156     if (type == "audio") icon = KIcon("kdenlive-show-audio");
157     else if (m_effect.attribute("tag") == "region") icon = KIcon("kdenlive-mask-effect");
158     else if (type == "custom") icon = KIcon("kdenlive-custom-effect");
159     else icon = KIcon("kdenlive-show-video");
160     title->setIcon(icon);
161             
162     m_menu = new QMenu;
163     m_menu->addAction(KIcon("view-refresh"), i18n("Reset effect"), this, SLOT(slotResetEffect()));
164     m_menu->addAction(KIcon("document-save"), i18n("Save effect"), this, SLOT(slotSaveEffect()));
165     title->setMenu(m_menu);
166     
167     if (m_effect.attribute("disable") == "1") {
168         enabledBox->setCheckState(Qt::Unchecked);
169         title->setEnabled(false);
170     }
171     else {
172         enabledBox->setCheckState(Qt::Checked);
173     }
174
175     connect(collapseButton, SIGNAL(clicked()), this, SLOT(slotSwitch()));
176     connect(enabledBox, SIGNAL(toggled(bool)), this, SLOT(slotEnable(bool)));
177     connect(buttonUp, SIGNAL(clicked()), this, SLOT(slotEffectUp()));
178     connect(buttonDown, SIGNAL(clicked()), this, SLOT(slotEffectDown()));
179     connect(buttonDel, SIGNAL(clicked()), this, SLOT(slotDeleteEffect()));
180
181     setupWidget(info, ix, metaInfo);
182     Q_FOREACH( QSpinBox * sp, findChildren<QSpinBox*>() ) {
183         sp->installEventFilter( this );
184         sp->setFocusPolicy( Qt::StrongFocus );
185     }
186     Q_FOREACH( KComboBox * cb, findChildren<KComboBox*>() ) {
187         cb->installEventFilter( this );
188         cb->setFocusPolicy( Qt::StrongFocus );
189     }
190     Q_FOREACH( QProgressBar * cb, findChildren<QProgressBar*>() ) {
191         cb->installEventFilter( this );
192         cb->setFocusPolicy( Qt::StrongFocus );
193     }
194 }
195
196 CollapsibleEffect::~CollapsibleEffect()
197 {
198     if (m_paramWidget) delete m_paramWidget;
199     delete m_menu;
200 }
201
202 bool CollapsibleEffect::eventFilter( QObject * o, QEvent * e ) 
203 {
204     if (e->type() == QEvent::Wheel) {
205         QWheelEvent *we = static_cast<QWheelEvent *>(e);
206         if (we->modifiers() != Qt::NoModifier) {
207             e->accept();
208             return false;
209         }
210         if (qobject_cast<QAbstractSpinBox*>(o)) {
211             if(qobject_cast<QAbstractSpinBox*>(o)->focusPolicy() == Qt::WheelFocus)
212             {
213                 e->accept();
214                 return false;
215             }
216             else
217             {
218                 e->ignore();
219                 return true;
220             }
221         }
222         if (qobject_cast<KComboBox*>(o)) {
223             if(qobject_cast<KComboBox*>(o)->focusPolicy() == Qt::WheelFocus)
224             {
225                 e->accept();
226                 return false;
227             }
228             else
229             {
230                 e->ignore();
231                 return true;
232             }
233         }
234         if (qobject_cast<QProgressBar*>(o)) {
235             if(qobject_cast<QProgressBar*>(o)->focusPolicy() == Qt::WheelFocus)
236             {
237                 e->accept();
238                 return false;
239             }
240             else
241             {
242                 e->ignore();
243                 return true;
244             }
245         }
246     }
247     return QWidget::eventFilter(o, e);
248 }
249
250 QDomElement CollapsibleEffect::effect() const
251 {
252     return m_effect;
253 }
254
255 void CollapsibleEffect::setActive(bool activate)
256 {
257     m_active = activate;
258     frame->setBackgroundRole(m_active ? QPalette::Mid : QPalette::Midlight);
259     frame->setAutoFillBackground(activate);
260 }
261
262 void CollapsibleEffect::mouseDoubleClickEvent ( QMouseEvent * event )
263 {
264     if (frame->underMouse() && collapseButton->isEnabled()) slotSwitch();
265     QWidget::mouseDoubleClickEvent(event);
266 }
267
268 void CollapsibleEffect::mousePressEvent ( QMouseEvent *event )
269 {
270     if (!m_active) emit activateEffect(m_paramWidget->index());
271     QWidget::mousePressEvent(event);
272 }
273
274 void CollapsibleEffect::enterEvent ( QEvent * event )
275 {
276     if (m_paramWidget->index() > 0) buttonUp->setVisible(true);
277     if (!m_lastEffect) buttonDown->setVisible(true);
278     buttonDel->setVisible(true);
279     if (!m_active) frame->setBackgroundRole(QPalette::Midlight);
280     frame->setAutoFillBackground(true);
281     QWidget::enterEvent(event);
282 }
283
284 void CollapsibleEffect::leaveEvent ( QEvent * event )
285 {
286     buttonUp->setVisible(false);
287     buttonDown->setVisible(false);
288     buttonDel->setVisible(false);
289     if (!m_active) frame->setAutoFillBackground(false);
290     QWidget::leaveEvent(event);
291 }
292
293 void CollapsibleEffect::slotEnable(bool enable)
294 {
295     title->setEnabled(enable);
296     m_effect.setAttribute("disable", enable ? 0 : 1);
297     if (enable || KdenliveSettings::disable_effect_parameters()) {
298         widgetFrame->setEnabled(enable);
299     }
300     emit effectStateChanged(!enable, m_paramWidget->index());
301 }
302
303 void CollapsibleEffect::slotDeleteEffect()
304 {
305     emit deleteEffect(m_effect, m_paramWidget->index());
306 }
307
308 void CollapsibleEffect::slotEffectUp()
309 {
310     emit changeEffectPosition(m_paramWidget->index(), true);
311 }
312
313 void CollapsibleEffect::slotEffectDown()
314 {
315     emit changeEffectPosition(m_paramWidget->index(), false);
316 }
317
318 void CollapsibleEffect::slotSaveEffect()
319 {
320     QString name = QInputDialog::getText(this, i18n("Save Effect"), i18n("Name for saved effect: "));
321     if (name.isEmpty()) return;
322     QString path = KStandardDirs::locateLocal("appdata", "effects/", true);
323     path = path + name + ".xml";
324     if (QFile::exists(path)) if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", path)) == KMessageBox::No) return;
325
326     QDomDocument doc;
327     QDomElement effect = m_effect.cloneNode().toElement();
328     doc.appendChild(doc.importNode(effect, true));
329     effect = doc.firstChild().toElement();
330     effect.removeAttribute("kdenlive_ix");
331     effect.setAttribute("id", name);
332     effect.setAttribute("type", "custom");
333     QDomElement effectname = effect.firstChildElement("name");
334     effect.removeChild(effectname);
335     effectname = doc.createElement("name");
336     QDomText nametext = doc.createTextNode(name);
337     effectname.appendChild(nametext);
338     effect.insertBefore(effectname, QDomNode());
339     QDomElement effectprops = effect.firstChildElement("properties");
340     effectprops.setAttribute("id", name);
341     effectprops.setAttribute("type", "custom");
342
343     QFile file(path);
344     if (file.open(QFile::WriteOnly | QFile::Truncate)) {
345         QTextStream out(&file);
346         out << doc.toString();
347     }
348     file.close();
349     emit reloadEffects();
350 }
351
352 void CollapsibleEffect::slotResetEffect()
353 {
354     emit resetEffect(m_paramWidget->index());
355 }
356
357 void CollapsibleEffect::slotSwitch()
358 {
359     bool enable = !widgetFrame->isVisible();
360     slotShow(enable);
361 }
362
363 void CollapsibleEffect::slotShow(bool show)
364 {
365     widgetFrame->setVisible(show);
366     if (show) {
367         collapseButton->setArrowType(Qt::DownArrow);
368         m_original_effect.removeAttribute("k_collapsed");
369     }
370     else {
371         collapseButton->setArrowType(Qt::RightArrow);
372         m_original_effect.setAttribute("k_collapsed", 1);
373     }
374 }
375
376 void CollapsibleEffect::updateWidget(ItemInfo info, int index, QDomElement effect, EffectMetaInfo *metaInfo)
377 {
378     if (m_paramWidget) {
379         // cleanup
380         delete m_paramWidget;
381         m_paramWidget = NULL;
382     }
383     m_effect = effect;
384     setupWidget(info, index, metaInfo);
385 }
386
387 void CollapsibleEffect::setupWidget(ItemInfo info, int index, EffectMetaInfo *metaInfo)
388 {
389     if (m_effect.isNull()) {
390 //         kDebug() << "// EMPTY EFFECT STACK";
391         return;
392     }
393
394     if (m_effect.attribute("tag") == "region") {
395         QVBoxLayout *vbox = new QVBoxLayout(widgetFrame);
396         vbox->setContentsMargins(0, 0, 0, 0);
397         vbox->setSpacing(2);
398         QDomNodeList effects =  m_effect.elementsByTagName("effect");
399         QDomNodeList origin_effects =  m_original_effect.elementsByTagName("effect");
400         QWidget *container = new QWidget(widgetFrame);
401         vbox->addWidget(container);
402         m_paramWidget = new ParameterContainer(m_effect.toElement(), info, metaInfo, index, container);
403         for (int i = 0; i < effects.count(); i++) {
404             CollapsibleEffect *coll = new CollapsibleEffect(effects.at(i).toElement(), origin_effects.at(i).toElement(), info, i, metaInfo, container);
405             m_subParamWidgets.append(coll);
406             //container = new QWidget(widgetFrame);
407             vbox->addWidget(coll);
408             //p = new ParameterContainer(effects.at(i).toElement(), info, isEffect, container);
409         }
410         
411     }
412     else {
413         m_paramWidget = new ParameterContainer(m_effect, info, metaInfo, index, widgetFrame);
414         if (m_effect.firstChildElement("parameter").isNull()) {
415             // Effect has no parameter, don't allow expand
416             collapseButton->setEnabled(false);
417             widgetFrame->setVisible(false);            
418         }
419     }
420     if (collapseButton->isEnabled()) slotShow(!m_effect.hasAttribute("k_collapsed"));
421     connect (m_paramWidget, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int)), this, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int)));
422     
423     connect(m_paramWidget, SIGNAL(startFilterJob(QString,QString,QString,QString,QString,QString)), this, SIGNAL(startFilterJob(QString,QString,QString,QString,QString,QString)));
424     
425     connect (this, SIGNAL(syncEffectsPos(int)), m_paramWidget, SIGNAL(syncEffectsPos(int)));
426     connect (this, SIGNAL(effectStateChanged(bool)), m_paramWidget, SIGNAL(effectStateChanged(bool)));
427     connect (m_paramWidget, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
428     connect (m_paramWidget, SIGNAL(seekTimeline(int)), this, SIGNAL(seekTimeline(int)));
429     
430     
431 }
432
433 void CollapsibleEffect::updateTimecodeFormat()
434 {
435     m_paramWidget->updateTimecodeFormat();
436     if (!m_subParamWidgets.isEmpty()) {
437         // we have a group
438         for (int i = 0; i < m_subParamWidgets.count(); i++)
439             m_subParamWidgets.at(i)->updateTimecodeFormat();
440     }
441 }
442
443 void CollapsibleEffect::slotSyncEffectsPos(int pos)
444 {
445     emit syncEffectsPos(pos);
446 }
447
448
449
450 ParameterContainer::ParameterContainer(QDomElement effect, ItemInfo info, EffectMetaInfo *metaInfo, int index, QWidget * parent) :
451         m_index(index),
452         m_keyframeEditor(NULL),
453         m_geometryWidget(NULL),
454         m_metaInfo(metaInfo),
455         m_effect(effect)
456 {
457     m_in = info.cropStart.frames(KdenliveSettings::project_fps());
458     m_out = (info.cropStart + info.cropDuration).frames(KdenliveSettings::project_fps()) - 1;
459
460     QDomNodeList namenode = effect.childNodes(); //elementsByTagName("parameter");
461     
462     QDomElement e = effect.toElement();
463     int minFrame = e.attribute("start").toInt();
464     int maxFrame = e.attribute("end").toInt();
465     // In transitions, maxFrame is in fact one frame after the end of transition
466     if (maxFrame > 0) maxFrame --;
467
468     bool disable = effect.attribute("disable") == "1" && KdenliveSettings::disable_effect_parameters();
469     parent->setEnabled(!disable);
470
471     bool stretch = true;
472     m_vbox = new QVBoxLayout(parent);
473     m_vbox->setContentsMargins(0, 0, 0, 0);
474     m_vbox->setSpacing(2);
475
476     for (int i = 0; i < namenode.count() ; i++) {
477         QDomElement pa = namenode.item(i).toElement();
478         if (pa.tagName() != "parameter") continue;
479         QDomElement na = pa.firstChildElement("name");
480         QDomElement commentElem = pa.firstChildElement("comment");
481         QString type = pa.attribute("type");
482         QString paramName = na.isNull() ? pa.attribute("name") : i18n(na.text().toUtf8().data());
483         QString comment;
484         if (!commentElem.isNull())
485             comment = i18n(commentElem.text().toUtf8().data());
486         QWidget * toFillin = new QWidget(parent);
487         QString value = pa.attribute("value").isNull() ?
488                         pa.attribute("default") : pa.attribute("value");
489
490
491         /** See effects/README for info on the different types */
492
493         if (type == "double" || type == "constant") {
494             double min;
495             double max;
496             if (pa.attribute("min").contains('%'))
497                 min = ProfilesDialog::getStringEval(m_metaInfo->profile, pa.attribute("min"), m_metaInfo->frameSize);
498             else
499                 min = pa.attribute("min").toDouble();
500             if (pa.attribute("max").contains('%'))
501                 max = ProfilesDialog::getStringEval(m_metaInfo->profile, pa.attribute("max"), m_metaInfo->frameSize);
502             else
503                 max = pa.attribute("max").toDouble();
504
505             DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, value.toDouble(), min, max,
506                     pa.attribute("default").toDouble(), comment, -1, pa.attribute("suffix"), pa.attribute("decimals").toInt(), parent);
507             doubleparam->setFocusPolicy(Qt::StrongFocus);
508             m_vbox->addWidget(doubleparam);
509             m_valueItems[paramName] = doubleparam;
510             connect(doubleparam, SIGNAL(valueChanged(double)), this, SLOT(slotCollectAllParameters()));
511             connect(this, SIGNAL(showComments(bool)), doubleparam, SLOT(slotShowComment(bool)));
512         } else if (type == "list") {
513             Listval *lsval = new Listval;
514             lsval->setupUi(toFillin);
515             lsval->list->setFocusPolicy(Qt::StrongFocus);
516             QStringList listitems = pa.attribute("paramlist").split(';');
517             if (listitems.count() == 1) {
518                 // probably custom effect created before change to ';' as separator
519                 listitems = pa.attribute("paramlist").split(",");
520             }
521             QDomElement list = pa.firstChildElement("paramlistdisplay");
522             QStringList listitemsdisplay;
523             if (!list.isNull()) {
524                 listitemsdisplay = i18n(list.text().toUtf8().data()).split(',');
525             } else {
526                 listitemsdisplay = i18n(pa.attribute("paramlistdisplay").toUtf8().data()).split(',');
527             }
528             if (listitemsdisplay.count() != listitems.count())
529                 listitemsdisplay = listitems;
530             lsval->list->setIconSize(QSize(30, 30));
531             for (int i = 0; i < listitems.count(); i++) {
532                 lsval->list->addItem(listitemsdisplay.at(i), listitems.at(i));
533                 QString entry = listitems.at(i);
534                 if (!entry.isEmpty() && (entry.endsWith(".png") || entry.endsWith(".pgm"))) {
535                     if (!CollapsibleEffect::iconCache.contains(entry)) {
536                         QImage pix(entry);
537                         CollapsibleEffect::iconCache[entry] = pix.scaled(30, 30);
538                     }
539                     lsval->list->setItemIcon(i, QPixmap::fromImage(CollapsibleEffect::iconCache[entry]));
540                 }
541             }
542             if (!value.isEmpty()) lsval->list->setCurrentIndex(listitems.indexOf(value));
543             lsval->name->setText(paramName);
544             lsval->labelComment->setText(comment);
545             lsval->widgetComment->setHidden(true);
546             m_valueItems[paramName] = lsval;
547             connect(lsval->list, SIGNAL(currentIndexChanged(int)) , this, SLOT(slotCollectAllParameters()));
548             if (!comment.isEmpty())
549                 connect(this, SIGNAL(showComments(bool)), lsval->widgetComment, SLOT(setVisible(bool)));
550             m_uiItems.append(lsval);
551         } else if (type == "bool") {
552             Boolval *bval = new Boolval;
553             bval->setupUi(toFillin);
554             bval->checkBox->setCheckState(value == "0" ? Qt::Unchecked : Qt::Checked);
555             bval->name->setText(paramName);
556             bval->labelComment->setText(comment);
557             bval->widgetComment->setHidden(true);
558             m_valueItems[paramName] = bval;
559             connect(bval->checkBox, SIGNAL(stateChanged(int)) , this, SLOT(slotCollectAllParameters()));
560             if (!comment.isEmpty())
561                 connect(this, SIGNAL(showComments(bool)), bval->widgetComment, SLOT(setVisible(bool)));
562             m_uiItems.append(bval);
563         } else if (type == "complex") {
564             ComplexParameter *pl = new ComplexParameter;
565             pl->setupParam(effect, pa.attribute("name"), 0, 100);
566             m_vbox->addWidget(pl);
567             m_valueItems[paramName+"complex"] = pl;
568             connect(pl, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
569         } else if (type == "geometry") {
570             if (KdenliveSettings::on_monitor_effects()) {
571                 m_geometryWidget = new GeometryWidget(m_metaInfo->monitor, m_metaInfo->timecode, 0, true, effect.hasAttribute("showrotation"), parent);
572                 m_geometryWidget->setFrameSize(m_metaInfo->frameSize);
573                 m_geometryWidget->slotShowScene(!disable);
574                 // connect this before setupParam to make sure the monitor scene shows up at startup
575                 connect(m_geometryWidget, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
576                 connect(m_geometryWidget, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
577                 if (minFrame == maxFrame)
578                     m_geometryWidget->setupParam(pa, m_in, m_out);
579                 else
580                     m_geometryWidget->setupParam(pa, minFrame, maxFrame);
581                 m_vbox->addWidget(m_geometryWidget);
582                 m_valueItems[paramName+"geometry"] = m_geometryWidget;
583                 connect(m_geometryWidget, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
584                 connect(this, SIGNAL(syncEffectsPos(int)), m_geometryWidget, SLOT(slotSyncPosition(int)));
585                 connect(this, SIGNAL(effectStateChanged(bool)), m_geometryWidget, SLOT(slotShowScene(bool)));
586             } else {
587                 Geometryval *geo = new Geometryval(m_metaInfo->profile, m_metaInfo->timecode, m_metaInfo->frameSize, 0);
588                 if (minFrame == maxFrame)
589                     geo->setupParam(pa, m_in, m_out);
590                 else
591                     geo->setupParam(pa, minFrame, maxFrame);
592                 m_vbox->addWidget(geo);
593                 m_valueItems[paramName+"geometry"] = geo;
594                 connect(geo, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
595                 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
596                 connect(this, SIGNAL(syncEffectsPos(int)), geo, SLOT(slotSyncPosition(int)));
597             }
598         } else if (type == "addedgeometry") {
599             // this is a parameter that should be linked to the geometry widget, for example rotation, shear, ...
600             if (m_geometryWidget) m_geometryWidget->addParameter(pa);
601         } else if (type == "keyframe" || type == "simplekeyframe") {
602             // keyframe editor widget
603             if (m_keyframeEditor == NULL) {
604                 KeyframeEdit *geo;
605                 if (pa.attribute("widget") == "corners") {
606                     // we want a corners-keyframe-widget
607                     CornersWidget *corners = new CornersWidget(m_metaInfo->monitor, pa, m_in, m_out, m_metaInfo->timecode, e.attribute("active_keyframe", "-1").toInt(), parent);
608                     corners->slotShowScene(!disable);
609                     connect(corners, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
610                     connect(this, SIGNAL(effectStateChanged(bool)), corners, SLOT(slotShowScene(bool)));
611                     connect(this, SIGNAL(syncEffectsPos(int)), corners, SLOT(slotSyncPosition(int)));
612                     geo = static_cast<KeyframeEdit *>(corners);
613                 } else {
614                     geo = new KeyframeEdit(pa, m_in, m_out, m_metaInfo->timecode, e.attribute("active_keyframe", "-1").toInt());
615                 }
616                 m_vbox->addWidget(geo);
617                 m_valueItems[paramName+"keyframe"] = geo;
618                 m_keyframeEditor = geo;
619                 connect(geo, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
620                 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
621                 connect(this, SIGNAL(showComments(bool)), geo, SIGNAL(showComments(bool)));
622             } else {
623                 // we already have a keyframe editor, so just add another column for the new param
624                 m_keyframeEditor->addParameter(pa);
625             }
626         } else if (type == "color") {
627             if (value.startsWith('#'))
628                 value = value.replace('#', "0x");
629             ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, value, parent);
630             m_vbox->addWidget(choosecolor);
631             m_valueItems[paramName] = choosecolor;
632             connect(choosecolor, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int)));
633             connect(choosecolor, SIGNAL(modified()) , this, SLOT(slotCollectAllParameters()));
634         } else if (type == "position") {
635             int pos = value.toInt();
636             if (effect.attribute("id") == "fadein" || effect.attribute("id") == "fade_from_black") {
637                 pos = pos - m_in;
638             } else if (effect.attribute("id") == "fadeout" || effect.attribute("id") == "fade_to_black") {
639                 // fadeout position starts from clip end
640                 pos = m_out - pos;
641             }
642             PositionEdit *posedit = new PositionEdit(paramName, pos, 0, m_out - m_in, m_metaInfo->timecode);
643             m_vbox->addWidget(posedit);
644             m_valueItems[paramName+"position"] = posedit;
645             connect(posedit, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
646         } else if (type == "curve") {
647             KisCurveWidget *curve = new KisCurveWidget(parent);
648             curve->setMaxPoints(pa.attribute("max").toInt());
649             QList<QPointF> points;
650             int number = EffectsList::parameter(e, pa.attribute("number")).toInt();
651             QString inName = pa.attribute("inpoints");
652             QString outName = pa.attribute("outpoints");
653             int start = pa.attribute("min").toInt();
654             for (int j = start; j <= number; j++) {
655                 QString in = inName;
656                 in.replace("%i", QString::number(j));
657                 QString out = outName;
658                 out.replace("%i", QString::number(j));
659                 points << QPointF(EffectsList::parameter(e, in).toDouble(), EffectsList::parameter(e, out).toDouble());
660             }
661             if (!points.isEmpty())
662                 curve->setCurve(KisCubicCurve(points));
663             MySpinBox *spinin = new MySpinBox();
664             spinin->setRange(0, 1000);
665             MySpinBox *spinout = new MySpinBox();
666             spinout->setRange(0, 1000);
667             curve->setupInOutControls(spinin, spinout, 0, 1000);
668             m_vbox->addWidget(curve);
669             m_vbox->addWidget(spinin);
670             m_vbox->addWidget(spinout);
671
672             connect(curve, SIGNAL(modified()), this, SLOT(slotCollectAllParameters()));
673             m_valueItems[paramName] = curve;
674
675             QString depends = pa.attribute("depends");
676             if (!depends.isEmpty())
677                 meetDependency(paramName, type, EffectsList::parameter(e, depends));
678         } else if (type == "bezier_spline") {
679             BezierSplineWidget *widget = new BezierSplineWidget(value, parent);
680             stretch = false;
681             m_vbox->addWidget(widget);
682             m_valueItems[paramName] = widget;
683             connect(widget, SIGNAL(modified()), this, SLOT(slotCollectAllParameters()));
684             QString depends = pa.attribute("depends");
685             if (!depends.isEmpty())
686                 meetDependency(paramName, type, EffectsList::parameter(e, depends));
687 #ifdef USE_QJSON
688         } else if (type == "roto-spline") {
689             RotoWidget *roto = new RotoWidget(value, m_metaInfo->monitor, info, m_metaInfo->timecode, parent);
690             roto->slotShowScene(!disable);
691             connect(roto, SIGNAL(valueChanged()), this, SLOT(slotCollectAllParameters()));
692             connect(roto, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
693             connect(roto, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
694             connect(this, SIGNAL(syncEffectsPos(int)), roto, SLOT(slotSyncPosition(int)));
695             connect(this, SIGNAL(effectStateChanged(bool)), roto, SLOT(slotShowScene(bool)));
696             m_vbox->addWidget(roto);
697             m_valueItems[paramName] = roto;
698 #endif
699         } else if (type == "wipe") {
700             Wipeval *wpval = new Wipeval;
701             wpval->setupUi(toFillin);
702             wipeInfo w = getWipeInfo(value);
703             switch (w.start) {
704             case UP:
705                 wpval->start_up->setChecked(true);
706                 break;
707             case DOWN:
708                 wpval->start_down->setChecked(true);
709                 break;
710             case RIGHT:
711                 wpval->start_right->setChecked(true);
712                 break;
713             case LEFT:
714                 wpval->start_left->setChecked(true);
715                 break;
716             default:
717                 wpval->start_center->setChecked(true);
718                 break;
719             }
720             switch (w.end) {
721             case UP:
722                 wpval->end_up->setChecked(true);
723                 break;
724             case DOWN:
725                 wpval->end_down->setChecked(true);
726                 break;
727             case RIGHT:
728                 wpval->end_right->setChecked(true);
729                 break;
730             case LEFT:
731                 wpval->end_left->setChecked(true);
732                 break;
733             default:
734                 wpval->end_center->setChecked(true);
735                 break;
736             }
737             wpval->start_transp->setValue(w.startTransparency);
738             wpval->end_transp->setValue(w.endTransparency);
739             m_valueItems[paramName] = wpval;
740             connect(wpval->end_up, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
741             connect(wpval->end_down, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
742             connect(wpval->end_left, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
743             connect(wpval->end_right, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
744             connect(wpval->end_center, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
745             connect(wpval->start_up, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
746             connect(wpval->start_down, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
747             connect(wpval->start_left, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
748             connect(wpval->start_right, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
749             connect(wpval->start_center, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
750             connect(wpval->start_transp, SIGNAL(valueChanged(int)), this, SLOT(slotCollectAllParameters()));
751             connect(wpval->end_transp, SIGNAL(valueChanged(int)), this, SLOT(slotCollectAllParameters()));
752             //wpval->title->setTitle(na.toElement().text());
753             m_uiItems.append(wpval);
754         } else if (type == "url") {
755             Urlval *cval = new Urlval;
756             cval->setupUi(toFillin);
757             cval->label->setText(paramName);
758             cval->urlwidget->fileDialog()->setFilter(ProjectList::getExtensions());
759             m_valueItems[paramName] = cval;
760             cval->urlwidget->setUrl(KUrl(value));
761             connect(cval->urlwidget, SIGNAL(returnPressed()) , this, SLOT(slotCollectAllParameters()));
762             connect(cval->urlwidget, SIGNAL(urlSelected(const KUrl&)) , this, SLOT(slotCollectAllParameters()));
763             m_uiItems.append(cval);
764         } else if (type == "keywords") {
765             Keywordval* kval = new Keywordval;
766             kval->setupUi(toFillin);
767             kval->label->setText(paramName);
768             kval->lineeditwidget->setText(value);
769             QDomElement klistelem = pa.firstChildElement("keywords");
770             QDomElement kdisplaylistelem = pa.firstChildElement("keywordsdisplay");
771             QStringList keywordlist;
772             QStringList keyworddisplaylist;
773             if (!klistelem.isNull()) {
774                 keywordlist = klistelem.text().split(';');
775                 keyworddisplaylist = i18n(kdisplaylistelem.text().toUtf8().data()).split(';');
776             }
777             if (keyworddisplaylist.count() != keywordlist.count()) {
778                 keyworddisplaylist = keywordlist;
779             }
780             for (int i = 0; i < keywordlist.count(); i++) {
781                 kval->comboboxwidget->addItem(keyworddisplaylist.at(i), keywordlist.at(i));
782             }
783             // Add disabled user prompt at index 0
784             kval->comboboxwidget->insertItem(0, i18n("<select a keyword>"), "");
785             kval->comboboxwidget->model()->setData( kval->comboboxwidget->model()->index(0,0), QVariant(Qt::NoItemFlags), Qt::UserRole -1);
786             kval->comboboxwidget->setCurrentIndex(0);
787             m_valueItems[paramName] = kval;
788             connect(kval->lineeditwidget, SIGNAL(editingFinished()) , this, SLOT(collectAllParameters()));
789             connect(kval->comboboxwidget, SIGNAL(activated (const QString&)), this, SLOT(collectAllParameters()));
790             m_uiItems.append(kval);
791         } else if (type == "fontfamily") {
792             Fontval* fval = new Fontval;
793             fval->setupUi(toFillin);
794             fval->name->setText(paramName);
795             fval->fontfamilywidget->setCurrentFont(QFont(value));
796             m_valueItems[paramName] = fval;
797             connect(fval->fontfamilywidget, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(collectAllParameters())) ;
798             m_uiItems.append(fval);
799         } else if (type == "filterjob") {
800             QVBoxLayout *l= new QVBoxLayout(toFillin);
801             QPushButton *button = new QPushButton(paramName, toFillin);
802             l->addWidget(button);
803             m_valueItems[paramName] = button;
804             connect(button, SIGNAL(pressed()), this, SLOT(slotStartFilterJobAction()));   
805         } else {
806             delete toFillin;
807             toFillin = NULL;
808         }
809
810         if (toFillin)
811             m_vbox->addWidget(toFillin);
812     }
813
814     if (stretch)
815         m_vbox->addStretch();
816
817     if (m_keyframeEditor)
818         m_keyframeEditor->checkVisibleParam();
819
820     // Make sure all doubleparam spinboxes have the same width, looks much better
821     QList<DoubleParameterWidget *> allWidgets = findChildren<DoubleParameterWidget *>();
822     int minSize = 0;
823     for (int i = 0; i < allWidgets.count(); i++) {
824         if (minSize < allWidgets.at(i)->spinSize()) minSize = allWidgets.at(i)->spinSize();
825     }
826     for (int i = 0; i < allWidgets.count(); i++) {
827         allWidgets.at(i)->setSpinSize(minSize);
828     }
829 }
830
831 ParameterContainer::~ParameterContainer()
832 {
833     //clearLayout(m_vbox);
834     delete m_vbox;
835 }
836
837 void ParameterContainer::meetDependency(const QString& name, QString type, QString value)
838 {
839     if (type == "curve") {
840         KisCurveWidget *curve = (KisCurveWidget*)m_valueItems[name];
841         if (curve) {
842             int color = value.toInt();
843             curve->setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(curve->size(), (ColorTools::ColorsRGB)(color == 3 ? 4 : color), 0.8)));
844         }
845     } else if (type == "bezier_spline") {
846         BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems[name];
847         if (widget) {
848             widget->setMode((BezierSplineWidget::CurveModes)((int)(value.toDouble() * 10)));
849         }
850     }
851 }
852
853 wipeInfo ParameterContainer::getWipeInfo(QString value)
854 {
855     wipeInfo info;
856     // Convert old geometry values that used a comma as separator
857     if (value.contains(',')) value.replace(',','/');
858     QString start = value.section(';', 0, 0);
859     QString end = value.section(';', 1, 1).section('=', 1, 1);
860     if (start.startsWith("-100%/0"))
861         info.start = LEFT;
862     else if (start.startsWith("100%/0"))
863         info.start = RIGHT;
864     else if (start.startsWith("0%/100%"))
865         info.start = DOWN;
866     else if (start.startsWith("0%/-100%"))
867         info.start = UP;
868     else
869         info.start = CENTER;
870
871     if (start.count(':') == 2)
872         info.startTransparency = start.section(':', -1).toInt();
873     else
874         info.startTransparency = 100;
875
876     if (end.startsWith("-100%/0"))
877         info.end = LEFT;
878     else if (end.startsWith("100%/0"))
879         info.end = RIGHT;
880     else if (end.startsWith("0%/100%"))
881         info.end = DOWN;
882     else if (end.startsWith("0%/-100%"))
883         info.end = UP;
884     else
885         info.end = CENTER;
886
887     if (end.count(':') == 2)
888         info.endTransparency = end.section(':', -1).toInt();
889     else
890         info.endTransparency = 100;
891
892     return info;
893 }
894
895 void ParameterContainer::updateTimecodeFormat()
896 {
897     if (m_keyframeEditor)
898         m_keyframeEditor->updateTimecodeFormat();
899
900     QDomNodeList namenode = m_effect.elementsByTagName("parameter");
901     for (int i = 0; i < namenode.count() ; i++) {
902         QDomNode pa = namenode.item(i);
903         QDomElement na = pa.firstChildElement("name");
904         QString type = pa.attributes().namedItem("type").nodeValue();
905         QString paramName = na.isNull() ? pa.attributes().namedItem("name").nodeValue() : i18n(na.text().toUtf8().data());
906
907         if (type == "geometry") {
908             if (KdenliveSettings::on_monitor_effects()) {
909                 if (m_geometryWidget) m_geometryWidget->updateTimecodeFormat();
910             } else {
911                 Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
912                 geom->updateTimecodeFormat();
913             }
914             break;
915         } else if (type == "position") {
916             PositionEdit *posi = ((PositionEdit*)m_valueItems[paramName+"position"]);
917             posi->updateTimecodeFormat();
918             break;
919 #ifdef USE_QJSON
920         } else if (type == "roto-spline") {
921             RotoWidget *widget = static_cast<RotoWidget *>(m_valueItems[paramName]);
922             widget->updateTimecodeFormat();
923 #endif
924         }
925     }
926 }
927
928 void ParameterContainer::slotCollectAllParameters()
929 {
930     if (m_valueItems.isEmpty() || m_effect.isNull()) return;
931     QLocale locale;
932     locale.setNumberOptions(QLocale::OmitGroupSeparator);
933     const QDomElement oldparam = m_effect.cloneNode().toElement();
934     //QDomElement newparam = oldparam.cloneNode().toElement();
935     QDomNodeList namenode = m_effect.elementsByTagName("parameter");
936
937     for (int i = 0; i < namenode.count() ; i++) {
938         QDomNode pa = namenode.item(i);
939         QDomElement na = pa.firstChildElement("name");
940         QString type = pa.attributes().namedItem("type").nodeValue();
941         QString paramName = na.isNull() ? pa.attributes().namedItem("name").nodeValue() : i18n(na.text().toUtf8().data());
942         if (type == "complex")
943             paramName.append("complex");
944         else if (type == "position")
945             paramName.append("position");
946         else if (type == "geometry")
947             paramName.append("geometry");
948         else if (type == "keyframe")
949             paramName.append("keyframe");
950         if (type != "simplekeyframe" && type != "fixed" && type != "addedgeometry" && !m_valueItems.contains(paramName)) {
951             kDebug() << "// Param: " << paramName << " NOT FOUND";
952             continue;
953         }
954
955         QString setValue;
956         if (type == "double" || type == "constant") {
957             DoubleParameterWidget *doubleparam = (DoubleParameterWidget*)m_valueItems.value(paramName);
958             setValue = locale.toString(doubleparam->getValue());
959         } else if (type == "list") {
960             KComboBox *box = ((Listval*)m_valueItems.value(paramName))->list;
961             setValue = box->itemData(box->currentIndex()).toString();
962         } else if (type == "bool") {
963             QCheckBox *box = ((Boolval*)m_valueItems.value(paramName))->checkBox;
964             setValue = box->checkState() == Qt::Checked ? "1" : "0" ;
965         } else if (type == "color") {
966             ChooseColorWidget *choosecolor = ((ChooseColorWidget*)m_valueItems.value(paramName));
967             setValue = choosecolor->getColor();
968         } else if (type == "complex") {
969             ComplexParameter *complex = ((ComplexParameter*)m_valueItems.value(paramName));
970             namenode.item(i) = complex->getParamDesc();
971         } else if (type == "geometry") {
972             if (KdenliveSettings::on_monitor_effects()) {
973                 if (m_geometryWidget) namenode.item(i).toElement().setAttribute("value", m_geometryWidget->getValue());
974             } else {
975                 Geometryval *geom = ((Geometryval*)m_valueItems.value(paramName));
976                 namenode.item(i).toElement().setAttribute("value", geom->getValue());
977             }
978         } else if (type == "addedgeometry") {
979             namenode.item(i).toElement().setAttribute("value", m_geometryWidget->getExtraValue(namenode.item(i).toElement().attribute("name")));
980         } else if (type == "position") {
981             PositionEdit *pedit = ((PositionEdit*)m_valueItems.value(paramName));
982             int pos = pedit->getPosition();
983             setValue = QString::number(pos);
984             if (m_effect.attribute("id") == "fadein" || m_effect.attribute("id") == "fade_from_black") {
985                 // Make sure duration is not longer than clip
986                 /*if (pos > m_out) {
987                     pos = m_out;
988                     pedit->setPosition(pos);
989                 }*/
990                 EffectsList::setParameter(m_effect, "in", QString::number(m_in));
991                 EffectsList::setParameter(m_effect, "out", QString::number(m_in + pos));
992                 setValue.clear();
993             } else if (m_effect.attribute("id") == "fadeout" || m_effect.attribute("id") == "fade_to_black") {
994                 // Make sure duration is not longer than clip
995                 /*if (pos > m_out) {
996                     pos = m_out;
997                     pedit->setPosition(pos);
998                 }*/
999                 EffectsList::setParameter(m_effect, "in", QString::number(m_out - pos));
1000                 EffectsList::setParameter(m_effect, "out", QString::number(m_out));
1001                 setValue.clear();
1002             }
1003         } else if (type == "curve") {
1004             KisCurveWidget *curve = ((KisCurveWidget*)m_valueItems.value(paramName));
1005             QList<QPointF> points = curve->curve().points();
1006             QString number = pa.attributes().namedItem("number").nodeValue();
1007             QString inName = pa.attributes().namedItem("inpoints").nodeValue();
1008             QString outName = pa.attributes().namedItem("outpoints").nodeValue();
1009             int off = pa.attributes().namedItem("min").nodeValue().toInt();
1010             int end = pa.attributes().namedItem("max").nodeValue().toInt();
1011             EffectsList::setParameter(m_effect, number, QString::number(points.count()));
1012             for (int j = 0; (j < points.count() && j + off <= end); j++) {
1013                 QString in = inName;
1014                 in.replace("%i", QString::number(j + off));
1015                 QString out = outName;
1016                 out.replace("%i", QString::number(j + off));
1017                 EffectsList::setParameter(m_effect, in, locale.toString(points.at(j).x()));
1018                 EffectsList::setParameter(m_effect, out, locale.toString(points.at(j).y()));
1019             }
1020             QString depends = pa.attributes().namedItem("depends").nodeValue();
1021             if (!depends.isEmpty())
1022                 meetDependency(paramName, type, EffectsList::parameter(m_effect, depends));
1023         } else if (type == "bezier_spline") {
1024             BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems.value(paramName);
1025             setValue = widget->spline();
1026             QString depends = pa.attributes().namedItem("depends").nodeValue();
1027             if (!depends.isEmpty())
1028                 meetDependency(paramName, type, EffectsList::parameter(m_effect, depends));
1029 #ifdef USE_QJSON
1030         } else if (type == "roto-spline") {
1031             RotoWidget *widget = static_cast<RotoWidget *>(m_valueItems.value(paramName));
1032             setValue = widget->getSpline();
1033 #endif
1034         } else if (type == "wipe") {
1035             Wipeval *wp = (Wipeval*)m_valueItems.value(paramName);
1036             wipeInfo info;
1037             if (wp->start_left->isChecked())
1038                 info.start = LEFT;
1039             else if (wp->start_right->isChecked())
1040                 info.start = RIGHT;
1041             else if (wp->start_up->isChecked())
1042                 info.start = UP;
1043             else if (wp->start_down->isChecked())
1044                 info.start = DOWN;
1045             else if (wp->start_center->isChecked())
1046                 info.start = CENTER;
1047             else
1048                 info.start = LEFT;
1049             info.startTransparency = wp->start_transp->value();
1050
1051             if (wp->end_left->isChecked())
1052                 info.end = LEFT;
1053             else if (wp->end_right->isChecked())
1054                 info.end = RIGHT;
1055             else if (wp->end_up->isChecked())
1056                 info.end = UP;
1057             else if (wp->end_down->isChecked())
1058                 info.end = DOWN;
1059             else if (wp->end_center->isChecked())
1060                 info.end = CENTER;
1061             else
1062                 info.end = RIGHT;
1063             info.endTransparency = wp->end_transp->value();
1064
1065             setValue = getWipeString(info);
1066         } else if ((type == "simplekeyframe" || type == "keyframe") && m_keyframeEditor) {
1067             QDomElement elem = pa.toElement();
1068             QString realName = i18n(na.toElement().text().toUtf8().data());
1069             QString val = m_keyframeEditor->getValue(realName);
1070             elem.setAttribute("keyframes", val);
1071
1072             if (m_keyframeEditor->isVisibleParam(realName))
1073                 elem.setAttribute("intimeline", "1");
1074             else if (elem.hasAttribute("intimeline"))
1075                 elem.removeAttribute("intimeline");
1076         } else if (type == "url") {
1077             KUrlRequester *req = ((Urlval*)m_valueItems.value(paramName))->urlwidget;
1078             setValue = req->url().path();
1079         } else if (type == "keywords"){
1080             QLineEdit *line = ((Keywordval*)m_valueItems.value(paramName))->lineeditwidget;
1081             QComboBox *combo = ((Keywordval*)m_valueItems.value(paramName))->comboboxwidget;
1082             if(combo->currentIndex())
1083             {
1084                 QString comboval = combo->itemData(combo->currentIndex()).toString();
1085                 line->insert(comboval);
1086                 combo->setCurrentIndex(0);
1087             }
1088             setValue = line->text();
1089         } else if (type == "fontfamily") {
1090             QFontComboBox* fontfamily = ((Fontval*)m_valueItems.value(paramName))->fontfamilywidget;
1091             setValue = fontfamily->currentFont().family();
1092         }
1093         if (!setValue.isNull())
1094             pa.attributes().namedItem("value").setNodeValue(setValue);
1095
1096     }
1097     emit parameterChanged(oldparam, m_effect, m_index);
1098 }
1099
1100 QString ParameterContainer::getWipeString(wipeInfo info)
1101 {
1102
1103     QString start;
1104     QString end;
1105     switch (info.start) {
1106     case LEFT:
1107         start = "-100%/0%:100%x100%";
1108         break;
1109     case RIGHT:
1110         start = "100%/0%:100%x100%";
1111         break;
1112     case DOWN:
1113         start = "0%/100%:100%x100%";
1114         break;
1115     case UP:
1116         start = "0%/-100%:100%x100%";
1117         break;
1118     default:
1119         start = "0%/0%:100%x100%";
1120         break;
1121     }
1122     start.append(':' + QString::number(info.startTransparency));
1123
1124     switch (info.end) {
1125     case LEFT:
1126         end = "-100%/0%:100%x100%";
1127         break;
1128     case RIGHT:
1129         end = "100%/0%:100%x100%";
1130         break;
1131     case DOWN:
1132         end = "0%/100%:100%x100%";
1133         break;
1134     case UP:
1135         end = "0%/-100%:100%x100%";
1136         break;
1137     default:
1138         end = "0%/0%:100%x100%";
1139         break;
1140     }
1141     end.append(':' + QString::number(info.endTransparency));
1142     return QString(start + ";-1=" + end);
1143 }
1144
1145 int ParameterContainer::index()
1146 {
1147     return m_index;
1148 }
1149
1150 void ParameterContainer::slotStartFilterJobAction()
1151 {
1152     QDomNodeList namenode = m_effect.elementsByTagName("parameter");
1153     for (int i = 0; i < namenode.count() ; i++) {
1154         QDomElement pa = namenode.item(i).toElement();
1155         QString type = pa.attribute("type");
1156         if (type == "filterjob") {
1157             emit startFilterJob(pa.attribute("filtertag"), pa.attribute("filterparams"), pa.attribute("finalfilter"), pa.attribute("consumer"), pa.attribute("consumerparams"), pa.attribute("wantedproperties"));
1158             kDebug()<<" - - -PROPS:\n"<<pa.attribute("filtertag")<<"-"<< pa.attribute("filterparams")<<"-"<< pa.attribute("consumer")<<"-"<< pa.attribute("consumerparams")<<"-"<< pa.attribute("wantedproperties");
1159             break;
1160         }
1161     }
1162 }