1 /***************************************************************************
2 * Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include "collapsibleeffect.h"
23 #include "ui_listval_ui.h"
24 #include "ui_boolval_ui.h"
25 #include "ui_wipeval_ui.h"
26 #include "ui_urlval_ui.h"
27 #include "ui_keywordval_ui.h"
28 #include "ui_fontval_ui.h"
29 #include "complexparameter.h"
30 #include "geometryval.h"
31 #include "positionedit.h"
32 #include "projectlist.h"
33 #include "effectslist.h"
34 #include "kdenlivesettings.h"
35 #include "profilesdialog.h"
36 #include "kis_curve_widget.h"
37 #include "kis_cubic_curve.h"
38 #include "choosecolorwidget.h"
39 #include "geometrywidget.h"
40 #include "colortools.h"
41 #include "doubleparameterwidget.h"
42 #include "cornerswidget.h"
43 #include "dragvalue.h"
44 #include "beziercurve/beziersplinewidget.h"
46 #include "rotoscoping/rotowidget.h"
49 #include <QInputDialog>
52 #include <QVBoxLayout>
55 #include <KGlobalSettings>
57 #include <KMessageBox>
58 #include <KStandardDirs>
59 #include <KFileDialog>
60 #include <KUrlRequester>
61 #include <KColorScheme>
62 #include <KColorUtils>
63 #include <KApplication>
65 class Boolval: public QWidget, public Ui::Boolval_UI
69 class Listval: public QWidget, public Ui::Listval_UI
73 class Wipeval: public QWidget, public Ui::Wipeval_UI
77 class Urlval: public QWidget, public Ui::Urlval_UI
81 class Keywordval: public QWidget, public Ui::Keywordval_UI
85 class Fontval: public QWidget, public Ui::Fontval_UI
89 QMap<QString, QImage> CollapsibleEffect::iconCache;
91 void clearLayout(QLayout *layout)
94 while((item = layout->takeAt(0))) {
96 clearLayout(item->layout());
97 delete item->layout();
100 delete item->widget();
106 MySpinBox::MySpinBox(QWidget * parent):
109 setFocusPolicy(Qt::StrongFocus);
112 void MySpinBox::focusInEvent(QFocusEvent *e)
114 setFocusPolicy(Qt::WheelFocus);
118 void MySpinBox::focusOutEvent(QFocusEvent *e)
120 setFocusPolicy(Qt::StrongFocus);
125 CollapsibleEffect::CollapsibleEffect(QDomElement effect, QDomElement original_effect, ItemInfo info, EffectMetaInfo *metaInfo, bool lastEffect, QWidget * parent) :
126 AbstractCollapsibleWidget(parent),
129 m_original_effect(original_effect),
130 m_lastEffect(lastEffect),
131 m_regionEffect(false)
134 if (m_effect.attribute("tag") == "region") {
135 m_regionEffect = true;
136 decoframe->setObjectName("decoframegroup");
138 filterWheelEvent = true;
139 m_info.fromString(effect.attribute("kdenlive_info"));
140 setFont(KGlobalSettings::smallestReadableFont());
141 buttonUp->setIcon(KIcon("kdenlive-up"));
142 buttonUp->setToolTip(i18n("Move effect up"));
144 buttonDown->setIcon(KIcon("kdenlive-down"));
145 buttonDown->setToolTip(i18n("Move effect down"));
147 buttonDel->setIcon(KIcon("kdenlive-deleffect"));
148 buttonDel->setToolTip(i18n("Delete effect"));
149 if (effectIndex() == 1) buttonUp->setVisible(false);
150 if (m_lastEffect) buttonDown->setVisible(false);
151 //buttonUp->setVisible(false);
152 //buttonDown->setVisible(false);
154 /*buttonReset->setIcon(KIcon("view-refresh"));
155 buttonReset->setToolTip(i18n("Reset effect"));*/
156 //checkAll->setToolTip(i18n("Enable/Disable all effects"));
157 //buttonShowComments->setIcon(KIcon("help-about"));
158 //buttonShowComments->setToolTip(i18n("Show additional information for the parameters"));
160 if (m_regionEffect) m_menu->addAction(KIcon("document-new"), i18n("Change Region"), this, SLOT(slotResetEffect()));
161 m_menu->addAction(KIcon("view-refresh"), i18n("Reset Effect"), this, SLOT(slotResetEffect()));
162 m_menu->addAction(KIcon("document-save"), i18n("Save Effect"), this, SLOT(slotSaveEffect()));
164 QDomElement namenode = m_effect.firstChildElement("name");
165 if (namenode.isNull()) return;
166 QString effectname = i18n(namenode.text().toUtf8().data());
167 if (m_regionEffect) effectname.append(":" + KUrl(EffectsList::parameter(m_effect, "resource")).fileName());
168 title->setText(effectname);
170 * Do not show icon, makes too much visual noise
171 QString type = m_effect.attribute("type", QString());
173 if (type == "audio") icon = KIcon("kdenlive-show-audio");
174 else if (m_effect.attribute("tag") == "region") icon = KIcon("kdenlive-mask-effect");
175 else if (type == "custom") icon = KIcon("kdenlive-custom-effect");
176 else icon = KIcon("kdenlive-show-video");
177 effecticon->setPixmap(icon.pixmap(16,16));*/
179 if (!m_regionEffect) {
180 m_menu->addAction(KIcon("folder-new"), i18n("Create Group"), this, SLOT(slotCreateGroup()));
181 m_menu->addAction(KIcon("folder-new"), i18n("Create Region"), this, SLOT(slotCreateRegion()));
183 setupWidget(info, metaInfo);
184 setAcceptDrops(true);
185 menuButton->setIcon(KIcon("kdenlive-menu"));
186 menuButton->setMenu(m_menu);
188 if (m_effect.attribute("disable") == "1") {
189 title->setEnabled(false);
190 enabledButton->setChecked(true);
191 enabledButton->setIcon(KIcon("novisible"));
194 enabledButton->setChecked(false);
195 enabledButton->setIcon(KIcon("visible"));
198 connect(collapseButton, SIGNAL(clicked()), this, SLOT(slotSwitch()));
199 connect(enabledButton, SIGNAL(toggled(bool)), this, SLOT(slotEnable(bool)));
200 connect(buttonUp, SIGNAL(clicked()), this, SLOT(slotEffectUp()));
201 connect(buttonDown, SIGNAL(clicked()), this, SLOT(slotEffectDown()));
202 connect(buttonDel, SIGNAL(clicked()), this, SLOT(slotDeleteEffect()));
204 Q_FOREACH( QSpinBox * sp, findChildren<QSpinBox*>() ) {
205 sp->installEventFilter( this );
206 sp->setFocusPolicy( Qt::StrongFocus );
208 Q_FOREACH( KComboBox * cb, findChildren<KComboBox*>() ) {
209 cb->installEventFilter( this );
210 cb->setFocusPolicy( Qt::StrongFocus );
212 Q_FOREACH( QProgressBar * cb, findChildren<QProgressBar*>() ) {
213 cb->installEventFilter( this );
214 cb->setFocusPolicy( Qt::StrongFocus );
218 CollapsibleEffect::~CollapsibleEffect()
220 if (m_paramWidget) delete m_paramWidget;
225 const QString CollapsibleEffect::getStyleSheet()
227 KColorScheme scheme(QApplication::palette().currentColorGroup(), KColorScheme::View, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
228 QColor selected_bg = scheme.decoration(KColorScheme::FocusColor).color();
229 QColor hgh = KColorUtils::mix(QApplication::palette().window().color(), selected_bg, 0.2);
230 QColor hover_bg = scheme.decoration(KColorScheme::HoverColor).color();
231 QColor light_bg = scheme.shade(KColorScheme::LightShade);
232 QColor alt_bg = scheme.background(KColorScheme::NormalBackground).color();
236 // group editable labels
237 stylesheet.append(QString("MyEditableLabel { background-color: transparent;color: palette(bright-text);} "));
240 stylesheet.append(QString("QFrame#decoframe {border-top-left-radius:5px;border-top-right-radius:5px;border-bottom:2px solid palette(mid);border-top:1px solid palette(light);} QFrame#decoframe[active=\"true\"] {background: %1;}").arg(hgh.name()));
242 // effect in group background
243 stylesheet.append(QString("QFrame#decoframesub {border-top:1px solid palette(light);} QFrame#decoframesub[active=\"true\"] {background: %1;}").arg(hgh.name()));
246 stylesheet.append(QString("QFrame#decoframegroup {border-top-left-radius:5px;border-top-right-radius:5px;border:2px solid palette(dark);margin:0px;margin-top:2px;} "));
249 stylesheet.append(QString("QFrame#frame {margin-bottom:2px;border-top-left-radius:5px;border-top-right-radius:5px;} QFrame#frame[target=\"true\"] {background: palette(highlight);}"));
251 // group effect title bar
252 stylesheet.append(QString("QFrame#framegroup {border-top-left-radius:2px;border-top-right-radius:2px;background: palette(dark);} QFrame#framegroup[target=\"true\"] {background: palette(highlight);} "));
254 // draggable effect bar content
255 stylesheet.append(QString("QProgressBar::chunk:horizontal {background: palette(button);border-top-left-radius: 4px;border-bottom-left-radius: 4px;} QProgressBar::chunk:horizontal#dragOnly {background: %1;border-top-left-radius: 4px;border-bottom-left-radius: 4px;} QProgressBar::chunk:horizontal:hover {background: %2;}").arg(alt_bg.name()).arg(selected_bg.name()));
257 // draggable effect bar
258 stylesheet.append(QString("QProgressBar:horizontal {border: 1px solid palette(dark);border-top-left-radius: 4px;border-bottom-left-radius: 4px;border-right:0px;background:%3;padding: 0px;text-align:left center} QProgressBar:horizontal:disabled {border: 1px solid palette(button)} QProgressBar:horizontal#dragOnly {background: %3} QProgressBar:horizontal[inTimeline=\"true\"] { border: 1px solid %1;border-right: 0px;background: %2;padding: 0px;text-align:left center } QProgressBar::chunk:horizontal[inTimeline=\"true\"] {background: %1;}").arg(hover_bg.name()).arg(light_bg.name()).arg(alt_bg.name()));
260 // spin box for draggable widget
261 stylesheet.append(QString("QAbstractSpinBox#dragBox {border: 1px solid palette(dark);border-top-right-radius: 4px;border-bottom-right-radius: 4px;padding-right:0px;} QAbstractSpinBox::down-button#dragBox {width:0px;padding:0px;} QAbstractSpinBox:disabled#dragBox {border: 1px solid palette(button);} QAbstractSpinBox::up-button#dragBox {width:0px;padding:0px;} QAbstractSpinBox[inTimeline=\"true\"]#dragBox { border: 1px solid %1;} QAbstractSpinBox:hover#dragBox {border: 1px solid %2;} ").arg(hover_bg.name()).arg(selected_bg.name()));
266 void CollapsibleEffect::slotCreateGroup()
268 emit createGroup(effectIndex());
271 void CollapsibleEffect::slotCreateRegion()
273 QString allExtensions = ProjectList::getExtensions();
274 const QString dialogFilter = allExtensions + ' ' + QLatin1Char('|') + i18n("All Supported Files") + "\n* " + QLatin1Char('|') + i18n("All Files");
275 KFileDialog *d = new KFileDialog(KUrl("kfiledialog:///clipfolder"), dialogFilter, kapp->activeWindow());
276 d->setOperationMode(KFileDialog::Opening);
277 d->setMode(KFile::File);
278 if (d->exec() == QDialog::Accepted) {
279 KUrl url = d->selectedUrl();
280 if (!url.isEmpty()) emit createRegion(effectIndex(), url);
285 void CollapsibleEffect::slotUnGroup()
290 bool CollapsibleEffect::eventFilter( QObject * o, QEvent * e )
292 if (e->type() == QEvent::Enter) {
293 frame->setProperty("mouseover", true);
294 frame->setStyleSheet(frame->styleSheet());
295 return QWidget::eventFilter(o, e);
297 if (e->type() == QEvent::Wheel) {
298 QWheelEvent *we = static_cast<QWheelEvent *>(e);
299 if (!filterWheelEvent || we->modifiers() != Qt::NoModifier) {
303 if (qobject_cast<QAbstractSpinBox*>(o)) {
304 if(qobject_cast<QAbstractSpinBox*>(o)->focusPolicy() == Qt::WheelFocus)
315 if (qobject_cast<KComboBox*>(o)) {
316 if(qobject_cast<KComboBox*>(o)->focusPolicy() == Qt::WheelFocus)
327 if (qobject_cast<QProgressBar*>(o)) {
328 if(qobject_cast<QProgressBar*>(o)->focusPolicy() == Qt::WheelFocus)
340 return QWidget::eventFilter(o, e);
343 QDomElement CollapsibleEffect::effect() const
348 bool CollapsibleEffect::isActive() const
350 return decoframe->property("active").toBool();
353 void CollapsibleEffect::setActive(bool activate)
355 decoframe->setProperty("active", activate);
356 decoframe->setStyleSheet(decoframe->styleSheet());
359 void CollapsibleEffect::mouseDoubleClickEvent ( QMouseEvent * event )
361 if (frame->underMouse() && collapseButton->isEnabled()) {
365 else event->ignore();
368 void CollapsibleEffect::mouseReleaseEvent( QMouseEvent *event )
370 if (!decoframe->property("active").toBool()) emit activateEffect(effectIndex());
371 QWidget::mouseReleaseEvent(event);
374 void CollapsibleEffect::slotEnable(bool disable, bool updateMainStatus)
376 title->setEnabled(!disable);
377 enabledButton->blockSignals(true);
378 enabledButton->setChecked(disable);
379 enabledButton->blockSignals(false);
380 enabledButton->setIcon(disable ? KIcon("novisible") : KIcon("visible"));
381 m_effect.setAttribute("disable", disable ? 1 : 0);
382 if (!disable || KdenliveSettings::disable_effect_parameters()) {
383 widgetFrame->setEnabled(!disable);
385 emit effectStateChanged(disable, effectIndex(), updateMainStatus);
388 void CollapsibleEffect::slotDeleteEffect()
390 emit deleteEffect(m_effect);
393 void CollapsibleEffect::slotEffectUp()
395 emit changeEffectPosition(effectIndex(), true);
398 void CollapsibleEffect::slotEffectDown()
400 emit changeEffectPosition(effectIndex(), false);
403 void CollapsibleEffect::slotSaveEffect()
405 QString name = QInputDialog::getText(this, i18n("Save Effect"), i18n("Name for saved effect: "));
406 if (name.isEmpty()) return;
407 QString path = KStandardDirs::locateLocal("appdata", "effects/", true);
408 path = path + name + ".xml";
409 if (QFile::exists(path)) if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", path)) == KMessageBox::No) return;
412 QDomElement effect = m_effect.cloneNode().toElement();
413 doc.appendChild(doc.importNode(effect, true));
414 effect = doc.firstChild().toElement();
415 effect.removeAttribute("kdenlive_ix");
416 effect.setAttribute("id", name);
417 effect.setAttribute("type", "custom");
418 QDomElement effectname = effect.firstChildElement("name");
419 effect.removeChild(effectname);
420 effectname = doc.createElement("name");
421 QDomText nametext = doc.createTextNode(name);
422 effectname.appendChild(nametext);
423 effect.insertBefore(effectname, QDomNode());
424 QDomElement effectprops = effect.firstChildElement("properties");
425 effectprops.setAttribute("id", name);
426 effectprops.setAttribute("type", "custom");
429 if (file.open(QFile::WriteOnly | QFile::Truncate)) {
430 QTextStream out(&file);
431 out << doc.toString();
434 emit reloadEffects();
437 void CollapsibleEffect::slotResetEffect()
439 emit resetEffect(effectIndex());
442 void CollapsibleEffect::slotSwitch()
444 bool enable = !widgetFrame->isVisible();
448 void CollapsibleEffect::slotShow(bool show)
450 widgetFrame->setVisible(show);
452 collapseButton->setArrowType(Qt::DownArrow);
453 m_info.isCollapsed = false;
456 collapseButton->setArrowType(Qt::RightArrow);
457 m_info.isCollapsed = true;
459 updateCollapsedState();
462 void CollapsibleEffect::groupStateChanged(bool collapsed)
464 m_info.groupIsCollapsed = collapsed;
465 updateCollapsedState();
468 void CollapsibleEffect::updateCollapsedState()
470 QString info = m_info.toString();
471 if (info != m_effect.attribute("kdenlive_info")) {
472 m_effect.setAttribute("kdenlive_info", info);
473 emit parameterChanged(m_original_effect, m_effect, effectIndex());
477 void CollapsibleEffect::setGroupIndex(int ix)
479 m_info.groupIndex = ix;
480 m_effect.setAttribute("kdenlive_info", m_info.toString());
483 void CollapsibleEffect::setGroupName(const QString &groupName)
485 m_info.groupName = groupName;
486 m_effect.setAttribute("kdenlive_info", m_info.toString());
489 QString CollapsibleEffect::infoString() const
491 return m_info.toString();
494 void CollapsibleEffect::removeFromGroup()
496 m_info.groupIndex = -1;
497 m_info.groupName.clear();
498 m_effect.setAttribute("kdenlive_info", m_info.toString());
499 emit parameterChanged(m_original_effect, m_effect, effectIndex());
502 int CollapsibleEffect::groupIndex() const
504 return m_info.groupIndex;
507 int CollapsibleEffect::effectIndex() const
509 if (m_effect.isNull()) return -1;
510 return m_effect.attribute("kdenlive_ix").toInt();
513 void CollapsibleEffect::updateWidget(ItemInfo info, QDomElement effect, EffectMetaInfo *metaInfo)
517 delete m_paramWidget;
518 m_paramWidget = NULL;
521 setupWidget(info, metaInfo);
524 void CollapsibleEffect::setupWidget(ItemInfo info, EffectMetaInfo *metaInfo)
526 if (m_effect.isNull()) {
527 // kDebug() << "// EMPTY EFFECT STACK";
531 if (m_effect.attribute("tag") == "region") {
532 m_regionEffect = true;
533 QVBoxLayout *vbox = new QVBoxLayout(widgetFrame);
534 vbox->setContentsMargins(0, 0, 0, 0);
536 QDomNodeList effects = m_effect.elementsByTagName("effect");
537 QDomNodeList origin_effects = m_original_effect.elementsByTagName("effect");
538 QWidget *container = new QWidget(widgetFrame);
539 vbox->addWidget(container);
540 // m_paramWidget = new ParameterContainer(m_effect.toElement(), info, metaInfo, container);
541 for (int i = 0; i < effects.count(); i++) {
542 CollapsibleEffect *coll = new CollapsibleEffect(effects.at(i).toElement(), origin_effects.at(i).toElement(), info, metaInfo, container);
543 m_subParamWidgets.append(coll);
544 connect(coll, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int)), this , SLOT(slotUpdateRegionEffectParams(const QDomElement, const QDomElement, int)));
545 //container = new QWidget(widgetFrame);
546 vbox->addWidget(coll);
547 //p = new ParameterContainer(effects.at(i).toElement(), info, isEffect, container);
552 m_paramWidget = new ParameterContainer(m_effect, info, metaInfo, widgetFrame);
553 if (m_effect.firstChildElement("parameter").isNull()) {
554 // Effect has no parameter, don't allow expand
555 collapseButton->setEnabled(false);
556 collapseButton->setVisible(false);
557 widgetFrame->setVisible(false);
560 if (collapseButton->isEnabled() && m_info.isCollapsed) {
561 widgetFrame->setVisible(false);
562 collapseButton->setArrowType(Qt::RightArrow);
565 connect (m_paramWidget, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int)), this, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int)));
567 connect(m_paramWidget, SIGNAL(startFilterJob(QString,QString,QString,QString,QString,QString)), this, SIGNAL(startFilterJob(QString,QString,QString,QString,QString,QString)));
569 connect (this, SIGNAL(syncEffectsPos(int)), m_paramWidget, SIGNAL(syncEffectsPos(int)));
570 connect (this, SIGNAL(effectStateChanged(bool)), m_paramWidget, SIGNAL(effectStateChanged(bool)));
571 connect (m_paramWidget, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
572 connect (m_paramWidget, SIGNAL(seekTimeline(int)), this, SIGNAL(seekTimeline(int)));
577 bool CollapsibleEffect::isGroup() const
582 void CollapsibleEffect::updateTimecodeFormat()
584 m_paramWidget->updateTimecodeFormat();
585 if (!m_subParamWidgets.isEmpty()) {
587 for (int i = 0; i < m_subParamWidgets.count(); i++)
588 m_subParamWidgets.at(i)->updateTimecodeFormat();
592 void CollapsibleEffect::slotUpdateRegionEffectParams(const QDomElement /*old*/, const QDomElement /*e*/, int /*ix*/)
594 kDebug()<<"// EMIT CHANGE SUBEFFECT.....:";
595 emit parameterChanged(m_original_effect, m_effect, effectIndex());
598 void CollapsibleEffect::slotSyncEffectsPos(int pos)
600 emit syncEffectsPos(pos);
603 void CollapsibleEffect::dragEnterEvent(QDragEnterEvent *event)
605 if (event->mimeData()->hasFormat("kdenlive/effectslist")) {
606 frame->setProperty("target", true);
607 frame->setStyleSheet(frame->styleSheet());
608 event->acceptProposedAction();
612 void CollapsibleEffect::dragLeaveEvent(QDragLeaveEvent */*event*/)
614 frame->setProperty("target", false);
615 frame->setStyleSheet(frame->styleSheet());
618 void CollapsibleEffect::dropEvent(QDropEvent *event)
620 frame->setProperty("target", false);
621 frame->setStyleSheet(frame->styleSheet());
622 const QString effects = QString::fromUtf8(event->mimeData()->data("kdenlive/effectslist"));
623 //event->acceptProposedAction();
625 doc.setContent(effects, true);
626 QDomElement e = doc.documentElement();
627 int ix = e.attribute("kdenlive_ix").toInt();
628 int currentEffectIx = effectIndex();
629 if (ix == currentEffectIx) {
630 // effect dropped on itself, reject
634 if (ix == 0 || e.tagName() == "effectgroup") {
635 if (e.tagName() == "effectgroup") {
637 QDomNodeList subeffects = e.elementsByTagName("effect");
638 if (subeffects.isEmpty()) {
643 info.fromString(subeffects.at(0).toElement().attribute("kdenlive_info"));
644 event->setDropAction(Qt::MoveAction);
646 if (info.groupIndex >= 0) {
648 QList <int> effectsIds;
649 // Collect moved effects ids
650 for (int i = 0; i < subeffects.count(); i++) {
651 QDomElement effect = subeffects.at(i).toElement();
652 effectsIds << effect.attribute("kdenlive_ix").toInt();
654 emit moveEffect(effectsIds, currentEffectIx, info.groupIndex, info.groupName);
657 // group effect dropped from effect list
658 if (m_info.groupIndex > -1) {
659 // TODO: Should we merge groups??
666 // effect dropped from effects list, add it
667 e.setAttribute("kdenlive_ix", ix);
668 if (m_info.groupIndex > -1) {
669 // Dropped on a group
670 e.setAttribute("kdenlive_info", m_info.toString());
672 event->setDropAction(Qt::CopyAction);
677 emit moveEffect(QList <int> () <<ix, currentEffectIx, m_info.groupIndex, m_info.groupName);
678 event->setDropAction(Qt::MoveAction);
682 ParameterContainer::ParameterContainer(QDomElement effect, ItemInfo info, EffectMetaInfo *metaInfo, QWidget * parent) :
683 m_keyframeEditor(NULL),
684 m_geometryWidget(NULL),
685 m_metaInfo(metaInfo),
688 m_in = info.cropStart.frames(KdenliveSettings::project_fps());
689 m_out = (info.cropStart + info.cropDuration).frames(KdenliveSettings::project_fps()) - 1;
691 QDomNodeList namenode = effect.childNodes(); //elementsByTagName("parameter");
693 QDomElement e = effect.toElement();
694 int minFrame = e.attribute("start").toInt();
695 int maxFrame = e.attribute("end").toInt();
696 // In transitions, maxFrame is in fact one frame after the end of transition
697 if (maxFrame > 0) maxFrame --;
699 bool disable = effect.attribute("disable") == "1" && KdenliveSettings::disable_effect_parameters();
700 parent->setEnabled(!disable);
703 m_vbox = new QVBoxLayout(parent);
704 m_vbox->setContentsMargins(4, 0, 4, 0);
705 m_vbox->setSpacing(2);
707 for (int i = 0; i < namenode.count() ; i++) {
708 QDomElement pa = namenode.item(i).toElement();
709 if (pa.tagName() != "parameter") continue;
710 QDomElement na = pa.firstChildElement("name");
711 QDomElement commentElem = pa.firstChildElement("comment");
712 QString type = pa.attribute("type");
713 QString paramName = na.isNull() ? pa.attribute("name") : i18n(na.text().toUtf8().data());
715 if (!commentElem.isNull())
716 comment = i18n(commentElem.text().toUtf8().data());
717 QWidget * toFillin = new QWidget(parent);
718 QString value = pa.attribute("value").isNull() ?
719 pa.attribute("default") : pa.attribute("value");
722 /** See effects/README for info on the different types */
724 if (type == "double" || type == "constant") {
727 if (pa.attribute("min").contains('%'))
728 min = ProfilesDialog::getStringEval(m_metaInfo->profile, pa.attribute("min"), m_metaInfo->frameSize);
730 min = pa.attribute("min").toDouble();
731 if (pa.attribute("max").contains('%'))
732 max = ProfilesDialog::getStringEval(m_metaInfo->profile, pa.attribute("max"), m_metaInfo->frameSize);
734 max = pa.attribute("max").toDouble();
736 DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, value.toDouble(), min, max,
737 pa.attribute("default").toDouble(), comment, -1, pa.attribute("suffix"), pa.attribute("decimals").toInt(), parent);
738 doubleparam->setFocusPolicy(Qt::StrongFocus);
739 m_vbox->addWidget(doubleparam);
740 m_valueItems[paramName] = doubleparam;
741 connect(doubleparam, SIGNAL(valueChanged(double)), this, SLOT(slotCollectAllParameters()));
742 connect(this, SIGNAL(showComments(bool)), doubleparam, SLOT(slotShowComment(bool)));
743 } else if (type == "list") {
744 Listval *lsval = new Listval;
745 lsval->setupUi(toFillin);
746 lsval->list->setFocusPolicy(Qt::StrongFocus);
747 QStringList listitems = pa.attribute("paramlist").split(';');
748 if (listitems.count() == 1) {
749 // probably custom effect created before change to ';' as separator
750 listitems = pa.attribute("paramlist").split(",");
752 QDomElement list = pa.firstChildElement("paramlistdisplay");
753 QStringList listitemsdisplay;
754 if (!list.isNull()) {
755 listitemsdisplay = i18n(list.text().toUtf8().data()).split(',');
757 listitemsdisplay = i18n(pa.attribute("paramlistdisplay").toUtf8().data()).split(',');
759 if (listitemsdisplay.count() != listitems.count())
760 listitemsdisplay = listitems;
761 lsval->list->setIconSize(QSize(30, 30));
762 for (int i = 0; i < listitems.count(); i++) {
763 lsval->list->addItem(listitemsdisplay.at(i), listitems.at(i));
764 QString entry = listitems.at(i);
765 if (!entry.isEmpty() && (entry.endsWith(".png") || entry.endsWith(".pgm"))) {
766 if (!CollapsibleEffect::iconCache.contains(entry)) {
768 CollapsibleEffect::iconCache[entry] = pix.scaled(30, 30);
770 lsval->list->setItemIcon(i, QPixmap::fromImage(CollapsibleEffect::iconCache[entry]));
773 if (!value.isEmpty()) lsval->list->setCurrentIndex(listitems.indexOf(value));
774 lsval->name->setText(paramName);
775 lsval->labelComment->setText(comment);
776 lsval->widgetComment->setHidden(true);
777 m_valueItems[paramName] = lsval;
778 connect(lsval->list, SIGNAL(currentIndexChanged(int)) , this, SLOT(slotCollectAllParameters()));
779 if (!comment.isEmpty())
780 connect(this, SIGNAL(showComments(bool)), lsval->widgetComment, SLOT(setVisible(bool)));
781 m_uiItems.append(lsval);
782 } else if (type == "bool") {
783 Boolval *bval = new Boolval;
784 bval->setupUi(toFillin);
785 bval->checkBox->setCheckState(value == "0" ? Qt::Unchecked : Qt::Checked);
786 bval->name->setText(paramName);
787 bval->labelComment->setText(comment);
788 bval->widgetComment->setHidden(true);
789 m_valueItems[paramName] = bval;
790 connect(bval->checkBox, SIGNAL(stateChanged(int)) , this, SLOT(slotCollectAllParameters()));
791 if (!comment.isEmpty())
792 connect(this, SIGNAL(showComments(bool)), bval->widgetComment, SLOT(setVisible(bool)));
793 m_uiItems.append(bval);
794 } else if (type == "complex") {
795 ComplexParameter *pl = new ComplexParameter;
796 pl->setupParam(effect, pa.attribute("name"), 0, 100);
797 m_vbox->addWidget(pl);
798 m_valueItems[paramName+"complex"] = pl;
799 connect(pl, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
800 } else if (type == "geometry") {
801 if (KdenliveSettings::on_monitor_effects()) {
802 m_geometryWidget = new GeometryWidget(m_metaInfo->monitor, m_metaInfo->timecode, 0, true, effect.hasAttribute("showrotation"), parent);
803 m_geometryWidget->setFrameSize(m_metaInfo->frameSize);
804 m_geometryWidget->slotShowScene(!disable);
805 // connect this before setupParam to make sure the monitor scene shows up at startup
806 connect(m_geometryWidget, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
807 connect(m_geometryWidget, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
808 if (minFrame == maxFrame)
809 m_geometryWidget->setupParam(pa, m_in, m_out);
811 m_geometryWidget->setupParam(pa, minFrame, maxFrame);
812 m_vbox->addWidget(m_geometryWidget);
813 m_valueItems[paramName+"geometry"] = m_geometryWidget;
814 connect(m_geometryWidget, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
815 connect(this, SIGNAL(syncEffectsPos(int)), m_geometryWidget, SLOT(slotSyncPosition(int)));
816 connect(this, SIGNAL(effectStateChanged(bool)), m_geometryWidget, SLOT(slotShowScene(bool)));
818 Geometryval *geo = new Geometryval(m_metaInfo->profile, m_metaInfo->timecode, m_metaInfo->frameSize, 0);
819 if (minFrame == maxFrame)
820 geo->setupParam(pa, m_in, m_out);
822 geo->setupParam(pa, minFrame, maxFrame);
823 m_vbox->addWidget(geo);
824 m_valueItems[paramName+"geometry"] = geo;
825 connect(geo, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
826 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
827 connect(this, SIGNAL(syncEffectsPos(int)), geo, SLOT(slotSyncPosition(int)));
829 } else if (type == "addedgeometry") {
830 // this is a parameter that should be linked to the geometry widget, for example rotation, shear, ...
831 if (m_geometryWidget) m_geometryWidget->addParameter(pa);
832 } else if (type == "keyframe" || type == "simplekeyframe") {
833 // keyframe editor widget
834 if (m_keyframeEditor == NULL) {
836 if (pa.attribute("widget") == "corners") {
837 // we want a corners-keyframe-widget
838 CornersWidget *corners = new CornersWidget(m_metaInfo->monitor, pa, m_in, m_out, m_metaInfo->timecode, e.attribute("active_keyframe", "-1").toInt(), parent);
839 corners->slotShowScene(!disable);
840 connect(corners, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
841 connect(this, SIGNAL(effectStateChanged(bool)), corners, SLOT(slotShowScene(bool)));
842 connect(this, SIGNAL(syncEffectsPos(int)), corners, SLOT(slotSyncPosition(int)));
843 geo = static_cast<KeyframeEdit *>(corners);
845 geo = new KeyframeEdit(pa, m_in, m_out, m_metaInfo->timecode, e.attribute("active_keyframe", "-1").toInt());
847 m_vbox->addWidget(geo);
848 m_valueItems[paramName+"keyframe"] = geo;
849 m_keyframeEditor = geo;
850 connect(geo, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
851 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
852 connect(this, SIGNAL(showComments(bool)), geo, SIGNAL(showComments(bool)));
854 // we already have a keyframe editor, so just add another column for the new param
855 m_keyframeEditor->addParameter(pa);
857 } else if (type == "color") {
858 if (pa.hasAttribute("paramprefix")) value.remove(0, pa.attribute("paramprefix").size());
859 if (value.startsWith('#'))
860 value = value.replace('#', "0x");
861 ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, value, parent);
862 choosecolor->setAlphaChannelEnabled(true);
863 m_vbox->addWidget(choosecolor);
864 m_valueItems[paramName] = choosecolor;
865 connect(choosecolor, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int)));
866 connect(choosecolor, SIGNAL(modified()) , this, SLOT(slotCollectAllParameters()));
867 } else if (type == "position") {
868 int pos = value.toInt();
869 if (effect.attribute("id") == "fadein" || effect.attribute("id") == "fade_from_black") {
871 } else if (effect.attribute("id") == "fadeout" || effect.attribute("id") == "fade_to_black") {
872 // fadeout position starts from clip end
875 PositionEdit *posedit = new PositionEdit(paramName, pos, 0, m_out - m_in, m_metaInfo->timecode);
876 m_vbox->addWidget(posedit);
877 m_valueItems[paramName+"position"] = posedit;
878 connect(posedit, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
879 } else if (type == "curve") {
880 KisCurveWidget *curve = new KisCurveWidget(parent);
881 curve->setMaxPoints(pa.attribute("max").toInt());
882 QList<QPointF> points;
884 if (e.attribute("version").toDouble() > 0.2) {
885 // Rounding gives really weird results. (int) (10 * 0.3) gives 2! So for now, add 0.5 to get correct result
886 number = EffectsList::parameter(e, pa.attribute("number")).toDouble() * 10 + 0.5;
888 number = EffectsList::parameter(e, pa.attribute("number")).toInt();
890 QString inName = pa.attribute("inpoints");
891 QString outName = pa.attribute("outpoints");
892 int start = pa.attribute("min").toInt();
893 for (int j = start; j <= number; j++) {
895 in.replace("%i", QString::number(j));
896 QString out = outName;
897 out.replace("%i", QString::number(j));
898 points << QPointF(EffectsList::parameter(e, in).toDouble(), EffectsList::parameter(e, out).toDouble());
900 if (!points.isEmpty())
901 curve->setCurve(KisCubicCurve(points));
902 MySpinBox *spinin = new MySpinBox();
903 spinin->setRange(0, 1000);
904 MySpinBox *spinout = new MySpinBox();
905 spinout->setRange(0, 1000);
906 curve->setupInOutControls(spinin, spinout, 0, 1000);
907 m_vbox->addWidget(curve);
908 m_vbox->addWidget(spinin);
909 m_vbox->addWidget(spinout);
911 connect(curve, SIGNAL(modified()), this, SLOT(slotCollectAllParameters()));
912 m_valueItems[paramName] = curve;
914 QString depends = pa.attribute("depends");
915 if (!depends.isEmpty())
916 meetDependency(paramName, type, EffectsList::parameter(e, depends));
917 } else if (type == "bezier_spline") {
918 BezierSplineWidget *widget = new BezierSplineWidget(value, parent);
920 m_vbox->addWidget(widget);
921 m_valueItems[paramName] = widget;
922 connect(widget, SIGNAL(modified()), this, SLOT(slotCollectAllParameters()));
923 QString depends = pa.attribute("depends");
924 if (!depends.isEmpty())
925 meetDependency(paramName, type, EffectsList::parameter(e, depends));
927 } else if (type == "roto-spline") {
928 RotoWidget *roto = new RotoWidget(value, m_metaInfo->monitor, info, m_metaInfo->timecode, parent);
929 roto->slotShowScene(!disable);
930 connect(roto, SIGNAL(valueChanged()), this, SLOT(slotCollectAllParameters()));
931 connect(roto, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
932 connect(roto, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
933 connect(this, SIGNAL(syncEffectsPos(int)), roto, SLOT(slotSyncPosition(int)));
934 connect(this, SIGNAL(effectStateChanged(bool)), roto, SLOT(slotShowScene(bool)));
935 m_vbox->addWidget(roto);
936 m_valueItems[paramName] = roto;
938 } else if (type == "wipe") {
939 Wipeval *wpval = new Wipeval;
940 wpval->setupUi(toFillin);
941 wipeInfo w = getWipeInfo(value);
944 wpval->start_up->setChecked(true);
947 wpval->start_down->setChecked(true);
950 wpval->start_right->setChecked(true);
953 wpval->start_left->setChecked(true);
956 wpval->start_center->setChecked(true);
961 wpval->end_up->setChecked(true);
964 wpval->end_down->setChecked(true);
967 wpval->end_right->setChecked(true);
970 wpval->end_left->setChecked(true);
973 wpval->end_center->setChecked(true);
976 wpval->start_transp->setValue(w.startTransparency);
977 wpval->end_transp->setValue(w.endTransparency);
978 m_valueItems[paramName] = wpval;
979 connect(wpval->end_up, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
980 connect(wpval->end_down, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
981 connect(wpval->end_left, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
982 connect(wpval->end_right, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
983 connect(wpval->end_center, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
984 connect(wpval->start_up, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
985 connect(wpval->start_down, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
986 connect(wpval->start_left, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
987 connect(wpval->start_right, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
988 connect(wpval->start_center, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
989 connect(wpval->start_transp, SIGNAL(valueChanged(int)), this, SLOT(slotCollectAllParameters()));
990 connect(wpval->end_transp, SIGNAL(valueChanged(int)), this, SLOT(slotCollectAllParameters()));
991 //wpval->title->setTitle(na.toElement().text());
992 m_uiItems.append(wpval);
993 } else if (type == "url") {
994 Urlval *cval = new Urlval;
995 cval->setupUi(toFillin);
996 cval->label->setText(paramName);
997 cval->urlwidget->fileDialog()->setFilter(ProjectList::getExtensions());
998 m_valueItems[paramName] = cval;
999 cval->urlwidget->setUrl(KUrl(value));
1000 connect(cval->urlwidget, SIGNAL(returnPressed()) , this, SLOT(slotCollectAllParameters()));
1001 connect(cval->urlwidget, SIGNAL(urlSelected(const KUrl&)) , this, SLOT(slotCollectAllParameters()));
1002 m_uiItems.append(cval);
1003 } else if (type == "keywords") {
1004 Keywordval* kval = new Keywordval;
1005 kval->setupUi(toFillin);
1006 kval->label->setText(paramName);
1007 kval->lineeditwidget->setText(value);
1008 QDomElement klistelem = pa.firstChildElement("keywords");
1009 QDomElement kdisplaylistelem = pa.firstChildElement("keywordsdisplay");
1010 QStringList keywordlist;
1011 QStringList keyworddisplaylist;
1012 if (!klistelem.isNull()) {
1013 keywordlist = klistelem.text().split(';');
1014 keyworddisplaylist = i18n(kdisplaylistelem.text().toUtf8().data()).split(';');
1016 if (keyworddisplaylist.count() != keywordlist.count()) {
1017 keyworddisplaylist = keywordlist;
1019 for (int i = 0; i < keywordlist.count(); i++) {
1020 kval->comboboxwidget->addItem(keyworddisplaylist.at(i), keywordlist.at(i));
1022 // Add disabled user prompt at index 0
1023 kval->comboboxwidget->insertItem(0, i18n("<select a keyword>"), "");
1024 kval->comboboxwidget->model()->setData( kval->comboboxwidget->model()->index(0,0), QVariant(Qt::NoItemFlags), Qt::UserRole -1);
1025 kval->comboboxwidget->setCurrentIndex(0);
1026 m_valueItems[paramName] = kval;
1027 connect(kval->lineeditwidget, SIGNAL(editingFinished()) , this, SLOT(collectAllParameters()));
1028 connect(kval->comboboxwidget, SIGNAL(activated (const QString&)), this, SLOT(collectAllParameters()));
1029 m_uiItems.append(kval);
1030 } else if (type == "fontfamily") {
1031 Fontval* fval = new Fontval;
1032 fval->setupUi(toFillin);
1033 fval->name->setText(paramName);
1034 fval->fontfamilywidget->setCurrentFont(QFont(value));
1035 m_valueItems[paramName] = fval;
1036 connect(fval->fontfamilywidget, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(collectAllParameters())) ;
1037 m_uiItems.append(fval);
1038 } else if (type == "filterjob") {
1039 QVBoxLayout *l= new QVBoxLayout(toFillin);
1040 QPushButton *button = new QPushButton(paramName, toFillin);
1041 l->addWidget(button);
1042 m_valueItems[paramName] = button;
1043 connect(button, SIGNAL(pressed()), this, SLOT(slotStartFilterJobAction()));
1050 m_vbox->addWidget(toFillin);
1054 m_vbox->addStretch();
1056 if (m_keyframeEditor)
1057 m_keyframeEditor->checkVisibleParam();
1059 // Make sure all doubleparam spinboxes have the same width, looks much better
1060 QList<DoubleParameterWidget *> allWidgets = findChildren<DoubleParameterWidget *>();
1062 for (int i = 0; i < allWidgets.count(); i++) {
1063 if (minSize < allWidgets.at(i)->spinSize()) minSize = allWidgets.at(i)->spinSize();
1065 for (int i = 0; i < allWidgets.count(); i++) {
1066 allWidgets.at(i)->setSpinSize(minSize);
1070 ParameterContainer::~ParameterContainer()
1072 clearLayout(m_vbox);
1076 void ParameterContainer::meetDependency(const QString& name, QString type, QString value)
1078 if (type == "curve") {
1079 KisCurveWidget *curve = (KisCurveWidget*)m_valueItems[name];
1081 int color = value.toInt();
1082 curve->setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(curve->size(), (ColorTools::ColorsRGB)(color == 3 ? 4 : color), 0.8)));
1084 } else if (type == "bezier_spline") {
1085 BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems[name];
1087 widget->setMode((BezierSplineWidget::CurveModes)((int)(value.toDouble() * 10 + 0.5)));
1092 wipeInfo ParameterContainer::getWipeInfo(QString value)
1095 // Convert old geometry values that used a comma as separator
1096 if (value.contains(',')) value.replace(',','/');
1097 QString start = value.section(';', 0, 0);
1098 QString end = value.section(';', 1, 1).section('=', 1, 1);
1099 if (start.startsWith("-100%/0"))
1101 else if (start.startsWith("100%/0"))
1103 else if (start.startsWith("0%/100%"))
1105 else if (start.startsWith("0%/-100%"))
1108 info.start = CENTER;
1110 if (start.count(':') == 2)
1111 info.startTransparency = start.section(':', -1).toInt();
1113 info.startTransparency = 100;
1115 if (end.startsWith("-100%/0"))
1117 else if (end.startsWith("100%/0"))
1119 else if (end.startsWith("0%/100%"))
1121 else if (end.startsWith("0%/-100%"))
1126 if (end.count(':') == 2)
1127 info.endTransparency = end.section(':', -1).toInt();
1129 info.endTransparency = 100;
1134 void ParameterContainer::updateTimecodeFormat()
1136 if (m_keyframeEditor)
1137 m_keyframeEditor->updateTimecodeFormat();
1139 QDomNodeList namenode = m_effect.elementsByTagName("parameter");
1140 for (int i = 0; i < namenode.count() ; i++) {
1141 QDomNode pa = namenode.item(i);
1142 QDomElement na = pa.firstChildElement("name");
1143 QString type = pa.attributes().namedItem("type").nodeValue();
1144 QString paramName = na.isNull() ? pa.attributes().namedItem("name").nodeValue() : i18n(na.text().toUtf8().data());
1146 if (type == "geometry") {
1147 if (KdenliveSettings::on_monitor_effects()) {
1148 if (m_geometryWidget) m_geometryWidget->updateTimecodeFormat();
1150 Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
1151 geom->updateTimecodeFormat();
1154 } else if (type == "position") {
1155 PositionEdit *posi = ((PositionEdit*)m_valueItems[paramName+"position"]);
1156 posi->updateTimecodeFormat();
1159 } else if (type == "roto-spline") {
1160 RotoWidget *widget = static_cast<RotoWidget *>(m_valueItems[paramName]);
1161 widget->updateTimecodeFormat();
1167 void ParameterContainer::slotCollectAllParameters()
1169 if (m_valueItems.isEmpty() || m_effect.isNull()) return;
1171 locale.setNumberOptions(QLocale::OmitGroupSeparator);
1172 const QDomElement oldparam = m_effect.cloneNode().toElement();
1173 //QDomElement newparam = oldparam.cloneNode().toElement();
1174 QDomNodeList namenode = m_effect.elementsByTagName("parameter");
1176 for (int i = 0; i < namenode.count() ; i++) {
1177 QDomElement pa = namenode.item(i).toElement();
1178 QDomElement na = pa.firstChildElement("name");
1179 QString type = pa.attribute("type");
1180 QString paramName = na.isNull() ? pa.attribute("name") : i18n(na.text().toUtf8().data());
1181 if (type == "complex")
1182 paramName.append("complex");
1183 else if (type == "position")
1184 paramName.append("position");
1185 else if (type == "geometry")
1186 paramName.append("geometry");
1187 else if (type == "keyframe")
1188 paramName.append("keyframe");
1189 if (type != "simplekeyframe" && type != "fixed" && type != "addedgeometry" && !m_valueItems.contains(paramName)) {
1190 kDebug() << "// Param: " << paramName << " NOT FOUND";
1195 if (type == "double" || type == "constant") {
1196 DoubleParameterWidget *doubleparam = (DoubleParameterWidget*)m_valueItems.value(paramName);
1197 setValue = locale.toString(doubleparam->getValue());
1198 } else if (type == "list") {
1199 KComboBox *box = ((Listval*)m_valueItems.value(paramName))->list;
1200 setValue = box->itemData(box->currentIndex()).toString();
1201 } else if (type == "bool") {
1202 QCheckBox *box = ((Boolval*)m_valueItems.value(paramName))->checkBox;
1203 setValue = box->checkState() == Qt::Checked ? "1" : "0" ;
1204 } else if (type == "color") {
1205 ChooseColorWidget *choosecolor = ((ChooseColorWidget*)m_valueItems.value(paramName));
1206 setValue = choosecolor->getColor();
1207 if (pa.hasAttribute("paramprefix")) setValue.prepend(pa.attribute("paramprefix"));
1208 } else if (type == "complex") {
1209 ComplexParameter *complex = ((ComplexParameter*)m_valueItems.value(paramName));
1210 namenode.item(i) = complex->getParamDesc();
1211 } else if (type == "geometry") {
1212 if (KdenliveSettings::on_monitor_effects()) {
1213 if (m_geometryWidget) namenode.item(i).toElement().setAttribute("value", m_geometryWidget->getValue());
1215 Geometryval *geom = ((Geometryval*)m_valueItems.value(paramName));
1216 namenode.item(i).toElement().setAttribute("value", geom->getValue());
1218 } else if (type == "addedgeometry") {
1219 namenode.item(i).toElement().setAttribute("value", m_geometryWidget->getExtraValue(namenode.item(i).toElement().attribute("name")));
1220 } else if (type == "position") {
1221 PositionEdit *pedit = ((PositionEdit*)m_valueItems.value(paramName));
1222 int pos = pedit->getPosition();
1223 setValue = QString::number(pos);
1224 if (m_effect.attribute("id") == "fadein" || m_effect.attribute("id") == "fade_from_black") {
1225 // Make sure duration is not longer than clip
1226 /*if (pos > m_out) {
1228 pedit->setPosition(pos);
1230 EffectsList::setParameter(m_effect, "in", QString::number(m_in));
1231 EffectsList::setParameter(m_effect, "out", QString::number(m_in + pos));
1233 } else if (m_effect.attribute("id") == "fadeout" || m_effect.attribute("id") == "fade_to_black") {
1234 // Make sure duration is not longer than clip
1235 /*if (pos > m_out) {
1237 pedit->setPosition(pos);
1239 EffectsList::setParameter(m_effect, "in", QString::number(m_out - pos));
1240 EffectsList::setParameter(m_effect, "out", QString::number(m_out));
1243 } else if (type == "curve") {
1244 KisCurveWidget *curve = ((KisCurveWidget*)m_valueItems.value(paramName));
1245 QList<QPointF> points = curve->curve().points();
1246 QString number = pa.attribute("number");
1247 QString inName = pa.attribute("inpoints");
1248 QString outName = pa.attribute("outpoints");
1249 int off = pa.attribute("min").toInt();
1250 int end = pa.attribute("max").toInt();
1251 if (oldparam.attribute("version").toDouble() > 0.2) {
1252 EffectsList::setParameter(m_effect, number, locale.toString(points.count() / 10.));
1254 EffectsList::setParameter(m_effect, number, QString::number(points.count()));
1256 for (int j = 0; (j < points.count() && j + off <= end); j++) {
1257 QString in = inName;
1258 in.replace("%i", QString::number(j + off));
1259 QString out = outName;
1260 out.replace("%i", QString::number(j + off));
1261 EffectsList::setParameter(m_effect, in, locale.toString(points.at(j).x()));
1262 EffectsList::setParameter(m_effect, out, locale.toString(points.at(j).y()));
1264 QString depends = pa.attribute("depends");
1265 if (!depends.isEmpty())
1266 meetDependency(paramName, type, EffectsList::parameter(m_effect, depends));
1267 } else if (type == "bezier_spline") {
1268 BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems.value(paramName);
1269 setValue = widget->spline();
1270 QString depends = pa.attribute("depends");
1271 if (!depends.isEmpty())
1272 meetDependency(paramName, type, EffectsList::parameter(m_effect, depends));
1274 } else if (type == "roto-spline") {
1275 RotoWidget *widget = static_cast<RotoWidget *>(m_valueItems.value(paramName));
1276 setValue = widget->getSpline();
1278 } else if (type == "wipe") {
1279 Wipeval *wp = (Wipeval*)m_valueItems.value(paramName);
1281 if (wp->start_left->isChecked())
1283 else if (wp->start_right->isChecked())
1285 else if (wp->start_up->isChecked())
1287 else if (wp->start_down->isChecked())
1289 else if (wp->start_center->isChecked())
1290 info.start = CENTER;
1293 info.startTransparency = wp->start_transp->value();
1295 if (wp->end_left->isChecked())
1297 else if (wp->end_right->isChecked())
1299 else if (wp->end_up->isChecked())
1301 else if (wp->end_down->isChecked())
1303 else if (wp->end_center->isChecked())
1307 info.endTransparency = wp->end_transp->value();
1309 setValue = getWipeString(info);
1310 } else if ((type == "simplekeyframe" || type == "keyframe") && m_keyframeEditor) {
1311 QString realName = i18n(na.toElement().text().toUtf8().data());
1312 QString val = m_keyframeEditor->getValue(realName);
1313 pa.setAttribute("keyframes", val);
1315 if (m_keyframeEditor->isVisibleParam(realName)) {
1316 pa.setAttribute("intimeline", "1");
1318 else if (pa.hasAttribute("intimeline"))
1319 pa.removeAttribute("intimeline");
1320 } else if (type == "url") {
1321 KUrlRequester *req = ((Urlval*)m_valueItems.value(paramName))->urlwidget;
1322 setValue = req->url().path();
1323 } else if (type == "keywords"){
1324 QLineEdit *line = ((Keywordval*)m_valueItems.value(paramName))->lineeditwidget;
1325 QComboBox *combo = ((Keywordval*)m_valueItems.value(paramName))->comboboxwidget;
1326 if(combo->currentIndex())
1328 QString comboval = combo->itemData(combo->currentIndex()).toString();
1329 line->insert(comboval);
1330 combo->setCurrentIndex(0);
1332 setValue = line->text();
1333 } else if (type == "fontfamily") {
1334 QFontComboBox* fontfamily = ((Fontval*)m_valueItems.value(paramName))->fontfamilywidget;
1335 setValue = fontfamily->currentFont().family();
1337 if (!setValue.isNull())
1338 pa.setAttribute("value", setValue);
1341 emit parameterChanged(oldparam, m_effect, m_effect.attribute("kdenlive_ix").toInt());
1344 QString ParameterContainer::getWipeString(wipeInfo info)
1349 switch (info.start) {
1351 start = "-100%/0%:100%x100%";
1354 start = "100%/0%:100%x100%";
1357 start = "0%/100%:100%x100%";
1360 start = "0%/-100%:100%x100%";
1363 start = "0%/0%:100%x100%";
1366 start.append(':' + QString::number(info.startTransparency));
1370 end = "-100%/0%:100%x100%";
1373 end = "100%/0%:100%x100%";
1376 end = "0%/100%:100%x100%";
1379 end = "0%/-100%:100%x100%";
1382 end = "0%/0%:100%x100%";
1385 end.append(':' + QString::number(info.endTransparency));
1386 return QString(start + ";-1=" + end);
1389 void ParameterContainer::updateParameter(const QString &key, const QString &value)
1391 m_effect.setAttribute(key, value);
1394 void ParameterContainer::slotStartFilterJobAction()
1396 QDomNodeList namenode = m_effect.elementsByTagName("parameter");
1397 for (int i = 0; i < namenode.count() ; i++) {
1398 QDomElement pa = namenode.item(i).toElement();
1399 QString type = pa.attribute("type");
1400 if (type == "filterjob") {
1401 emit startFilterJob(pa.attribute("filtertag"), pa.attribute("filterparams"), pa.attribute("finalfilter"), pa.attribute("consumer"), pa.attribute("consumerparams"), pa.attribute("wantedproperties"));
1402 kDebug()<<" - - -PROPS:\n"<<pa.attribute("filtertag")<<"-"<< pa.attribute("filterparams")<<"-"<< pa.attribute("consumer")<<"-"<< pa.attribute("consumerparams")<<"-"<< pa.attribute("wantedproperties");