]> git.sesse.net Git - kdenlive/blobdiff - src/profilesdialog.cpp
Allow effects to have parameters depending on the project's profile properties (width...
[kdenlive] / src / profilesdialog.cpp
index d86ee605db75aad7ac27b99adf43608269d8cb20..fc2a6421e6f6ece490d3fc272f998b7335ca193a 100644 (file)
@@ -228,6 +228,20 @@ MltVideoProfile ProfilesDialog::getVideoProfile(QString name)
     return result;
 }
 
+// static
+double ProfilesDialog::getStringEval(const MltVideoProfile &profile, QString eval)
+{
+    double result;
+    eval.replace("%width", QString::number(profile.width));
+    eval.replace("%height", QString::number(profile.height));
+    if (eval.contains('/')) result = (double) eval.section('/', 0, 0).toInt() / eval.section('/', 1, 1).toInt();
+    else if (eval.contains('*')) result = (double) eval.section('*', 0, 0).toInt() * eval.section('*', 1, 1).toInt();
+    else if (eval.contains('+')) result = (double) eval.section('+', 0, 0).toInt() + eval.section('+', 1, 1).toInt();
+    else if (eval.contains('-')) result = (double) eval.section('-', 0, 0).toInt() - eval.section('-', 1, 1).toInt();
+    else result = eval.toDouble();
+    return result;
+}
+
 
 // static
 bool ProfilesDialog::existingProfileDescription(const QString &desc)