X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fprofilesdialog.cpp;h=68aff4698fce879418471f83f7a5890c307b4ab1;hb=2b4a438e09bf373960bcd127dcf6701a74b3ee22;hp=c8c4a0dd80c5eb39da00a99446e560c98bc48f7d;hpb=2ca42e6e5c050248a2994f4acd6ce111c1a16f34;p=kdenlive diff --git a/src/profilesdialog.cpp b/src/profilesdialog.cpp index c8c4a0dd..68aff469 100644 --- a/src/profilesdialog.cpp +++ b/src/profilesdialog.cpp @@ -26,7 +26,9 @@ #include #include +#include #include +#include ProfilesDialog::ProfilesDialog(QWidget * parent) : QDialog(parent), @@ -281,17 +283,14 @@ MltVideoProfile ProfilesDialog::getVideoProfile(QString name) } // static -double ProfilesDialog::getStringEval(const MltVideoProfile &profile, QString eval) +double ProfilesDialog::getStringEval(const MltVideoProfile &profile, QString eval, QPoint frameSize) { - 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; + QScriptEngine sEngine; + sEngine.globalObject().setProperty("maxWidth", profile.width > frameSize.x() ? profile.width : frameSize.x()); + sEngine.globalObject().setProperty("maxHeight", profile.height > frameSize.y() ? profile.height : frameSize.y()); + sEngine.globalObject().setProperty("width", profile.width); + sEngine.globalObject().setProperty("height", profile.height); + return sEngine.evaluate(eval.remove('%')).toNumber(); } @@ -570,7 +569,7 @@ void ProfilesDialog::slotUpdateDisplay(QString currentProfile) m_view.profiles_list->blockSignals(false); return; } - + QLocale locale; m_selectedProfileIndex = m_view.profiles_list->currentIndex(); if (currentProfile.isEmpty()) currentProfile = m_view.profiles_list->itemData(m_view.profiles_list->currentIndex()).toString(); m_isCustomProfile = currentProfile.contains('/'); @@ -590,9 +589,9 @@ void ProfilesDialog::slotUpdateDisplay(QString currentProfile) m_view.frame_den->setValue(values.value("frame_rate_den").toInt()); m_view.progressive->setChecked(values.value("progressive").toInt()); if (values.value("progressive").toInt()) { - m_view.fields->setText(QString::number((double) values.value("frame_rate_num").toInt() / values.value("frame_rate_den").toInt(), 'f', 2)); + m_view.fields->setText(locale.toString((double) values.value("frame_rate_num").toInt() / values.value("frame_rate_den").toInt(), 'f', 2)); } else { - m_view.fields->setText(QString::number((double) 2 * values.value("frame_rate_num").toInt() / values.value("frame_rate_den").toInt(), 'f', 2)); + m_view.fields->setText(locale.toString((double) 2 * values.value("frame_rate_num").toInt() / values.value("frame_rate_den").toInt(), 'f', 2)); } int colorix = m_view.colorspace->findData(values.value("colorspace").toInt());