]> git.sesse.net Git - kdenlive/blobdiff - src/effectstackedit.cpp
Improve proxy handling, fix project tree staying disabled after loading project
[kdenlive] / src / effectstackedit.cpp
index a2d2b5ff1e07e45b81a26514f4d9f8ddee8d6241..7253b4957a0cab52c6caac74781804f0ccb70029 100644 (file)
@@ -82,7 +82,7 @@ EffectStackEdit::EffectStackEdit(Monitor *monitor, QWidget *parent) :
     m_geometryWidget(NULL)
 {
     m_baseWidget = new QWidget(this);
-    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+    setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
     setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
     setFrameStyle(QFrame::NoFrame);
     setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding));
@@ -205,7 +205,7 @@ void EffectStackEdit::updateParameter(const QString &name, const QString &value)
     }
 }
 
-void EffectStackEdit::transferParamDesc(const QDomElement d, ItemInfo info, bool isEffect)
+void EffectStackEdit::transferParamDesc(const QDomElement &d, ItemInfo info, bool isEffect)
 {
     clearAllItems();
     if (m_keyframeEditor) delete m_keyframeEditor;
@@ -232,9 +232,10 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, ItemInfo info, bool
         }
     }
 #endif
-    QDomElement e = m_params.toElement();
-    const int minFrame = e.attribute("start").toInt();
-    const int maxFrame = e.attribute("end").toInt();
+    int minFrame = d.attribute("start").toInt();
+    int maxFrame = d.attribute("end").toInt();
+    // In transitions, maxFrame is in fact one frame after the end of transition
+    if (maxFrame > 0) maxFrame --;
 
     bool disable = d.attribute("disable") == "1" && KdenliveSettings::disable_effect_parameters();
     setEnabled(!disable);
