Skip to content

Commit

Permalink
RemoteControl: Allow comma as decimal separator
Browse files Browse the repository at this point in the history
- This is mostly to fight a Localisation bug in an external app.
  • Loading branch information
gzotti committed Feb 2, 2024
1 parent bfe03bf commit 09dcffd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
10 changes: 10 additions & 0 deletions plugins/RemoteControl/src/LocationService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 10 additions & 3 deletions plugins/RemoteControl/src/MainService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,16 @@ void MainService::post(const QByteArray& operation, const APIParameters &paramet

//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...)
Expand All @@ -304,14 +309,16 @@ void MainService::post(const QByteArray& operation, const APIParameters &paramet
QMetaObject::invokeMethod(core,"setJD", SERVICE_DEFAULT_INVOKETYPE,
Q_ARG(double,jday));
}
else
qWarning() << "RC Main Service time request for invalid time string:" << raw;
}
}
{
const QByteArray& raw = parameters.value("timerate");
if(!raw.isEmpty())
{
//parse timerate and set it
double rate = QString(raw).toDouble(&ok);
double rate = raw.toDouble(&ok);
if(ok)
{
doneSomething = true;
Expand Down

0 comments on commit 09dcffd

Please sign in to comment.