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