@@ -261,12 +262,12 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, ItemInfo info, bool
         if (type == "double" || type == "constant") {
             double min;
             double max;
-            if (pa.attribute("min").startsWith('%'))
-                min = ProfilesDialog::getStringEval(m_profile, pa.attribute("min"));
+            if (pa.attribute("min").contains('%'))
+                min = ProfilesDialog::getStringEval(m_profile, pa.attribute("min"), m_frameSize);
             else
                 min = pa.attribute("min").toDouble();
-            if (pa.attribute("max").startsWith('%'))
-                max = ProfilesDialog::getStringEval(m_profile, pa.attribute("max"));
+            if (pa.attribute("max").contains('%'))
+                max = ProfilesDialog::getStringEval(m_profile, pa.attribute("max"), m_frameSize);
             else
                 max = pa.attribute("max").toDouble();
 
@@ -279,11 +280,18 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, ItemInfo info, bool
         } else if (type == "list") {
             Listval *lsval = new Listval;
             lsval->setupUi(toFillin);
-            QStringList listitems = pa.attribute("paramlist").split(',');
+            QStringList listitems = pa.attribute("paramlist").split(';');
+            if (listitems.count() == 1) {
+                // probably custom effect created before change to ';' as separator
+                listitems = pa.attribute("paramlist").split(',');
+            }
             QDomElement list = pa.firstChildElement("paramlistdisplay");
             QStringList listitemsdisplay;
-            if (!list.isNull()) listitemsdisplay = i18n(list.text().toUtf8().data()).split(',');
-            else listitemsdisplay = i18n(pa.attribute("paramlistdisplay").toUtf8().data()).split(',');
+            if (!list.isNull()) {
+                listitemsdisplay = i18n(list.text().toUtf8().data()).split(',');
+            } else {
+                listitemsdisplay = i18n(pa.attribute("paramlistdisplay").toUtf8().data()).split(',');
+            }
             if (listitemsdisplay.count() != listitems.count())
                 listitemsdisplay = listitems;
             lsval->list->setIconSize(QSize(30, 30));
@@ -363,14 +371,14 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, ItemInfo info, bool
                 KeyframeEdit *geo;
                 if (pa.attribute("widget") == "corners") {
                     // we want a corners-keyframe-widget
-                    CornersWidget *corners = new CornersWidget(m_monitor, pa, m_in, m_out, m_timecode, e.attribute("active_keyframe", "-1").toInt(), this);
+                    CornersWidget *corners = new CornersWidget(m_monitor, pa, m_in, m_out, m_timecode, d.attribute("active_keyframe", "-1").toInt(), this);
                     corners->slotShowScene(!disable);
                     connect(corners, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
                     connect(this, SIGNAL(effectStateChanged(bool)), corners, SLOT(slotShowScene(bool)));
                     connect(this, SIGNAL(syncEffectsPos(int)), corners, SLOT(slotSyncPosition(int)));
                     geo = static_cast<KeyframeEdit *>(corners);
                 } else {
-                    geo = new KeyframeEdit(pa, m_in, m_out, m_timecode, e.attribute("active_keyframe", "-1").toInt());
+                    geo = new KeyframeEdit(pa, m_in, m_out, m_timecode, d.attribute("active_keyframe", "-1").toInt());
                 }
                 m_vbox->addWidget(geo);
                 m_valueItems[paramName+"keyframe"] = geo;
@@ -407,7 +415,12 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, ItemInfo info, bool
             KisCurveWidget *curve = new KisCurveWidget(this);
             curve->setMaxPoints(pa.attribute("max").toInt());
             QList<QPointF> points;
-            int number = EffectsList::parameter(e, pa.attribute("number")).toInt();
+            int number;
+            if (d.attribute("version").toDouble() > 0.2) {
+                number = EffectsList::parameter(d, pa.attribute("number")).toDouble() * 10;
+            } else {
+                number = EffectsList::parameter(d, pa.attribute("number")).toInt();
+            }
             QString inName = pa.attribute("inpoints");
             QString outName = pa.attribute("outpoints");
             int start = pa.attribute("min").toInt();
@@ -416,7 +429,7 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, ItemInfo info, bool
                 in.replace("%i", QString::number(j));
                 QString out = outName;
                 out.replace("%i", QString::number(j));
-                points << QPointF(EffectsList::parameter(e, in).toDouble(), EffectsList::parameter(e, out).toDouble());
+                points << QPointF(EffectsList::parameter(d, in).toDouble(), EffectsList::parameter(d, out).toDouble());
             }
             if (!points.isEmpty())
                 curve->setCurve(KisCubicCurve(points));
@@ -434,7 +447,7 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, ItemInfo info, bool
 
             QString depends = pa.attribute("depends");
             if (!depends.isEmpty())
-                meetDependency(paramName, type, EffectsList::parameter(e, depends));
+                meetDependency(paramName, type, EffectsList::parameter(d, depends));
         } else if (type == "bezier_spline") {
             BezierSplineWidget *widget = new BezierSplineWidget(value, this);
             stretch = false;
@@ -443,7 +456,7 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, ItemInfo info, bool
             connect(widget, SIGNAL(modified()), this, SLOT(collectAllParameters()));
             QString depends = pa.attribute("depends");
             if (!depends.isEmpty())
-                meetDependency(paramName, type, EffectsList::parameter(e, depends));
+                meetDependency(paramName, type, EffectsList::parameter(d, depends));
 #ifdef QJSON
         } else if (type == "roto-spline") {
             RotoWidget *roto = new RotoWidget(value, m_monitor, info, m_timecode, this);
@@ -550,16 +563,17 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, ItemInfo info, bool
 wipeInfo EffectStackEdit::getWipeInfo(QString value)
 {
     wipeInfo info;
+    // Convert old geometry values that used a comma as separator
+    if (value.contains(',')) value.replace(',','/');
     QString start = value.section(';', 0, 0);
     QString end = value.section(';', 1, 1).section('=', 1, 1);
-
-    if (start.startsWith("-100%,0"))
+    if (start.startsWith("-100%/0"))
         info.start = LEFT;
-    else if (start.startsWith("100%,0"))
+    else if (start.startsWith("100%/0"))
         info.start = RIGHT;
-    else if (start.startsWith("0%,100%"))
+    else if (start.startsWith("0%/100%"))
         info.start = DOWN;
-    else if (start.startsWith("0%,-100%"))
+    else if (start.startsWith("0%/-100%"))
         info.start = UP;
     else
         info.start = CENTER;
@@ -569,13 +583,13 @@ wipeInfo EffectStackEdit::getWipeInfo(QString value)
     else
         info.startTransparency = 100;
 
-    if (end.startsWith("-100%,0"))
+    if (end.startsWith("-100%/0"))
         info.end = LEFT;
-    else if (end.startsWith("100%,0"))
+    else if (end.startsWith("100%/0"))
         info.end = RIGHT;
-    else if (end.startsWith("0%,100%"))
+    else if (end.startsWith("0%/100%"))
         info.end = DOWN;
-    else if (end.startsWith("0%,-100%"))
+    else if (end.startsWith("0%/-100%"))
         info.end = UP;
     else
         info.end = CENTER;
@@ -595,38 +609,38 @@ QString EffectStackEdit::getWipeString(wipeInfo info)
     QString end;
     switch (info.start) {
     case LEFT:
-        start = "-100%,0%:100%x100%";
+        start = "-100%/0%:100%x100%";
         break;
     case RIGHT:
-        start = "100%,0%:100%x100%";
+        start = "100%/0%:100%x100%";
         break;
     case DOWN:
-        start = "0%,100%:100%x100%";
+        start = "0%/100%:100%x100%";
         break;
     case UP:
-        start = "0%,-100%:100%x100%";
+        start = "0%/-100%:100%x100%";
         break;
     default:
-        start = "0%,0%:100%x100%";
+        start = "0%/0%:100%x100%";
         break;
     }
     start.append(':' + QString::number(info.startTransparency));
 
     switch (info.end) {
     case LEFT:
-        end = "-100%,0%:100%x100%";
+        end = "-100%/0%:100%x100%";
         break;
     case RIGHT:
-        end = "100%,0%:100%x100%";
+        end = "100%/0%:100%x100%";
         break;
     case DOWN:
-        end = "0%,100%:100%x100%";
+        end = "0%/100%:100%x100%";
         break;
     case UP:
-        end = "0%,-100%:100%x100%";
+        end = "0%/-100%:100%x100%";
         break;
     default:
-        end = "0%,0%:100%x100%";
+        end = "0%/0%:100%x100%";
         break;
     }
     end.append(':' + QString::number(info.endTransparency));
@@ -639,6 +653,7 @@ void EffectStackEdit::collectAllParameters()
     const QDomElement oldparam = m_params.cloneNode().toElement();
     QDomElement newparam = oldparam.cloneNode().toElement();
     QDomNodeList namenode = newparam.elementsByTagName("parameter");
+    QLocale locale;
 
     for (int i = 0; i < namenode.count() ; i++) {
         QDomNode pa = namenode.item(i);
@@ -661,7 +676,7 @@ void EffectStackEdit::collectAllParameters()
         QString setValue;
         if (type == "double" || type == "constant") {
             DoubleParameterWidget *doubleparam = (DoubleParameterWidget*)m_valueItems.value(paramName);
-            setValue = QString::number(doubleparam->getValue());
+            setValue = locale.toString(doubleparam->getValue());
         } else if (type == "list") {
             KComboBox *box = ((Listval*)m_valueItems.value(paramName))->list;
             setValue = box->itemData(box->currentIndex()).toString();
@@ -714,14 +729,18 @@ void EffectStackEdit::collectAllParameters()
             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(newparam, number, QString::number(points.count()));
+            if (oldparam.attribute("version").toDouble() > 0.2) {
+                EffectsList::setParameter(newparam, number, locale.toString(points.count() / 10.));
+            } else {
+                EffectsList::setParameter(newparam, 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));
                 QString out = outName;
                 out.replace("%i", QString::number(j + off));
-                EffectsList::setParameter(newparam, in, QString::number(points.at(j).x()));
-                EffectsList::setParameter(newparam, out, QString::number(points.at(j).y()));
+                EffectsList::setParameter(newparam, in, locale.toString(points.at(j).x()));
+                EffectsList::setParameter(newparam, out, locale.toString(points.at(j).y()));
             }
             QString depends = pa.attributes().namedItem("depends").nodeValue();
             if (!depends.isEmpty())