]> git.sesse.net Git - kdenlive/blobdiff - src/effectstack/collapsibleeffect.cpp
First steps for the incredible filter region
[kdenlive] / src / effectstack / collapsibleeffect.cpp
index 6ab1eb8cdfef4221e1a29976a0d99d6ea7babb9c..0bf2bb2e0bf6b4f961713714e7b4d349901e1523 100644 (file)
@@ -59,6 +59,8 @@
 #include <KFileDialog>
 #include <KUrlRequester>
 #include <KColorScheme>
+#include <KColorUtils>
+#include <KApplication>
 
 class Boolval: public QWidget, public Ui::Boolval_UI
 {
@@ -107,14 +109,16 @@ MySpinBox::MySpinBox(QWidget * parent):
     setFocusPolicy(Qt::StrongFocus);
 }
 
-void MySpinBox::focusInEvent(QFocusEvent*)
+void MySpinBox::focusInEvent(QFocusEvent *e)
 {
      setFocusPolicy(Qt::WheelFocus);
+     e->accept();
 }
 
-void MySpinBox::focusOutEvent(QFocusEvent*)
+void MySpinBox::focusOutEvent(QFocusEvent *e)
 {
      setFocusPolicy(Qt::StrongFocus);
+     e->accept();
 }
 
 
