Commit 4fc20a3f authored by Simon Eugster's avatar Simon Eugster

Review remaining occurrences of QLocale

Related: #713
parent 2b9f415c
Pipeline #24551 passed with stage
in 18 minutes and 35 seconds
......@@ -89,7 +89,7 @@ AssetMultiCommand::AssetMultiCommand(const std::shared_ptr<AssetParameterModel>
}
for (QModelIndex ix : m_indexes) {
QVariant previousVal = m_model->data(ix, AssetParameterModel::ValueRole);
m_oldValues << previousVal.toString());
m_oldValues << previousVal.toString();
}
}
......
......@@ -29,7 +29,6 @@
#include <QDir>
#include <QJsonArray>
#include <QJsonObject>
#include <QLocale>
#include <QString>
#include <effects/effectsrepository.hpp>
#define DEBUG_LOCALE false
......@@ -52,7 +51,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
if (assetXml.hasAttribute(QStringLiteral("LC_NUMERIC"))) {
QLocale effectLocale = QLocale(assetXml.attribute(QStringLiteral("LC_NUMERIC")));
QLocale effectLocale = QLocale(assetXml.attribute(QStringLiteral("LC_NUMERIC"))); // Check if effect has a special locale → probably OK
if (QLocale::c().decimalPoint() != effectLocale.decimalPoint()) {
needsLocaleConversion = true;
separator = QLocale::c().decimalPoint();
......
......@@ -21,7 +21,6 @@
#define LUMALIFTGAINPARAMWIDGET_H
#include "abstractparamwidget.hpp"
#include <QLocale>
#include <QWidget>
#include <QDomElement>
......
......@@ -286,7 +286,7 @@ MixerManager *Core::mixer()
void Core::initLocale()
{
qDebug() << "Using modified system locale without group separator for numbers";
QLocale systemLocale = QLocale();
QLocale systemLocale = QLocale(); // For disabling group separator by default → OK
systemLocale.setNumberOptions(QLocale::OmitGroupSeparator);
QLocale::setDefault(systemLocale);
}
......
......@@ -572,6 +572,9 @@ QDomDocument KdenliveDoc::xmlSceneList(const QString &scene)
bool KdenliveDoc::saveSceneList(const QString &path, const QString &scene)
{
QLocale currentLocale; // For restoring after XML export
qDebug() << "Current locale is " << currentLocale;
QLocale::setDefault(QLocale::c()); // Not sure if helpful …
QDomDocument sceneList = xmlSceneList(scene);
if (sceneList.isNull()) {
// Make sure we don't save if scenelist is corrupted
......@@ -618,8 +621,6 @@ bool KdenliveDoc::saveSceneList(const QString &path, const QString &scene)
return false;
}
QLocale currentLocale;
qDebug() << "Current locale is " << currentLocale;
const QByteArray sceneData = sceneList.toString().toUtf8();
QLocale::setDefault(currentLocale);
......
......@@ -224,14 +224,8 @@ 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()));
} else {
Xml::setXmlProperty(sub, param.first, param.second.toString());
}
Xml::setXmlProperty(sub, param.first, param.second.toString());
}
container.appendChild(sub);
}
......@@ -263,14 +257,8 @@ 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()));
} else {
Xml::setXmlProperty(sub, param.first, param.second.toString());
}
Xml::setXmlProperty(sub, param.first, param.second.toString());
}
container.appendChild(sub);
return container;
......
......@@ -65,17 +65,12 @@ CollapsibleEffectView::CollapsibleEffectView(const std::shared_ptr<EffectItemMod
decoframe->setObjectName(QStringLiteral("decoframegroup"));
}
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
// decoframe->setProperty("active", true);
// m_info.fromString(effect.attribute(QStringLiteral("kdenlive_info")));
// setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
buttonUp->setIcon(QIcon::fromTheme(QStringLiteral("kdenlive-up")));
buttonUp->setToolTip(i18n("Move effect up"));
buttonDown->setIcon(QIcon::fromTheme(QStringLiteral("kdenlive-down")));
buttonDown->setToolTip(i18n("Move effect down"));
buttonDel->setIcon(QIcon::fromTheme(QStringLiteral("kdenlive-deleffect")));
buttonDel->setToolTip(i18n("Delete effect"));
// buttonUp->setEnabled(canMoveUp);
// buttonDown->setEnabled(!lastEffect);
if (effectId == QLatin1String("speed")) {
// Speed effect is a "pseudo" effect, cannot be moved
......@@ -87,9 +82,6 @@ CollapsibleEffectView::CollapsibleEffectView(const std::shared_ptr<EffectItemMod
setAcceptDrops(true);
}
// checkAll->setToolTip(i18n("Enable/Disable all effects"));
// buttonShowComments->setIcon(QIcon::fromTheme("help-about"));
// buttonShowComments->setToolTip(i18n("Show additional information for the parameters"));
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
m_collapse = new KDualAction(i18n("Collapse Effect"), i18n("Expand Effect"), this);
m_collapse->setActiveIcon(QIcon::fromTheme(QStringLiteral("arrow-right")));
......@@ -449,14 +441,8 @@ void CollapsibleEffectView::slotSaveEffect()
// Adjust param values
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()));
} else {
values.insert(param.first, param.second.toString());
}
values.insert(param.first, param.second.toString());
}
QDomNodeList params = effect.elementsByTagName("parameter");
for (int i = 0; i < params.count(); ++i) {
......@@ -473,12 +459,7 @@ void CollapsibleEffectView::slotSaveEffect()
effect.setAttribute(QStringLiteral("id"), name);
QString masterType = effect.attribute(QLatin1String("type"));
effect.setAttribute(QStringLiteral("type"), (masterType == QLatin1String("audio") || masterType == QLatin1String("customAudio")) ? QStringLiteral("customAudio") : QStringLiteral("customVideo"));
/*
if (m_paramWidget) {
int in = m_paramWidget->range().x();
EffectsController::offsetKeyframes(in, effect);
}
*/
QDomElement effectname = effect.firstChildElement(QStringLiteral("name"));
effect.removeChild(effectname);
effectname = doc.createElement(QStringLiteral("name"));
......@@ -509,18 +490,12 @@ QDomDocument CollapsibleEffectView::toXml() const
QDomElement effect = doc.createElement(QStringLiteral("effect"));
doc.appendChild(effect);
effect.setAttribute(QStringLiteral("id"), effectId);
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
for (const auto &param : currentValues) {
QDomElement xmlParam = doc.createElement(QStringLiteral("property"));
effect.appendChild(xmlParam);
xmlParam.setAttribute(QStringLiteral("name"), param.first);
QString value;
if (param.second.type() == QVariant::Double) {
value = locale.toString(param.second.toDouble());
} else {
value = param.second.toString();
}
value = param.second.toString();
QDomText val = doc.createTextNode(value);
xmlParam.appendChild(val);
}
......@@ -799,25 +774,6 @@ void CollapsibleEffectView::dropEvent(QDropEvent *event)
}
event->setDropAction(Qt::MoveAction);
event->accept();
/*
EffectInfo info;
info.fromString(subeffects.at(0).toElement().attribute(QStringLiteral("kdenlive_info")));
if (info.groupIndex >= 0) {
// Moving group
QList<int> effectsIds;
// Collect moved effects ids
for (int i = 0; i < subeffects.count(); ++i) {
QDomElement effect = subeffects.at(i).toElement();
effectsIds << effect.attribute(QStringLiteral("kdenlive_ix")).toInt();
}
// emit moveEffect(effectsIds, currentEffectIx, info.groupIndex, info.groupName);
} else {
// group effect dropped from effect list
if (m_info.groupIndex > -1) {
// TODO: Should we merge groups??
}
emit addEffect(e);
}*/
emit addEffect(e);
return;
}
......
......@@ -83,9 +83,7 @@ QHash<ProjectClip *, AbstractClipJob *> FilterJob::prepareJob(const QList<Projec
: QUrl::fromLocalFile(sources.constFirst()).adjusted(QUrl::RemoveFilename),
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));
QString speedString = QStringLiteral("timewarp:%1:").arg(QString::number(d->speed() / 100, 'f'));
QDir destFolder;
if (multipleSelection) {
destFolder = QDir(d->selectedUrl().toLocalFile());
......
......@@ -44,7 +44,7 @@ QPair<QLocale, LocaleHandling::MatchType> LocaleHandling::getQLocaleForDecimalPo
const QList<QLocale> list = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale().script(), QLocale::AnyCountry);
QLocale matching = QLocale::c();
QLocale locale;
QLocale locale; // Best matching locale
MatchType matchType = MatchType::NoMatch;
for (const QLocale &loc : list) {
......
......@@ -453,9 +453,6 @@ 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");
m_originalProperties.insert(QStringLiteral("force_fps"), force_fps.isEmpty() ? QStringLiteral("-") : force_fps);
......@@ -471,7 +468,7 @@ ClipPropertiesController::ClipPropertiesController(ClipController *controller, Q
if (force_fps.isEmpty()) {
spin->setValue(controller->originalFps());
} else {
spin->setValue(locale.toDouble(force_fps));
spin->setValue(force_fps.toDouble());
}
connect(box, &QAbstractButton::toggled, spin, &QWidget::setEnabled);
box->setChecked(!force_fps.isEmpty());
......@@ -855,12 +852,11 @@ ClipPropertiesController::ClipPropertiesController(ClipController *controller, Q
spinSync->setValue(qRound(1000 * m_sourceProperties.get_double("video_delay")));
spinSync->setObjectName(QStringLiteral("video_delay"));
if (spinSync->value() != 0) {
m_originalProperties.insert(QStringLiteral("video_delay"), locale.toString(m_sourceProperties.get_double("video_delay")));
m_originalProperties.insert(QStringLiteral("video_delay"), QString::number(m_sourceProperties.get_double("video_delay"), 'f'));
}
//QObject::connect(spinSync, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [this, spinSync]() {
QObject::connect(spinSync, &QSpinBox::editingFinished, [this, spinSync, locale]() {
QObject::connect(spinSync, &QSpinBox::editingFinished, [this, spinSync]() {
QMap<QString, QString> properties;
properties.insert(QStringLiteral("video_delay"), locale.toString(spinSync->value() / 1000.));
properties.insert(QStringLiteral("video_delay"), QString::number(spinSync->value() / 1000., 'f'));
emit updateClipProperties(m_id, m_originalProperties, properties);
m_originalProperties = properties;
});
......@@ -1053,8 +1049,6 @@ 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")) {
......@@ -1090,7 +1084,7 @@ void ClipPropertiesController::slotEnableForce(int state)
if (!spin) {
return;
}
properties.insert(param, locale.toString(spin->value()));
properties.insert(param, QString::number(spin->value(), 'f'));
} else if (param == QLatin1String("threads")) {
auto *spin = findChild<QSpinBox *>(param + QStringLiteral("_value"));
if (!spin) {
......@@ -1115,7 +1109,7 @@ void ClipPropertiesController::slotEnableForce(int state)
}
properties.insert(QStringLiteral("force_aspect_den"), QString::number(spin2->value()));
properties.insert(QStringLiteral("force_aspect_num"), QString::number(spin->value()));
properties.insert(QStringLiteral("force_aspect_ratio"), locale.toString((double)spin->value() / spin2->value()));
properties.insert(QStringLiteral("force_aspect_ratio"), QString::number((double)spin->value() / spin2->value(), 'f'));
}
}
if (properties.isEmpty()) {
......@@ -1133,9 +1127,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));
properties.insert(param, QString::number(value, 'f'));
emit updateClipProperties(m_id, m_originalProperties, properties);
m_originalProperties = properties;
}
......@@ -1163,9 +1155,7 @@ void ClipPropertiesController::slotAspectValueChanged(int)
QMap<QString, QString> properties;
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()));
properties.insert(QStringLiteral("force_aspect_ratio"), QString::number((double)spin->value() / spin2->value(), 'f'));
emit updateClipProperties(m_id, m_originalProperties, properties);
m_originalProperties = properties;
}
......
......@@ -100,15 +100,9 @@ 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) {
params[it.first] = locale.toString(it.second.toDouble());
} else {
params[it.first] = it.second.toString();
}
params[it.first] = it.second.toString();
}
return params;
}
......
......@@ -139,7 +139,7 @@ ProfileWidget::~ProfileWidget() = default;
void ProfileWidget::refreshFpsCombo()
{
QLocale locale;
QLocale locale; // Used for UI → OK
QVariant currentValue;
if (m_fpsFilt->count() > 1) {
// remember last selected value
......
......@@ -215,7 +215,7 @@ QImage Vectorscope::renderHUD(uint)
{
QImage hud;
QLocale locale;
QLocale locale; // Used for UI → OK
locale.setNumberOptions(QLocale::OmitGroupSeparator);
if (m_mouseWithinWidget) {
// Mouse moved: Draw a circle over the scope
......@@ -494,7 +494,7 @@ QImage Vectorscope::renderBackground(uint)
void Vectorscope::slotGainChanged(int newval)
{
QLocale locale;
QLocale locale; // Used for UI → OK
locale.setNumberOptions(QLocale::OmitGroupSeparator);
m_gain = 1 + (float)newval / 10;
m_ui->lblGain->setText(locale.toString(m_gain, 'f', 1) + QLatin1Char('x'));
......
......@@ -295,9 +295,7 @@ const QString Timecode::getTimecodeFrames(const GenTime &time) const
const QString Timecode::getTimecodeSeconds(const GenTime &time) const
{
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
return locale.toString(time.seconds());
return QString::number(time.seconds(), 'f');
}
const QString Timecode::getTimecodeDropFrame(const GenTime &time) const
......
......@@ -775,7 +775,6 @@ void ClipModel::setFakePosition(int fid)
QDomElement ClipModel::toXml(QDomDocument &document)
{
QLocale locale;
QDomElement container = document.createElement(QStringLiteral("clip"));
container.setAttribute(QStringLiteral("binid"), m_binClipId);
container.setAttribute(QStringLiteral("id"), m_id);
......@@ -800,7 +799,7 @@ QDomElement ClipModel::toXml(QDomDocument &document)
}
}
}
container.setAttribute(QStringLiteral("speed"), locale.toString(m_speed));
container.setAttribute(QStringLiteral("speed"), QString::number(m_speed, 'f'));
container.setAttribute(QStringLiteral("audioStream"), getIntProperty(QStringLiteral("audio_index")));
if (!qFuzzyCompare(m_speed, 1.)) {
container.setAttribute(QStringLiteral("warp_pitch"), getIntProperty(QStringLiteral("warp_pitch")));
......
......@@ -1633,7 +1633,6 @@ bool TimelineFunctions::pasteTimelineClips(const std::shared_ptr<TimelineItemMod
int offset = copiedItems.documentElement().attribute(QStringLiteral("offset")).toInt();
bool res = true;
QLocale locale;
std::unordered_map<int, int> correspondingIds;
for (int i = 0; i < clips.count(); i++) {
QDomElement prod = clips.at(i).toElement();
......@@ -1653,7 +1652,7 @@ bool TimelineFunctions::pasteTimelineClips(const std::shared_ptr<TimelineItemMod
return false;
}
int pos = prod.attribute(QStringLiteral("position")).toInt() - offset;
double speed = locale.toDouble(prod.attribute(QStringLiteral("speed")));
double speed = prod.attribute(QStringLiteral("speed")).toDouble();
bool warp_pitch = false;
if (!qFuzzyCompare(speed, 1.)) {
warp_pitch = prod.attribute(QStringLiteral("warp_pitch")).toInt();
......@@ -1772,7 +1771,6 @@ QDomDocument TimelineFunctions::extractClip(const std::shared_ptr<TimelineItemMo
container.setAttribute(QStringLiteral("offset"), pos);
container.setAttribute(QStringLiteral("documentid"), QStringLiteral("000000"));
// Process producers
QLocale locale;
QList <int> processedProducers;
QMap <QString, int> producerMap;
QMap <QString, double> producerSpeed;
......@@ -1818,7 +1816,7 @@ QDomDocument TimelineFunctions::extractClip(const std::shared_ptr<TimelineItemMo
QString mltService = Xml::getXmlProperty(currentProd, QStringLiteral("mlt_service"));
if (mltService == QLatin1String("timewarp")) {
// Speed producer
double speed = locale.toDouble(Xml::getXmlProperty(currentProd, QStringLiteral("warp_speed")));
double speed = Xml::getXmlProperty(currentProd, QStringLiteral("warp_speed")).toDouble();
Xml::setXmlProperty(currentProd, QStringLiteral("mlt_service"), QStringLiteral("avformat"));
producerSpeedResource.insert(Xml::getXmlProperty(currentProd, QLatin1String("resource")), clipId);
qDebug()<<"===== CLIP SPEED RESOURCE: "<<Xml::getXmlProperty(currentProd, QLatin1String("resource"))<<" = "<<clipId;
......
......@@ -2089,11 +2089,6 @@ void TitleWidget::setXml(const QDomDocument &doc, const QString &id)
m_missingMessage->animatedShow();
}
title_duration->setText(m_tc.getTimecode(GenTime(duration, m_fps)));
/*if (doc.documentElement().hasAttribute("out")) {
GenTime duration = GenTime(doc.documentElement().attribute("out").toDouble() / 1000.0);
title_duration->setText(m_tc.getTimecode(duration));
}
else title_duration->setText(m_tc.getTimecode(GenTime(5000)));*/
QDomElement e = doc.documentElement();
m_transformations.clear();
......
......@@ -234,13 +234,10 @@ void ArchiveOrg::slotParseResults(KJob *job)
QMap<QString, QVariant> filesMetaDataList = fileMetaData.toMap();
QMap<QString, QVariant>::const_iterator k = filesMetaDataList.constBegin();
while (k != filesMetaDataList.constEnd()) {
// qCDebug(KDENLIVE_LOG)<< k.key()<<": "<<k.value().toString();
if (k.key() == QLatin1String("format")) {
// qCDebug(KDENLIVE_LOG)<<"Format: "<<k.value().toString();
format = k.value().toString();
} else if (k.key() == QLatin1String("size")) {
fileSize = QLocale::system().toString(k.value().toInt() / 1024);
// qCDebug(KDENLIVE_LOG)<<" fileSize: "<<k.value().toInt()/1024;
fileSize = QLocale().toString(k.value().toInt() / 1024);
} else if (k.key() == QLatin1String("length")) {
minsLong = QString::number(k.value().toFloat() / 60, 'f', 1);
}
......@@ -258,11 +255,8 @@ void ArchiveOrg::slotParseResults(KJob *job)
QStringLiteral("min) ") +
QStringLiteral("</td><td><a href=\"%1\">%2</a></td></tr>").arg(sDownloadUrl + QStringLiteral("_import"), i18n("Import"));
}
// if (format==QLatin1String("Animated GIF"))// widget does not run through the frames of the animated gif
if (format == QLatin1String("Thumbnail") && !bThumbNailFound) {
sThumbUrl = QStringLiteral("https://archive.org/download/") + m_metaInfo.value(QStringLiteral("id")) + j.key();
// m_metaInfo.insert(QStringLiteral("preview"), sPreviewUrl);
// qCDebug(KDENLIVE_LOG)<<" sPreviewUrl: "<<sPreviewUrl;
bThumbNailFound = true;
emit gotThumb(sThumbUrl);
}
......
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