1 /***************************************************************************
2 effecstackedit.cpp - description
5 copyright : (C) 2008 by Marco Gittler
6 email : g.marco@freenet.de
7 ***************************************************************************/
9 /***************************************************************************
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. *
16 ***************************************************************************/
18 #include "effectstackedit.h"
19 #include "ui_listval_ui.h"
20 #include "ui_boolval_ui.h"
21 #include "ui_wipeval_ui.h"
22 #include "ui_urlval_ui.h"
23 #include "complexparameter.h"
24 #include "geometryval.h"
25 #include "positionedit.h"
26 #include "projectlist.h"
27 #include "effectslist.h"
28 #include "kdenlivesettings.h"
29 #include "profilesdialog.h"
30 #include "kis_curve_widget.h"
31 #include "kis_cubic_curve.h"
32 #include "choosecolorwidget.h"
33 #include "geometrywidget.h"
34 #include "colortools.h"
35 #include "doubleparameterwidget.h"
36 #include "cornerswidget.h"
37 #include "beziercurve/beziersplinewidget.h"
41 #include <KFileDialog>
43 #include <QVBoxLayout>
45 #include <QPushButton>
47 #include <QScrollArea>
50 class Boolval: public QWidget, public Ui::Boolval_UI
54 class Listval: public QWidget, public Ui::Listval_UI
58 class Wipeval: public QWidget, public Ui::Wipeval_UI
62 class Urlval: public QWidget, public Ui::Urlval_UI
66 QMap<QString, QImage> EffectStackEdit::iconCache;
68 EffectStackEdit::EffectStackEdit(Monitor *monitor, QWidget *parent) :
72 m_frameSize(QPoint()),
73 m_keyframeEditor(NULL),
76 m_baseWidget = new QWidget(this);
77 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
78 setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
79 setFrameStyle(QFrame::NoFrame);
80 setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding));
82 setWidget(m_baseWidget);
83 setWidgetResizable(true);
84 m_vbox = new QVBoxLayout(m_baseWidget);
85 m_vbox->setContentsMargins(0, 0, 0, 0);
86 m_vbox->setSpacing(0);
90 EffectStackEdit::~EffectStackEdit()
96 void EffectStackEdit::setFrameSize(QPoint p)
99 QDomNodeList namenode = m_params.elementsByTagName("parameter");
100 for (int i = 0; i < namenode.count() ; i++) {
101 QDomNode pa = namenode.item(i);
102 QDomNode na = pa.firstChildElement("name");
103 QString type = pa.attributes().namedItem("type").nodeValue();
104 QString paramName = i18n(na.toElement().text().toUtf8().data());
106 if (type == "geometry" && !KdenliveSettings::on_monitor_effects()) {
107 Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
108 geom->setFrameSize(m_frameSize);
114 void EffectStackEdit::updateTimecodeFormat()
116 if (m_keyframeEditor)
117 m_keyframeEditor->updateTimecodeFormat();
119 QDomNodeList namenode = m_params.elementsByTagName("parameter");
120 for (int i = 0; i < namenode.count() ; i++) {
121 QDomNode pa = namenode.item(i);
122 QDomNode na = pa.firstChildElement("name");
123 QString type = pa.attributes().namedItem("type").nodeValue();
124 QString paramName = i18n(na.toElement().text().toUtf8().data());
126 if (type == "geometry") {
127 if (KdenliveSettings::on_monitor_effects()) {
128 GeometryWidget *geom = (GeometryWidget*)m_valueItems[paramName+"geometry"];
129 geom->updateTimecodeFormat();
131 Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
132 geom->updateTimecodeFormat();
136 if (type == "position") {
137 PositionEdit *posi = ((PositionEdit*)m_valueItems[paramName+"position"]);
138 posi->updateTimecodeFormat();
144 void EffectStackEdit::meetDependency(const QString& name, QString type, QString value)
146 if (type == "curve") {
147 KisCurveWidget *curve = (KisCurveWidget*)m_valueItems[name];
149 int color = value.toInt();
150 curve->setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(curve->size(), (ColorTools::ColorsRGB)color, 0.8)));
155 void EffectStackEdit::updateProjectFormat(MltVideoProfile profile, Timecode t)
161 void EffectStackEdit::updateParameter(const QString &name, const QString &value)
163 m_params.setAttribute(name, value);
165 if (name == "disable") {
166 // if effect is disabled, disable parameters widget
167 setEnabled(value.toInt() == 0 || !KdenliveSettings::disable_effect_parameters());
168 if (KdenliveSettings::on_monitor_effects()) {
169 // effect disabled, hide monitor scene if any
170 QDomNodeList namenode = m_params.elementsByTagName("parameter");
171 for (int i = 0; i < namenode.count() ; i++) {
172 QDomNode pa = namenode.item(i);
173 QDomNode na = pa.firstChildElement("name");
174 QString type = pa.attributes().namedItem("type").nodeValue();
175 if (type == "geometry") {
176 QString paramName = i18n(na.toElement().text().toUtf8().data());
177 paramName.append("geometry");
178 GeometryWidget *geometry = ((GeometryWidget*)m_valueItems.value(paramName));
179 geometry->slotShowScene(value.toInt() == 0 || !KdenliveSettings::disable_effect_parameters());
186 void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, int out, bool isEffect)
189 if (m_keyframeEditor) delete m_keyframeEditor;
190 m_keyframeEditor = NULL;
194 if (m_params.isNull()) {
195 kDebug() << "// EMPTY EFFECT STACK";
199 QDomNodeList namenode = m_params.elementsByTagName("parameter");
200 QDomElement e = m_params.toElement();
201 const int minFrame = e.attribute("start").toInt();
202 const int maxFrame = e.attribute("end").toInt();
204 bool disable = d.attribute("disable") == "1" && KdenliveSettings::disable_effect_parameters();
205 setEnabled(!disable);
210 for (int i = 0; i < namenode.count() ; i++) {
211 QDomElement pa = namenode.item(i).toElement();
212 QDomElement na = pa.firstChildElement("name");
213 QDomElement commentElem = pa.firstChildElement("comment");
214 QString type = pa.attribute("type");
215 QString paramName = i18n(na.text().toUtf8().data());
217 if (!commentElem.isNull())
218 comment = i18n(commentElem.text().toUtf8().data());
219 QWidget * toFillin = new QWidget(m_baseWidget);
220 QString value = pa.attribute("value").isNull() ?
221 pa.attribute("default") : pa.attribute("value");
223 /** Currently supported parameter types are:
224 * constant (=double): a slider with an integer value (use the "factor" attribute to divide the value so that you can get a double
225 * list: a combobox containing a list of values to choose
227 * complex: designed for keyframe parameters, but old and not finished, do not use
228 * geometry: a rectangle that can be moved & resized, with possible keyframes, used in composite transition
229 * keyframe: a list widget with a list of entries (position and value)
230 * color: a color chooser button
231 * position: a slider representing the position of a frame in the current clip
232 * curve: a single curve representing multiple points
233 * wipe: a widget designed for the wipe transition, allowing to choose a position (left, right, top,...)
236 if (type == "double" || type == "constant") {
239 if (pa.attribute("min").startsWith('%'))
240 min = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("min"));
242 min = pa.attribute("min").toInt();
243 if (pa.attribute("max").startsWith('%'))
244 max = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("max"));
246 max = pa.attribute("max").toInt();
248 DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, (int)(value.toDouble() + 0.5), min, max,
249 pa.attribute("default").toInt(), comment, pa.attribute("suffix"), this);
250 m_vbox->addWidget(doubleparam);
251 m_valueItems[paramName] = doubleparam;
252 connect(doubleparam, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
253 connect(this, SIGNAL(showComments()), doubleparam, SLOT(slotShowComment()));
254 } else if (type == "list") {
255 Listval *lsval = new Listval;
256 lsval->setupUi(toFillin);
257 QStringList listitems = pa.attribute("paramlist").split(',');
258 QStringList listitemsdisplay = pa.attribute("paramlistdisplay").split(',');
259 if (listitemsdisplay.count() != listitems.count())
260 listitemsdisplay = listitems;
261 lsval->list->setIconSize(QSize(30, 30));
262 for (int i = 0; i < listitems.count(); i++) {
263 lsval->list->addItem(listitemsdisplay.at(i), listitems.at(i));
264 QString entry = listitems.at(i);
265 if (!entry.isEmpty() && (entry.endsWith(".png") || entry.endsWith(".pgm"))) {
266 if (!EffectStackEdit::iconCache.contains(entry)) {
268 EffectStackEdit::iconCache[entry] = pix.scaled(30, 30);
270 lsval->list->setItemIcon(i, QPixmap::fromImage(iconCache[entry]));
273 if (!value.isEmpty()) lsval->list->setCurrentIndex(listitems.indexOf(value));
274 lsval->name->setText(paramName);
275 m_valueItems[paramName] = lsval;
276 connect(lsval->list, SIGNAL(currentIndexChanged(int)) , this, SLOT(collectAllParameters()));
277 m_uiItems.append(lsval);
278 } else if (type == "bool") {
279 Boolval *bval = new Boolval;
280 bval->setupUi(toFillin);
281 bval->checkBox->setCheckState(value == "0" ? Qt::Unchecked : Qt::Checked);
282 bval->name->setText(paramName);
283 m_valueItems[paramName] = bval;
284 connect(bval->checkBox, SIGNAL(stateChanged(int)) , this, SLOT(collectAllParameters()));
285 m_uiItems.append(bval);
286 } else if (type == "complex") {
287 ComplexParameter *pl = new ComplexParameter;
288 pl->setupParam(d, pa.attribute("name"), 0, 100);
289 m_vbox->addWidget(pl);
290 m_valueItems[paramName+"complex"] = pl;
291 connect(pl, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
292 } else if (type == "geometry") {
293 if (KdenliveSettings::on_monitor_effects()) {
294 GeometryWidget *geometry = new GeometryWidget(m_monitor, m_timecode, pos, isEffect, disable, this);
295 // connect this before setupParam to make sure the monitor scene shows up at startup
296 connect(geometry, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
297 connect(geometry, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
298 if (minFrame == maxFrame)
299 geometry->setupParam(pa, m_in, m_out);
301 geometry->setupParam(pa, minFrame, maxFrame);
302 m_vbox->addWidget(geometry);
303 m_valueItems[paramName+"geometry"] = geometry;
304 connect(geometry, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
305 connect(this, SIGNAL(syncEffectsPos(int)), geometry, SLOT(slotSyncPosition(int)));
307 Geometryval *geo = new Geometryval(m_profile, m_timecode, m_frameSize, pos);
308 if (minFrame == maxFrame)
309 geo->setupParam(pa, m_in, m_out);
311 geo->setupParam(pa, minFrame, maxFrame);
312 m_vbox->addWidget(geo);
313 m_valueItems[paramName+"geometry"] = geo;
314 connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
315 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
316 connect(this, SIGNAL(syncEffectsPos(int)), geo, SLOT(slotSyncPosition(int)));
318 } else if (type == "keyframe" || type == "simplekeyframe") {
319 // keyframe editor widget
320 if (m_keyframeEditor == NULL) {
321 KeyframeEdit *geo = new KeyframeEdit(pa, m_in, m_in + m_out, m_timecode, e.attribute("active_keyframe", "-1").toInt());
322 m_vbox->addWidget(geo);
323 m_valueItems[paramName+"keyframe"] = geo;
324 m_keyframeEditor = geo;
325 connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
326 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
327 connect(this, SIGNAL(showComments()), geo, SIGNAL(showComments()));
329 // we already have a keyframe editor, so just add another column for the new param
330 m_keyframeEditor->addParameter(pa);
332 } else if (type == "color") {
333 if (value.startsWith('#'))
334 value = value.replace('#', "0x");
336 ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, QColor(value.toUInt(&ok, 16)), this);
337 m_vbox->addWidget(choosecolor);
338 m_valueItems[paramName] = choosecolor;
339 connect(choosecolor, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int)));
340 connect(choosecolor, SIGNAL(modified()) , this, SLOT(collectAllParameters()));
341 } else if (type == "position") {
342 int pos = value.toInt();
343 if (d.attribute("id") == "fadein" || d.attribute("id") == "fade_from_black") {
345 } else if (d.attribute("id") == "fadeout" || d.attribute("id") == "fade_to_black") {
346 // fadeout position starts from clip end
349 PositionEdit *posedit = new PositionEdit(paramName, pos, 0, m_out - m_in, m_timecode);
350 m_vbox->addWidget(posedit);
351 m_valueItems[paramName+"position"] = posedit;
352 connect(posedit, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
353 } else if (type == "curve") {
354 KisCurveWidget *curve = new KisCurveWidget(this);
355 curve->setMaxPoints(pa.attribute("max").toInt());
356 QList<QPointF> points;
357 int number = EffectsList::parameter(e, pa.attribute("number")).toInt();
358 QString inName = pa.attribute("inpoints");
359 QString outName = pa.attribute("outpoints");
360 int start = pa.attribute("min").toInt();
361 for (int j = start; j <= number; j++) {
363 in.replace("%i", QString::number(j));
364 QString out = outName;
365 out.replace("%i", QString::number(j));
366 points << QPointF(EffectsList::parameter(e, in).toDouble(), EffectsList::parameter(e, out).toDouble());
368 if (!points.isEmpty())
369 curve->setCurve(KisCubicCurve(points));
370 QSpinBox *spinin = new QSpinBox();
371 spinin->setRange(0, 1000);
372 QSpinBox *spinout = new QSpinBox();
373 spinout->setRange(0, 1000);
374 curve->setupInOutControls(spinin, spinout, 0, 1000);
375 m_vbox->addWidget(curve);
376 m_vbox->addWidget(spinin);
377 m_vbox->addWidget(spinout);
379 connect(curve, SIGNAL(modified()), this, SLOT(collectAllParameters()));
380 m_valueItems[paramName] = curve;
382 QString depends = pa.attribute("depends");
383 if (!depends.isEmpty())
384 meetDependency(paramName, type, EffectsList::parameter(e, depends));
385 } else if (type == "bezier_spline") {
386 BezierSplineWidget *widget = new BezierSplineWidget(value, this);
388 m_vbox->addWidget(widget);
389 m_valueItems[paramName] = widget;
390 connect(widget, SIGNAL(modified()), this, SLOT(collectAllParameters()));
391 } else if (type == "corners") {
392 CornersWidget *corners = new CornersWidget(m_monitor, pos, isEffect, pa.attribute("factor").toInt(), this);
393 connect(corners, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
394 if (minFrame == maxFrame)
395 corners->setRange(m_in, m_out);
397 corners->setRange(minFrame, maxFrame);
399 QString xName = pa.attribute("xpoints");
400 QString yName = pa.attribute("ypoints");
403 for (int j = 1; j <= 4; ++j) {
404 x = EffectsList::parameter(e, QString(xName).replace("%i", QString::number(j))).toInt();
405 y = EffectsList::parameter(e, QString(yName).replace("%i", QString::number(j))).toInt();
406 points << QPoint(x, y);
408 corners->setValue(points);
410 m_vbox->addWidget(corners);
411 connect(corners, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
412 m_valueItems[paramName] = corners;
413 } else if (type == "wipe") {
414 Wipeval *wpval = new Wipeval;
415 wpval->setupUi(toFillin);
416 wipeInfo w = getWipeInfo(value);
419 wpval->start_up->setChecked(true);
422 wpval->start_down->setChecked(true);
425 wpval->start_right->setChecked(true);
428 wpval->start_left->setChecked(true);
431 wpval->start_center->setChecked(true);
436 wpval->end_up->setChecked(true);
439 wpval->end_down->setChecked(true);
442 wpval->end_right->setChecked(true);
445 wpval->end_left->setChecked(true);
448 wpval->end_center->setChecked(true);
451 wpval->start_transp->setValue(w.startTransparency);
452 wpval->end_transp->setValue(w.endTransparency);
453 m_valueItems[paramName] = wpval;
454 connect(wpval->end_up, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
455 connect(wpval->end_down, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
456 connect(wpval->end_left, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
457 connect(wpval->end_right, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
458 connect(wpval->end_center, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
459 connect(wpval->start_up, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
460 connect(wpval->start_down, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
461 connect(wpval->start_left, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
462 connect(wpval->start_right, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
463 connect(wpval->start_center, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
464 connect(wpval->start_transp, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
465 connect(wpval->end_transp, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
466 //wpval->title->setTitle(na.toElement().text());
467 m_uiItems.append(wpval);
468 } else if (type == "url") {
469 Urlval *cval = new Urlval;
470 cval->setupUi(toFillin);
471 cval->label->setText(paramName);
472 cval->urlwidget->fileDialog()->setFilter(ProjectList::getExtensions());
473 m_valueItems[paramName] = cval;
474 cval->urlwidget->setUrl(KUrl(value));
475 connect(cval->urlwidget, SIGNAL(returnPressed()) , this, SLOT(collectAllParameters()));
476 connect(cval->urlwidget, SIGNAL(urlSelected(const KUrl&)) , this, SLOT(collectAllParameters()));
477 m_uiItems.append(cval);
484 m_vbox->addWidget(toFillin);
488 m_vbox->addStretch();
490 if (m_keyframeEditor)
491 m_keyframeEditor->checkVisibleParam();
494 wipeInfo EffectStackEdit::getWipeInfo(QString value)
497 QString start = value.section(';', 0, 0);
498 QString end = value.section(';', 1, 1).section('=', 1, 1);
500 if (start.startsWith("-100%,0"))
502 else if (start.startsWith("100%,0"))
504 else if (start.startsWith("0%,100%"))
506 else if (start.startsWith("0%,-100%"))
511 if (start.count(':') == 2)
512 info.startTransparency = start.section(':', -1).toInt();
514 info.startTransparency = 100;
516 if (end.startsWith("-100%,0"))
518 else if (end.startsWith("100%,0"))
520 else if (end.startsWith("0%,100%"))
522 else if (end.startsWith("0%,-100%"))
527 if (end.count(':') == 2)
528 info.endTransparency = end.section(':', -1).toInt();
530 info.endTransparency = 100;
535 QString EffectStackEdit::getWipeString(wipeInfo info)
540 switch (info.start) {
542 start = "-100%,0%:100%x100%";
545 start = "100%,0%:100%x100%";
548 start = "0%,100%:100%x100%";
551 start = "0%,-100%:100%x100%";
554 start = "0%,0%:100%x100%";
557 start.append(':' + QString::number(info.startTransparency));
561 end = "-100%,0%:100%x100%";
564 end = "100%,0%:100%x100%";
567 end = "0%,100%:100%x100%";
570 end = "0%,-100%:100%x100%";
573 end = "0%,0%:100%x100%";
576 end.append(':' + QString::number(info.endTransparency));
577 return QString(start + ";-1=" + end);
580 void EffectStackEdit::collectAllParameters()
582 if (m_valueItems.isEmpty() || m_params.isNull()) return;
583 const QDomElement oldparam = m_params.cloneNode().toElement();
584 QDomElement newparam = oldparam.cloneNode().toElement();
585 QDomNodeList namenode = newparam.elementsByTagName("parameter");
587 for (int i = 0; i < namenode.count() ; i++) {
588 QDomNode pa = namenode.item(i);
589 QDomNode na = pa.firstChildElement("name");
590 QString type = pa.attributes().namedItem("type").nodeValue();
591 QString paramName = i18n(na.toElement().text().toUtf8().data());
592 if (type == "complex")
593 paramName.append("complex");
594 else if (type == "position")
595 paramName.append("position");
596 else if (type == "geometry")
597 paramName.append("geometry");
598 else if (type == "keyframe")
599 paramName.append("keyframe");
600 if (type != "simplekeyframe" && !m_valueItems.contains(paramName)) {
601 kDebug() << "// Param: " << paramName << " NOT FOUND";
606 if (type == "double" || type == "constant") {
607 DoubleParameterWidget *doubleparam = (DoubleParameterWidget*)m_valueItems.value(paramName);
608 setValue = QString::number(doubleparam->getValue());
609 } else if (type == "list") {
610 KComboBox *box = ((Listval*)m_valueItems.value(paramName))->list;
611 setValue = box->itemData(box->currentIndex()).toString();
612 } else if (type == "bool") {
613 QCheckBox *box = ((Boolval*)m_valueItems.value(paramName))->checkBox;
614 setValue = box->checkState() == Qt::Checked ? "1" : "0" ;
615 } else if (type == "color") {
616 ChooseColorWidget *choosecolor = ((ChooseColorWidget*)m_valueItems.value(paramName));
617 setValue = choosecolor->getColor().name();
618 } else if (type == "complex") {
619 ComplexParameter *complex = ((ComplexParameter*)m_valueItems.value(paramName));
620 namenode.item(i) = complex->getParamDesc();
621 } else if (type == "geometry") {
622 if (KdenliveSettings::on_monitor_effects()) {
623 GeometryWidget *geometry = ((GeometryWidget*)m_valueItems.value(paramName));
624 namenode.item(i).toElement().setAttribute("value", geometry->getValue());
626 Geometryval *geom = ((Geometryval*)m_valueItems.value(paramName));
627 namenode.item(i).toElement().setAttribute("value", geom->getValue());
629 } else if (type == "position") {
630 PositionEdit *pedit = ((PositionEdit*)m_valueItems.value(paramName));
631 int pos = pedit->getPosition();
632 setValue = QString::number(pos);
633 if (newparam.attribute("id") == "fadein" || newparam.attribute("id") == "fade_from_black") {
634 // Make sure duration is not longer than clip
637 pedit->setPosition(pos);
639 EffectsList::setParameter(newparam, "in", QString::number(m_in));
640 EffectsList::setParameter(newparam, "out", QString::number(m_in + pos));
642 } else if (newparam.attribute("id") == "fadeout" || newparam.attribute("id") == "fade_to_black") {
643 // Make sure duration is not longer than clip
646 pedit->setPosition(pos);
648 EffectsList::setParameter(newparam, "in", QString::number(m_out - pos));
649 EffectsList::setParameter(newparam, "out", QString::number(m_out));
652 } else if (type == "curve") {
653 KisCurveWidget *curve = ((KisCurveWidget*)m_valueItems.value(paramName));
654 QList<QPointF> points = curve->curve().points();
655 QString number = pa.attributes().namedItem("number").nodeValue();
656 QString inName = pa.attributes().namedItem("inpoints").nodeValue();
657 QString outName = pa.attributes().namedItem("outpoints").nodeValue();
658 int off = pa.attributes().namedItem("min").nodeValue().toInt();
659 int end = pa.attributes().namedItem("max").nodeValue().toInt();
660 EffectsList::setParameter(newparam, number, QString::number(points.count()));
661 for (int j = 0; (j < points.count() && j + off <= end); j++) {
663 in.replace("%i", QString::number(j + off));
664 QString out = outName;
665 out.replace("%i", QString::number(j + off));
666 EffectsList::setParameter(newparam, in, QString::number(points.at(j).x()));
667 EffectsList::setParameter(newparam, out, QString::number(points.at(j).y()));
669 QString depends = pa.attributes().namedItem("depends").nodeValue();
670 if (!depends.isEmpty())
671 meetDependency(paramName, type, EffectsList::parameter(newparam, depends));
672 } else if (type == "bezier_spline") {
673 BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems.value(paramName);
674 setValue = widget->spline();
675 } else if (type == "corners") {
676 CornersWidget *corners = ((CornersWidget*)m_valueItems.value(paramName));
677 QString xName = pa.attributes().namedItem("xpoints").nodeValue();
678 QString yName = pa.attributes().namedItem("ypoints").nodeValue();
679 QPolygon points = corners->getValue();
681 for (int j = 1; j <= 4; ++j) {
682 p = points.at(j - 1);
683 EffectsList::setParameter(newparam, QString(xName).replace("%i", QString::number(j)), QString::number(p.x()));
684 EffectsList::setParameter(newparam, QString(yName).replace("%i", QString::number(j)), QString::number(p.y()));
686 } else if (type == "wipe") {
687 Wipeval *wp = (Wipeval*)m_valueItems.value(paramName);
689 if (wp->start_left->isChecked())
691 else if (wp->start_right->isChecked())
693 else if (wp->start_up->isChecked())
695 else if (wp->start_down->isChecked())
697 else if (wp->start_center->isChecked())
701 info.startTransparency = wp->start_transp->value();
703 if (wp->end_left->isChecked())
705 else if (wp->end_right->isChecked())
707 else if (wp->end_up->isChecked())
709 else if (wp->end_down->isChecked())
711 else if (wp->end_center->isChecked())
715 info.endTransparency = wp->end_transp->value();
717 setValue = getWipeString(info);
718 } else if ((type == "simplekeyframe" || type == "keyframe") && m_keyframeEditor) {
719 QDomElement elem = pa.toElement();
720 QString realName = i18n(na.toElement().text().toUtf8().data());
721 QString val = m_keyframeEditor->getValue(realName);
722 elem.setAttribute("keyframes", val);
724 if (m_keyframeEditor->isVisibleParam(realName))
725 elem.setAttribute("intimeline", "1");
726 else if (elem.hasAttribute("intimeline"))
727 elem.removeAttribute("intimeline");
728 } else if (type == "url") {
729 KUrlRequester *req = ((Urlval*)m_valueItems.value(paramName))->urlwidget;
730 setValue = req->url().path();
733 if (!setValue.isNull())
734 pa.attributes().namedItem("value").setNodeValue(setValue);
737 emit parameterChanged(oldparam, newparam);
740 void EffectStackEdit::clearAllItems()
743 m_valueItems.clear();
745 /*while (!m_items.isEmpty()) {
746 QWidget *die = m_items.takeFirst();
750 //qDeleteAll(m_uiItems);
752 while ((child = m_vbox->takeAt(0)) != 0) {
753 QWidget *wid = child->widget();
757 m_keyframeEditor = NULL;
761 void EffectStackEdit::slotSyncEffectsPos(int pos)
763 emit syncEffectsPos(pos);