]> git.sesse.net Git - kdenlive/blob - src/effectstackedit.cpp
Fix issue with fade out and fade to black effects, might solve:
[kdenlive] / src / effectstackedit.cpp
1 /***************************************************************************
2                           effecstackedit.cpp  -  description
3                              -------------------
4     begin                : Feb 15 2008
5     copyright            : (C) 2008 by Marco Gittler
6     email                : g.marco@freenet.de
7  ***************************************************************************/
8
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17
18 #include "effectstackedit.h"
19 #include "ui_listval_ui.h"
20 #include "ui_boolval_ui.h"
21 #include "ui_wipeval_ui.h"
22 #include "ui_urlval_ui.h"
23 #include "complexparameter.h"
24 #include "geometryval.h"
25 #include "positionedit.h"
26 #include "projectlist.h"
27 #include "effectslist.h"
28 #include "kdenlivesettings.h"
29 #include "profilesdialog.h"
30 #include "kis_curve_widget.h"
31 #include "kis_cubic_curve.h"
32 #include "choosecolorwidget.h"
33 #include "geometrywidget.h"
34 #include "colortools.h"
35 #include "doubleparameterwidget.h"
36
37 #include <KDebug>
38 #include <KLocale>
39 #include <KFileDialog>
40
41 #include <QVBoxLayout>
42 #include <QLabel>
43 #include <QPushButton>
44 #include <QCheckBox>
45 #include <QScrollArea>
46
47
48 class Boolval: public QWidget, public Ui::Boolval_UI
49 {
50 };
51
52 class Listval: public QWidget, public Ui::Listval_UI
53 {
54 };
55
56 class Wipeval: public QWidget, public Ui::Wipeval_UI
57 {
58 };
59
60 class Urlval: public QWidget, public Ui::Urlval_UI
61 {
62 };
63
64 QMap<QString, QImage> EffectStackEdit::iconCache;
65
66 EffectStackEdit::EffectStackEdit(Monitor *monitor, QWidget *parent) :
67         QScrollArea(parent),
68         m_in(0),
69         m_out(0),
70         m_frameSize(QPoint()),
71         m_keyframeEditor(NULL),
72         m_monitor(monitor)
73 {
74     m_baseWidget = new QWidget(this);
75     setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
76     setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
77     setFrameStyle(QFrame::NoFrame);
78     setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding));
79
80     setWidget(m_baseWidget);
81     setWidgetResizable(true);
82     m_vbox = new QVBoxLayout(m_baseWidget);
83     m_vbox->setContentsMargins(0, 0, 0, 0);
84     m_vbox->setSpacing(0);
85     //wid->show();
86 }
87
88 EffectStackEdit::~EffectStackEdit()
89 {
90     iconCache.clear();
91     delete m_baseWidget;
92 }
93
94 void EffectStackEdit::setFrameSize(QPoint p)
95 {
96     m_frameSize = p;
97     QDomNodeList namenode = m_params.elementsByTagName("parameter");
98     for (int i = 0; i < namenode.count() ; i++) {
99         QDomNode pa = namenode.item(i);
100         QDomNode na = pa.firstChildElement("name");
101         QString type = pa.attributes().namedItem("type").nodeValue();
102         QString paramName = i18n(na.toElement().text().toUtf8().data());
103
104         if (type == "geometry" && !KdenliveSettings::on_monitor_effects()) {
105             Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
106             geom->setFrameSize(m_frameSize);
107             break;
108         }
109     }
110 }
111
112 void EffectStackEdit::updateTimecodeFormat()
113 {
114     if (m_keyframeEditor)
115         m_keyframeEditor->updateTimecodeFormat();
116
117     QDomNodeList namenode = m_params.elementsByTagName("parameter");
118     for (int i = 0; i < namenode.count() ; i++) {
119         QDomNode pa = namenode.item(i);
120         QDomNode na = pa.firstChildElement("name");
121         QString type = pa.attributes().namedItem("type").nodeValue();
122         QString paramName = i18n(na.toElement().text().toUtf8().data());
123
124         if (type == "geometry") {
125             if (KdenliveSettings::on_monitor_effects()) {
126                 GeometryWidget *geom = (GeometryWidget*)m_valueItems[paramName+"geometry"];
127                 geom->updateTimecodeFormat();
128             } else {
129                 Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
130                 geom->updateTimecodeFormat();
131             }
132             break;
133         }
134         if (type == "position") {
135             PositionEdit *posi = ((PositionEdit*)m_valueItems[paramName+"position"]);
136             posi->updateTimecodeFormat();
137             break;
138         }
139     }
140 }
141
142 void EffectStackEdit::meetDependency(const QString& name, QString type, QString value)
143 {
144     if (type == "curve") {
145         KisCurveWidget *curve = (KisCurveWidget*)m_valueItems[name];
146         if (curve) {
147             int color = value.toInt();
148             curve->setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(curve->size(), (ColorTools::ColorsRGB)color)));
149         }
150     }
151 }
152
153 void EffectStackEdit::updateProjectFormat(MltVideoProfile profile, Timecode t)
154 {
155     m_profile = profile;
156     m_timecode = t;
157 }
158
159 void EffectStackEdit::updateParameter(const QString &name, const QString &value)
160 {
161     m_params.setAttribute(name, value);
162 }
163
164 void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, int out, bool isEffect)
165 {
166     clearAllItems();
167     if (m_keyframeEditor) delete m_keyframeEditor;
168     m_keyframeEditor = NULL;
169     m_params = d;
170     m_in = in;
171     m_out = out;
172     if (m_params.isNull()) {
173         kDebug() << "// EMPTY EFFECT STACK";
174         return;
175     }
176
177     QDomNodeList namenode = m_params.elementsByTagName("parameter");
178     QDomElement e = m_params.toElement();
179     const int minFrame = e.attribute("start").toInt();
180     const int maxFrame = e.attribute("end").toInt();
181
182
183     for (int i = 0; i < namenode.count() ; i++) {
184         QDomElement pa = namenode.item(i).toElement();
185         QDomNode na = pa.firstChildElement("name");
186         QString type = pa.attribute("type");
187         QString paramName = i18n(na.toElement().text().toUtf8().data());
188         QWidget * toFillin = new QWidget(m_baseWidget);
189         QString value = pa.attribute("value").isNull() ?
190                         pa.attribute("default") : pa.attribute("value");
191
192         /** Currently supported parameter types are:
193             * constant (=double): a slider with an integer value (use the "factor" attribute to divide the value so that you can get a double
194             * list: a combobox containing a list of values to choose
195             * bool: a checkbox
196             * complex: designed for keyframe parameters, but old and not finished, do not use
197             * geometry: a rectangle that can be moved & resized, with possible keyframes, used in composite transition
198             * keyframe: a list widget with a list of entries (position and value)
199             * color: a color chooser button
200             * position: a slider representing the position of a frame in the current clip
201             * curve: a single curve representing multiple points
202             * wipe: a widget designed for the wipe transition, allowing to choose a position (left, right, top,...)
203         */
204
205         if (type == "double" || type == "constant") {
206             int min;
207             int max;
208             if (pa.attribute("min").startsWith('%'))
209                 min = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("min"));
210             else
211                 min = pa.attribute("min").toInt();
212             if (pa.attribute("max").startsWith('%'))
213                 max = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("max"));
214             else
215                 max = pa.attribute("max").toInt();
216
217             DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, (int)(value.toDouble() + 0.5), min, max,
218                     pa.attribute("default").toInt(), pa.attribute("suffix"), this);
219             m_vbox->addWidget(doubleparam);
220             m_valueItems[paramName] = doubleparam;
221             connect(doubleparam, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
222         } else if (type == "list") {
223             Listval *lsval = new Listval;
224             lsval->setupUi(toFillin);
225             QStringList listitems = pa.attribute("paramlist").split(',');
226             QStringList listitemsdisplay = pa.attribute("paramlistdisplay").split(',');
227             if (listitemsdisplay.count() != listitems.count()) listitemsdisplay = listitems;
228             //lsval->list->addItems(listitems);
229             lsval->list->setIconSize(QSize(30, 30));
230             for (int i = 0; i < listitems.count(); i++) {
231                 lsval->list->addItem(listitemsdisplay.at(i), listitems.at(i));
232                 QString entry = listitems.at(i);
233                 if (!entry.isEmpty() && (entry.endsWith(".png") || entry.endsWith(".pgm"))) {
234                     if (!EffectStackEdit::iconCache.contains(entry)) {
235                         QImage pix(entry);
236                         EffectStackEdit::iconCache[entry] = pix.scaled(30, 30);
237                     }
238                     lsval->list->setItemIcon(i, QPixmap::fromImage(iconCache[entry]));
239                 }
240             }
241             if (!value.isEmpty()) lsval->list->setCurrentIndex(listitems.indexOf(value));
242             lsval->title->setTitle(paramName);
243             m_valueItems[paramName] = lsval;
244             connect(lsval->list, SIGNAL(currentIndexChanged(int)) , this, SLOT(collectAllParameters()));
245             m_uiItems.append(lsval);
246         } else if (type == "bool") {
247             Boolval *bval = new Boolval;
248             bval->setupUi(toFillin);
249             bval->checkBox->setCheckState(value == "0" ? Qt::Unchecked : Qt::Checked);
250             bval->checkBox->setText(paramName);
251             m_valueItems[paramName] = bval;
252             connect(bval->checkBox, SIGNAL(stateChanged(int)) , this, SLOT(collectAllParameters()));
253             m_uiItems.append(bval);
254         } else if (type == "complex") {
255             ComplexParameter *pl = new ComplexParameter;
256             pl->setupParam(d, pa.attribute("name"), 0, 100);
257             m_vbox->addWidget(pl);
258             m_valueItems[paramName+"complex"] = pl;
259             connect(pl, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
260         } else if (type == "geometry") {
261             if (KdenliveSettings::on_monitor_effects()) {
262                 GeometryWidget *geometry = new GeometryWidget(m_monitor, m_timecode, pos, isEffect, this);
263                 // connect this before setupParam to make sure the monitor scene shows up at startup
264                 connect(geometry, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
265                 connect(geometry, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
266                 if (minFrame == maxFrame)
267                     geometry->setupParam(pa, m_in, m_out);
268                 else
269                     geometry->setupParam(pa, minFrame, maxFrame);
270                 m_vbox->addWidget(geometry);
271                 m_valueItems[paramName+"geometry"] = geometry;
272                 connect(geometry, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
273                 connect(this, SIGNAL(syncEffectsPos(int)), geometry, SLOT(slotSyncPosition(int)));
274             } else {
275                 Geometryval *geo = new Geometryval(m_profile, m_timecode, m_frameSize, pos);
276                 if (minFrame == maxFrame)
277                     geo->setupParam(pa, m_in, m_out);
278                 else
279                     geo->setupParam(pa, minFrame, maxFrame);
280                 m_vbox->addWidget(geo);
281                 m_valueItems[paramName+"geometry"] = geo;
282                 connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
283                 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
284                 connect(this, SIGNAL(syncEffectsPos(int)), geo, SLOT(slotSyncPosition(int)));
285             }
286         } else if (type == "keyframe" || type == "simplekeyframe") {
287             // keyframe editor widget
288             kDebug() << "min: " << m_in << ", MAX: " << m_out;
289             if (m_keyframeEditor == NULL) {
290                 KeyframeEdit *geo = new KeyframeEdit(pa, m_in, m_in + m_out, pa.attribute("min").toInt(), pa.attribute("max").toInt(), m_timecode, e.attribute("active_keyframe", "-1").toInt());
291                 m_vbox->addWidget(geo);
292                 m_valueItems[paramName+"keyframe"] = geo;
293                 m_keyframeEditor = geo;
294                 connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
295                 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
296             } else {
297                 // we already have a keyframe editor, so just add another column for the new param
298                 m_keyframeEditor->addParameter(pa);
299             }
300         } else if (type == "color") {
301             if (value.startsWith('#'))
302                 value = value.replace('#', "0x");
303             bool ok;
304             ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, QColor(value.toUInt(&ok, 16)), this);
305             m_vbox->addWidget(choosecolor);
306             m_valueItems[paramName] = choosecolor;
307             connect(choosecolor, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int)));
308             connect(choosecolor, SIGNAL(modified()) , this, SLOT(collectAllParameters()));
309         } else if (type == "position") {
310             int pos = value.toInt();
311             if (d.attribute("id") == "fadein" || d.attribute("id") == "fade_from_black") {
312                 pos = pos - m_in;
313             } else if (d.attribute("id") == "fadeout" || d.attribute("id") == "fade_to_black") {
314                 // fadeout position starts from clip end
315                 pos = m_out - pos;
316             }
317             PositionEdit *posedit = new PositionEdit(paramName, pos, 0, m_out - m_in, m_timecode);
318             m_vbox->addWidget(posedit);
319             m_valueItems[paramName+"position"] = posedit;
320             connect(posedit, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
321         } else if (type == "curve") {
322             KisCurveWidget *curve = new KisCurveWidget(this);
323             curve->setMaxPoints(pa.attribute("max").toInt());
324             QList<QPointF> points;
325             int number = EffectsList::parameter(e, pa.attribute("number")).toInt();
326             QString inName = pa.attribute("inpoints");
327             QString outName = pa.attribute("outpoints");
328             int start = pa.attribute("min").toInt();
329             for (int j = start; j <= number; j++) {
330                 QString in = inName;
331                 in.replace("%i", QString::number(j));
332                 QString out = outName;
333                 out.replace("%i", QString::number(j));
334                 points << QPointF(EffectsList::parameter(e, in).toDouble(), EffectsList::parameter(e, out).toDouble());
335             }
336             if (!points.isEmpty())
337                 curve->setCurve(KisCubicCurve(points));
338             QSpinBox *spinin = new QSpinBox();
339             spinin->setRange(0, 1000);
340             QSpinBox *spinout = new QSpinBox();
341             spinout->setRange(0, 1000);
342             curve->setupInOutControls(spinin, spinout, 0, 1000);
343             m_vbox->addWidget(curve);
344             m_vbox->addWidget(spinin);
345             m_vbox->addWidget(spinout);
346
347             connect(curve, SIGNAL(modified()), this, SLOT(collectAllParameters()));
348             m_valueItems[paramName] = curve;
349
350             QString depends = pa.attribute("depends");
351             if (!depends.isEmpty())
352                 meetDependency(paramName, type, EffectsList::parameter(e, depends));
353         } else if (type == "wipe") {
354             Wipeval *wpval = new Wipeval;
355             wpval->setupUi(toFillin);
356             wipeInfo w = getWipeInfo(value);
357             switch (w.start) {
358             case UP:
359                 wpval->start_up->setChecked(true);
360                 break;
361             case DOWN:
362                 wpval->start_down->setChecked(true);
363                 break;
364             case RIGHT:
365                 wpval->start_right->setChecked(true);
366                 break;
367             case LEFT:
368                 wpval->start_left->setChecked(true);
369                 break;
370             default:
371                 wpval->start_center->setChecked(true);
372                 break;
373             }
374             switch (w.end) {
375             case UP:
376                 wpval->end_up->setChecked(true);
377                 break;
378             case DOWN:
379                 wpval->end_down->setChecked(true);
380                 break;
381             case RIGHT:
382                 wpval->end_right->setChecked(true);
383                 break;
384             case LEFT:
385                 wpval->end_left->setChecked(true);
386                 break;
387             default:
388                 wpval->end_center->setChecked(true);
389                 break;
390             }
391             wpval->start_transp->setValue(w.startTransparency);
392             wpval->end_transp->setValue(w.endTransparency);
393             m_valueItems[paramName] = wpval;
394             connect(wpval->end_up, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
395             connect(wpval->end_down, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
396             connect(wpval->end_left, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
397             connect(wpval->end_right, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
398             connect(wpval->end_center, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
399             connect(wpval->start_up, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
400             connect(wpval->start_down, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
401             connect(wpval->start_left, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
402             connect(wpval->start_right, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
403             connect(wpval->start_center, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
404             connect(wpval->start_transp, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
405             connect(wpval->end_transp, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
406             //wpval->title->setTitle(na.toElement().text());
407             m_uiItems.append(wpval);
408         } else if (type == "url") {
409             Urlval *cval = new Urlval;
410             cval->setupUi(toFillin);
411             cval->label->setText(paramName);
412             cval->urlwidget->fileDialog()->setFilter(ProjectList::getExtensions());
413             m_valueItems[paramName] = cval;
414             cval->urlwidget->setUrl(KUrl(value));
415             connect(cval->urlwidget, SIGNAL(returnPressed()) , this, SLOT(collectAllParameters()));
416             connect(cval->urlwidget, SIGNAL(urlSelected(const KUrl&)) , this, SLOT(collectAllParameters()));
417             m_uiItems.append(cval);
418         } else {
419             delete toFillin;
420             toFillin = NULL;
421         }
422
423         if (toFillin)
424             m_vbox->addWidget(toFillin);
425     }
426     m_vbox->addStretch();
427 }
428
429 wipeInfo EffectStackEdit::getWipeInfo(QString value)
430 {
431     wipeInfo info;
432     QString start = value.section(';', 0, 0);
433     QString end = value.section(';', 1, 1).section('=', 1, 1);
434
435     if (start.startsWith("-100%,0"))
436         info.start = LEFT;
437     else if (start.startsWith("100%,0"))
438         info.start = RIGHT;
439     else if (start.startsWith("0%,100%"))
440         info.start = DOWN;
441     else if (start.startsWith("0%,-100%"))
442         info.start = UP;
443     else
444         info.start = CENTER;
445
446     if (start.count(':') == 2)
447         info.startTransparency = start.section(':', -1).toInt();
448     else
449         info.startTransparency = 100;
450
451     if (end.startsWith("-100%,0"))
452         info.end = LEFT;
453     else if (end.startsWith("100%,0"))
454         info.end = RIGHT;
455     else if (end.startsWith("0%,100%"))
456         info.end = DOWN;
457     else if (end.startsWith("0%,-100%"))
458         info.end = UP;
459     else
460         info.end = CENTER;
461
462     if (end.count(':') == 2)
463         info.endTransparency = end.section(':', -1).toInt();
464     else
465         info.endTransparency = 100;
466
467     return info;
468 }
469
470 QString EffectStackEdit::getWipeString(wipeInfo info)
471 {
472
473     QString start;
474     QString end;
475     switch (info.start) {
476     case LEFT:
477         start = "-100%,0%:100%x100%";
478         break;
479     case RIGHT:
480         start = "100%,0%:100%x100%";
481         break;
482     case DOWN:
483         start = "0%,100%:100%x100%";
484         break;
485     case UP:
486         start = "0%,-100%:100%x100%";
487         break;
488     default:
489         start = "0%,0%:100%x100%";
490         break;
491     }
492     start.append(':' + QString::number(info.startTransparency));
493
494     switch (info.end) {
495     case LEFT:
496         end = "-100%,0%:100%x100%";
497         break;
498     case RIGHT:
499         end = "100%,0%:100%x100%";
500         break;
501     case DOWN:
502         end = "0%,100%:100%x100%";
503         break;
504     case UP:
505         end = "0%,-100%:100%x100%";
506         break;
507     default:
508         end = "0%,0%:100%x100%";
509         break;
510     }
511     end.append(':' + QString::number(info.endTransparency));
512     return QString(start + ";-1=" + end);
513 }
514
515 void EffectStackEdit::collectAllParameters()
516 {
517     if (m_valueItems.isEmpty() || m_params.isNull()) return;
518     const QDomElement oldparam = m_params.cloneNode().toElement();
519     QDomElement newparam = oldparam.cloneNode().toElement();
520     QDomNodeList namenode = newparam.elementsByTagName("parameter");
521
522     for (int i = 0; i < namenode.count() ; i++) {
523         QDomNode pa = namenode.item(i);
524         QDomNode na = pa.firstChildElement("name");
525         QString type = pa.attributes().namedItem("type").nodeValue();
526         QString paramName = i18n(na.toElement().text().toUtf8().data());
527         if (type == "complex")
528             paramName.append("complex");
529         else if (type == "position")
530             paramName.append("position");
531         else if (type == "geometry")
532             paramName.append("geometry");
533         else if (type == "keyframe")
534             paramName.append("keyframe");
535         if (type != "simplekeyframe" && !m_valueItems.contains(paramName)) {
536             kDebug() << "// Param: " << paramName << " NOT FOUND";
537             continue;
538         }
539
540         QString setValue;
541         if (type == "double" || type == "constant") {
542             DoubleParameterWidget *doubleparam = (DoubleParameterWidget*)m_valueItems.value(paramName);
543             setValue = QString::number(doubleparam->getValue());
544         } else if (type == "list") {
545             KComboBox *box = ((Listval*)m_valueItems.value(paramName))->list;
546             setValue = box->itemData(box->currentIndex()).toString();
547         } else if (type == "bool") {
548             QCheckBox *box = ((Boolval*)m_valueItems.value(paramName))->checkBox;
549             setValue = box->checkState() == Qt::Checked ? "1" : "0" ;
550         } else if (type == "color") {
551             ChooseColorWidget *choosecolor = ((ChooseColorWidget*)m_valueItems.value(paramName));
552             setValue = choosecolor->getColor().name();
553         } else if (type == "complex") {
554             ComplexParameter *complex = ((ComplexParameter*)m_valueItems.value(paramName));
555             namenode.item(i) = complex->getParamDesc();
556         } else if (type == "geometry") {
557             if (KdenliveSettings::on_monitor_effects()) {
558                 GeometryWidget *geometry = ((GeometryWidget*)m_valueItems.value(paramName));
559                 namenode.item(i).toElement().setAttribute("value", geometry->getValue());
560             } else {
561                 Geometryval *geom = ((Geometryval*)m_valueItems.value(paramName));
562                 namenode.item(i).toElement().setAttribute("value", geom->getValue());
563             }
564         } else if (type == "position") {
565             PositionEdit *pedit = ((PositionEdit*)m_valueItems.value(paramName));
566             int pos = pedit->getPosition();
567             setValue = QString::number(pos);
568             if (newparam.attribute("id") == "fadein" || newparam.attribute("id") == "fade_from_black") {
569                 // Make sure duration is not longer than clip
570                 /*if (pos > m_out) {
571                     pos = m_out;
572                     pedit->setPosition(pos);
573                 }*/
574                 EffectsList::setParameter(newparam, "in", QString::number(m_in));
575                 EffectsList::setParameter(newparam, "out", QString::number(m_in + pos));
576                 setValue.clear();
577             } else if (newparam.attribute("id") == "fadeout" || newparam.attribute("id") == "fade_to_black") {
578                 // Make sure duration is not longer than clip
579                 /*if (pos > m_out) {
580                     pos = m_out;
581                     pedit->setPosition(pos);
582                 }*/
583                 EffectsList::setParameter(newparam, "in", QString::number(m_out - pos));
584                 EffectsList::setParameter(newparam, "out", QString::number(m_out));
585                 setValue.clear();
586             }
587         } else if (type == "curve") {
588             KisCurveWidget *curve = ((KisCurveWidget*)m_valueItems.value(paramName));
589             QList<QPointF> points = curve->curve().points();
590             QString number = pa.attributes().namedItem("number").nodeValue();
591             QString inName = pa.attributes().namedItem("inpoints").nodeValue();
592             QString outName = pa.attributes().namedItem("outpoints").nodeValue();
593             int off = pa.attributes().namedItem("min").nodeValue().toInt();
594             int end = pa.attributes().namedItem("max").nodeValue().toInt();
595             EffectsList::setParameter(newparam, number, QString::number(points.count()));
596             for (int j = 0; (j < points.count() && j + off <= end); j++) {
597                 QString in = inName;
598                 in.replace("%i", QString::number(j + off));
599                 QString out = outName;
600                 out.replace("%i", QString::number(j + off));
601                 EffectsList::setParameter(newparam, in, QString::number(points.at(j).x()));
602                 EffectsList::setParameter(newparam, out, QString::number(points.at(j).y()));
603             }
604             QString depends = pa.attributes().namedItem("depends").nodeValue();
605             if (!depends.isEmpty())
606                 meetDependency(paramName, type, EffectsList::parameter(newparam, depends));
607         } else if (type == "wipe") {
608             Wipeval *wp = (Wipeval*)m_valueItems.value(paramName);
609             wipeInfo info;
610             if (wp->start_left->isChecked())
611                 info.start = LEFT;
612             else if (wp->start_right->isChecked())
613                 info.start = RIGHT;
614             else if (wp->start_up->isChecked())
615                 info.start = UP;
616             else if (wp->start_down->isChecked())
617                 info.start = DOWN;
618             else if (wp->start_center->isChecked())
619                 info.start = CENTER;
620             else
621                 info.start = LEFT;
622             info.startTransparency = wp->start_transp->value();
623
624             if (wp->end_left->isChecked())
625                 info.end = LEFT;
626             else if (wp->end_right->isChecked())
627                 info.end = RIGHT;
628             else if (wp->end_up->isChecked())
629                 info.end = UP;
630             else if (wp->end_down->isChecked())
631                 info.end = DOWN;
632             else if (wp->end_center->isChecked())
633                 info.end = CENTER;
634             else
635                 info.end = RIGHT;
636             info.endTransparency = wp->end_transp->value();
637
638             setValue = getWipeString(info);
639         } else if ((type == "simplekeyframe" || type == "keyframe") && m_keyframeEditor) {
640             QString realName = i18n(na.toElement().text().toUtf8().data());
641             QString val = m_keyframeEditor->getValue(realName);
642             //kDebug() << "SET VALUE: " << val;
643             namenode.item(i).toElement().setAttribute("keyframes", val);
644         } else if (type == "url") {
645             KUrlRequester *req = ((Urlval*)m_valueItems.value(paramName))->urlwidget;
646             setValue = req->url().path();
647         }
648
649         if (!setValue.isNull())
650             pa.attributes().namedItem("value").setNodeValue(setValue);
651
652     }
653     emit parameterChanged(oldparam, newparam);
654 }
655
656 void EffectStackEdit::clearAllItems()
657 {
658     blockSignals(true);
659     m_valueItems.clear();
660     m_uiItems.clear();
661     /*while (!m_items.isEmpty()) {
662         QWidget *die = m_items.takeFirst();
663         die->disconnect();
664         delete die;
665     }*/
666     //qDeleteAll(m_uiItems);
667     QLayoutItem *child;
668     while ((child = m_vbox->takeAt(0)) != 0) {
669         QWidget *wid = child->widget();
670         delete child;
671         if (wid) delete wid;
672     }
673     m_keyframeEditor = NULL;
674     blockSignals(false);
675 }
676
677 void EffectStackEdit::slotSyncEffectsPos(int pos)
678 {
679     emit syncEffectsPos(pos);
680 }