From 09dcffd7fb2282e27fb9c855cfabbeccc1fbb779 Mon Sep 17 00:00:00 2001 From: Georg Zotti Date: Fri, 2 Feb 2024 18:30:56 +0100 Subject: [PATCH] RemoteControl: Allow comma as decimal separator - This is mostly to fight a Localisation bug in an external app. --- plugins/RemoteControl/src/LocationService.cpp | 10 ++++++++++ plugins/RemoteControl/src/MainService.cpp | 13 ++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/plugins/RemoteControl/src/LocationService.cpp b/plugins/RemoteControl/src/LocationService.cpp index 836a4b9217f63..3246b6636a7fd 100644 --- a/plugins/RemoteControl/src/LocationService.cpp +++ b/plugins/RemoteControl/src/LocationService.cpp @@ -170,12 +170,22 @@ void LocationService::post(const QByteArray& operation, const APIParameters &par bool doneSomething = false; bool ok = false; float latitude = sLatitude.toFloat(&ok); + if (!ok) + { + sLatitude.replace(",", "."); + latitude = sLatitude.toFloat(&ok); + } if(ok && (latitude - loc.getLatitude()) != 0.0f) { loc.setLatitude(latitude); doneSomething = true; } float longitude = sLongitude.toFloat(&ok); + if (!ok) + { + sLongitude.replace(",", "."); + longitude = sLongitude.toFloat(&ok); + } if(ok && (longitude - loc.getLongitude()) != 0.0f) { loc.setLongitude(longitude); diff --git a/plugins/RemoteControl/src/MainService.cpp b/plugins/RemoteControl/src/MainService.cpp index f53c133a48671..3cc1cad2dd79d 100644 --- a/plugins/RemoteControl/src/MainService.cpp +++ b/plugins/RemoteControl/src/MainService.cpp @@ -283,11 +283,16 @@ void MainService::post(const QByteArray& operation, const APIParameters ¶met //set the time + timerate { - const QByteArray& raw = parameters.value("time"); + QByteArray raw = parameters.value("time"); if(!raw.isEmpty()) { //parse time and set it - double jday = QString(raw).toDouble(&ok); + double jday = raw.toDouble(&ok); + if (!ok) + { + raw.replace(',', '.'); + jday=raw.toDouble(&ok); + } if(ok) { //check for invalid double (NaN, inf...) @@ -304,6 +309,8 @@ void MainService::post(const QByteArray& operation, const APIParameters ¶met QMetaObject::invokeMethod(core,"setJD", SERVICE_DEFAULT_INVOKETYPE, Q_ARG(double,jday)); } + else + qWarning() << "RC Main Service time request for invalid time string:" << raw; } } { @@ -311,7 +318,7 @@ void MainService::post(const QByteArray& operation, const APIParameters ¶met if(!raw.isEmpty()) { //parse timerate and set it - double rate = QString(raw).toDouble(&ok); + double rate = raw.toDouble(&ok); if(ok) { doneSomething = true;