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