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"
40 #include <KFileDialog>
42 #include <QVBoxLayout>
44 #include <QPushButton>
46 #include <QScrollArea>
49 class Boolval: public QWidget, public Ui::Boolval_UI
53 class Listval: public QWidget, public Ui::Listval_UI
57 class Wipeval: public QWidget, public Ui::Wipeval_UI
61 class Urlval: public QWidget, public Ui::Urlval_UI
65 QMap<QString, QImage> EffectStackEdit::iconCache;
67 EffectStackEdit::EffectStackEdit(Monitor *monitor, QWidget *parent) :
71 m_frameSize(QPoint()),
72 m_keyframeEditor(NULL),
75 m_baseWidget = new QWidget(this);
76 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
77 setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
78 setFrameStyle(QFrame::NoFrame);
79 setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding));
81 setWidget(m_baseWidget);
82 setWidgetResizable(true);
83 m_vbox = new QVBoxLayout(m_baseWidget);
84 m_vbox->setContentsMargins(0, 0, 0, 0);
85 m_vbox->setSpacing(0);
89 EffectStackEdit::~EffectStackEdit()
95 void EffectStackEdit::setFrameSize(QPoint p)
98 QDomNodeList namenode = m_params.elementsByTagName("parameter");
99 for (int i = 0; i < namenode.count() ; i++) {
100 QDomNode pa = namenode.item(i);
101 QDomNode na = pa.firstChildElement("name");
102 QString type = pa.attributes().namedItem("type").nodeValue();
103 QString paramName = i18n(na.toElement().text().toUtf8().data());
105 if (type == "geometry" && !KdenliveSettings::on_monitor_effects()) {
106 Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
107 geom->setFrameSize(m_frameSize);
113 void EffectStackEdit::updateTimecodeFormat()
115 if (m_keyframeEditor)
116 m_keyframeEditor->updateTimecodeFormat();
118 QDomNodeList namenode = m_params.elementsByTagName("parameter");
119 for (int i = 0; i < namenode.count() ; i++) {
120 QDomNode pa = namenode.item(i);
121 QDomNode na = pa.firstChildElement("name");
122 QString type = pa.attributes().namedItem("type").nodeValue();
123 QString paramName = i18n(na.toElement().text().toUtf8().data());
125 if (type == "geometry") {
126 if (KdenliveSettings::on_monitor_effects()) {
127 GeometryWidget *geom = (GeometryWidget*)m_valueItems[paramName+"geometry"];
128 geom->updateTimecodeFormat();
130 Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
131 geom->updateTimecodeFormat();
135 if (type == "position") {
136 PositionEdit *posi = ((PositionEdit*)m_valueItems[paramName+"position"]);
137 posi->updateTimecodeFormat();
143 void EffectStackEdit::meetDependency(const QString& name, QString type, QString value)
145 if (type == "curve") {
146 KisCurveWidget *curve = (KisCurveWidget*)m_valueItems[name];
148 int color = value.toInt();
149 curve->setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(curve->size(), (ColorTools::ColorsRGB)color, 0.8)));
154 void EffectStackEdit::updateProjectFormat(MltVideoProfile profile, Timecode t)
160 void EffectStackEdit::updateParameter(const QString &name, const QString &value)
162 m_params.setAttribute(name, value);
164 if (name == "disable") {
165 // if effect is disabled, disable parameters widget
166 setEnabled(value.toInt() == 0 || !KdenliveSettings::disable_effect_parameters());
167 if (KdenliveSettings::on_monitor_effects()) {
168 // effect disabled, hide monitor scene if any
169 QDomNodeList namenode = m_params.elementsByTagName("parameter");
170 for (int i = 0; i < namenode.count() ; i++) {
171 QDomNode pa = namenode.item(i);
172 QDomNode na = pa.firstChildElement("name");
173 QString type = pa.attributes().namedItem("type").nodeValue();
174 if (type == "geometry") {
175 QString paramName = i18n(na.toElement().text().toUtf8().data());
176 paramName.append("geometry");
177 GeometryWidget *geometry = ((GeometryWidget*)m_valueItems.value(paramName));
178 geometry->slotShowScene(value.toInt() == 0 || !KdenliveSettings::disable_effect_parameters());
185 void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, int out, bool isEffect)
188 if (m_keyframeEditor) delete m_keyframeEditor;
189 m_keyframeEditor = NULL;
193 if (m_params.isNull()) {
194 kDebug() << "// EMPTY EFFECT STACK";
198 QDomNodeList namenode = m_params.elementsByTagName("parameter");
199 QDomElement e = m_params.toElement();
200 const int minFrame = e.attribute("start").toInt();
201 const int maxFrame = e.attribute("end").toInt();
203 bool disable = d.attribute("disable") == "1" && KdenliveSettings::disable_effect_parameters();
204 setEnabled(!disable);
207 for (int i = 0; i < namenode.count() ; i++) {
208 QDomElement pa = namenode.item(i).toElement();
209 QDomNode na = pa.firstChildElement("name");
210 QString type = pa.attribute("type");
211 QString paramName = i18n(na.toElement().text().toUtf8().data());
212 QWidget * toFillin = new QWidget(m_baseWidget);
213 QString value = pa.attribute("value").isNull() ?
214 pa.attribute("default") : pa.attribute("value");
216 /** Currently supported parameter types are:
217 * constant (=double): a slider with an integer value (use the "factor" attribute to divide the value so that you can get a double
218 * list: a combobox containing a list of values to choose
220 * complex: designed for keyframe parameters, but old and not finished, do not use
221 * geometry: a rectangle that can be moved & resized, with possible keyframes, used in composite transition
222 * keyframe: a list widget with a list of entries (position and value)
223 * color: a color chooser button
224 * position: a slider representing the position of a frame in the current clip
225 * curve: a single curve representing multiple points
226 * wipe: a widget designed for the wipe transition, allowing to choose a position (left, right, top,...)
229 if (type == "double" || type == "constant") {
232 if (pa.attribute("min").startsWith('%'))
233 min = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("min"));
235 min = pa.attribute("min").toInt();
236 if (pa.attribute("max").startsWith('%'))
237 max = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("max"));
239 max = pa.attribute("max").toInt();
241 DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, (int)(value.toDouble() + 0.5), min, max,
242 pa.attribute("default").toInt(), pa.attribute("suffix"), this);
243 m_vbox->addWidget(doubleparam);
244 m_valueItems[paramName] = doubleparam;
245 connect(doubleparam, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
246 } else if (type == "list") {
247 Listval *lsval = new Listval;
248 lsval->setupUi(toFillin);
249 QStringList listitems = pa.attribute("paramlist").split(',');
250 QStringList listitemsdisplay = pa.attribute("paramlistdisplay").split(',');
251 if (listitemsdisplay.count() != listitems.count())
252 listitemsdisplay = listitems;
253 lsval->list->setIconSize(QSize(30, 30));
254 for (int i = 0; i < listitems.count(); i++) {
255 lsval->list->addItem(listitemsdisplay.at(i), listitems.at(i));
256 QString entry = listitems.at(i);
257 if (!entry.isEmpty() && (entry.endsWith(".png") || entry.endsWith(".pgm"))) {
258 if (!EffectStackEdit::iconCache.contains(entry)) {
260 EffectStackEdit::iconCache[entry] = pix.scaled(30, 30);
262 lsval->list->setItemIcon(i, QPixmap::fromImage(iconCache[entry]));
265 if (!value.isEmpty()) lsval->list->setCurrentIndex(listitems.indexOf(value));
266 lsval->name->setText(paramName);
267 m_valueItems[paramName] = lsval;
268 connect(lsval->list, SIGNAL(currentIndexChanged(int)) , this, SLOT(collectAllParameters()));
269 m_uiItems.append(lsval);
270 } else if (type == "bool") {
271 Boolval *bval = new Boolval;
272 bval->setupUi(toFillin);
273 bval->checkBox->setCheckState(value == "0" ? Qt::Unchecked : Qt::Checked);
274 bval->name->setText(paramName);
275 m_valueItems[paramName] = bval;
276 connect(bval->checkBox, SIGNAL(stateChanged(int)) , this, SLOT(collectAllParameters()));
277 m_uiItems.append(bval);
278 } else if (type == "complex") {
279 ComplexParameter *pl = new ComplexParameter;
280 pl->setupParam(d, pa.attribute("name"), 0, 100);
281 m_vbox->addWidget(pl);
282 m_valueItems[paramName+"complex"] = pl;
283 connect(pl, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
284 } else if (type == "geometry") {
285 if (KdenliveSettings::on_monitor_effects()) {
286 GeometryWidget *geometry = new GeometryWidget(m_monitor, m_timecode, pos, isEffect, disable, this);
287 // connect this before setupParam to make sure the monitor scene shows up at startup
288 connect(geometry, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
289 connect(geometry, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
290 if (minFrame == maxFrame)
291 geometry->setupParam(pa, m_in, m_out);
293 geometry->setupParam(pa, minFrame, maxFrame);
294 m_vbox->addWidget(geometry);
295 m_valueItems[paramName+"geometry"] = geometry;
296 connect(geometry, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
297 connect(this, SIGNAL(syncEffectsPos(int)), geometry, SLOT(slotSyncPosition(int)));
299 Geometryval *geo = new Geometryval(m_profile, m_timecode, m_frameSize, pos);
300 if (minFrame == maxFrame)
301 geo->setupParam(pa, m_in, m_out);
303 geo->setupParam(pa, minFrame, maxFrame);
304 m_vbox->addWidget(geo);
305 m_valueItems[paramName+"geometry"] = geo;
306 connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
307 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
308 connect(this, SIGNAL(syncEffectsPos(int)), geo, SLOT(slotSyncPosition(int)));
310 } else if (type == "keyframe" || type == "simplekeyframe") {
311 // keyframe editor widget
312 kDebug() << "min: " << m_in << ", MAX: " << m_out;
313 if (m_keyframeEditor == NULL) {
314 KeyframeEdit *geo = new KeyframeEdit(pa, m_in, m_in + m_out, m_timecode, e.attribute("active_keyframe", "-1").toInt());
315 m_vbox->addWidget(geo);
316 m_valueItems[paramName+"keyframe"] = geo;
317 m_keyframeEditor = geo;
318 connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
319 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
321 // we already have a keyframe editor, so just add another column for the new param
322 m_keyframeEditor->addParameter(pa);
324 } else if (type == "color") {
325 if (value.startsWith('#'))
326 value = value.replace('#', "0x");
328 ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, QColor(value.toUInt(&ok, 16)), this);
329 m_vbox->addWidget(choosecolor);
330 m_valueItems[paramName] = choosecolor;
331 connect(choosecolor, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int)));
332 connect(choosecolor, SIGNAL(modified()) , this, SLOT(collectAllParameters()));
333 } else if (type == "position") {
334 int pos = value.toInt();
335 if (d.attribute("id") == "fadein" || d.attribute("id") == "fade_from_black") {
337 } else if (d.attribute("id") == "fadeout" || d.attribute("id") == "fade_to_black") {
338 // fadeout position starts from clip end
341 PositionEdit *posedit = new PositionEdit(paramName, pos, 0, m_out - m_in, m_timecode);
342 m_vbox->addWidget(posedit);
343 m_valueItems[paramName+"position"] = posedit;
344 connect(posedit, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
345 } else if (type == "curve") {
346 KisCurveWidget *curve = new KisCurveWidget(this);
347 curve->setMaxPoints(pa.attribute("max").toInt());
348 QList<QPointF> points;
349 int number = EffectsList::parameter(e, pa.attribute("number")).toInt();
350 QString inName = pa.attribute("inpoints");
351 QString outName = pa.attribute("outpoints");
352 int start = pa.attribute("min").toInt();
353 for (int j = start; j <= number; j++) {
355 in.replace("%i", QString::number(j));
356 QString out = outName;
357 out.replace("%i", QString::number(j));
358 points << QPointF(EffectsList::parameter(e, in).toDouble(), EffectsList::parameter(e, out).toDouble());
360 if (!points.isEmpty())
361 curve->setCurve(KisCubicCurve(points));
362 QSpinBox *spinin = new QSpinBox();
363 spinin->setRange(0, 1000);
364 QSpinBox *spinout = new QSpinBox();
365 spinout->setRange(0, 1000);
366 curve->setupInOutControls(spinin, spinout, 0, 1000);
367 m_vbox->addWidget(curve);
368 m_vbox->addWidget(spinin);
369 m_vbox->addWidget(spinout);
371 connect(curve, SIGNAL(modified()), this, SLOT(collectAllParameters()));
372 m_valueItems[paramName] = curve;
374 QString depends = pa.attribute("depends");
375 if (!depends.isEmpty())
376 meetDependency(paramName, type, EffectsList::parameter(e, depends));
377 } else if (type == "corners") {
378 CornersWidget *corners = new CornersWidget(m_monitor, pos, isEffect, pa.attribute("factor").toInt(), this);
379 connect(corners, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
380 if (minFrame == maxFrame)
381 corners->setRange(m_in, m_out);
383 corners->setRange(minFrame, maxFrame);
385 QString xName = pa.attribute("xpoints");
386 QString yName = pa.attribute("ypoints");
389 for (int j = 1; j <= 4; ++j) {
390 x = EffectsList::parameter(e, QString(xName).replace("%i", QString::number(j))).toInt();
391 y = EffectsList::parameter(e, QString(yName).replace("%i", QString::number(j))).toInt();
392 points << QPoint(x, y);
394 corners->setValue(points);
396 m_vbox->addWidget(corners);
397 connect(corners, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
398 m_valueItems[paramName] = corners;
399 } else if (type == "wipe") {
400 Wipeval *wpval = new Wipeval;
401 wpval->setupUi(toFillin);
402 wipeInfo w = getWipeInfo(value);
405 wpval->start_up->setChecked(true);
408 wpval->start_down->setChecked(true);
411 wpval->start_right->setChecked(true);
414 wpval->start_left->setChecked(true);
417 wpval->start_center->setChecked(true);
422 wpval->end_up->setChecked(true);
425 wpval->end_down->setChecked(true);
428 wpval->end_right->setChecked(true);
431 wpval->end_left->setChecked(true);
434 wpval->end_center->setChecked(true);
437 wpval->start_transp->setValue(w.startTransparency);
438 wpval->end_transp->setValue(w.endTransparency);
439 m_valueItems[paramName] = wpval;
440 connect(wpval->end_up, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
441 connect(wpval->end_down, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
442 connect(wpval->end_left, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
443 connect(wpval->end_right, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
444 connect(wpval->end_center, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
445 connect(wpval->start_up, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
446 connect(wpval->start_down, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
447 connect(wpval->start_left, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
448 connect(wpval->start_right, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
449 connect(wpval->start_center, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
450 connect(wpval->start_transp, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
451 connect(wpval->end_transp, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
452 //wpval->title->setTitle(na.toElement().text());
453 m_uiItems.append(wpval);
454 } else if (type == "url") {
455 Urlval *cval = new Urlval;
456 cval->setupUi(toFillin);
457 cval->label->setText(paramName);
458 cval->urlwidget->fileDialog()->setFilter(ProjectList::getExtensions());
459 m_valueItems[paramName] = cval;
460 cval->urlwidget->setUrl(KUrl(value));
461 connect(cval->urlwidget, SIGNAL(returnPressed()) , this, SLOT(collectAllParameters()));
462 connect(cval->urlwidget, SIGNAL(urlSelected(const KUrl&)) , this, SLOT(collectAllParameters()));
463 m_uiItems.append(cval);
470 m_vbox->addWidget(toFillin);
472 m_vbox->addStretch();
474 if (m_keyframeEditor)
475 m_keyframeEditor->checkVisibleParam();
478 wipeInfo EffectStackEdit::getWipeInfo(QString value)
481 QString start = value.section(';', 0, 0);
482 QString end = value.section(';', 1, 1).section('=', 1, 1);
484 if (start.startsWith("-100%,0"))
486 else if (start.startsWith("100%,0"))
488 else if (start.startsWith("0%,100%"))
490 else if (start.startsWith("0%,-100%"))
495 if (start.count(':') == 2)
496 info.startTransparency = start.section(':', -1).toInt();
498 info.startTransparency = 100;
500 if (end.startsWith("-100%,0"))
502 else if (end.startsWith("100%,0"))
504 else if (end.startsWith("0%,100%"))
506 else if (end.startsWith("0%,-100%"))
511 if (end.count(':') == 2)
512 info.endTransparency = end.section(':', -1).toInt();
514 info.endTransparency = 100;
519 QString EffectStackEdit::getWipeString(wipeInfo info)
524 switch (info.start) {
526 start = "-100%,0%:100%x100%";
529 start = "100%,0%:100%x100%";
532 start = "0%,100%:100%x100%";
535 start = "0%,-100%:100%x100%";
538 start = "0%,0%:100%x100%";
541 start.append(':' + QString::number(info.startTransparency));
545 end = "-100%,0%:100%x100%";
548 end = "100%,0%:100%x100%";
551 end = "0%,100%:100%x100%";
554 end = "0%,-100%:100%x100%";
557 end = "0%,0%:100%x100%";
560 end.append(':' + QString::number(info.endTransparency));
561 return QString(start + ";-1=" + end);
564 void EffectStackEdit::collectAllParameters()
566 if (m_valueItems.isEmpty() || m_params.isNull()) return;
567 const QDomElement oldparam = m_params.cloneNode().toElement();
568 QDomElement newparam = oldparam.cloneNode().toElement();
569 QDomNodeList namenode = newparam.elementsByTagName("parameter");
571 for (int i = 0; i < namenode.count() ; i++) {
572 QDomNode pa = namenode.item(i);
573 QDomNode na = pa.firstChildElement("name");
574 QString type = pa.attributes().namedItem("type").nodeValue();
575 QString paramName = i18n(na.toElement().text().toUtf8().data());
576 if (type == "complex")
577 paramName.append("complex");
578 else if (type == "position")
579 paramName.append("position");
580 else if (type == "geometry")
581 paramName.append("geometry");
582 else if (type == "keyframe")
583 paramName.append("keyframe");
584 if (type != "simplekeyframe" && !m_valueItems.contains(paramName)) {
585 kDebug() << "// Param: " << paramName << " NOT FOUND";
590 if (type == "double" || type == "constant") {
591 DoubleParameterWidget *doubleparam = (DoubleParameterWidget*)m_valueItems.value(paramName);
592 setValue = QString::number(doubleparam->getValue());
593 } else if (type == "list") {
594 KComboBox *box = ((Listval*)m_valueItems.value(paramName))->list;
595 setValue = box->itemData(box->currentIndex()).toString();
596 } else if (type == "bool") {
597 QCheckBox *box = ((Boolval*)m_valueItems.value(paramName))->checkBox;
598 setValue = box->checkState() == Qt::Checked ? "1" : "0" ;
599 } else if (type == "color") {
600 ChooseColorWidget *choosecolor = ((ChooseColorWidget*)m_valueItems.value(paramName));
601 setValue = choosecolor->getColor().name();
602 } else if (type == "complex") {
603 ComplexParameter *complex = ((ComplexParameter*)m_valueItems.value(paramName));
604 namenode.item(i) = complex->getParamDesc();
605 } else if (type == "geometry") {
606 if (KdenliveSettings::on_monitor_effects()) {
607 GeometryWidget *geometry = ((GeometryWidget*)m_valueItems.value(paramName));
608 namenode.item(i).toElement().setAttribute("value", geometry->getValue());
610 Geometryval *geom = ((Geometryval*)m_valueItems.value(paramName));
611 namenode.item(i).toElement().setAttribute("value", geom->getValue());
613 } else if (type == "position") {
614 PositionEdit *pedit = ((PositionEdit*)m_valueItems.value(paramName));
615 int pos = pedit->getPosition();
616 setValue = QString::number(pos);
617 if (newparam.attribute("id") == "fadein" || newparam.attribute("id") == "fade_from_black") {
618 // Make sure duration is not longer than clip
621 pedit->setPosition(pos);
623 EffectsList::setParameter(newparam, "in", QString::number(m_in));
624 EffectsList::setParameter(newparam, "out", QString::number(m_in + pos));
626 } else if (newparam.attribute("id") == "fadeout" || newparam.attribute("id") == "fade_to_black") {
627 // Make sure duration is not longer than clip
630 pedit->setPosition(pos);
632 EffectsList::setParameter(newparam, "in", QString::number(m_out - pos));
633 EffectsList::setParameter(newparam, "out", QString::number(m_out));
636 } else if (type == "curve") {
637 KisCurveWidget *curve = ((KisCurveWidget*)m_valueItems.value(paramName));
638 QList<QPointF> points = curve->curve().points();
639 QString number = pa.attributes().namedItem("number").nodeValue();
640 QString inName = pa.attributes().namedItem("inpoints").nodeValue();
641 QString outName = pa.attributes().namedItem("outpoints").nodeValue();
642 int off = pa.attributes().namedItem("min").nodeValue().toInt();
643 int end = pa.attributes().namedItem("max").nodeValue().toInt();
644 EffectsList::setParameter(newparam, number, QString::number(points.count()));
645 for (int j = 0; (j < points.count() && j + off <= end); j++) {
647 in.replace("%i", QString::number(j + off));
648 QString out = outName;
649 out.replace("%i", QString::number(j + off));
650 EffectsList::setParameter(newparam, in, QString::number(points.at(j).x()));
651 EffectsList::setParameter(newparam, out, QString::number(points.at(j).y()));
653 QString depends = pa.attributes().namedItem("depends").nodeValue();
654 if (!depends.isEmpty())
655 meetDependency(paramName, type, EffectsList::parameter(newparam, depends));
656 } else if (type == "corners") {
657 CornersWidget *corners = ((CornersWidget*)m_valueItems.value(paramName));
658 QString xName = pa.attributes().namedItem("xpoints").nodeValue();
659 QString yName = pa.attributes().namedItem("ypoints").nodeValue();
660 QPolygon points = corners->getValue();
662 for (int j = 1; j <= 4; ++j) {
663 p = points.at(j - 1);
664 EffectsList::setParameter(newparam, QString(xName).replace("%i", QString::number(j)), QString::number(p.x()));
665 EffectsList::setParameter(newparam, QString(yName).replace("%i", QString::number(j)), QString::number(p.y()));
667 } else if (type == "wipe") {
668 Wipeval *wp = (Wipeval*)m_valueItems.value(paramName);
670 if (wp->start_left->isChecked())
672 else if (wp->start_right->isChecked())
674 else if (wp->start_up->isChecked())
676 else if (wp->start_down->isChecked())
678 else if (wp->start_center->isChecked())
682 info.startTransparency = wp->start_transp->value();
684 if (wp->end_left->isChecked())
686 else if (wp->end_right->isChecked())
688 else if (wp->end_up->isChecked())
690 else if (wp->end_down->isChecked())
692 else if (wp->end_center->isChecked())
696 info.endTransparency = wp->end_transp->value();
698 setValue = getWipeString(info);
699 } else if ((type == "simplekeyframe" || type == "keyframe") && m_keyframeEditor) {
700 QDomElement elem = pa.toElement();
701 QString realName = i18n(na.toElement().text().toUtf8().data());
702 QString val = m_keyframeEditor->getValue(realName);
703 elem.setAttribute("keyframes", val);
705 if (m_keyframeEditor->isVisibleParam(realName))
706 elem.setAttribute("intimeline", "1");
707 else if (elem.hasAttribute("intimeline"))
708 elem.removeAttribute("intimeline");
709 } else if (type == "url") {
710 KUrlRequester *req = ((Urlval*)m_valueItems.value(paramName))->urlwidget;
711 setValue = req->url().path();
714 if (!setValue.isNull())
715 pa.attributes().namedItem("value").setNodeValue(setValue);
718 emit parameterChanged(oldparam, newparam);
721 void EffectStackEdit::clearAllItems()
724 m_valueItems.clear();
726 /*while (!m_items.isEmpty()) {
727 QWidget *die = m_items.takeFirst();
731 //qDeleteAll(m_uiItems);
733 while ((child = m_vbox->takeAt(0)) != 0) {
734 QWidget *wid = child->widget();
738 m_keyframeEditor = NULL;
742 void EffectStackEdit::slotSyncEffectsPos(int pos)
744 emit syncEffectsPos(pos);