]> git.sesse.net Git - kdenlive/blobdiff - src/effectstackedit.cpp
Fix possible crash in DVD wizard chapters:
[kdenlive] / src / effectstackedit.cpp
index a2d2b5ff1e07e45b81a26514f4d9f8ddee8d6241..955f0c55ff73f7285d7ec07db5b27dd5e9444308 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));
@@ -233,8 +233,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 = e.attribute("start").toInt();
+    int maxFrame = e.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 +263,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 +281,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));
@@ -550,16 +559,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 +579,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 +605,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));
@@ -636,6 +646,7 @@ QString EffectStackEdit::getWipeString(wipeInfo info)
 void EffectStackEdit::collectAllParameters()
 {
     if (m_valueItems.isEmpty() || m_params.isNull()) return;
+    QLocale locale;
     const QDomElement oldparam = m_params.cloneNode().toElement();
     QDomElement newparam = oldparam.cloneNode().toElement();
     QDomNodeList namenode = newparam.elementsByTagName("parameter");
@@ -661,7 +672,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();
@@ -720,8 +731,8 @@ void EffectStackEdit::collectAllParameters()
                 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())