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