]> git.sesse.net Git - kdenlive/blob - src/effectstackedit.cpp
Allow to reset single effect parameters:
[kdenlive] / src / effectstackedit.cpp
1 /***************************************************************************
2                           effecstackview.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             if (color < 3)
149                 curve->setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(curve->size(), (ColorTools::ColorsRGB)color)));
150             else
151                 curve->setPixmap(QPixmap());
152         }
153     }
154 }
155
156 void EffectStackEdit::updateProjectFormat(MltVideoProfile profile, Timecode t)
157 {
158     m_profile = profile;
159     m_timecode = t;
160 }
161
162 void EffectStackEdit::updateParameter(const QString &name, const QString &value)
163 {
164     m_params.setAttribute(name, value);
165 }
166
167 void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, int out, bool isEffect)
168 {
169     clearAllItems();
170     if (m_keyframeEditor) delete m_keyframeEditor;
171     m_keyframeEditor = NULL;
172     m_params = d;
173     m_in = in;
174     m_out = out;
175     if (m_params.isNull()) {
176         kDebug() << "// EMPTY EFFECT STACK";
177         return;
178     }
179
180     QDomNodeList namenode = m_params.elementsByTagName("parameter");
181     QDomElement e = m_params.toElement();
182     const int minFrame = e.attribute("start").toInt();
183     const int maxFrame = e.attribute("end").toInt();
184
185
186     for (int i = 0; i < namenode.count() ; i++) {
187         QDomElement pa = namenode.item(i).toElement();
188         QDomNode na = pa.firstChildElement("name");
189         QString type = pa.attribute("type");
190         QString paramName = i18n(na.toElement().text().toUtf8().data());
191         QWidget * toFillin = new QWidget(m_baseWidget);
192         QString value = pa.attribute("value").isNull() ?
193                         pa.attribute("default") : pa.attribute("value");
194
195         /** Currently supported parameter types are:
196             * constant (=double): a slider with an integer value (use the "factor" attribute to divide the value so that you can get a double
197             * list: a combobox containing a list of values to choose
198             * bool: a checkbox
199             * complex: designed for keyframe parameters, but old and not finished, do not use
200             * geometry: a rectangle that can be moved & resized, with possible keyframes, used in composite transition
201             * keyframe: a list widget with a list of entries (position and value)
202             * color: a color chooser button
203             * position: a slider representing the position of a frame in the current clip
204             * curve: a single curve representing multiple points
205             * wipe: a widget designed for the wipe transition, allowing to choose a position (left, right, top,...)
206         */
207
208         if (type == "double" || type == "constant") {
209             int min;
210             int max;
211             if (pa.attribute("min").startsWith('%'))
212                 min = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("min"));
213             else
214                 min = pa.attribute("min").toInt();
215             if (pa.attribute("max").startsWith('%'))
216                 max = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("max"));
217             else
218                 max = pa.attribute("max").toInt();
219
220             DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, (int)(value.toDouble() + 0.5), min, max,
221                                                                            pa.attribute("default").toInt(), pa.attribute("suffix"), this);
222             m_vbox->addWidget(doubleparam);
223             m_valueItems[paramName] = doubleparam;
224             connect(doubleparam, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
225         } else if (type == "list") {
226             Listval *lsval = new Listval;
227             lsval->setupUi(toFillin);
228             QStringList listitems = pa.attribute("paramlist").split(',');
229             QStringList listitemsdisplay = pa.attribute("paramlistdisplay").split(',');
230             if (listitemsdisplay.count() != listitems.count()) listitemsdisplay = listitems;
231             //lsval->list->addItems(listitems);
232             lsval->list->setIconSize(QSize(30, 30));
233             for (int i = 0; i < listitems.count(); i++) {
234                 lsval->list->addItem(listitemsdisplay.at(i), listitems.at(i));
235                 QString entry = listitems.at(i);
236                 if (!entry.isEmpty() && (entry.endsWith(".png") || entry.endsWith(".pgm"))) {
237                     if (!EffectStackEdit::iconCache.contains(entry)) {
238                         QImage pix(entry);
239                         EffectStackEdit::iconCache[entry] = pix.scaled(30, 30);
240                     }
241                     lsval->list->setItemIcon(i, QPixmap::fromImage(iconCache[entry]));
242                 }
243             }
244             if (!value.isEmpty()) lsval->list->setCurrentIndex(listitems.indexOf(value));
245             lsval->title->setTitle(paramName);
246             m_valueItems[paramName] = lsval;
247             connect(lsval->list, SIGNAL(currentIndexChanged(int)) , this, SLOT(collectAllParameters()));
248             m_uiItems.append(lsval);
249         } else if (type == "bool") {
250             Boolval *bval = new Boolval;
251             bval->setupUi(toFillin);
252             bval->checkBox->setCheckState(value == "0" ? Qt::Unchecked : Qt::Checked);
253             bval->checkBox->setText(paramName);
254             m_valueItems[paramName] = bval;
255             connect(bval->checkBox, SIGNAL(stateChanged(int)) , this, SLOT(collectAllParameters()));
256             m_uiItems.append(bval);
257         } else if (type == "complex") {
258             ComplexParameter *pl = new ComplexParameter;
259             pl->setupParam(d, pa.attribute("name"), 0, 100);
260             m_vbox->addWidget(pl);
261             m_valueItems[paramName+"complex"] = pl;
262             connect(pl, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
263         } else if (type == "geometry") {
264             if (KdenliveSettings::on_monitor_effects()) {
265                 GeometryWidget *geometry = new GeometryWidget(m_monitor, m_timecode, pos, isEffect, this);
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(parameterChanged()), this, SLOT(collectAllParameters()));
273                 connect(geometry, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
274                 connect(geometry, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
275                 connect(this, SIGNAL(syncEffectsPos(int)), geometry, SLOT(slotSyncPosition(int)));
276             } else {
277                 Geometryval *geo = new Geometryval(m_profile, m_timecode, m_frameSize, pos);
278                 if (minFrame == maxFrame)
279                     geo->setupParam(pa, m_in, m_out);
280                 else
281                     geo->setupParam(pa, minFrame, maxFrame);
282                 m_vbox->addWidget(geo);
283                 m_valueItems[paramName+"geometry"] = geo;
284                 connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
285                 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
286                 connect(this, SIGNAL(syncEffectsPos(int)), geo, SLOT(slotSyncPosition(int)));
287             }
288         } else if (type == "keyframe" || type == "simplekeyframe") {
289             // keyframe editor widget
290             kDebug() << "min: " << m_in << ", MAX: " << m_out;
291             if (m_keyframeEditor == NULL) {
292                 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());
293                 m_vbox->addWidget(geo);
294                 m_valueItems[paramName+"keyframe"] = geo;
295                 m_keyframeEditor = geo;
296                 connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
297                 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
298             } else {
299                 // we already have a keyframe editor, so just add another column for the new param
300                 m_keyframeEditor->addParameter(pa);
301             }
302         } else if (type == "color") {
303             if (value.startsWith('#'))
304                 value = value.replace('#', "0x");
305             bool ok;
306             ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, QColor(value.toUInt(&ok, 16)), this);
307             m_vbox->addWidget(choosecolor);
308             m_valueItems[paramName] = choosecolor;
309             connect(choosecolor, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int)));
310             connect(choosecolor, SIGNAL(modified()) , this, SLOT(collectAllParameters()));
311         } else if (type == "position") {
312             int pos = value.toInt();
313             if (d.attribute("id") == "fadein" || d.attribute("id") == "fade_from_black") {
314                 pos = pos - m_in;
315             } else if (d.attribute("id") == "fadeout" || d.attribute("id") == "fade_to_black") {
316                 // fadeout position starts from clip end
317                 pos = m_out - (pos - m_in);
318             }
319             PositionEdit *posedit = new PositionEdit(paramName, pos, 1, m_out, m_timecode);
320             m_vbox->addWidget(posedit);
321             m_valueItems[paramName+"position"] = posedit;
322             connect(posedit, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
323         } else if (type == "curve") {
324             KisCurveWidget *curve = new KisCurveWidget(this);
325             curve->setMaxPoints(pa.attribute("max").toInt());
326             QList<QPointF> points;
327             int number = EffectsList::parameter(e, pa.attribute("number")).toInt();
328             QString inName = pa.attribute("inpoints");
329             QString outName = pa.attribute("outpoints");
330             int start = pa.attribute("min").toInt();
331             for (int j = start; j <= number; j++) {
332                 QString in = inName;
333                 in.replace("%i", QString::number(j));
334                 QString out = outName;
335                 out.replace("%i", QString::number(j));
336                 points << QPointF(EffectsList::parameter(e, in).toDouble(), EffectsList::parameter(e, out).toDouble());
337             }
338             if (!points.isEmpty())
339                 curve->setCurve(KisCubicCurve(points));
340             QSpinBox *spinin = new QSpinBox();
341             spinin->setRange(0, 1000);
342             QSpinBox *spinout = new QSpinBox();
343             spinout->setRange(0, 1000);
344             curve->setupInOutControls(spinin, spinout, 0, 1000);
345             m_vbox->addWidget(curve);
346             m_vbox->addWidget(spinin);
347             m_vbox->addWidget(spinout);
348
349             connect(curve, SIGNAL(modified()), this, SLOT(collectAllParameters()));
350             m_valueItems[paramName] = curve;
351
352             QString depends = pa.attribute("depends");
353             if (!depends.isEmpty())
354                 meetDependency(paramName, type, EffectsList::parameter(e, depends));
355         } else if (type == "wipe") {
356             Wipeval *wpval = new Wipeval;
357             wpval->setupUi(toFillin);
358             wipeInfo w = getWipeInfo(value);
359             switch (w.start) {
360             case UP:
361                 wpval->start_up->setChecked(true);
362                 break;
363             case DOWN:
364                 wpval->start_down->setChecked(true);
365                 break;
366             case RIGHT:
367                 wpval->start_right->setChecked(true);
368                 break;
369             case LEFT:
370                 wpval->start_left->setChecked(true);
371                 break;
372             default:
373                 wpval->start_center->setChecked(true);
374                 break;
375             }
376             switch (w.end) {
377             case UP:
378                 wpval->end_up->setChecked(true);
379                 break;
380             case DOWN:
381                 wpval->end_down->setChecked(true);
382                 break;
383             case RIGHT:
384                 wpval->end_right->setChecked(true);
385                 break;
386             case LEFT:
387                 wpval->end_left->setChecked(true);
388                 break;
389             default:
390                 wpval->end_center->setChecked(true);
391                 break;
392             }
393             wpval->start_transp->setValue(w.startTransparency);
394             wpval->end_transp->setValue(w.endTransparency);
395             m_valueItems[paramName] = wpval;
396             connect(wpval->end_up, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
397             connect(wpval->end_down, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
398             connect(wpval->end_left, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
399             connect(wpval->end_right, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
400             connect(wpval->end_center, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
401             connect(wpval->start_up, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
402             connect(wpval->start_down, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
403             connect(wpval->start_left, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
404             connect(wpval->start_right, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
405             connect(wpval->start_center, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
406             connect(wpval->start_transp, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
407             connect(wpval->end_transp, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
408             //wpval->title->setTitle(na.toElement().text());
409             m_uiItems.append(wpval);
410         } else if (type == "url") {
411             Urlval *cval = new Urlval;
412             cval->setupUi(toFillin);
413             cval->label->setText(paramName);
414             cval->urlwidget->fileDialog()->setFilter(ProjectList::getExtensions());
415             m_valueItems[paramName] = cval;
416             cval->urlwidget->setUrl(KUrl(value));
417             connect(cval->urlwidget, SIGNAL(returnPressed()) , this, SLOT(collectAllParameters()));
418             connect(cval->urlwidget, SIGNAL(urlSelected(const KUrl&)) , this, SLOT(collectAllParameters()));
419             m_uiItems.append(cval);
420         } else {
421             delete toFillin;
422             toFillin = NULL;
423         }
424
425         if (toFillin)
426             m_vbox->addWidget(toFillin);
427     }
428     m_vbox->addStretch();
429 }
430
431 wipeInfo EffectStackEdit::getWipeInfo(QString value)
432 {
433     wipeInfo info;
434     QString start = value.section(';', 0, 0);
435     QString end = value.section(';', 1, 1).section('=', 1, 1);
436
437     if (start.startsWith("-100%,0"))
438         info.start = LEFT;
439     else if (start.startsWith("100%,0"))
440         info.start = RIGHT;
441     else if (start.startsWith("0%,100%"))
442         info.start = DOWN;
443     else if (start.startsWith("0%,-100%"))
444         info.start = UP;
445     else
446         info.start = CENTER;
447
448     if (start.count(':') == 2)
449         info.startTransparency = start.section(':', -1).toInt();
450     else
451         info.startTransparency = 100;
452
453     if (end.startsWith("-100%,0"))
454         info.end = LEFT;
455     else if (end.startsWith("100%,0"))
456         info.end = RIGHT;
457     else if (end.startsWith("0%,100%"))
458         info.end = DOWN;
459     else if (end.startsWith("0%,-100%"))
460         info.end = UP;
461     else
462         info.end = CENTER;
463
464     if (end.count(':') == 2)
465         info.endTransparency = end.section(':', -1).toInt();
466     else
467         info.endTransparency = 100;
468
469     return info;
470 }
471
472 QString EffectStackEdit::getWipeString(wipeInfo info)
473 {
474
475     QString start;
476     QString end;
477     switch (info.start) {
478     case LEFT:
479         start = "-100%,0%:100%x100%";
480         break;
481     case RIGHT:
482         start = "100%,0%:100%x100%";
483         break;
484     case DOWN:
485         start = "0%,100%:100%x100%";
486         break;
487     case UP:
488         start = "0%,-100%:100%x100%";
489         break;
490     default:
491         start = "0%,0%:100%x100%";
492         break;
493     }
494     start.append(':' + QString::number(info.startTransparency));
495
496     switch (info.end) {
497     case LEFT:
498         end = "-100%,0%:100%x100%";
499         break;
500     case RIGHT:
501         end = "100%,0%:100%x100%";
502         break;
503     case DOWN:
504         end = "0%,100%:100%x100%";
505         break;
506     case UP:
507         end = "0%,-100%:100%x100%";
508         break;
509     default:
510         end = "0%,0%:100%x100%";
511         break;
512     }
513     end.append(':' + QString::number(info.endTransparency));
514     return QString(start + ";-1=" + end);
515 }
516
517 void EffectStackEdit::collectAllParameters()
518 {
519     if (m_valueItems.isEmpty() || m_params.isNull()) return;
520     const QDomElement oldparam = m_params.cloneNode().toElement();
521     QDomElement newparam = oldparam.cloneNode().toElement();
522     QDomNodeList namenode = newparam.elementsByTagName("parameter");
523
524     for (int i = 0; i < namenode.count() ; i++) {
525         QDomNode pa = namenode.item(i);
526         QDomNode na = pa.firstChildElement("name");
527         QString type = pa.attributes().namedItem("type").nodeValue();
528         QString paramName = i18n(na.toElement().text().toUtf8().data());
529         if (type == "complex")
530             paramName.append("complex");
531         else if (type == "position")
532             paramName.append("position");
533         else if (type == "geometry")
534             paramName.append("geometry");
535         else if (type == "keyframe")
536             paramName.append("keyframe");
537         if (type != "simplekeyframe" && !m_valueItems.contains(paramName)) {
538             kDebug() << "// Param: " << paramName << " NOT FOUND";
539             continue;
540         }
541
542         QString setValue;
543         if (type == "double" || type == "constant") {
544             DoubleParameterWidget *doubleparam = (DoubleParameterWidget*)m_valueItems.value(paramName);
545             setValue = QString::number(doubleparam->getValue());
546         } else if (type == "list") {
547             KComboBox *box = ((Listval*)m_valueItems.value(paramName))->list;
548             setValue = box->itemData(box->currentIndex()).toString();
549         } else if (type == "bool") {
550             QCheckBox *box = ((Boolval*)m_valueItems.value(paramName))->checkBox;
551             setValue = box->checkState() == Qt::Checked ? "1" : "0" ;
552         } else if (type == "color") {
553             ChooseColorWidget *choosecolor = ((ChooseColorWidget*)m_valueItems.value(paramName));
554             setValue = choosecolor->getColor().name();
555         } else if (type == "complex") {
556             ComplexParameter *complex = ((ComplexParameter*)m_valueItems.value(paramName));
557             namenode.item(i) = complex->getParamDesc();
558         } else if (type == "geometry") {
559             if (KdenliveSettings::on_monitor_effects()) {
560                 GeometryWidget *geometry = ((GeometryWidget*)m_valueItems.value(paramName));
561                 namenode.item(i).toElement().setAttribute("value", geometry->getValue());
562             } else {
563                 Geometryval *geom = ((Geometryval*)m_valueItems.value(paramName));
564                 namenode.item(i).toElement().setAttribute("value", geom->getValue());
565             }
566         } else if (type == "position") {
567             PositionEdit *pedit = ((PositionEdit*)m_valueItems.value(paramName));
568             int pos = pedit->getPosition();
569             setValue = QString::number(pos);
570             if (newparam.attribute("id") == "fadein" || newparam.attribute("id") == "fade_from_black") {
571                 // Make sure duration is not longer than clip
572                 /*if (pos > m_out) {
573                     pos = m_out;
574                     pedit->setPosition(pos);
575                 }*/
576                 EffectsList::setParameter(newparam, "in", QString::number(m_in));
577                 EffectsList::setParameter(newparam, "out", QString::number(m_in + pos));
578                 setValue.clear();
579             } else if (newparam.attribute("id") == "fadeout" || newparam.attribute("id") == "fade_to_black") {
580                 // Make sure duration is not longer than clip
581                 /*if (pos > m_out) {
582                     pos = m_out;
583                     pedit->setPosition(pos);
584                 }*/
585                 EffectsList::setParameter(newparam, "in", QString::number(m_out + m_in - pos));
586                 EffectsList::setParameter(newparam, "out", QString::number(m_out + m_in));
587                 setValue.clear();
588             }
589         } else if (type == "curve") {
590             KisCurveWidget *curve = ((KisCurveWidget*)m_valueItems.value(paramName));
591             QList<QPointF> points = curve->curve().points();
592             QString number = pa.attributes().namedItem("number").nodeValue();
593             QString inName = pa.attributes().namedItem("inpoints").nodeValue();
594             QString outName = pa.attributes().namedItem("outpoints").nodeValue();
595             int off = pa.attributes().namedItem("min").nodeValue().toInt();
596             int end = pa.attributes().namedItem("max").nodeValue().toInt();
597             EffectsList::setParameter(newparam, number, QString::number(points.count()));
598             for (int j = 0; (j < points.count() && j + off <= end); j++) {
599                 QString in = inName;
600                 in.replace("%i", QString::number(j + off));
601                 QString out = outName;
602                 out.replace("%i", QString::number(j + off));
603                 EffectsList::setParameter(newparam, in, QString::number(points.at(j).x()));
604                 EffectsList::setParameter(newparam, out, QString::number(points.at(j).y()));
605             }
606             QString depends = pa.attributes().namedItem("depends").nodeValue();
607             if (!depends.isEmpty())
608                 meetDependency(paramName, type, EffectsList::parameter(newparam, depends));
609         } else if (type == "wipe") {
610             Wipeval *wp = (Wipeval*)m_valueItems.value(paramName);
611             wipeInfo info;
612             if (wp->start_left->isChecked())
613                 info.start = LEFT;
614             else if (wp->start_right->isChecked())
615                 info.start = RIGHT;
616             else if (wp->start_up->isChecked())
617                 info.start = UP;
618             else if (wp->start_down->isChecked())
619                 info.start = DOWN;
620             else if (wp->start_center->isChecked())
621                 info.start = CENTER;
622             else
623                 info.start = LEFT;
624             info.startTransparency = wp->start_transp->value();
625
626             if (wp->end_left->isChecked())
627                 info.end = LEFT;
628             else if (wp->end_right->isChecked())
629                 info.end = RIGHT;
630             else if (wp->end_up->isChecked())
631                 info.end = UP;
632             else if (wp->end_down->isChecked())
633                 info.end = DOWN;
634             else if (wp->end_center->isChecked())
635                 info.end = CENTER;
636             else
637                 info.end = RIGHT;
638             info.endTransparency = wp->end_transp->value();
639
640             setValue = getWipeString(info);
641         } else if ((type == "simplekeyframe" || type == "keyframe") && m_keyframeEditor) {
642             QString realName = i18n(na.toElement().text().toUtf8().data());
643             QString val = m_keyframeEditor->getValue(realName);
644             kDebug() << "SET VALUE: " << val;
645             namenode.item(i).toElement().setAttribute("keyframes", val);
646         } else if (type == "url") {
647             KUrlRequester *req = ((Urlval*)m_valueItems.value(paramName))->urlwidget;
648             setValue = req->url().path();
649         }
650
651         if (!setValue.isNull())
652             pa.attributes().namedItem("value").setNodeValue(setValue);
653
654     }
655     emit parameterChanged(oldparam, newparam);
656 }
657
658 void EffectStackEdit::clearAllItems()
659 {
660     blockSignals(true);
661     m_valueItems.clear();
662     m_uiItems.clear();
663     /*while (!m_items.isEmpty()) {
664         QWidget *die = m_items.takeFirst();
665         die->disconnect();
666         delete die;
667     }*/
668     //qDeleteAll(m_uiItems);
669     QLayoutItem *child;
670     while ((child = m_vbox->takeAt(0)) != 0) {
671         QWidget *wid = child->widget();
672         delete child;
673         if (wid) delete wid;
674     }
675     m_keyframeEditor = NULL;
676     blockSignals(false);
677 }
678
679 void EffectStackEdit::slotSyncEffectsPos(int pos)
680 {
681     emit syncEffectsPos(pos);
682 }