Add control button to activate and deactivate swift weather

- GUI changes
- Context and ISimulator APIs
- Refactored settings and static weather injection in CSimulatorCommon

refs #807
This commit is contained in:
Roland Winklmeier
2017-01-07 21:06:56 +01:00
committed by Mathew Sutcliffe
parent 2cea07f174
commit 1a6c7fa192
18 changed files with 135 additions and 84 deletions

View File

@@ -52,6 +52,8 @@ namespace BlackGui
auto scenario = m_weatherScenarioSetting.get();
ui->cb_weatherScenario->setCurrentIndex(scenario.getIndex());
ui->pb_ActivateWeather->setIcon(CIcons::metar());
setupConnections();
setupInputValidators();
setupCompleter();
@@ -107,6 +109,21 @@ namespace BlackGui
}
}
void CWeatherComponent::toggleWeatherActivation()
{
if (m_isWeatherActivated)
{
m_isWeatherActivated = false;
ui->pb_ActivateWeather->setText("Activate");
}
else
{
m_isWeatherActivated = true;
ui->pb_ActivateWeather->setText("Deactivate");
}
sGui->getIContextSimulator()->setWeatherActivated(m_isWeatherActivated);
}
void CWeatherComponent::setWeatherScenario(int index)
{
if (index == -1) { return; }
@@ -198,6 +215,7 @@ namespace BlackGui
connect(ui->le_Lon, &QLineEdit::returnPressed, this, &CWeatherComponent::updateWeatherInformation);
connect(ui->cb_UseOwnAcftPosition, &QCheckBox::toggled, this, &CWeatherComponent::toggleUseOwnAircraftPosition);
connect(&m_weatherUpdateTimer, &QTimer::timeout, this, &CWeatherComponent::updateWeatherInformation);
connect(ui->pb_ActivateWeather, &QPushButton::clicked, this, &CWeatherComponent::toggleWeatherActivation);
// Context connections
Q_ASSERT(sGui->getIContextSimulator());

View File

@@ -59,6 +59,7 @@ namespace BlackGui
private:
void toggleUseOwnAircraftPosition(bool checked);
void toggleWeatherActivation();
void setWeatherScenario(int index);
void updateWeatherInformation();
@@ -76,6 +77,7 @@ namespace BlackGui
QTimer m_weatherUpdateTimer { this };
BlackMisc::Geo::CCoordinateGeodetic m_lastOwnAircraftPosition;
BlackMisc::CSetting<BlackMisc::Simulation::TSelectedWeatherScenario> m_weatherScenarioSetting { this };
bool m_isWeatherActivated = false;
};
} // namespace
} // namespace

View File

@@ -35,9 +35,16 @@
<string>Weather Control</string>
</property>
<layout class="QGridLayout" name="gl_WeatherComponent">
<item row="0" column="0">
<item row="0" column="0" colspan="2">
<widget class="QComboBox" name="cb_weatherScenario"/>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pb_ActivateWeather">
<property name="text">
<string>Activate</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>