mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 10:15:38 +08:00
Add default unit for "rec.gnd.positions" radius
* utility functions * append default unit to PQ string if needed
This commit is contained in:
committed by
Mat Sutcliffe
parent
6b6a6e0d8e
commit
b9c6541a55
@@ -78,7 +78,7 @@ namespace BlackGui
|
||||
connect(ui->pb_ApplyMaxDistance, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyMaxRenderedDistance, Qt::QueuedConnection);
|
||||
connect(ui->pb_ApplyComSync, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyComSync, Qt::QueuedConnection);
|
||||
connect(ui->pb_ApplyCGSource, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyCGSource, Qt::QueuedConnection);
|
||||
connect(ui->pb_ApplyRecordOwnAircraftGnd, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyRecordGnd, Qt::QueuedConnection);
|
||||
connect(ui->pb_ApplyRecordOwnAircraftGnd, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyRecordGnd, Qt::QueuedConnection);
|
||||
|
||||
connect(ui->pb_ClearRestrictedRendering, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::clearRestricedRendering);
|
||||
connect(ui->pb_DisableRendering, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyDisableRendering);
|
||||
@@ -338,8 +338,17 @@ namespace BlackGui
|
||||
bool ok = false;
|
||||
CSimulatorSettings settings = this->getSimulatorSettings(ok);
|
||||
if (!ok) { return; }
|
||||
CLength radius;
|
||||
radius.parseFromString(ui->le_RecordOwnGndPositionsRadius->text());
|
||||
|
||||
// get value, automatically add default unit if unit is missing
|
||||
CLength radius = CLength::null();
|
||||
QString radiusString = ui->le_RecordOwnGndPositionsRadius->text().trimmed();
|
||||
if (!radiusString.isEmpty())
|
||||
{
|
||||
if (!CMeasurementUnit::endWithValidUnitSymbol<CLengthUnit>(radiusString)) { radiusString += "m"; }
|
||||
radius.parseFromString(radiusString);
|
||||
}
|
||||
ui->le_RecordOwnGndPositionsRadius->setText(radius.valueRoundedWithUnit(1));
|
||||
|
||||
const bool c1 = settings.setRecordOwnAircraftGnd(ui->cb_RecordOwnGndPositions->isChecked());
|
||||
const bool c2 = settings.setRecordedGndRadius(radius);
|
||||
if (!c1 && !c2) { return; }
|
||||
|
||||
@@ -471,6 +471,36 @@ namespace BlackMisc
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Contains valid unit symbol?
|
||||
* \param candidate to be tested
|
||||
* \param caseSensitivity check case sensitiv?
|
||||
*/
|
||||
template <class U> static bool containsValidUnitSymbol(const QString &candidate, Qt::CaseSensitivity caseSensitivity = Qt::CaseSensitive)
|
||||
{
|
||||
if (candidate.isEmpty()) return false;
|
||||
for (const auto &unit : U::allUnits())
|
||||
{
|
||||
if (candidate.contains(unit.getSymbol(), caseSensitivity)) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Ends with valid unit symbol?
|
||||
* \param candidate to be tested
|
||||
* \param caseSensitivity check case sensitiv?
|
||||
*/
|
||||
template <class U> static bool endWithValidUnitSymbol(const QString &candidate, Qt::CaseSensitivity caseSensitivity = Qt::CaseSensitive)
|
||||
{
|
||||
if (candidate.isEmpty()) return false;
|
||||
for (const auto &unit : U::allUnits())
|
||||
{
|
||||
if (candidate.endsWith(unit.getSymbol(), caseSensitivity)) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Dimensionless unit
|
||||
static CMeasurementUnit None()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user