@@ -123,13 +127,17 @@ CollapsibleEffect::CollapsibleEffect(QDomElement effect, QDomElement original_ef
         m_paramWidget(NULL),
         m_effect(effect),
         m_original_effect(original_effect),
-        m_lastEffect(lastEffect)
+        m_lastEffect(lastEffect),
+        m_regionEffect(false)
 {
     setupUi(this);
+    if (m_effect.attribute("tag") == "region") {
+       m_regionEffect = true;
+       decoframe->setObjectName("decoframegroup");
+    }
     filterWheelEvent = true;
     m_info.fromString(effect.attribute("kdenlive_info"));
     setFont(KGlobalSettings::smallestReadableFont());
-   
     buttonUp->setIcon(KIcon("kdenlive-up"));
     buttonUp->setToolTip(i18n("Move effect up"));
     if (!lastEffect) {
@@ -149,36 +157,46 @@ CollapsibleEffect::CollapsibleEffect(QDomElement effect, QDomElement original_ef
     //buttonShowComments->setIcon(KIcon("help-about"));
     //buttonShowComments->setToolTip(i18n("Show additional information for the parameters"));
     m_menu = new QMenu;
-    m_menu->addAction(KIcon("view-refresh"), i18n("Reset effect"), this, SLOT(slotResetEffect()));
-    m_menu->addAction(KIcon("document-save"), i18n("Save effect"), this, SLOT(slotSaveEffect()));
+    if (m_regionEffect) m_menu->addAction(KIcon("document-new"), i18n("Change Region"), this, SLOT(slotResetEffect()));
+    m_menu->addAction(KIcon("view-refresh"), i18n("Reset Effect"), this, SLOT(slotResetEffect()));
+    m_menu->addAction(KIcon("document-save"), i18n("Save Effect"), this, SLOT(slotSaveEffect()));
     
     QDomElement namenode = m_effect.firstChildElement("name");
     if (namenode.isNull()) return;
-    title->setText(i18n(namenode.text().toUtf8().data()));
+    QString effectname = i18n(namenode.text().toUtf8().data());
+    if (m_regionEffect) effectname.append(":" + KUrl(EffectsList::parameter(m_effect, "resource")).fileName());
+    title->setText(effectname);
+    /*
+     * Do not show icon, makes too much visual noise
     QString type = m_effect.attribute("type", QString());
     KIcon icon;
     if (type == "audio") icon = KIcon("kdenlive-show-audio");
     else if (m_effect.attribute("tag") == "region") icon = KIcon("kdenlive-mask-effect");
     else if (type == "custom") icon = KIcon("kdenlive-custom-effect");
     else icon = KIcon("kdenlive-show-video");
-    effecticon->setPixmap(icon.pixmap(16,16));
-    m_menu->addAction(KIcon("folder-new"), i18n("Create Group"), this, SLOT(slotCreateGroup()));
-    setupWidget(info, metaInfo);
+    effecticon->setPixmap(icon.pixmap(16,16));*/
     
+    if (!m_regionEffect) {
+       m_menu->addAction(KIcon("folder-new"), i18n("Create Group"), this, SLOT(slotCreateGroup()));
+       m_menu->addAction(KIcon("folder-new"), i18n("Create Region"), this, SLOT(slotCreateRegion()));
+    }
+    setupWidget(info, metaInfo);
     setAcceptDrops(true);
     menuButton->setIcon(KIcon("kdenlive-menu"));
     menuButton->setMenu(m_menu);
     
     if (m_effect.attribute("disable") == "1") {
         title->setEnabled(false);
-       enabledBox->setChecked(false);
+       enabledButton->setChecked(true);
+       enabledButton->setIcon(KIcon("novisible"));
     }
     else {
-        enabledBox->setChecked(true);
+        enabledButton->setChecked(false);
+       enabledButton->setIcon(KIcon("visible"));
     }
 
     connect(collapseButton, SIGNAL(clicked()), this, SLOT(slotSwitch()));
-    connect(enabledBox, SIGNAL(toggled(bool)), this, SLOT(slotEnable(bool)));
+    connect(enabledButton, SIGNAL(toggled(bool)), this, SLOT(slotEnable(bool)));
     connect(buttonUp, SIGNAL(clicked()), this, SLOT(slotEffectUp()));
     connect(buttonDown, SIGNAL(clicked()), this, SLOT(slotEffectDown()));
     connect(buttonDel, SIGNAL(clicked()), this, SLOT(slotDeleteEffect()));
@@ -204,47 +222,43 @@ CollapsibleEffect::~CollapsibleEffect()
 }
 
 //static
-const QString CollapsibleEffect::getStyleSheet(QPalette p)
+const QString CollapsibleEffect::getStyleSheet()
 {
-    KColorScheme scheme(p.currentColorGroup(), KColorScheme::View, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
-    QColor dark_bg = scheme.shade(KColorScheme::DarkShade);
+    KColorScheme scheme(QApplication::palette().currentColorGroup(), KColorScheme::View, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
     QColor selected_bg = scheme.decoration(KColorScheme::FocusColor).color();
+    QColor hgh = KColorUtils::mix(QApplication::palette().window().color(), selected_bg, 0.2);
     QColor hover_bg = scheme.decoration(KColorScheme::HoverColor).color();
     QColor light_bg = scheme.shade(KColorScheme::LightShade);
-    QColor midlight_bg = scheme.shade(KColorScheme::MidlightShade);
-    QColor normal_bg = scheme.background(KColorScheme::AlternateBackground).color();
     QColor alt_bg = scheme.background(KColorScheme::NormalBackground).color();
     
-    KColorScheme scheme2(p.currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
-    QColor normal_bg2 = scheme2.background(KColorScheme::NormalBackground).color();
-    QColor normal_bg3 = scheme2.background(KColorScheme::AlternateBackground).color();
-    
     QString stylesheet;
     
     // group editable labels
-    stylesheet.append(QString("MyEditableLabel { background-color: transparent;} "));
+    stylesheet.append(QString("MyEditableLabel { background-color: transparent;color: palette(bright-text);} "));
     
     // effect background
-    stylesheet.append(QString("QFrame#decoframe {border-radius:5px;border:0px solid %1;background:%3;}  QFrame:hover#decoframe {background:%4;} QFrame#decoframe[active=\"true\"] {background:%2;} ").arg(dark_bg.name()).arg(alt_bg.name()).arg(normal_bg2.name()).arg(normal_bg.name()));
+    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()));
+
+    // effect in group background
+    stylesheet.append(QString("QFrame#decoframesub {border-top:1px solid palette(light);}  QFrame#decoframesub[active=\"true\"] {background: %1;}").arg(hgh.name()));
     
-    // effect group background
-    stylesheet.append(QString("QFrame#decoframegroup {border-radius:5px;border:1px solid %1;background:%2;} QFrame#decoframegroup[active=\"true\"] {background:%3;} ").arg(dark_bg.name()).arg(normal_bg2.name()).arg(alt_bg.name()));
+    // group background
+    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;} "));
     
     // effect title bar
-    stylesheet.append(QString("QFrame#frame {border-radius: 5px;} QFrame#frame[active=\"true\"] {background:%1;}").arg(selected_bg.name()));
-    
+    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);}"));
+
     // group effect title bar
-    stylesheet.append(QString("QFrame#framegroup {border-radius: 5px; background: %2;}  QFrame#framegroup[active=\"true\"] {background:%1;} ").arg(selected_bg.name()).arg(normal_bg3.name()));
+    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);} "));
     
