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