]> git.sesse.net Git - kdenlive/blobdiff - src/effectstackedit.cpp
Revert commit 5845. The consumer producer does not automatically get invoked.
[kdenlive] / src / effectstackedit.cpp
index ad4df484dca03fa0cf5e70f9cb5164e1941ce38e..2ed0bc631b4c2e2c24c2585370b9fee01ecfd649 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));
@@ -122,9 +122,9 @@ void EffectStackEdit::setFrameSize(QPoint p)
     QDomNodeList namenode = m_params.elementsByTagName("parameter");
     for (int i = 0; i < namenode.count() ; i++) {
         QDomNode pa = namenode.item(i);
-        QDomNode na = pa.firstChildElement("name");
+        QDomElement na = pa.firstChildElement("name");
         QString type = pa.attributes().namedItem("type").nodeValue();
-        QString paramName = i18n(na.toElement().text().toUtf8().data());
+        QString paramName = na.isNull() ? pa.attributes().namedItem("name").nodeValue() : i18n(na.text().toUtf8().data());
 
         if (type == "geometry") {
             if (!KdenliveSettings::on_monitor_effects()) {
@@ -148,9 +148,9 @@ void EffectStackEdit::updateTimecodeFormat()
     QDomNodeList namenode = m_params.elementsByTagName("parameter");
     for (int i = 0; i < namenode.count() ; i++) {
         QDomNode pa = namenode.item(i);
-        QDomNode na = pa.firstChildElement("name");
+        QDomElement na = pa.firstChildElement("name");
         QString type = pa.attributes().namedItem("type").nodeValue();
-        QString paramName = i18n(na.toElement().text().toUtf8().data());
+        QString paramName = na.isNull() ? pa.attributes().namedItem("name").nodeValue() : i18n(na.text().toUtf8().data());
 
         if (type == "geometry") {
             if (KdenliveSettings::on_monitor_effects()) {
@@ -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);
@@ -247,7 +249,7 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, ItemInfo info, bool
         QDomElement na = pa.firstChildElement("name");
         QDomElement commentElem = pa.firstChildElement("comment");
         QString type = pa.attribute("type");
-        QString paramName = i18n(na.text().toUtf8().data());
+        QString paramName = na.isNull() ? pa.attribute("name") : i18n(na.text().toUtf8().data());
         QString comment;
         if (!commentElem.isNull())
             comment = i18n(commentElem.text().toUtf8().data());
@@ -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();
 
@@ -274,16 +276,23 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, ItemInfo info, bool
                     pa.attribute("default").toDouble(), comment, -1, pa.attribute("suffix"), pa.attribute("decimals").toInt(), this);
             m_vbox->addWidget(doubleparam);
             m_valueItems[paramName] = doubleparam;
-            connect(doubleparam, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
+            connect(doubleparam, SIGNAL(valueChanged(double)), this, SLOT(collectAllParameters()));
             connect(this, SIGNAL(showComments(bool)), doubleparam, SLOT(slotShowComment(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,15 +646,17 @@ QString EffectStackEdit::getWipeString(wipeInfo info)
 void EffectStackEdit::collectAllParameters()
 {
     if (m_valueItems.isEmpty() || m_params.isNull()) return;
+    QLocale locale;
+    locale.setNumberOptions(QLocale::OmitGroupSeparator);
     const QDomElement oldparam = m_params.cloneNode().toElement();
     QDomElement newparam = oldparam.cloneNode().toElement();
     QDomNodeList namenode = newparam.elementsByTagName("parameter");
 
     for (int i = 0; i < namenode.count() ; i++) {
         QDomNode pa = namenode.item(i);
-        QDomNode na = pa.firstChildElement("name");
+        QDomElement na = pa.firstChildElement("name");
         QString type = pa.attributes().namedItem("type").nodeValue();
-        QString paramName = i18n(na.toElement().text().toUtf8().data());
+        QString paramName = na.isNull() ? pa.attributes().namedItem("name").nodeValue() : i18n(na.text().toUtf8().data());
         if (type == "complex")
             paramName.append("complex");
         else if (type == "position")
@@ -661,7 +673,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 +732,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())