-    // draggable effect content bar
-    stylesheet.append(QString("QProgressBar::chunk:horizontal {background: %1;border-top-left-radius: 4px;border-bottom-left-radius: 4px;} QProgressBar::chunk:horizontal#dragOnly {background: %2;border-top-left-radius: 4px;border-bottom-left-radius: 4px;} QProgressBar::chunk:horizontal:hover {background: %3;}").arg(normal_bg2.name()).arg(alt_bg.name()).arg(selected_bg.name()));
-    
-    // draggable effect content bar
-    stylesheet.append(QString("QProgressBar:horizontal {border: 1px solid %1;border-top-left-radius: 4px;border-bottom-left-radius: 4px;border-right:0px;background:%4;padding: 0px;text-align:left center} QProgressBar:horizontal:disabled {border: 1px solid %5} QProgressBar:horizontal#dragOnly {background: %4} QProgressBar:horizontal[inTimeline=\"true\"] { border: 1px solid %2;border-right: 0px;background: %3;padding: 0px;text-align:left center } QProgressBar::chunk:horizontal[inTimeline=\"true\"] {background: %2;}").arg(dark_bg.name()).arg(hover_bg.name()).arg(light_bg.name()).arg(alt_bg.name()).arg(normal_bg2.name()));
+    // draggable effect bar content
+    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()));
     
+    // draggable effect bar
+    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()));
     
     // spin box for draggable widget
-    stylesheet.append(QString("QAbstractSpinBox#dragBox {border: 1px solid %1;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 %4;} QAbstractSpinBox::up-button#dragBox {width:0px;padding:0px;} QAbstractSpinBox[inTimeline=\"true\"]#dragBox { border: 1px solid %2;} QAbstractSpinBox:hover#dragBox {border: 1px solid %3;} ").arg(dark_bg.name()).arg(hover_bg.name()).arg(selected_bg.name()).arg(normal_bg2.name()));
+    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()));
 
     return stylesheet;
 }
@@ -254,6 +268,20 @@ void CollapsibleEffect::slotCreateGroup()
     emit createGroup(effectIndex());
 }
 
