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)
133 if (m_effect.attribute("tag") == "region") {
134 m_regionEffect = true;
135 decoframe->setObjectName("decoframegroup");
137 filterWheelEvent = true;
138 m_info.fromString(effect.attribute("kdenlive_info"));
139 setFont(KGlobalSettings::smallestReadableFont());
140 buttonUp->setIcon(KIcon("kdenlive-up"));
141 buttonUp->setToolTip(i18n("Move effect up"));
143 buttonDown->setIcon(KIcon("kdenlive-down"));
144 buttonDown->setToolTip(i18n("Move effect down"));
146 buttonDel->setIcon(KIcon("kdenlive-deleffect"));
147 buttonDel->setToolTip(i18n("Delete effect"));
148 if (effectIndex() == 1) buttonUp->setVisible(false);
149 if (m_lastEffect) buttonDown->setVisible(false);
150 //buttonUp->setVisible(false);
151 //buttonDown->setVisible(false);
153 /*buttonReset->setIcon(KIcon("view-refresh"));
154 buttonReset->setToolTip(i18n("Reset effect"));*/
155 //checkAll->setToolTip(i18n("Enable/Disable all effects"));
156 //buttonShowComments->setIcon(KIcon("help-about"));
157 //buttonShowComments->setToolTip(i18n("Show additional information for the parameters"));
159 if (m_regionEffect) m_menu->addAction(KIcon("document-new"), i18n("Change Region"), this, SLOT(slotResetEffect()));
160 m_menu->addAction(KIcon("view-refresh"), i18n("Reset Effect"), this, SLOT(slotResetEffect()));
161 m_menu->addAction(KIcon("document-save"), i18n("Save Effect"), this, SLOT(slotSaveEffect()));
163 QDomElement namenode = m_effect.firstChildElement("name");
164 if (namenode.isNull()) return;
165 QString effectname = i18n(namenode.text().toUtf8().data());
166 if (m_regionEffect) effectname.append(":" + KUrl(EffectsList::parameter(m_effect, "resource")).fileName());
168 QHBoxLayout *l = static_cast <QHBoxLayout *>(frame->layout());
169 title = new QLabel(this);
170 l->insertWidget(2, title);
172 title->setText(effectname);
174 * Do not show icon, makes too much visual noise
175 QString type = m_effect.attribute("type", QString());
177 if (type == "audio") icon = KIcon("kdenlive-show-audio");
178 else if (m_effect.attribute("tag") == "region") icon = KIcon("kdenlive-mask-effect");
179 else if (type == "custom") icon = KIcon("kdenlive-custom-effect");
180 else icon = KIcon("kdenlive-show-video");
181 effecticon->setPixmap(icon.pixmap(16,16));*/
182 m_groupAction = new QAction(KIcon("folder-new"), i18n("Create Group"), this);
183 connect(m_groupAction, SIGNAL(triggered(bool)), this, SLOT(slotCreateGroup()));
184 if (!m_regionEffect) {
185 if (m_info.groupIndex == -1) m_menu->addAction(m_groupAction);
186 m_menu->addAction(KIcon("folder-new"), i18n("Create Region"), this, SLOT(slotCreateRegion()));
188 setupWidget(info, metaInfo);
189 setAcceptDrops(true);
190 menuButton->setIcon(KIcon("kdenlive-menu"));
191 menuButton->setMenu(m_menu);
193 if (m_effect.attribute("disable") == "1") {
194 title->setEnabled(false);
195 enabledButton->setChecked(true);
196 enabledButton->setIcon(KIcon("novisible"));
199 enabledButton->setChecked(false);
200 enabledButton->setIcon(KIcon("visible"));
203 connect(collapseButton, SIGNAL(clicked()), this, SLOT(slotSwitch()));
204 connect(enabledButton, SIGNAL(toggled(bool)), this, SLOT(slotEnable(bool)));
205 connect(buttonUp, SIGNAL(clicked()), this, SLOT(slotEffectUp()));
206 connect(buttonDown, SIGNAL(clicked()), this, SLOT(slotEffectDown()));
207 connect(buttonDel, SIGNAL(clicked()), this, SLOT(slotDeleteEffect()));
209 Q_FOREACH( QSpinBox * sp, findChildren<QSpinBox*>() ) {
210 sp->installEventFilter( this );
211 sp->setFocusPolicy( Qt::StrongFocus );
213 Q_FOREACH( KComboBox * cb, findChildren<KComboBox*>() ) {
214 cb->installEventFilter( this );
215 cb->setFocusPolicy( Qt::StrongFocus );
217 Q_FOREACH( QProgressBar * cb, findChildren<QProgressBar*>() ) {
218 cb->installEventFilter( this );
219 cb->setFocusPolicy( Qt::StrongFocus );
223 CollapsibleEffect::~CollapsibleEffect()
225 if (m_paramWidget) delete m_paramWidget;
230 const QString CollapsibleEffect::getStyleSheet()
232 KColorScheme scheme(QApplication::palette().currentColorGroup(), KColorScheme::View, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
233 QColor selected_bg = scheme.decoration(KColorScheme::FocusColor).color();
234 QColor hgh = KColorUtils::mix(QApplication::palette().window().color(), selected_bg, 0.2);
235 QColor hover_bg = scheme.decoration(KColorScheme::HoverColor).color();
236 QColor light_bg = scheme.shade(KColorScheme::LightShade);
237 QColor alt_bg = scheme.background(KColorScheme::NormalBackground).color();
242 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()));
244 // effect in group background
245 stylesheet.append(QString("QFrame#decoframesub {border-top:1px solid palette(light);} QFrame#decoframesub[active=\"true\"] {background: %1;}").arg(hgh.name()));
248 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;} "));
251 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);}"));
253 // group effect title bar
254 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);} "));
256 // draggable effect bar content
257 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()));
259 // draggable effect bar
260 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()));
262 // spin box for draggable widget
263 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()));
265 // group editable labels
266 stylesheet.append(QString("MyEditableLabel { background-color: transparent; color: palette(bright-text); border-radius: 2px;border: 1px solid transparent;} MyEditableLabel:hover {border: 1px solid palette(highlight);} "));
271 void CollapsibleEffect::slotCreateGroup()
273 emit createGroup(effectIndex());
276 void CollapsibleEffect::slotCreateRegion()
278 QString allExtensions = ProjectList::getExtensions();
279 const QString dialogFilter = allExtensions + ' ' + QLatin1Char('|') + i18n("All Supported Files") + "\n* " + QLatin1Char('|') + i18n("All Files");
280 KFileDialog *d = new KFileDialog(KUrl("kfiledialog:///clipfolder"), dialogFilter, kapp->activeWindow());
281 d->setOperationMode(KFileDialog::Opening);
282 d->setMode(KFile::File);
283 if (d->exec() == QDialog::Accepted) {
284 KUrl url = d->selectedUrl();
285 if (!url.isEmpty()) emit createRegion(effectIndex(), url);
290 void CollapsibleEffect::slotUnGroup()
295 bool CollapsibleEffect::eventFilter( QObject * o, QEvent * e )
297 if (e->type() == QEvent::Enter) {
298 frame->setProperty("mouseover", true);
299 frame->setStyleSheet(frame->styleSheet());
300 return QWidget::eventFilter(o, e);
302 if (e->type() == QEvent::Wheel) {
303 QWheelEvent *we = static_cast<QWheelEvent *>(e);
304 if (!filterWheelEvent || we->modifiers() != Qt::NoModifier) {
308 if (qobject_cast<QAbstractSpinBox*>(o)) {
309 if(qobject_cast<QAbstractSpinBox*>(o)->focusPolicy() == Qt::WheelFocus)
320 if (qobject_cast<KComboBox*>(o)) {
321 if(qobject_cast<KComboBox*>(o)->focusPolicy() == Qt::WheelFocus)
332 if (qobject_cast<QProgressBar*>(o)) {
333 if(qobject_cast<QProgressBar*>(o)->focusPolicy() == Qt::WheelFocus)
345 return QWidget::eventFilter(o, e);
348 QDomElement CollapsibleEffect::effect() const
353 bool CollapsibleEffect::isActive() const
355 return decoframe->property("active").toBool();
358 void CollapsibleEffect::setActive(bool activate)
360 decoframe->setProperty("active", activate);
361 decoframe->setStyleSheet(decoframe->styleSheet());
364 void CollapsibleEffect::mouseDoubleClickEvent ( QMouseEvent * event )
366 if (frame->underMouse() && collapseButton->isEnabled()) {
370 else event->ignore();
373 void CollapsibleEffect::mouseReleaseEvent( QMouseEvent *event )
375 if (!decoframe->property("active").toBool()) emit activateEffect(effectIndex());
376 QWidget::mouseReleaseEvent(event);
379 void CollapsibleEffect::slotEnable(bool disable, bool updateMainStatus)
381 title->setEnabled(!disable);
382 enabledButton->blockSignals(true);
383 enabledButton->setChecked(disable);
384 enabledButton->blockSignals(false);
385 enabledButton->setIcon(disable ? KIcon("novisible") : KIcon("visible"));
386 m_effect.setAttribute("disable", disable ? 1 : 0);
387 if (!disable || KdenliveSettings::disable_effect_parameters()) {
388 widgetFrame->setEnabled(!disable);
390 emit effectStateChanged(disable, effectIndex(), updateMainStatus);
393 void CollapsibleEffect::slotDeleteEffect()
395 emit deleteEffect(m_effect);
398 void CollapsibleEffect::slotEffectUp()
400 emit changeEffectPosition(QList <int>() <<effectIndex(), true);
403 void CollapsibleEffect::slotEffectDown()
405 emit changeEffectPosition(QList <int>() <<effectIndex(), false);
408 void CollapsibleEffect::slotSaveEffect()
410 QString name = QInputDialog::getText(this, i18n("Save Effect"), i18n("Name for saved effect: "));
411 if (name.isEmpty()) return;
412 QString path = KStandardDirs::locateLocal("appdata", "effects/", true);
413 path = path + name + ".xml";
414 if (QFile::exists(path)) if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", path)) == KMessageBox::No) return;
417 QDomElement effect = m_effect.cloneNode().toElement();
418 doc.appendChild(doc.importNode(effect, true));
419 effect = doc.firstChild().toElement();
420 effect.removeAttribute("kdenlive_ix");
421 effect.setAttribute("id", name);
422 effect.setAttribute("type", "custom");
423 QDomElement effectname = effect.firstChildElement("name");
424 effect.removeChild(effectname);
425 effectname = doc.createElement("name");
426 QDomText nametext = doc.createTextNode(name);
427 effectname.appendChild(nametext);
428 effect.insertBefore(effectname, QDomNode());
429 QDomElement effectprops = effect.firstChildElement("properties");
430 effectprops.setAttribute("id", name);
431 effectprops.setAttribute("type", "custom");
434 if (file.open(QFile::WriteOnly | QFile::Truncate)) {
435 QTextStream out(&file);
436 out << doc.toString();
439 emit reloadEffects();
442 void CollapsibleEffect::slotResetEffect()
444 emit resetEffect(effectIndex());
447 void CollapsibleEffect::slotSwitch()
449 bool enable = !widgetFrame->isVisible();
453 void CollapsibleEffect::slotShow(bool show)
455 widgetFrame->setVisible(show);
457 collapseButton->setArrowType(Qt::DownArrow);
458 m_info.isCollapsed = false;
461 collapseButton->setArrowType(Qt::RightArrow);
462 m_info.isCollapsed = true;
464 updateCollapsedState();
467 void CollapsibleEffect::groupStateChanged(bool collapsed)
469 m_info.groupIsCollapsed = collapsed;
470 updateCollapsedState();
473 void CollapsibleEffect::updateCollapsedState()
475 QString info = m_info.toString();
476 if (info != m_effect.attribute("kdenlive_info")) {
477 m_effect.setAttribute("kdenlive_info", info);
478 emit parameterChanged(m_original_effect, m_effect, effectIndex());
482 void CollapsibleEffect::setGroupIndex(int ix)
484 if (m_info.groupIndex == -1 && ix != -1) {
485 m_menu->removeAction(m_groupAction);
487 else if (m_info.groupIndex != -1 && ix == -1) {
488 m_menu->addAction(m_groupAction);
490 m_info.groupIndex = ix;
491 m_effect.setAttribute("kdenlive_info", m_info.toString());
494 void CollapsibleEffect::setGroupName(const QString &groupName)
496 m_info.groupName = groupName;
497 m_effect.setAttribute("kdenlive_info", m_info.toString());
500 QString CollapsibleEffect::infoString() const
502 return m_info.toString();
505 void CollapsibleEffect::removeFromGroup()
507 if (m_info.groupIndex != -1) {
508 m_menu->addAction(m_groupAction);
510 m_info.groupIndex = -1;
511 m_info.groupName.clear();
512 m_effect.setAttribute("kdenlive_info", m_info.toString());
513 emit parameterChanged(m_original_effect, m_effect, effectIndex());
516 int CollapsibleEffect::groupIndex() const
518 return m_info.groupIndex;
521 int CollapsibleEffect::effectIndex() const
523 if (m_effect.isNull()) return -1;
524 return m_effect.attribute("kdenlive_ix").toInt();
527 void CollapsibleEffect::updateWidget(ItemInfo info, QDomElement effect, EffectMetaInfo *metaInfo)
531 delete m_paramWidget;
532 m_paramWidget = NULL;
535 setupWidget(info, metaInfo);
538 void CollapsibleEffect::setupWidget(ItemInfo info, EffectMetaInfo *metaInfo)
540 if (m_effect.isNull()) {
541 // kDebug() << "// EMPTY EFFECT STACK";
545 if (m_effect.attribute("tag") == "region") {
546 m_regionEffect = true;
547 QVBoxLayout *vbox = new QVBoxLayout(widgetFrame);
548 vbox->setContentsMargins(0, 0, 0, 0);
550 QDomNodeList effects = m_effect.elementsByTagName("effect");
551 QDomNodeList origin_effects = m_original_effect.elementsByTagName("effect");
552 QWidget *container = new QWidget(widgetFrame);
553 vbox->addWidget(container);
554 // m_paramWidget = new ParameterContainer(m_effect.toElement(), info, metaInfo, container);
555 for (int i = 0; i < effects.count(); i++) {
556 CollapsibleEffect *coll = new CollapsibleEffect(effects.at(i).toElement(), origin_effects.at(i).toElement(), info, metaInfo, container);
557 m_subParamWidgets.append(coll);
558 connect(coll, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int)), this , SLOT(slotUpdateRegionEffectParams(const QDomElement, const QDomElement, int)));
559 //container = new QWidget(widgetFrame);
560 vbox->addWidget(coll);
561 //p = new ParameterContainer(effects.at(i).toElement(), info, isEffect, container);
566 m_paramWidget = new ParameterContainer(m_effect, info, metaInfo, widgetFrame);
567 if (m_effect.firstChildElement("parameter").isNull()) {
568 // Effect has no parameter, don't allow expand
569 collapseButton->setEnabled(false);
570 collapseButton->setVisible(false);
571 widgetFrame->setVisible(false);
574 if (collapseButton->isEnabled() && m_info.isCollapsed) {
575 widgetFrame->setVisible(false);
576 collapseButton->setArrowType(Qt::RightArrow);
579 connect (m_paramWidget, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int)), this, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int)));
581 connect(m_paramWidget, SIGNAL(startFilterJob(QString,QString,QString,QString,QString,QString)), this, SIGNAL(startFilterJob(QString,QString,QString,QString,QString,QString)));
583 connect (this, SIGNAL(syncEffectsPos(int)), m_paramWidget, SIGNAL(syncEffectsPos(int)));
584 connect (this, SIGNAL(effectStateChanged(bool)), m_paramWidget, SIGNAL(effectStateChanged(bool)));
585 connect (m_paramWidget, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
586 connect (m_paramWidget, SIGNAL(seekTimeline(int)), this, SIGNAL(seekTimeline(int)));
591 bool CollapsibleEffect::isGroup() const
596 void CollapsibleEffect::updateTimecodeFormat()
598 m_paramWidget->updateTimecodeFormat();
599 if (!m_subParamWidgets.isEmpty()) {
601 for (int i = 0; i < m_subParamWidgets.count(); i++)
602 m_subParamWidgets.at(i)->updateTimecodeFormat();
606 void CollapsibleEffect::slotUpdateRegionEffectParams(const QDomElement /*old*/, const QDomElement /*e*/, int /*ix*/)
608 kDebug()<<"// EMIT CHANGE SUBEFFECT.....:";
609 emit parameterChanged(m_original_effect, m_effect, effectIndex());
612 void CollapsibleEffect::slotSyncEffectsPos(int pos)
614 emit syncEffectsPos(pos);
617 void CollapsibleEffect::dragEnterEvent(QDragEnterEvent *event)
619 if (event->mimeData()->hasFormat("kdenlive/effectslist")) {
620 frame->setProperty("target", true);
621 frame->setStyleSheet(frame->styleSheet());
622 event->acceptProposedAction();
626 void CollapsibleEffect::dragLeaveEvent(QDragLeaveEvent */*event*/)
628 frame->setProperty("target", false);
629 frame->setStyleSheet(frame->styleSheet());
632 void CollapsibleEffect::dropEvent(QDropEvent *event)
634 frame->setProperty("target", false);
635 frame->setStyleSheet(frame->styleSheet());
636 const QString effects = QString::fromUtf8(event->mimeData()->data("kdenlive/effectslist"));
637 //event->acceptProposedAction();
639 doc.setContent(effects, true);
640 QDomElement e = doc.documentElement();
641 int ix = e.attribute("kdenlive_ix").toInt();
642 int currentEffectIx = effectIndex();
643 if (ix == currentEffectIx) {
644 // effect dropped on itself, reject
648 if (ix == 0 || e.tagName() == "effectgroup") {
649 if (e.tagName() == "effectgroup") {
651 QDomNodeList subeffects = e.elementsByTagName("effect");
652 if (subeffects.isEmpty()) {
657 info.fromString(subeffects.at(0).toElement().attribute("kdenlive_info"));
658 event->setDropAction(Qt::MoveAction);
660 if (info.groupIndex >= 0) {
662 QList <int> effectsIds;
663 // Collect moved effects ids
664 for (int i = 0; i < subeffects.count(); i++) {
665 QDomElement effect = subeffects.at(i).toElement();
666 effectsIds << effect.attribute("kdenlive_ix").toInt();
668 emit moveEffect(effectsIds, currentEffectIx, info.groupIndex, info.groupName);
671 // group effect dropped from effect list
672 if (m_info.groupIndex > -1) {
673 // TODO: Should we merge groups??
680 // effect dropped from effects list, add it
681 e.setAttribute("kdenlive_ix", ix);
682 if (m_info.groupIndex > -1) {
683 // Dropped on a group
684 e.setAttribute("kdenlive_info", m_info.toString());
686 event->setDropAction(Qt::CopyAction);
691 emit moveEffect(QList <int> () <<ix, currentEffectIx, m_info.groupIndex, m_info.groupName);
692 event->setDropAction(Qt::MoveAction);
697 void CollapsibleEffect::adjustButtons(int ix, int max)
699 buttonUp->setVisible(ix > 0);
700 buttonDown->setVisible(ix < max - 1);
703 ParameterContainer::ParameterContainer(QDomElement effect, ItemInfo info, EffectMetaInfo *metaInfo, QWidget * parent) :
704 m_keyframeEditor(NULL),
705 m_geometryWidget(NULL),
706 m_metaInfo(metaInfo),
709 m_in = info.cropStart.frames(KdenliveSettings::project_fps());
710 m_out = (info.cropStart + info.cropDuration).frames(KdenliveSettings::project_fps()) - 1;
712 QDomNodeList namenode = effect.childNodes(); //elementsByTagName("parameter");
714 QDomElement e = effect.toElement();
715 int minFrame = e.attribute("start").toInt();
716 int maxFrame = e.attribute("end").toInt();
717 // In transitions, maxFrame is in fact one frame after the end of transition
718 if (maxFrame > 0) maxFrame --;
720 bool disable = effect.attribute("disable") == "1" && KdenliveSettings::disable_effect_parameters();
721 parent->setEnabled(!disable);
724 m_vbox = new QVBoxLayout(parent);
725 m_vbox->setContentsMargins(4, 0, 4, 0);
726 m_vbox->setSpacing(2);
728 for (int i = 0; i < namenode.count() ; i++) {
729 QDomElement pa = namenode.item(i).toElement();
730 if (pa.tagName() != "parameter") continue;
731 QDomElement na = pa.firstChildElement("name");
732 QDomElement commentElem = pa.firstChildElement("comment");
733 QString type = pa.attribute("type");
734 QString paramName = na.isNull() ? pa.attribute("name") : i18n(na.text().toUtf8().data());
736 if (!commentElem.isNull())
737 comment = i18n(commentElem.text().toUtf8().data());
738 QWidget * toFillin = new QWidget(parent);
739 QString value = pa.attribute("value").isNull() ?
740 pa.attribute("default") : pa.attribute("value");
743 /** See effects/README for info on the different types */
745 if (type == "double" || type == "constant") {
748 if (pa.attribute("min").contains('%'))
749 min = ProfilesDialog::getStringEval(m_metaInfo->profile, pa.attribute("min"), m_metaInfo->frameSize);
751 min = pa.attribute("min").toDouble();
752 if (pa.attribute("max").contains('%'))
753 max = ProfilesDialog::getStringEval(m_metaInfo->profile, pa.attribute("max"), m_metaInfo->frameSize);
755 max = pa.attribute("max").toDouble();
757 DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, value.toDouble(), min, max,
758 pa.attribute("default").toDouble(), comment, -1, pa.attribute("suffix"), pa.attribute("decimals").toInt(), parent);
759 doubleparam->setFocusPolicy(Qt::StrongFocus);
760 m_vbox->addWidget(doubleparam);
761 m_valueItems[paramName] = doubleparam;
762 connect(doubleparam, SIGNAL(valueChanged(double)), this, SLOT(slotCollectAllParameters()));
763 connect(this, SIGNAL(showComments(bool)), doubleparam, SLOT(slotShowComment(bool)));
764 } else if (type == "list") {
765 Listval *lsval = new Listval;
766 lsval->setupUi(toFillin);
767 lsval->list->setFocusPolicy(Qt::StrongFocus);
768 QStringList listitems = pa.attribute("paramlist").split(';');
769 if (listitems.count() == 1) {
770 // probably custom effect created before change to ';' as separator
771 listitems = pa.attribute("paramlist").split(",");
773 QDomElement list = pa.firstChildElement("paramlistdisplay");
774 QStringList listitemsdisplay;
775 if (!list.isNull()) {
776 listitemsdisplay = i18n(list.text().toUtf8().data()).split(',');
778 listitemsdisplay = i18n(pa.attribute("paramlistdisplay").toUtf8().data()).split(',');
780 if (listitemsdisplay.count() != listitems.count())
781 listitemsdisplay = listitems;
782 lsval->list->setIconSize(QSize(30, 30));
783 for (int i = 0; i < listitems.count(); i++) {
784 lsval->list->addItem(listitemsdisplay.at(i), listitems.at(i));
785 QString entry = listitems.at(i);
786 if (!entry.isEmpty() && (entry.endsWith(".png") || entry.endsWith(".pgm"))) {
787 if (!CollapsibleEffect::iconCache.contains(entry)) {
789 CollapsibleEffect::iconCache[entry] = pix.scaled(30, 30);
791 lsval->list->setItemIcon(i, QPixmap::fromImage(CollapsibleEffect::iconCache[entry]));
794 if (!value.isEmpty()) lsval->list->setCurrentIndex(listitems.indexOf(value));
795 lsval->name->setText(paramName);
796 lsval->labelComment->setText(comment);
797 lsval->widgetComment->setHidden(true);
798 m_valueItems[paramName] = lsval;
799 connect(lsval->list, SIGNAL(currentIndexChanged(int)) , this, SLOT(slotCollectAllParameters()));
800 if (!comment.isEmpty())
801 connect(this, SIGNAL(showComments(bool)), lsval->widgetComment, SLOT(setVisible(bool)));
802 m_uiItems.append(lsval);
803 } else if (type == "bool") {
804 Boolval *bval = new Boolval;
805 bval->setupUi(toFillin);
806 bval->checkBox->setCheckState(value == "0" ? Qt::Unchecked : Qt::Checked);
807 bval->name->setText(paramName);
808 bval->labelComment->setText(comment);
809 bval->widgetComment->setHidden(true);
810 m_valueItems[paramName] = bval;
811 connect(bval->checkBox, SIGNAL(stateChanged(int)) , this, SLOT(slotCollectAllParameters()));
812 if (!comment.isEmpty())
813 connect(this, SIGNAL(showComments(bool)), bval->widgetComment, SLOT(setVisible(bool)));
814 m_uiItems.append(bval);
815 } else if (type == "complex") {
816 ComplexParameter *pl = new ComplexParameter;
817 pl->setupParam(effect, pa.attribute("name"), 0, 100);
818 m_vbox->addWidget(pl);
819 m_valueItems[paramName+"complex"] = pl;
820 connect(pl, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
821 } else if (type == "geometry") {
822 if (KdenliveSettings::on_monitor_effects()) {
823 m_geometryWidget = new GeometryWidget(m_metaInfo->monitor, m_metaInfo->timecode, 0, true, effect.hasAttribute("showrotation"), parent);
824 m_geometryWidget->setFrameSize(m_metaInfo->frameSize);
825 m_geometryWidget->slotShowScene(!disable);
826 // connect this before setupParam to make sure the monitor scene shows up at startup
827 connect(m_geometryWidget, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
828 connect(m_geometryWidget, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
829 if (minFrame == maxFrame)
830 m_geometryWidget->setupParam(pa, m_in, m_out);
832 m_geometryWidget->setupParam(pa, minFrame, maxFrame);
833 m_vbox->addWidget(m_geometryWidget);
834 m_valueItems[paramName+"geometry"] = m_geometryWidget;
835 connect(m_geometryWidget, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
836 connect(this, SIGNAL(syncEffectsPos(int)), m_geometryWidget, SLOT(slotSyncPosition(int)));
837 connect(this, SIGNAL(effectStateChanged(bool)), m_geometryWidget, SLOT(slotShowScene(bool)));
839 Geometryval *geo = new Geometryval(m_metaInfo->profile, m_metaInfo->timecode, m_metaInfo->frameSize, 0);
840 if (minFrame == maxFrame)
841 geo->setupParam(pa, m_in, m_out);
843 geo->setupParam(pa, minFrame, maxFrame);
844 m_vbox->addWidget(geo);
845 m_valueItems[paramName+"geometry"] = geo;
846 connect(geo, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
847 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
848 connect(this, SIGNAL(syncEffectsPos(int)), geo, SLOT(slotSyncPosition(int)));
850 } else if (type == "addedgeometry") {
851 // this is a parameter that should be linked to the geometry widget, for example rotation, shear, ...
852 if (m_geometryWidget) m_geometryWidget->addParameter(pa);
853 } else if (type == "keyframe" || type == "simplekeyframe") {
854 // keyframe editor widget
855 if (m_keyframeEditor == NULL) {
857 if (pa.attribute("widget") == "corners") {
858 // we want a corners-keyframe-widget
859 CornersWidget *corners = new CornersWidget(m_metaInfo->monitor, pa, m_in, m_out, m_metaInfo->timecode, e.attribute("active_keyframe", "-1").toInt(), parent);
860 corners->slotShowScene(!disable);
861 connect(corners, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
862 connect(this, SIGNAL(effectStateChanged(bool)), corners, SLOT(slotShowScene(bool)));
863 connect(this, SIGNAL(syncEffectsPos(int)), corners, SLOT(slotSyncPosition(int)));
864 geo = static_cast<KeyframeEdit *>(corners);
866 geo = new KeyframeEdit(pa, m_in, m_out, m_metaInfo->timecode, e.attribute("active_keyframe", "-1").toInt());
868 m_vbox->addWidget(geo);
869 m_valueItems[paramName+"keyframe"] = geo;
870 m_keyframeEditor = geo;
871 connect(geo, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
872 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
873 connect(this, SIGNAL(showComments(bool)), geo, SIGNAL(showComments(bool)));
875 // we already have a keyframe editor, so just add another column for the new param
876 m_keyframeEditor->addParameter(pa);
878 } else if (type == "color") {
879 if (pa.hasAttribute("paramprefix")) value.remove(0, pa.attribute("paramprefix").size());
880 if (value.startsWith('#'))
881 value = value.replace('#', "0x");
882 ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, value, parent);
883 choosecolor->setAlphaChannelEnabled(true);
884 m_vbox->addWidget(choosecolor);
885 m_valueItems[paramName] = choosecolor;
886 connect(choosecolor, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int)));
887 connect(choosecolor, SIGNAL(modified()) , this, SLOT(slotCollectAllParameters()));
888 } else if (type == "position") {
889 int pos = value.toInt();
890 if (effect.attribute("id") == "fadein" || effect.attribute("id") == "fade_from_black") {
892 } else if (effect.attribute("id") == "fadeout" || effect.attribute("id") == "fade_to_black") {
893 // fadeout position starts from clip end
896 PositionEdit *posedit = new PositionEdit(paramName, pos, 0, m_out - m_in, m_metaInfo->timecode);
897 m_vbox->addWidget(posedit);
898 m_valueItems[paramName+"position"] = posedit;
899 connect(posedit, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
900 } else if (type == "curve") {
901 KisCurveWidget *curve = new KisCurveWidget(parent);
902 curve->setMaxPoints(pa.attribute("max").toInt());
903 QList<QPointF> points;
905 if (e.attribute("version").toDouble() > 0.2) {
906 // Rounding gives really weird results. (int) (10 * 0.3) gives 2! So for now, add 0.5 to get correct result
907 number = EffectsList::parameter(e, pa.attribute("number")).toDouble() * 10 + 0.5;
909 number = EffectsList::parameter(e, pa.attribute("number")).toInt();
911 QString inName = pa.attribute("inpoints");
912 QString outName = pa.attribute("outpoints");
913 int start = pa.attribute("min").toInt();
914 for (int j = start; j <= number; j++) {
916 in.replace("%i", QString::number(j));
917 QString out = outName;
918 out.replace("%i", QString::number(j));
919 points << QPointF(EffectsList::parameter(e, in).toDouble(), EffectsList::parameter(e, out).toDouble());
921 if (!points.isEmpty())
922 curve->setCurve(KisCubicCurve(points));
923 MySpinBox *spinin = new MySpinBox();
924 spinin->setRange(0, 1000);
925 MySpinBox *spinout = new MySpinBox();
926 spinout->setRange(0, 1000);
927 curve->setupInOutControls(spinin, spinout, 0, 1000);
928 m_vbox->addWidget(curve);
929 m_vbox->addWidget(spinin);
930 m_vbox->addWidget(spinout);
932 connect(curve, SIGNAL(modified()), this, SLOT(slotCollectAllParameters()));
933 m_valueItems[paramName] = curve;
935 QString depends = pa.attribute("depends");
936 if (!depends.isEmpty())
937 meetDependency(paramName, type, EffectsList::parameter(e, depends));
938 } else if (type == "bezier_spline") {
939 BezierSplineWidget *widget = new BezierSplineWidget(value, parent);
941 m_vbox->addWidget(widget);
942 m_valueItems[paramName] = widget;
943 connect(widget, SIGNAL(modified()), this, SLOT(slotCollectAllParameters()));
944 QString depends = pa.attribute("depends");
945 if (!depends.isEmpty())
946 meetDependency(paramName, type, EffectsList::parameter(e, depends));
948 } else if (type == "roto-spline") {
949 RotoWidget *roto = new RotoWidget(value, m_metaInfo->monitor, info, m_metaInfo->timecode, parent);
950 roto->slotShowScene(!disable);
951 connect(roto, SIGNAL(valueChanged()), this, SLOT(slotCollectAllParameters()));
952 connect(roto, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
953 connect(roto, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
954 connect(this, SIGNAL(syncEffectsPos(int)), roto, SLOT(slotSyncPosition(int)));
955 connect(this, SIGNAL(effectStateChanged(bool)), roto, SLOT(slotShowScene(bool)));
956 m_vbox->addWidget(roto);
957 m_valueItems[paramName] = roto;
959 } else if (type == "wipe") {
960 Wipeval *wpval = new Wipeval;
961 wpval->setupUi(toFillin);
962 wipeInfo w = getWipeInfo(value);
965 wpval->start_up->setChecked(true);
968 wpval->start_down->setChecked(true);
971 wpval->start_right->setChecked(true);
974 wpval->start_left->setChecked(true);
977 wpval->start_center->setChecked(true);
982 wpval->end_up->setChecked(true);
985 wpval->end_down->setChecked(true);
988 wpval->end_right->setChecked(true);
991 wpval->end_left->setChecked(true);
994 wpval->end_center->setChecked(true);
997 wpval->start_transp->setValue(w.startTransparency);
998 wpval->end_transp->setValue(w.endTransparency);
999 m_valueItems[paramName] = wpval;
1000 connect(wpval->end_up, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
1001 connect(wpval->end_down, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
1002 connect(wpval->end_left, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
1003 connect(wpval->end_right, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
1004 connect(wpval->end_center, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
1005 connect(wpval->start_up, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
1006 connect(wpval->start_down, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
1007 connect(wpval->start_left, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
1008 connect(wpval->start_right, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
1009 connect(wpval->start_center, SIGNAL(clicked()), this, SLOT(slotCollectAllParameters()));
1010 connect(wpval->start_transp, SIGNAL(valueChanged(int)), this, SLOT(slotCollectAllParameters()));
1011 connect(wpval->end_transp, SIGNAL(valueChanged(int)), this, SLOT(slotCollectAllParameters()));
1012 //wpval->title->setTitle(na.toElement().text());
1013 m_uiItems.append(wpval);
1014 } else if (type == "url") {
1015 Urlval *cval = new Urlval;
1016 cval->setupUi(toFillin);
1017 cval->label->setText(paramName);
1018 cval->urlwidget->fileDialog()->setFilter(ProjectList::getExtensions());
1019 m_valueItems[paramName] = cval;
1020 cval->urlwidget->setUrl(KUrl(value));
1021 connect(cval->urlwidget, SIGNAL(returnPressed()) , this, SLOT(slotCollectAllParameters()));
1022 connect(cval->urlwidget, SIGNAL(urlSelected(const KUrl&)) , this, SLOT(slotCollectAllParameters()));
1023 m_uiItems.append(cval);
1024 } else if (type == "keywords") {
1025 Keywordval* kval = new Keywordval;
1026 kval->setupUi(toFillin);
1027 kval->label->setText(paramName);
1028 kval->lineeditwidget->setText(value);
1029 QDomElement klistelem = pa.firstChildElement("keywords");
1030 QDomElement kdisplaylistelem = pa.firstChildElement("keywordsdisplay");
1031 QStringList keywordlist;
1032 QStringList keyworddisplaylist;
1033 if (!klistelem.isNull()) {
1034 keywordlist = klistelem.text().split(';');
1035 keyworddisplaylist = i18n(kdisplaylistelem.text().toUtf8().data()).split(';');
1037 if (keyworddisplaylist.count() != keywordlist.count()) {
1038 keyworddisplaylist = keywordlist;
1040 for (int i = 0; i < keywordlist.count(); i++) {
1041 kval->comboboxwidget->addItem(keyworddisplaylist.at(i), keywordlist.at(i));
1043 // Add disabled user prompt at index 0
1044 kval->comboboxwidget->insertItem(0, i18n("<select a keyword>"), "");
1045 kval->comboboxwidget->model()->setData( kval->comboboxwidget->model()->index(0,0), QVariant(Qt::NoItemFlags), Qt::UserRole -1);
1046 kval->comboboxwidget->setCurrentIndex(0);
1047 m_valueItems[paramName] = kval;
1048 connect(kval->lineeditwidget, SIGNAL(editingFinished()) , this, SLOT(collectAllParameters()));
1049 connect(kval->comboboxwidget, SIGNAL(activated (const QString&)), this, SLOT(collectAllParameters()));
1050 m_uiItems.append(kval);
1051 } else if (type == "fontfamily") {
1052 Fontval* fval = new Fontval;
1053 fval->setupUi(toFillin);
1054 fval->name->setText(paramName);
1055 fval->fontfamilywidget->setCurrentFont(QFont(value));
1056 m_valueItems[paramName] = fval;
1057 connect(fval->fontfamilywidget, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(collectAllParameters())) ;
1058 m_uiItems.append(fval);
1059 } else if (type == "filterjob") {
1060 QVBoxLayout *l= new QVBoxLayout(toFillin);
1061 QPushButton *button = new QPushButton(paramName, toFillin);
1062 l->addWidget(button);
1063 m_valueItems[paramName] = button;
1064 connect(button, SIGNAL(pressed()), this, SLOT(slotStartFilterJobAction()));
1071 m_vbox->addWidget(toFillin);
1075 m_vbox->addStretch();
1077 if (m_keyframeEditor)
1078 m_keyframeEditor->checkVisibleParam();
1080 // Make sure all doubleparam spinboxes have the same width, looks much better
1081 QList<DoubleParameterWidget *> allWidgets = findChildren<DoubleParameterWidget *>();
1083 for (int i = 0; i < allWidgets.count(); i++) {
1084 if (minSize < allWidgets.at(i)->spinSize()) minSize = allWidgets.at(i)->spinSize();
1086 for (int i = 0; i < allWidgets.count(); i++) {
1087 allWidgets.at(i)->setSpinSize(minSize);
1091 ParameterContainer::~ParameterContainer()
1093 clearLayout(m_vbox);
1097 void ParameterContainer::meetDependency(const QString& name, QString type, QString value)
1099 if (type == "curve") {
1100 KisCurveWidget *curve = (KisCurveWidget*)m_valueItems[name];
1102 int color = value.toInt();
1103 curve->setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(curve->size(), (ColorTools::ColorsRGB)(color == 3 ? 4 : color), 0.8)));
1105 } else if (type == "bezier_spline") {
1106 BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems[name];
1108 widget->setMode((BezierSplineWidget::CurveModes)((int)(value.toDouble() * 10 + 0.5)));
1113 wipeInfo ParameterContainer::getWipeInfo(QString value)
1116 // Convert old geometry values that used a comma as separator
1117 if (value.contains(',')) value.replace(',','/');
1118 QString start = value.section(';', 0, 0);
1119 QString end = value.section(';', 1, 1).section('=', 1, 1);
1120 if (start.startsWith("-100%/0"))
1122 else if (start.startsWith("100%/0"))
1124 else if (start.startsWith("0%/100%"))
1126 else if (start.startsWith("0%/-100%"))
1129 info.start = CENTER;
1131 if (start.count(':') == 2)
1132 info.startTransparency = start.section(':', -1).toInt();
1134 info.startTransparency = 100;
1136 if (end.startsWith("-100%/0"))
1138 else if (end.startsWith("100%/0"))
1140 else if (end.startsWith("0%/100%"))
1142 else if (end.startsWith("0%/-100%"))
1147 if (end.count(':') == 2)
1148 info.endTransparency = end.section(':', -1).toInt();
1150 info.endTransparency = 100;
1155 void ParameterContainer::updateTimecodeFormat()
1157 if (m_keyframeEditor)
1158 m_keyframeEditor->updateTimecodeFormat();
1160 QDomNodeList namenode = m_effect.elementsByTagName("parameter");
1161 for (int i = 0; i < namenode.count() ; i++) {
1162 QDomNode pa = namenode.item(i);
1163 QDomElement na = pa.firstChildElement("name");
1164 QString type = pa.attributes().namedItem("type").nodeValue();
1165 QString paramName = na.isNull() ? pa.attributes().namedItem("name").nodeValue() : i18n(na.text().toUtf8().data());
1167 if (type == "geometry") {
1168 if (KdenliveSettings::on_monitor_effects()) {
1169 if (m_geometryWidget) m_geometryWidget->updateTimecodeFormat();
1171 Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
1172 geom->updateTimecodeFormat();
1175 } else if (type == "position") {
1176 PositionEdit *posi = ((PositionEdit*)m_valueItems[paramName+"position"]);
1177 posi->updateTimecodeFormat();
1180 } else if (type == "roto-spline") {
1181 RotoWidget *widget = static_cast<RotoWidget *>(m_valueItems[paramName]);
1182 widget->updateTimecodeFormat();
1188 void ParameterContainer::slotCollectAllParameters()
1190 if (m_valueItems.isEmpty() || m_effect.isNull()) return;
1192 locale.setNumberOptions(QLocale::OmitGroupSeparator);
1193 const QDomElement oldparam = m_effect.cloneNode().toElement();
1194 //QDomElement newparam = oldparam.cloneNode().toElement();
1195 QDomNodeList namenode = m_effect.elementsByTagName("parameter");
1197 for (int i = 0; i < namenode.count() ; i++) {
1198 QDomElement pa = namenode.item(i).toElement();
1199 QDomElement na = pa.firstChildElement("name");
1200 QString type = pa.attribute("type");
1201 QString paramName = na.isNull() ? pa.attribute("name") : i18n(na.text().toUtf8().data());
1202 if (type == "complex")
1203 paramName.append("complex");
1204 else if (type == "position")
1205 paramName.append("position");
1206 else if (type == "geometry")
1207 paramName.append("geometry");
1208 else if (type == "keyframe")
1209 paramName.append("keyframe");
1210 if (type != "simplekeyframe" && type != "fixed" && type != "addedgeometry" && !m_valueItems.contains(paramName)) {
1211 kDebug() << "// Param: " << paramName << " NOT FOUND";
1216 if (type == "double" || type == "constant") {
1217 DoubleParameterWidget *doubleparam = (DoubleParameterWidget*)m_valueItems.value(paramName);
1218 setValue = locale.toString(doubleparam->getValue());
1219 } else if (type == "list") {
1220 KComboBox *box = ((Listval*)m_valueItems.value(paramName))->list;
1221 setValue = box->itemData(box->currentIndex()).toString();
1222 } else if (type == "bool") {
1223 QCheckBox *box = ((Boolval*)m_valueItems.value(paramName))->checkBox;
1224 setValue = box->checkState() == Qt::Checked ? "1" : "0" ;
1225 } else if (type == "color") {
1226 ChooseColorWidget *choosecolor = ((ChooseColorWidget*)m_valueItems.value(paramName));
1227 setValue = choosecolor->getColor();
1228 if (pa.hasAttribute("paramprefix")) setValue.prepend(pa.attribute("paramprefix"));
1229 } else if (type == "complex") {
1230 ComplexParameter *complex = ((ComplexParameter*)m_valueItems.value(paramName));
1231 namenode.item(i) = complex->getParamDesc();
1232 } else if (type == "geometry") {
1233 if (KdenliveSettings::on_monitor_effects()) {
1234 if (m_geometryWidget) namenode.item(i).toElement().setAttribute("value", m_geometryWidget->getValue());
1236 Geometryval *geom = ((Geometryval*)m_valueItems.value(paramName));
1237 namenode.item(i).toElement().setAttribute("value", geom->getValue());
1239 } else if (type == "addedgeometry") {
1240 namenode.item(i).toElement().setAttribute("value", m_geometryWidget->getExtraValue(namenode.item(i).toElement().attribute("name")));
1241 } else if (type == "position") {
1242 PositionEdit *pedit = ((PositionEdit*)m_valueItems.value(paramName));
1243 int pos = pedit->getPosition();
1244 setValue = QString::number(pos);
1245 if (m_effect.attribute("id") == "fadein" || m_effect.attribute("id") == "fade_from_black") {
1246 // Make sure duration is not longer than clip
1247 /*if (pos > m_out) {
1249 pedit->setPosition(pos);
1251 EffectsList::setParameter(m_effect, "in", QString::number(m_in));
1252 EffectsList::setParameter(m_effect, "out", QString::number(m_in + pos));
1254 } else if (m_effect.attribute("id") == "fadeout" || m_effect.attribute("id") == "fade_to_black") {
1255 // Make sure duration is not longer than clip
1256 /*if (pos > m_out) {
1258 pedit->setPosition(pos);
1260 EffectsList::setParameter(m_effect, "in", QString::number(m_out - pos));
1261 EffectsList::setParameter(m_effect, "out", QString::number(m_out));
1264 } else if (type == "curve") {
1265 KisCurveWidget *curve = ((KisCurveWidget*)m_valueItems.value(paramName));
1266 QList<QPointF> points = curve->curve().points();
1267 QString number = pa.attribute("number");
1268 QString inName = pa.attribute("inpoints");
1269 QString outName = pa.attribute("outpoints");
1270 int off = pa.attribute("min").toInt();
1271 int end = pa.attribute("max").toInt();
1272 if (oldparam.attribute("version").toDouble() > 0.2) {
1273 EffectsList::setParameter(m_effect, number, locale.toString(points.count() / 10.));
1275 EffectsList::setParameter(m_effect, number, QString::number(points.count()));
1277 for (int j = 0; (j < points.count() && j + off <= end); j++) {
1278 QString in = inName;
1279 in.replace("%i", QString::number(j + off));
1280 QString out = outName;
1281 out.replace("%i", QString::number(j + off));
1282 EffectsList::setParameter(m_effect, in, locale.toString(points.at(j).x()));
1283 EffectsList::setParameter(m_effect, out, locale.toString(points.at(j).y()));
1285 QString depends = pa.attribute("depends");
1286 if (!depends.isEmpty())
1287 meetDependency(paramName, type, EffectsList::parameter(m_effect, depends));
1288 } else if (type == "bezier_spline") {
1289 BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems.value(paramName);
1290 setValue = widget->spline();
1291 QString depends = pa.attribute("depends");
1292 if (!depends.isEmpty())
1293 meetDependency(paramName, type, EffectsList::parameter(m_effect, depends));
1295 } else if (type == "roto-spline") {
1296 RotoWidget *widget = static_cast<RotoWidget *>(m_valueItems.value(paramName));
1297 setValue = widget->getSpline();
1299 } else if (type == "wipe") {
1300 Wipeval *wp = (Wipeval*)m_valueItems.value(paramName);
1302 if (wp->start_left->isChecked())
1304 else if (wp->start_right->isChecked())
1306 else if (wp->start_up->isChecked())
1308 else if (wp->start_down->isChecked())
1310 else if (wp->start_center->isChecked())
1311 info.start = CENTER;
1314 info.startTransparency = wp->start_transp->value();
1316 if (wp->end_left->isChecked())
1318 else if (wp->end_right->isChecked())
1320 else if (wp->end_up->isChecked())
1322 else if (wp->end_down->isChecked())
1324 else if (wp->end_center->isChecked())
1328 info.endTransparency = wp->end_transp->value();
1330 setValue = getWipeString(info);
1331 } else if ((type == "simplekeyframe" || type == "keyframe") && m_keyframeEditor) {
1332 QString realName = i18n(na.toElement().text().toUtf8().data());
1333 QString val = m_keyframeEditor->getValue(realName);
1334 pa.setAttribute("keyframes", val);
1336 if (m_keyframeEditor->isVisibleParam(realName)) {
1337 pa.setAttribute("intimeline", "1");
1339 else if (pa.hasAttribute("intimeline"))
1340 pa.removeAttribute("intimeline");
1341 } else if (type == "url") {
1342 KUrlRequester *req = ((Urlval*)m_valueItems.value(paramName))->urlwidget;
1343 setValue = req->url().path();
1344 } else if (type == "keywords"){
1345 QLineEdit *line = ((Keywordval*)m_valueItems.value(paramName))->lineeditwidget;
1346 QComboBox *combo = ((Keywordval*)m_valueItems.value(paramName))->comboboxwidget;
1347 if(combo->currentIndex())
1349 QString comboval = combo->itemData(combo->currentIndex()).toString();
1350 line->insert(comboval);
1351 combo->setCurrentIndex(0);
1353 setValue = line->text();
1354 } else if (type == "fontfamily") {
1355 QFontComboBox* fontfamily = ((Fontval*)m_valueItems.value(paramName))->fontfamilywidget;
1356 setValue = fontfamily->currentFont().family();
1358 if (!setValue.isNull())
1359 pa.setAttribute("value", setValue);
1362 emit parameterChanged(oldparam, m_effect, m_effect.attribute("kdenlive_ix").toInt());
1365 QString ParameterContainer::getWipeString(wipeInfo info)
1370 switch (info.start) {
1372 start = "-100%/0%:100%x100%";
1375 start = "100%/0%:100%x100%";
1378 start = "0%/100%:100%x100%";
1381 start = "0%/-100%:100%x100%";
1384 start = "0%/0%:100%x100%";
1387 start.append(':' + QString::number(info.startTransparency));
1391 end = "-100%/0%:100%x100%";
1394 end = "100%/0%:100%x100%";
1397 end = "0%/100%:100%x100%";
1400 end = "0%/-100%:100%x100%";
1403 end = "0%/0%:100%x100%";
1406 end.append(':' + QString::number(info.endTransparency));
1407 return QString(start + ";-1=" + end);
1410 void ParameterContainer::updateParameter(const QString &key, const QString &value)
1412 m_effect.setAttribute(key, value);
1415 void ParameterContainer::slotStartFilterJobAction()
1417 QDomNodeList namenode = m_effect.elementsByTagName("parameter");
1418 for (int i = 0; i < namenode.count() ; i++) {
1419 QDomElement pa = namenode.item(i).toElement();
1420 QString type = pa.attribute("type");
1421 if (type == "filterjob") {
1422 emit startFilterJob(pa.attribute("filtertag"), pa.attribute("filterparams"), pa.attribute("finalfilter"), pa.attribute("consumer"), pa.attribute("consumerparams"), pa.attribute("wantedproperties"));
1423 kDebug()<<" - - -PROPS:\n"<<pa.attribute("filtertag")<<"-"<< pa.attribute("filterparams")<<"-"<< pa.attribute("consumer")<<"-"<< pa.attribute("consumerparams")<<"-"<< pa.attribute("wantedproperties");