Commit 3315ad4f authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Ensure we don't insert thousand separator in number conversion, and only send...

Ensure we don't insert thousand separator in number conversion, and only send integer coordinates on keyframe import.
Related to #510
parent 43bcc553
......@@ -878,6 +878,7 @@ QVariant KeyframeModel::updateInterpolated(const QVariant &interpValue, double v
{
QStringList vals = interpValue.toString().split(QLatin1Char(' '));
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
if (!vals.isEmpty()) {
vals[vals.size() - 1] = locale.toString(val);
}
......@@ -1105,7 +1106,6 @@ QList<QPoint> KeyframeModel::getRanges(const QString &animData, const std::share
{
Mlt::Properties mlt_prop;
model->passProperties(mlt_prop);
QLocale locale;
mlt_prop.set("key", animData.toUtf8().constData());
// This is a fake query to force the animation to be parsed
(void)mlt_prop.anim_get_int("key", 0, 0);
......
......@@ -34,6 +34,7 @@ AssetCommand::AssetCommand(const std::shared_ptr<AssetParameterModel> &model, co
, m_stamp(QTime::currentTime())
{
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
m_name = m_model->data(index, AssetParameterModel::NameRole).toString();
const QString id = model->getAssetId();
if (EffectsRepository::get()->exists(id)) {
......@@ -82,6 +83,7 @@ AssetMultiCommand::AssetMultiCommand(const std::shared_ptr<AssetParameterModel>
, m_stamp(QTime::currentTime())
{
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
qDebug()<<"CREATING MULTIPLE COMMAND!!!\nVALUES: "<<m_values;
m_name = m_model->data(indexes.first(), AssetParameterModel::NameRole).toString();
const QString id = model->getAssetId();
......
......@@ -50,6 +50,7 @@ AssetParameterModel::AssetParameterModel(std::unique_ptr<Mlt::Properties> asset,
QChar separator, oldSeparator;
// Check locale, default effects xml has no LC_NUMERIC defined and always uses the C locale
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
if (assetXml.hasAttribute(QStringLiteral("LC_NUMERIC"))) {
QLocale effectLocale = QLocale(assetXml.attribute(QStringLiteral("LC_NUMERIC")));
if (QLocale::c().decimalPoint() != effectLocale.decimalPoint()) {
......@@ -598,7 +599,6 @@ QVector<QPair<QString, QVariant>> AssetParameterModel::getAllParameters() const
QJsonDocument AssetParameterModel::toJson(bool includeFixed) const
{
QJsonArray list;
QLocale locale;
if (includeFixed) {
for (const auto &fixed : m_fixedParams) {
QJsonObject currentParam;
......@@ -813,6 +813,7 @@ const QVector<QPair<QString, QVariant>> AssetParameterModel::loadPreset(const QS
void AssetParameterModel::setParameters(const QVector<QPair<QString, QVariant>> &params)
{
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
for (const auto &param : params) {
if (param.second.type() == QVariant::Double) {
setParameter(param.first, locale.toString(param.second.toDouble()), false);
......
......@@ -136,6 +136,7 @@ void AssetParameterView::setModel(const std::shared_ptr<AssetParameterModel> &mo
QVector<QPair<QString, QVariant>> AssetParameterView::getDefaultValues() const
{
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
QVector<QPair<QString, QVariant>> values;
for (int i = 0; i < m_model->rowCount(); ++i) {
QModelIndex index = m_model->index(i, 0);
......
......@@ -779,7 +779,6 @@ void AnimationWidget::addParameter(QModelIndex ix)
void AnimationWidget::buildSliderWidget(const QString &paramTag, QModelIndex ix)
{
QLocale locale;
QString paramName = i18n(m_model->data(ix, Qt::DisplayRole).toString().toUtf8().data());
QString comment = m_model->data(ix, AssetParameterModel::CommentRole).toString();
if (!comment.isEmpty()) {
......@@ -1072,6 +1071,7 @@ const QMap<QString, QString> AnimationWidget::getAnimation()
mlt_keyframe_type type;
QString key;
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
QStringList result;
int duration = m_outPoint;
for (int j = 0; j < m_animController.key_count(); ++j) {
......@@ -1413,7 +1413,6 @@ void AnimationWidget::reload(const QString &tag, const QString &data)
}
// Also add keyframes positions in other parameters
QStringList paramNames = m_doubleWidgets.keys();
QLocale locale;
m_animController = m_animProperties.get_animation(tag.toUtf8().constData());
for (int i = 0; i < paramNames.count(); i++) {
const QString &currentParam = paramNames.at(i);
......
......@@ -648,6 +648,7 @@ void KeyframeImport::importSelectedData()
QPoint rectOffset;
int finalAlign = m_alignCombo->currentIndex();
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
for (const auto &ix : m_indexes) {
// update keyframes in other indexes
KeyframeModel *km = kfrModel->getKeyModel(ix);
......@@ -707,27 +708,27 @@ void KeyframeImport::importSelectedData()
}
switch (convertMode) {
case ImportRoles::FullGeometry:
kfrData[0] = locale.toString(rect.x);
kfrData[1] = locale.toString(rect.y);
kfrData[2] = locale.toString(rect.w);
kfrData[3] = locale.toString(rect.h);
kfrData[0] = locale.toString((int)rect.x);
kfrData[1] = locale.toString((int)rect.y);
kfrData[2] = locale.toString((int)rect.w);
kfrData[3] = locale.toString((int)rect.h);
break;
case ImportRoles::Position:
kfrData[0] = locale.toString(rect.x);
kfrData[1] = locale.toString(rect.y);
kfrData[0] = locale.toString((int)rect.x);
kfrData[1] = locale.toString((int)rect.y);
break;
case ImportRoles::SimpleValue:
case ImportRoles::XOnly:
kfrData[0] = locale.toString(rect.x);
kfrData[0] = locale.toString((int)rect.x);
break;
case ImportRoles::YOnly:
kfrData[1] = locale.toString(rect.y);
kfrData[1] = locale.toString((int)rect.y);
break;
case ImportRoles::WidthOnly:
kfrData[2] = locale.toString(rect.w);
kfrData[2] = locale.toString((int)rect.w);
break;
case ImportRoles::HeightOnly:
kfrData[3] = locale.toString(rect.h);
kfrData[3] = locale.toString((int)rect.h);
break;
default:
break;
......
......@@ -43,7 +43,6 @@ ListParamWidget::ListParamWidget(std::shared_ptr<AssetParameterModel> model, QMo
// setup the name
m_labelName->setText(m_model->data(m_index, Qt::DisplayRole).toString());
slotRefresh();
QLocale locale;
// emit the signal of the base class when appropriate
// The connection is ugly because the signal "currentIndexChanged" is overloaded in QComboBox
......@@ -130,6 +129,7 @@ void ListParamWidget::slotRefresh()
names = values;
}
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
for (int i = 0; i < names.count(); i++) {
QString val = values.at(i);
bool ok;
......
......@@ -1601,6 +1601,7 @@ bool DocumentValidator::upgrade(double version, const double currentVersion)
}
QStringList parsedValues;
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
QMapIterator<int, double> l(values);
if (id == QLatin1String("volume")) {
// convert old volume range (0-300) to new dB values (-60-60)
......@@ -2221,6 +2222,7 @@ QString DocumentValidator::factorizeGeomValue(const QString &value, double facto
const QStringList vals = value.split(QLatin1Char(';'));
QString result;
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
for (int i = 0; i < vals.count(); i++) {
const QString &s = vals.at(i);
QString key = s.section(QLatin1Char('='), 0, 0);
......
......@@ -225,6 +225,7 @@ QDomElement EffectStackModel::toXml(QDomDocument &document)
}
QVector<QPair<QString, QVariant>> params = sourceEffect->getAllParameters();
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
for (const auto &param : params) {
if (param.second.type() == QVariant::Double) {
Xml::setXmlProperty(sub, param.first, locale.toString(param.second.toDouble()));
......@@ -263,6 +264,7 @@ QDomElement EffectStackModel::rowToXml(int row, QDomDocument &document)
}
QVector<QPair<QString, QVariant>> params = sourceEffect->getAllParameters();
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
for (const auto &param : params) {
if (param.second.type() == QVariant::Double) {
Xml::setXmlProperty(sub, param.first, locale.toString(param.second.toDouble()));
......
......@@ -434,6 +434,7 @@ void CollapsibleEffectView::slotSaveEffect()
QVector<QPair<QString, QVariant>> currentValues = m_model->getAllParameters();
QMap<QString, QString> values;
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
for (const auto &param : currentValues) {
if (param.second.type() == QVariant::Double) {
values.insert(param.first, locale.toString(param.second.toDouble()));
......
......@@ -128,7 +128,6 @@ int CutClipJob::prepareJob(const std::shared_ptr<JobManager> &ptr, const std::ve
bool CutClipJob::startJob()
{
QLocale locale;
bool result;
if (m_destUrl == m_sourceUrl) {
m_errorMessage.append(i18n("You cannot overwrite original clip."));
......
......@@ -84,6 +84,7 @@ QHash<ProjectClip *, AbstractClipJob *> FilterJob::prepareJob(const QList<Projec
multipleSelection, QApplication::activeWindow());
if (d->exec() == QDialog::Accepted) {
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
QString speedString = QStringLiteral("timewarp:%1:").arg(locale.toString(d->speed() / 100));
QDir destFolder;
if (multipleSelection) {
......
......@@ -442,6 +442,7 @@ ClipPropertiesController::ClipPropertiesController(ClipController *controller, Q
if (m_type == ClipType::AV || m_type == ClipType::Video) {
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
// Fps
QString force_fps = m_properties->get("force_fps");
......@@ -819,6 +820,7 @@ void ClipPropertiesController::slotEnableForce(int state)
QString param = box->objectName();
QMap<QString, QString> properties;
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
if (state == Qt::Unchecked) {
// The force property was disable, remove it / reset default if necessary
if (param == QLatin1String("force_duration")) {
......@@ -898,6 +900,7 @@ void ClipPropertiesController::slotValueChanged(double value)
QString param = box->objectName().section(QLatin1Char('_'), 0, -2);
QMap<QString, QString> properties;
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
properties.insert(param, locale.toString(value));
emit updateClipProperties(m_id, m_originalProperties, properties);
m_originalProperties = properties;
......@@ -927,6 +930,7 @@ void ClipPropertiesController::slotAspectValueChanged(int)
properties.insert(QStringLiteral("force_aspect_den"), QString::number(spin2->value()));
properties.insert(QStringLiteral("force_aspect_num"), QString::number(spin->value()));
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
properties.insert(QStringLiteral("force_aspect_ratio"), locale.toString((double)spin->value() / spin2->value()));
emit updateClipProperties(m_id, m_originalProperties, properties);
m_originalProperties = properties;
......
......@@ -101,6 +101,7 @@ std::unordered_map<QString, QString> ClipStabilize::filterParams() const
QVector<QPair<QString, QVariant>> result = m_assetModel->getAllParameters();
std::unordered_map<QString, QString> params;
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
for (const auto &it : result) {
if (it.second.type() == QVariant::Double) {
......
......@@ -415,6 +415,7 @@ const QString GeometryWidget::getValue() const
{
if (m_opacity) {
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
return QStringLiteral("%1 %2 %3 %4 %5")
.arg(m_spinX->value())
.arg(m_spinY->value())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment