Commit a8644836 authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Allow comma when dot is decimal separator

BUG: 406388
FIXED-IN: 5.20

This allows us to use a comma as a decimal separator, even if we have a
dot configured.
Especially when there is a difference between the official and
implemented decimal separator (see bug report) or if the user switches
between settings with a different separator.
By making sure that no [ or ] character(used for vectors) is contained
before replacing the string we make sure that we still provide all the
features Qalculate does.
parent 4a44b30b
......@@ -183,7 +183,14 @@ void CalculatorRunner::hexSubstitutions(QString& cmd)
void CalculatorRunner::userFriendlySubstitutions(QString& cmd)
{
cmd.replace(QLocale().decimalPoint(), QLatin1Char('.'), Qt::CaseInsensitive);
if (QLocale().decimalPoint() != QLatin1Char('.')) {
cmd.replace(QLocale().decimalPoint(), QLatin1Char('.'), Qt::CaseInsensitive);
} else if (!cmd.contains(QLatin1Char('[')) && !cmd.contains(QLatin1Char(']'))) {
// If we are sure that the user does not want to use vectors we can replace this char
// Especially when switching between locales that use a different decimal separator
// this ensures that the results are valid, see BUG: 406388
cmd.replace(QLatin1Char(','), QLatin1Char('.'), Qt::CaseInsensitive);
}
// the following substitutions are not needed with libqalculate
#ifndef ENABLE_QALCULATE
......
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