+void CollapsibleEffect::slotCreateRegion()
+{
+    QString allExtensions = ProjectList::getExtensions();
+    const QString dialogFilter = allExtensions + ' ' + QLatin1Char('|') + i18n("All Supported Files") + "\n* " + QLatin1Char('|') + i18n("All Files");
+    KFileDialog *d = new KFileDialog(KUrl("kfiledialog:///clipfolder"), dialogFilter, kapp->activeWindow());
+    d->setOperationMode(KFileDialog::Opening);
+    d->setMode(KFile::File);
+    if (d->exec() == QDialog::Accepted) {
+       KUrl url = d->selectedUrl();
+       if (!url.isEmpty()) emit createRegion(effectIndex(), url);
+    }
+    delete d;
+}
+
 void CollapsibleEffect::slotUnGroup()
 {
     emit unGroup(this);
@@ -261,6 +289,11 @@ void CollapsibleEffect::slotUnGroup()
 
 bool CollapsibleEffect::eventFilter( QObject * o, QEvent * e ) 
 {
+    if (e->type() == QEvent::Enter) {
+       frame->setProperty("mouseover", true);
+       frame->setStyleSheet(frame->styleSheet());
+       return QWidget::eventFilter(o, e);
+    }
     if (e->type() == QEvent::Wheel) {
        QWheelEvent *we = static_cast<QWheelEvent *>(e);
        if (!filterWheelEvent || we->modifiers() != Qt::NoModifier) {
@@ -325,29 +358,31 @@ void CollapsibleEffect::setActive(bool activate)
 
 void CollapsibleEffect::mouseDoubleClickEvent ( QMouseEvent * event )
 {
-    if (frame->underMouse() && collapseButton->isEnabled()) slotSwitch();
-    QWidget::mouseDoubleClickEvent(event);
+    if (frame->underMouse() && collapseButton->isEnabled()) {
+        event->accept();
+        slotSwitch();
+    }
+    else event->ignore();
 }
 
-void CollapsibleEffect::mousePressEvent ( QMouseEvent *event )
+void CollapsibleEffect::mouseReleaseEvent( QMouseEvent *event )
 {
-  
-    if (!decoframe->property("active").toBool() && !isGroup()) emit activateEffect(effectIndex());
-    QWidget::mousePressEvent(event);
+  if (!decoframe->property("active").toBool()) emit activateEffect(effectIndex());
+  QWidget::mouseReleaseEvent(event);
 }
 
-
-void CollapsibleEffect::slotEnable(bool enable)
+void CollapsibleEffect::slotEnable(bool disable, bool updateMainStatus)
 {
-    title->setEnabled(enable);
-    enabledBox->blockSignals(true);
-    enabledBox->setChecked(enable);
-    enabledBox->blockSignals(false);
-    m_effect.setAttribute("disable", enable ? 0 : 1);
-    if (enable || KdenliveSettings::disable_effect_parameters()) {
-       widgetFrame->setEnabled(enable);
+    title->setEnabled(!disable);
+    enabledButton->blockSignals(true);
+    enabledButton->setChecked(disable);
+    enabledButton->blockSignals(false);
+    enabledButton->setIcon(disable ? KIcon("novisible") : KIcon("visible"));
+    m_effect.setAttribute("disable", disable ? 1 : 0);
+    if (!disable || KdenliveSettings::disable_effect_parameters()) {
+        widgetFrame->setEnabled(!disable);
     }
-    emit effectStateChanged(!enable, effectIndex());
+    emit effectStateChanged(disable, effectIndex(), updateMainStatus);
 }
 
 void CollapsibleEffect::slotDeleteEffect()
@@ -415,23 +450,16 @@ void CollapsibleEffect::slotShow(bool show)
     widgetFrame->setVisible(show);
     if (show) {
         collapseButton->setArrowType(Qt::DownArrow);
-       m_info.isCollapsed = false;
+        m_info.isCollapsed = false;
     }
     else {
         collapseButton->setArrowType(Qt::RightArrow);
-       m_info.isCollapsed = true;
+        m_info.isCollapsed = true;
     }
     m_effect.setAttribute("kdenlive_info", m_info.toString());
     emit parameterChanged(m_original_effect, m_effect, effectIndex());   
 }
 
-void CollapsibleEffect::updateGroupIndex(int groupIndex)
-{
-    m_info.groupIndex = groupIndex;
-    m_effect.setAttribute("kdenlive_info", m_info.toString());
-    emit parameterChanged(m_original_effect, m_effect, effectIndex());
-}
-
 void CollapsibleEffect::setGroupIndex(int ix)
 {
     m_info.groupIndex = ix;
@@ -447,18 +475,12 @@ QString CollapsibleEffect::infoString() const
     return m_info.toString();
 }
 
-void CollapsibleEffect::removeGroup(int ix, QVBoxLayout *layout)
+void CollapsibleEffect::removeFromGroup()
 {
-    QVBoxLayout *vbox = static_cast<QVBoxLayout *>(widgetFrame->layout());
-    if (vbox == NULL) return;
-    
-    for (int j = vbox->count() - 1; j >= 0; j--) {
-       QLayoutItem *child = vbox->takeAt(j);
-       CollapsibleEffect *e = static_cast<CollapsibleEffect *>(child->widget());
-       layout->insertWidget(ix, e);
-       e->updateGroupIndex(-1);
-       delete child;
-    }
+    m_info.groupIndex = -1;
+    m_info.groupName.clear();
+    m_effect.setAttribute("kdenlive_info", m_info.toString());
+    emit parameterChanged(m_original_effect, m_effect, effectIndex());
 }
 
 int CollapsibleEffect::groupIndex() const
@@ -475,9 +497,9 @@ int CollapsibleEffect::effectIndex() const
 void CollapsibleEffect::updateWidget(ItemInfo info, QDomElement effect, EffectMetaInfo *metaInfo)
 {
     if (m_paramWidget) {
-       // cleanup
-       delete m_paramWidget;
-       m_paramWidget = NULL;
+        // cleanup
+        delete m_paramWidget;
+        m_paramWidget = NULL;
     }
     m_effect = effect;
     setupWidget(info, metaInfo);
@@ -491,17 +513,19 @@ void CollapsibleEffect::setupWidget(ItemInfo info, EffectMetaInfo *metaInfo)
     }
 
     if (m_effect.attribute("tag") == "region") {
+       m_regionEffect = true;
         QVBoxLayout *vbox = new QVBoxLayout(widgetFrame);
-        vbox->setContentsMargins(2, 0, 2, 0);
-       vbox->setSpacing(2);
+        vbox->setContentsMargins(0, 0, 0, 0);
+        vbox->setSpacing(2);
         QDomNodeList effects =  m_effect.elementsByTagName("effect");
-       QDomNodeList origin_effects =  m_original_effect.elementsByTagName("effect");
+        QDomNodeList origin_effects =  m_original_effect.elementsByTagName("effect");
         QWidget *container = new QWidget(widgetFrame);
         vbox->addWidget(container);
-        m_paramWidget = new ParameterContainer(m_effect.toElement(), info, metaInfo, container);
+       // m_paramWidget = new ParameterContainer(m_effect.toElement(), info, metaInfo, container);
         for (int i = 0; i < effects.count(); i++) {
             CollapsibleEffect *coll = new CollapsibleEffect(effects.at(i).toElement(), origin_effects.at(i).toElement(), info, metaInfo, container);
             m_subParamWidgets.append(coll);
+           connect(coll, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int)), this , SLOT(slotUpdateRegionEffectParams(const QDomElement, const QDomElement, int)));
             //container = new QWidget(widgetFrame);
             vbox->addWidget(coll);
             //p = new ParameterContainer(effects.at(i).toElement(), info, isEffect, container);
@@ -549,6 +573,12 @@ void CollapsibleEffect::updateTimecodeFormat()
     }
 }
 
+void CollapsibleEffect::slotUpdateRegionEffectParams(const QDomElement /*old*/, const QDomElement /*e*/, int /*ix*/)
+{
+    kDebug()<<"// EMIT CHANGE SUBEFFECT.....:";
+    emit parameterChanged(m_original_effect, m_effect, effectIndex());
+}
+
 void CollapsibleEffect::slotSyncEffectsPos(int pos)
 {
     emit syncEffectsPos(pos);
@@ -557,7 +587,7 @@ void CollapsibleEffect::slotSyncEffectsPos(int pos)
 void CollapsibleEffect::dragEnterEvent(QDragEnterEvent *event)
 {
     if (event->mimeData()->hasFormat("kdenlive/effectslist")) {
-       frame->setProperty("active", true);
+       frame->setProperty("target", true);
        frame->setStyleSheet(frame->styleSheet());
        event->acceptProposedAction();
     }
@@ -565,13 +595,13 @@ void CollapsibleEffect::dragEnterEvent(QDragEnterEvent *event)
 
 void CollapsibleEffect::dragLeaveEvent(QDragLeaveEvent */*event*/)
 {
-    frame->setProperty("active", false);
+    frame->setProperty("target", false);
     frame->setStyleSheet(frame->styleSheet());
 }
 
 void CollapsibleEffect::dropEvent(QDropEvent *event)
 {
-    frame->setProperty("active", false);
+    frame->setProperty("target", false);
     frame->setStyleSheet(frame->styleSheet());
     const QString effects = QString::fromUtf8(event->mimeData()->data("kdenlive/effectslist"));
     //event->acceptProposedAction();
@@ -592,7 +622,7 @@ void CollapsibleEffect::dropEvent(QDropEvent *event)
        emit addEffect(e);
        return;
     }
-    emit moveEffect(ix, effectIndex(), groupIndex());
+    emit moveEffect(ix, effectIndex(), m_info.groupIndex, m_info.groupName);
     event->setDropAction(Qt::MoveAction);
     event->accept();
 }
@@ -619,7 +649,7 @@ ParameterContainer::ParameterContainer(QDomElement effect, ItemInfo info, Effect
 
     bool stretch = true;
     m_vbox = new QVBoxLayout(parent);
-    m_vbox->setContentsMargins(2, 0, 2, 0);
+    m_vbox->setContentsMargins(4, 0, 4, 0);
     m_vbox->setSpacing(2);
 
     for (int i = 0; i < namenode.count() ; i++) {
@@ -773,9 +803,11 @@ ParameterContainer::ParameterContainer(QDomElement effect, ItemInfo info, Effect
                 m_keyframeEditor->addParameter(pa);
             }
         } else if (type == "color") {
+           if (pa.hasAttribute("paramprefix")) value.remove(0, pa.attribute("paramprefix").size());
             if (value.startsWith('#'))
                 value = value.replace('#', "0x");
             ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, value, parent);
+           choosecolor->setAlphaChannelEnabled(true);
             m_vbox->addWidget(choosecolor);
             m_valueItems[paramName] = choosecolor;
             connect(choosecolor, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int)));
@@ -796,7 +828,13 @@ ParameterContainer::ParameterContainer(QDomElement effect, ItemInfo info, Effect
             KisCurveWidget *curve = new KisCurveWidget(parent);
             curve->setMaxPoints(pa.attribute("max").toInt());
             QList<QPointF> points;
-            int number = EffectsList::parameter(e, pa.attribute("number")).toInt();
+            int number;
+           if (e.attribute("version").toDouble() > 0.2) {
+               // Rounding gives really weird results. (int) (10 * 0.3) gives 2! So for now, add 0.5 to get correct result
+                number = EffectsList::parameter(e, pa.attribute("number")).toDouble() * 10 + 0.5;
+            } else {
+                number = EffectsList::parameter(e, pa.attribute("number")).toInt();
+            }
             QString inName = pa.attribute("inpoints");
             QString outName = pa.attribute("outpoints");
             int start = pa.attribute("min").toInt();
@@ -994,7 +1032,7 @@ void ParameterContainer::meetDependency(const QString& name, QString type, QStri
     } else if (type == "bezier_spline") {
         BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems[name];
         if (widget) {
-            widget->setMode((BezierSplineWidget::CurveModes)((int)(value.toDouble() * 10)));
+            widget->setMode((BezierSplineWidget::CurveModes)((int)(value.toDouble() * 10 + 0.5)));
         }
     }
 }
@@ -1084,10 +1122,10 @@ void ParameterContainer::slotCollectAllParameters()
     QDomNodeList namenode = m_effect.elementsByTagName("parameter");
 
     for (int i = 0; i < namenode.count() ; i++) {
-        QDomNode pa = namenode.item(i);
+        QDomElement pa = namenode.item(i).toElement();
         QDomElement na = pa.firstChildElement("name");
-        QString type = pa.attributes().namedItem("type").nodeValue();
-        QString paramName = na.isNull() ? pa.attributes().namedItem("name").nodeValue() : i18n(na.text().toUtf8().data());
+        QString type = pa.attribute("type");
+        QString paramName = na.isNull() ? pa.attribute("name") : i18n(na.text().toUtf8().data());
         if (type == "complex")
             paramName.append("complex");
         else if (type == "position")
@@ -1114,6 +1152,7 @@ void ParameterContainer::slotCollectAllParameters()
         } else if (type == "color") {
             ChooseColorWidget *choosecolor = ((ChooseColorWidget*)m_valueItems.value(paramName));
             setValue = choosecolor->getColor();
+           if (pa.hasAttribute("paramprefix")) setValue.prepend(pa.attribute("paramprefix"));
         } else if (type == "complex") {
             ComplexParameter *complex = ((ComplexParameter*)m_valueItems.value(paramName));
             namenode.item(i) = complex->getParamDesc();
@@ -1152,12 +1191,16 @@ void ParameterContainer::slotCollectAllParameters()
         } else if (type == "curve") {
             KisCurveWidget *curve = ((KisCurveWidget*)m_valueItems.value(paramName));
             QList<QPointF> points = curve->curve().points();
-            QString number = pa.attributes().namedItem("number").nodeValue();
-            QString inName = pa.attributes().namedItem("inpoints").nodeValue();
-            QString outName = pa.attributes().namedItem("outpoints").nodeValue();
-            int off = pa.attributes().namedItem("min").nodeValue().toInt();
-            int end = pa.attributes().namedItem("max").nodeValue().toInt();
-            EffectsList::setParameter(m_effect, number, QString::number(points.count()));
+            QString number = pa.attribute("number");
+            QString inName = pa.attribute("inpoints");
+            QString outName = pa.attribute("outpoints");
+            int off = pa.attribute("min").toInt();
+            int end = pa.attribute("max").toInt();
+            if (oldparam.attribute("version").toDouble() > 0.2) {
+                EffectsList::setParameter(m_effect, number, locale.toString(points.count() / 10.));
+            } else {
+                EffectsList::setParameter(m_effect, number, QString::number(points.count()));
+            }
             for (int j = 0; (j < points.count() && j + off <= end); j++) {
                 QString in = inName;
                 in.replace("%i", QString::number(j + off));
@@ -1166,13 +1209,13 @@ void ParameterContainer::slotCollectAllParameters()
                 EffectsList::setParameter(m_effect, in, locale.toString(points.at(j).x()));
                 EffectsList::setParameter(m_effect, out, locale.toString(points.at(j).y()));
             }
-            QString depends = pa.attributes().namedItem("depends").nodeValue();
+            QString depends = pa.attribute("depends");
             if (!depends.isEmpty())
                 meetDependency(paramName, type, EffectsList::parameter(m_effect, depends));
         } else if (type == "bezier_spline") {
             BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems.value(paramName);
             setValue = widget->spline();
-            QString depends = pa.attributes().namedItem("depends").nodeValue();
+            QString depends = pa.attribute("depends");
             if (!depends.isEmpty())
                 meetDependency(paramName, type, EffectsList::parameter(m_effect, depends));
 #ifdef USE_QJSON
@@ -1213,15 +1256,15 @@ void ParameterContainer::slotCollectAllParameters()
 
             setValue = getWipeString(info);
         } else if ((type == "simplekeyframe" || type == "keyframe") && m_keyframeEditor) {
-            QDomElement elem = pa.toElement();
             QString realName = i18n(na.toElement().text().toUtf8().data());
             QString val = m_keyframeEditor->getValue(realName);
-            elem.setAttribute("keyframes", val);
+            pa.setAttribute("keyframes", val);
 
-            if (m_keyframeEditor->isVisibleParam(realName))
-                elem.setAttribute("intimeline", "1");
-            else if (elem.hasAttribute("intimeline"))
-                elem.removeAttribute("intimeline");
+            if (m_keyframeEditor->isVisibleParam(realName)) {
+                pa.setAttribute("intimeline", "1");
+           }
+            else if (pa.hasAttribute("intimeline"))
+                pa.removeAttribute("intimeline");
         } else if (type == "url") {
             KUrlRequester *req = ((Urlval*)m_valueItems.value(paramName))->urlwidget;
             setValue = req->url().path();
@@ -1240,7 +1283,7 @@ void ParameterContainer::slotCollectAllParameters()
             setValue = fontfamily->currentFont().family();
         }
         if (!setValue.isNull())
-            pa.attributes().namedItem("value").setNodeValue(setValue);
+            pa.setAttribute("value", setValue);
 
     }
     emit parameterChanged(oldparam, m_effect, m_effect.attribute("kdenlive_ix").toInt());