]> git.sesse.net Git - kdenlive/blob - src/effectstackedit.cpp
Pre-select the first parameter on effects with not other parameter selected to be...
[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 #include "cornerswidget.h"
37
38 #include <KDebug>
39 #include <KLocale>
40 #include <KFileDialog>
41
42 #include <QVBoxLayout>
43 #include <QLabel>
44 #include <QPushButton>
45 #include <QCheckBox>
46 #include <QScrollArea>
47
48
49 class Boolval: public QWidget, public Ui::Boolval_UI
50 {
51 };
52
53 class Listval: public QWidget, public Ui::Listval_UI
54 {
55 };
56
57 class Wipeval: public QWidget, public Ui::Wipeval_UI
58 {
59 };
60
61 class Urlval: public QWidget, public Ui::Urlval_UI
62 {
63 };
64
65 QMap<QString, QImage> EffectStackEdit::iconCache;
66
67 EffectStackEdit::EffectStackEdit(Monitor *monitor, QWidget *parent) :
68         QScrollArea(parent),
69         m_in(0),
70         m_out(0),
71         m_frameSize(QPoint()),
72         m_keyframeEditor(NULL),
73         m_monitor(monitor)
74 {
75     m_baseWidget = new QWidget(this);
76     setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
77     setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
78     setFrameStyle(QFrame::NoFrame);
79     setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding));
80
81     setWidget(m_baseWidget);
82     setWidgetResizable(true);
83     m_vbox = new QVBoxLayout(m_baseWidget);
84     m_vbox->setContentsMargins(0, 0, 0, 0);
85     m_vbox->setSpacing(0);
86     //wid->show();
87 }
88
89 EffectStackEdit::~EffectStackEdit()
90 {
91     iconCache.clear();
92     delete m_baseWidget;
93 }
94
95 void EffectStackEdit::setFrameSize(QPoint p)
96 {
97     m_frameSize = p;
98     QDomNodeList namenode = m_params.elementsByTagName("parameter");
99     for (int i = 0; i < namenode.count() ; i++) {
100         QDomNode pa = namenode.item(i);
101         QDomNode na = pa.firstChildElement("name");
102         QString type = pa.attributes().namedItem("type").nodeValue();
103         QString paramName = i18n(na.toElement().text().toUtf8().data());
104
105         if (type == "geometry" && !KdenliveSettings::on_monitor_effects()) {
106             Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
107             geom->setFrameSize(m_frameSize);
108             break;
109         }
110     }
111 }
112
113 void EffectStackEdit::updateTimecodeFormat()
114 {
115     if (m_keyframeEditor)
116         m_keyframeEditor->updateTimecodeFormat();
117
118     QDomNodeList namenode = m_params.elementsByTagName("parameter");
119     for (int i = 0; i < namenode.count() ; i++) {
120         QDomNode pa = namenode.item(i);
121         QDomNode na = pa.firstChildElement("name");
122         QString type = pa.attributes().namedItem("type").nodeValue();
123         QString paramName = i18n(na.toElement().text().toUtf8().data());
124
125         if (type == "geometry") {
126             if (KdenliveSettings::on_monitor_effects()) {
127                 GeometryWidget *geom = (GeometryWidget*)m_valueItems[paramName+"geometry"];
128                 geom->updateTimecodeFormat();
129             } else {
130                 Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
131                 geom->updateTimecodeFormat();
132             }
133             break;
134         }
135         if (type == "position") {
136             PositionEdit *posi = ((PositionEdit*)m_valueItems[paramName+"position"]);
137             posi->updateTimecodeFormat();
138             break;
139         }
140     }
141 }
142
143 void EffectStackEdit::meetDependency(const QString& name, QString type, QString value)
144 {
145     if (type == "curve") {
146         KisCurveWidget *curve = (KisCurveWidget*)m_valueItems[name];
147         if (curve) {
148             int color = value.toInt();
149             curve->setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(curve->size(), (ColorTools::ColorsRGB)color, 0.8)));
150         }
151     }
152 }
153
154 void EffectStackEdit::updateProjectFormat(MltVideoProfile profile, Timecode t)
155 {
156     m_profile = profile;
157     m_timecode = t;
158 }
159
160 void EffectStackEdit::updateParameter(const QString &name, const QString &value)
161 {
162     m_params.setAttribute(name, value);
163 }
164
165 void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, int out, bool isEffect)
166 {
167     clearAllItems();
168     if (m_keyframeEditor) delete m_keyframeEditor;
169     m_keyframeEditor = NULL;
170     m_params = d;
171     m_in = in;
172     m_out = out;
173     if (m_params.isNull()) {
174         kDebug() << "// EMPTY EFFECT STACK";
175         return;
176     }
177
178     QDomNodeList namenode = m_params.elementsByTagName("parameter");
179     QDomElement e = m_params.toElement();
180     const int minFrame = e.attribute("start").toInt();
181     const int maxFrame = e.attribute("end").toInt();
182
183
184     for (int i = 0; i < namenode.count() ; i++) {
185         QDomElement pa = namenode.item(i).toElement();
186         QDomNode na = pa.firstChildElement("name");
187         QString type = pa.attribute("type");
188         QString paramName = i18n(na.toElement().text().toUtf8().data());
189         QWidget * toFillin = new QWidget(m_baseWidget);
190         QString value = pa.attribute("value").isNull() ?
191                         pa.attribute("default") : pa.attribute("value");
192
193         /** Currently supported parameter types are:
194             * constant (=double): a slider with an integer value (use the "factor" attribute to divide the value so that you can get a double
195             * list: a combobox containing a list of values to choose
196             * bool: a checkbox
197             * complex: designed for keyframe parameters, but old and not finished, do not use
198             * geometry: a rectangle that can be moved & resized, with possible keyframes, used in composite transition
199             * keyframe: a list widget with a list of entries (position and value)
200             * color: a color chooser button
201             * position: a slider representing the position of a frame in the current clip
202             * curve: a single curve representing multiple points
203             * wipe: a widget designed for the wipe transition, allowing to choose a position (left, right, top,...)
204         */
205
206         if (type == "double" || type == "constant") {
207             int min;
208             int max;
209             if (pa.attribute("min").startsWith('%'))
210                 min = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("min"));
211             else
212                 min = pa.attribute("min").toInt();
213             if (pa.attribute("max").startsWith('%'))
214                 max = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("max"));
215             else
216                 max = pa.attribute("max").toInt();
217
218             DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, (int)(value.toDouble() + 0.5), min, max,
219                     pa.attribute("default").toInt(), pa.attribute("suffix"), this);
220             m_vbox->addWidget(doubleparam);
221             m_valueItems[paramName] = doubleparam;
222             connect(doubleparam, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
223         } else if (type == "list") {
224             Listval *lsval = new Listval;
225             lsval->setupUi(toFillin);
226             QStringList listitems = pa.attribute("paramlist").split(',');
227             QStringList listitemsdisplay = pa.attribute("paramlistdisplay").split(',');
228             if (listitemsdisplay.count() != listitems.count())
229                 listitemsdisplay = listitems;
230             lsval->list->setIconSize(QSize(30, 30));
231             for (int i = 0; i < listitems.count(); i++) {
232                 lsval->list->addItem(listitemsdisplay.at(i), listitems.at(i));
233                 QString entry = listitems.at(i);
234                 if (!entry.isEmpty() && (entry.endsWith(".png") || entry.endsWith(".pgm"))) {
235                     if (!EffectStackEdit::iconCache.contains(entry)) {
236                         QImage pix(entry);
237                         EffectStackEdit::iconCache[entry] = pix.scaled(30, 30);
238                     }
239                     lsval->list->setItemIcon(i, QPixmap::fromImage(iconCache[entry]));
240                 }
241             }
242             if (!value.isEmpty()) lsval->list->setCurrentIndex(listitems.indexOf(value));
243             lsval->name->setText(paramName);
244             m_valueItems[paramName] = lsval;
245             connect(lsval->list, SIGNAL(currentIndexChanged(int)) , this, SLOT(collectAllParameters()));
246             m_uiItems.append(lsval);
247         } else if (type == "bool") {
248             Boolval *bval = new Boolval;
249             bval->setupUi(toFillin);
250             bval->checkBox->setCheckState(value == "0" ? Qt::Unchecked : Qt::Checked);
251             bval->name->setText(paramName);
252             m_valueItems[paramName] = bval;
253             connect(bval->checkBox, SIGNAL(stateChanged(int)) , this, SLOT(collectAllParameters()));
254             m_uiItems.append(bval);
255         } else if (type == "complex") {
256             ComplexParameter *pl = new ComplexParameter;
257             pl->setupParam(d, pa.attribute("name"), 0, 100);
258             m_vbox->addWidget(pl);
259             m_valueItems[paramName+"complex"] = pl;
260             connect(pl, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
261         } else if (type == "geometry") {
262             if (KdenliveSettings::on_monitor_effects()) {
263                 GeometryWidget *geometry = new GeometryWidget(m_monitor, m_timecode, pos, isEffect, this);
264                 // connect this before setupParam to make sure the monitor scene shows up at startup
265                 connect(geometry, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
266                 connect(geometry, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
267                 if (minFrame == maxFrame)
268                     geometry->setupParam(pa, m_in, m_out);
269                 else
270                     geometry->setupParam(pa, minFrame, maxFrame);
271                 m_vbox->addWidget(geometry);
272                 m_valueItems[paramName+"geometry"] = geometry;
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, 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;
317             }
318             PositionEdit *posedit = new PositionEdit(paramName, pos, 0, m_out - m_in, 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 == "corners") {
355             CornersWidget *corners = new CornersWidget(m_monitor, pos, isEffect, pa.attribute("factor").toInt(), this);
356             connect(corners, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
357             if (minFrame == maxFrame)
358                 corners->setRange(m_in, m_out);
359             else
360                 corners->setRange(minFrame, maxFrame);
361
362             QString xName = pa.attribute("xpoints");
363             QString yName = pa.attribute("ypoints");
364             QPolygon points;
365             int x, y;
366             for (int j = 1; j <= 4; ++j) {
367                 x = EffectsList::parameter(e, QString(xName).replace("%i", QString::number(j))).toInt();
368                 y = EffectsList::parameter(e, QString(yName).replace("%i", QString::number(j))).toInt();
369                 points << QPoint(x, y);
370             }
371             corners->setValue(points);
372
373             m_vbox->addWidget(corners);
374             connect(corners, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
375             m_valueItems[paramName] = corners;
376         } else if (type == "wipe") {
377             Wipeval *wpval = new Wipeval;
378             wpval->setupUi(toFillin);
379             wipeInfo w = getWipeInfo(value);
380             switch (w.start) {
381             case UP:
382                 wpval->start_up->setChecked(true);
383                 break;
384             case DOWN:
385                 wpval->start_down->setChecked(true);
386                 break;
387             case RIGHT:
388                 wpval->start_right->setChecked(true);
389                 break;
390             case LEFT:
391                 wpval->start_left->setChecked(true);
392                 break;
393             default:
394                 wpval->start_center->setChecked(true);
395                 break;
396             }
397             switch (w.end) {
398             case UP:
399                 wpval->end_up->setChecked(true);
400                 break;
401             case DOWN:
402                 wpval->end_down->setChecked(true);
403                 break;
404             case RIGHT:
405                 wpval->end_right->setChecked(true);
406                 break;
407             case LEFT:
408                 wpval->end_left->setChecked(true);
409                 break;
410             default:
411                 wpval->end_center->setChecked(true);
412                 break;
413             }
414             wpval->start_transp->setValue(w.startTransparency);
415             wpval->end_transp->setValue(w.endTransparency);
416             m_valueItems[paramName] = wpval;
417             connect(wpval->end_up, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
418             connect(wpval->end_down, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
419             connect(wpval->end_left, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
420             connect(wpval->end_right, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
421             connect(wpval->end_center, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
422             connect(wpval->start_up, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
423             connect(wpval->start_down, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
424             connect(wpval->start_left, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
425             connect(wpval->start_right, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
426             connect(wpval->start_center, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
427             connect(wpval->start_transp, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
428             connect(wpval->end_transp, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
429             //wpval->title->setTitle(na.toElement().text());
430             m_uiItems.append(wpval);
431         } else if (type == "url") {
432             Urlval *cval = new Urlval;
433             cval->setupUi(toFillin);
434             cval->label->setText(paramName);
435             cval->urlwidget->fileDialog()->setFilter(ProjectList::getExtensions());
436             m_valueItems[paramName] = cval;
437             cval->urlwidget->setUrl(KUrl(value));
438             connect(cval->urlwidget, SIGNAL(returnPressed()) , this, SLOT(collectAllParameters()));
439             connect(cval->urlwidget, SIGNAL(urlSelected(const KUrl&)) , this, SLOT(collectAllParameters()));
440             m_uiItems.append(cval);
441         } else {
442             delete toFillin;
443             toFillin = NULL;
444         }
445
446         if (toFillin)
447             m_vbox->addWidget(toFillin);
448     }
449     m_vbox->addStretch();
450
451     if(m_keyframeEditor)
452         m_keyframeEditor->checkVisibleParam();
453 }
454
455 wipeInfo EffectStackEdit::getWipeInfo(QString value)
456 {
457     wipeInfo info;
458     QString start = value.section(';', 0, 0);
459     QString end = value.section(';', 1, 1).section('=', 1, 1);
460
461     if (start.startsWith("-100%,0"))
462         info.start = LEFT;
463     else if (start.startsWith("100%,0"))
464         info.start = RIGHT;
465     else if (start.startsWith("0%,100%"))
466         info.start = DOWN;
467     else if (start.startsWith("0%,-100%"))
468         info.start = UP;
469     else
470         info.start = CENTER;
471
472     if (start.count(':') == 2)
473         info.startTransparency = start.section(':', -1).toInt();
474     else
475         info.startTransparency = 100;
476
477     if (end.startsWith("-100%,0"))
478         info.end = LEFT;
479     else if (end.startsWith("100%,0"))
480         info.end = RIGHT;
481     else if (end.startsWith("0%,100%"))
482         info.end = DOWN;
483     else if (end.startsWith("0%,-100%"))
484         info.end = UP;
485     else
486         info.end = CENTER;
487
488     if (end.count(':') == 2)
489         info.endTransparency = end.section(':', -1).toInt();
490     else
491         info.endTransparency = 100;
492
493     return info;
494 }
495
496 QString EffectStackEdit::getWipeString(wipeInfo info)
497 {
498
499     QString start;
500     QString end;
501     switch (info.start) {
502     case LEFT:
503         start = "-100%,0%:100%x100%";
504         break;
505     case RIGHT:
506         start = "100%,0%:100%x100%";
507         break;
508     case DOWN:
509         start = "0%,100%:100%x100%";
510         break;
511     case UP:
512         start = "0%,-100%:100%x100%";
513         break;
514     default:
515         start = "0%,0%:100%x100%";
516         break;
517     }
518     start.append(':' + QString::number(info.startTransparency));
519
520     switch (info.end) {
521     case LEFT:
522         end = "-100%,0%:100%x100%";
523         break;
524     case RIGHT:
525         end = "100%,0%:100%x100%";
526         break;
527     case DOWN:
528         end = "0%,100%:100%x100%";
529         break;
530     case UP:
531         end = "0%,-100%:100%x100%";
532         break;
533     default:
534         end = "0%,0%:100%x100%";
535         break;
536     }
537     end.append(':' + QString::number(info.endTransparency));
538     return QString(start + ";-1=" + end);
539 }
540
541 void EffectStackEdit::collectAllParameters()
542 {
543     if (m_valueItems.isEmpty() || m_params.isNull()) return;
544     const QDomElement oldparam = m_params.cloneNode().toElement();
545     QDomElement newparam = oldparam.cloneNode().toElement();
546     QDomNodeList namenode = newparam.elementsByTagName("parameter");
547
548     for (int i = 0; i < namenode.count() ; i++) {
549         QDomNode pa = namenode.item(i);
550         QDomNode na = pa.firstChildElement("name");
551         QString type = pa.attributes().namedItem("type").nodeValue();
552         QString paramName = i18n(na.toElement().text().toUtf8().data());
553         if (type == "complex")
554             paramName.append("complex");
555         else if (type == "position")
556             paramName.append("position");
557         else if (type == "geometry")
558             paramName.append("geometry");
559         else if (type == "keyframe")
560             paramName.append("keyframe");
561         if (type != "simplekeyframe" && !m_valueItems.contains(paramName)) {
562             kDebug() << "// Param: " << paramName << " NOT FOUND";
563             continue;
564         }
565
566         QString setValue;
567         if (type == "double" || type == "constant") {
568             DoubleParameterWidget *doubleparam = (DoubleParameterWidget*)m_valueItems.value(paramName);
569             setValue = QString::number(doubleparam->getValue());
570         } else if (type == "list") {
571             KComboBox *box = ((Listval*)m_valueItems.value(paramName))->list;
572             setValue = box->itemData(box->currentIndex()).toString();
573         } else if (type == "bool") {
574             QCheckBox *box = ((Boolval*)m_valueItems.value(paramName))->checkBox;
575             setValue = box->checkState() == Qt::Checked ? "1" : "0" ;
576         } else if (type == "color") {
577             ChooseColorWidget *choosecolor = ((ChooseColorWidget*)m_valueItems.value(paramName));
578             setValue = choosecolor->getColor().name();
579         } else if (type == "complex") {
580             ComplexParameter *complex = ((ComplexParameter*)m_valueItems.value(paramName));
581             namenode.item(i) = complex->getParamDesc();
582         } else if (type == "geometry") {
583             if (KdenliveSettings::on_monitor_effects()) {
584                 GeometryWidget *geometry = ((GeometryWidget*)m_valueItems.value(paramName));
585                 namenode.item(i).toElement().setAttribute("value", geometry->getValue());
586             } else {
587                 Geometryval *geom = ((Geometryval*)m_valueItems.value(paramName));
588                 namenode.item(i).toElement().setAttribute("value", geom->getValue());
589             }
590         } else if (type == "position") {
591             PositionEdit *pedit = ((PositionEdit*)m_valueItems.value(paramName));
592             int pos = pedit->getPosition();
593             setValue = QString::number(pos);
594             if (newparam.attribute("id") == "fadein" || newparam.attribute("id") == "fade_from_black") {
595                 // Make sure duration is not longer than clip
596                 /*if (pos > m_out) {
597                     pos = m_out;
598                     pedit->setPosition(pos);
599                 }*/
600                 EffectsList::setParameter(newparam, "in", QString::number(m_in));
601                 EffectsList::setParameter(newparam, "out", QString::number(m_in + pos));
602                 setValue.clear();
603             } else if (newparam.attribute("id") == "fadeout" || newparam.attribute("id") == "fade_to_black") {
604                 // Make sure duration is not longer than clip
605                 /*if (pos > m_out) {
606                     pos = m_out;
607                     pedit->setPosition(pos);
608                 }*/
609                 EffectsList::setParameter(newparam, "in", QString::number(m_out - pos));
610                 EffectsList::setParameter(newparam, "out", QString::number(m_out));
611                 setValue.clear();
612             }
613         } else if (type == "curve") {
614             KisCurveWidget *curve = ((KisCurveWidget*)m_valueItems.value(paramName));
615             QList<QPointF> points = curve->curve().points();
616             QString number = pa.attributes().namedItem("number").nodeValue();
617             QString inName = pa.attributes().namedItem("inpoints").nodeValue();
618             QString outName = pa.attributes().namedItem("outpoints").nodeValue();
619             int off = pa.attributes().namedItem("min").nodeValue().toInt();
620             int end = pa.attributes().namedItem("max").nodeValue().toInt();
621             EffectsList::setParameter(newparam, number, QString::number(points.count()));
622             for (int j = 0; (j < points.count() && j + off <= end); j++) {
623                 QString in = inName;
624                 in.replace("%i", QString::number(j + off));
625                 QString out = outName;
626                 out.replace("%i", QString::number(j + off));
627                 EffectsList::setParameter(newparam, in, QString::number(points.at(j).x()));
628                 EffectsList::setParameter(newparam, out, QString::number(points.at(j).y()));
629             }
630             QString depends = pa.attributes().namedItem("depends").nodeValue();
631             if (!depends.isEmpty())
632                 meetDependency(paramName, type, EffectsList::parameter(newparam, depends));
633         } else if (type == "corners") {
634             CornersWidget *corners = ((CornersWidget*)m_valueItems.value(paramName));
635             QString xName = pa.attributes().namedItem("xpoints").nodeValue();
636             QString yName = pa.attributes().namedItem("ypoints").nodeValue();
637             QPolygon points = corners->getValue();
638             QPoint p;
639             for (int j = 1; j <= 4; ++j) {
640                 p = points.at(j - 1);
641                 EffectsList::setParameter(newparam, QString(xName).replace("%i", QString::number(j)), QString::number(p.x()));
642                 EffectsList::setParameter(newparam, QString(yName).replace("%i", QString::number(j)), QString::number(p.y()));
643             }
644         } else if (type == "wipe") {
645             Wipeval *wp = (Wipeval*)m_valueItems.value(paramName);
646             wipeInfo info;
647             if (wp->start_left->isChecked())
648                 info.start = LEFT;
649             else if (wp->start_right->isChecked())
650                 info.start = RIGHT;
651             else if (wp->start_up->isChecked())
652                 info.start = UP;
653             else if (wp->start_down->isChecked())
654                 info.start = DOWN;
655             else if (wp->start_center->isChecked())
656                 info.start = CENTER;
657             else
658                 info.start = LEFT;
659             info.startTransparency = wp->start_transp->value();
660
661             if (wp->end_left->isChecked())
662                 info.end = LEFT;
663             else if (wp->end_right->isChecked())
664                 info.end = RIGHT;
665             else if (wp->end_up->isChecked())
666                 info.end = UP;
667             else if (wp->end_down->isChecked())
668                 info.end = DOWN;
669             else if (wp->end_center->isChecked())
670                 info.end = CENTER;
671             else
672                 info.end = RIGHT;
673             info.endTransparency = wp->end_transp->value();
674
675             setValue = getWipeString(info);
676         } else if ((type == "simplekeyframe" || type == "keyframe") && m_keyframeEditor) {
677             QDomElement elem = pa.toElement();
678             QString realName = i18n(na.toElement().text().toUtf8().data());
679             QString val = m_keyframeEditor->getValue(realName);
680             elem.setAttribute("keyframes", val);
681
682             if (m_keyframeEditor->isVisibleParam(realName))
683                 elem.setAttribute("intimeline", "1");
684             else if (elem.hasAttribute("intimeline"))
685                 elem.removeAttribute("intimeline");
686         } else if (type == "url") {
687             KUrlRequester *req = ((Urlval*)m_valueItems.value(paramName))->urlwidget;
688             setValue = req->url().path();
689         }
690
691         if (!setValue.isNull())
692             pa.attributes().namedItem("value").setNodeValue(setValue);
693
694     }
695     emit parameterChanged(oldparam, newparam);
696 }
697
698 void EffectStackEdit::clearAllItems()
699 {
700     blockSignals(true);
701     m_valueItems.clear();
702     m_uiItems.clear();
703     /*while (!m_items.isEmpty()) {
704         QWidget *die = m_items.takeFirst();
705         die->disconnect();
706         delete die;
707     }*/
708     //qDeleteAll(m_uiItems);
709     QLayoutItem *child;
710     while ((child = m_vbox->takeAt(0)) != 0) {
711         QWidget *wid = child->widget();
712         delete child;
713         if (wid) delete wid;
714     }
715     m_keyframeEditor = NULL;
716     blockSignals(false);
717 }
718
719 void EffectStackEdit::slotSyncEffectsPos(int pos)
720 {
721     emit syncEffectsPos(pos);
722 }