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