mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
[Weather] Allow to trigger reload of weather from UI
This commit is contained in:
committed by
Mat Sutcliffe
parent
c2ecf167b7
commit
24bc57ac32
@@ -77,7 +77,6 @@ namespace BlackCore
|
||||
m_plugins->collectPlugins();
|
||||
this->restoreSimulatorPlugins();
|
||||
|
||||
connect(&m_weatherManager, &CWeatherManager::weatherGridReceived, this, &CContextSimulator::weatherGridReceived, Qt::QueuedConnection);
|
||||
connect(&m_weatherManager, &CWeatherManager::weatherGridReceived, this, &CContextSimulator::onWeatherGridReceived, Qt::QueuedConnection);
|
||||
connect(&m_aircraftMatcher, &CAircraftMatcher::setupChanged, this, &CContextSimulator::matchingSetupChanged);
|
||||
connect(&CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance(), &CCentralMultiSimulatorModelSetCachesProvider::cacheChanged, this, &CContextSimulator::modelSetChanged);
|
||||
@@ -882,6 +881,9 @@ namespace BlackCore
|
||||
|
||||
void CContextSimulator::onWeatherGridReceived(const CWeatherGrid &weatherGrid, const CIdentifier &identifier)
|
||||
{
|
||||
if (!sApp || sApp->isShuttingDown()) { return; }
|
||||
emit this->weatherGridReceived(weatherGrid, identifier);
|
||||
|
||||
if (!this->isSimulatorPluginAvailable()) { return; }
|
||||
if (!m_simulatorPlugin.second) { return; }
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace BlackGui
|
||||
m_coordinateDialog->showElevation(false);
|
||||
m_coordinateDialog->setReadOnly(ui->cb_UseOwnAcftPosition->isChecked());
|
||||
connect(ui->pb_SetPosition, &QPushButton::clicked, this, &CWeatherComponent::showCoordinateDialog);
|
||||
connect(ui->pb_Update, &QPushButton::clicked, this, &CWeatherComponent::updateWeatherInformationForced);
|
||||
|
||||
m_weatherScenarios = CWeatherGrid::getAllScenarios();
|
||||
for (const auto &scenario : as_const(m_weatherScenarios))
|
||||
@@ -76,11 +77,9 @@ namespace BlackGui
|
||||
QPointer<CWeatherComponent> myself(this);
|
||||
QTimer::singleShot(1000, this, [ = ]
|
||||
{
|
||||
if (myself)
|
||||
{
|
||||
myself->updateWeatherInformation();
|
||||
myself->updateWeatherInfoLine();
|
||||
}
|
||||
if (!myself) { return; }
|
||||
myself->updateWeatherInformation(true);
|
||||
myself->updateWeatherInfoLine();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -90,7 +89,7 @@ namespace BlackGui
|
||||
bool CWeatherComponent::setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget)
|
||||
{
|
||||
CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea(parentDockableWidget);
|
||||
bool c = connect(this->getParentInfoArea(), &CInfoArea::changedInfoAreaTabBarIndex, this, &CWeatherComponent::infoAreaTabBarChanged, Qt::QueuedConnection);
|
||||
const bool c = connect(this->getParentInfoArea(), &CInfoArea::changedInfoAreaTabBarIndex, this, &CWeatherComponent::infoAreaTabBarChanged, Qt::QueuedConnection);
|
||||
Q_ASSERT_X(c, Q_FUNC_INFO, "failed connect");
|
||||
Q_ASSERT_X(parentDockableWidget, Q_FUNC_INFO, "missing parent");
|
||||
return c && parentDockableWidget;
|
||||
@@ -123,7 +122,7 @@ namespace BlackGui
|
||||
m_coordinateDialog->setCoordinate(c);
|
||||
ui->pb_SetPosition->setText("Select Position");
|
||||
}
|
||||
updateWeatherInformation();
|
||||
updateWeatherInformation(false);
|
||||
}
|
||||
|
||||
void CWeatherComponent::toggleWeatherActivation()
|
||||
@@ -154,7 +153,7 @@ namespace BlackGui
|
||||
m_lastOwnAircraftPosition = {};
|
||||
const CWeatherScenario scenario = m_weatherScenarios[index];
|
||||
m_weatherScenarioSetting.set(scenario);
|
||||
this->updateWeatherInformation();
|
||||
this->updateWeatherInformation(false);
|
||||
this->updateWeatherInfoLine();
|
||||
}
|
||||
|
||||
@@ -185,7 +184,7 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CWeatherComponent::updateWeatherInformation()
|
||||
void CWeatherComponent::updateWeatherInformation(bool forceRealWeatherReload)
|
||||
{
|
||||
setWeatherGrid({});
|
||||
ui->lbl_Status->setText({});
|
||||
@@ -212,7 +211,7 @@ namespace BlackGui
|
||||
|
||||
if (CWeatherScenario::isRealWeatherScenario(scenario))
|
||||
{
|
||||
if (m_lastOwnAircraftPosition.isNull() ||
|
||||
if (m_lastOwnAircraftPosition.isNull() || forceRealWeatherReload ||
|
||||
calculateGreatCircleDistance(position, m_lastOwnAircraftPosition).value(CLengthUnit::km()) > 20)
|
||||
{
|
||||
this->requestWeatherGrid(position);
|
||||
@@ -244,10 +243,10 @@ namespace BlackGui
|
||||
void CWeatherComponent::setupConnections()
|
||||
{
|
||||
// UI connections
|
||||
connect(m_coordinateDialog.data(), &CCoordinateDialog::changedCoordinate, this, &CWeatherComponent::updateWeatherInformationForced);
|
||||
connect(&m_weatherUpdateTimer, &QTimer::timeout, this, &CWeatherComponent::updateWeatherInformationChecked);
|
||||
connect(ui->cb_weatherScenario, qOverload<int>(&QComboBox::currentIndexChanged), this, &CWeatherComponent::setWeatherScenario);
|
||||
connect(m_coordinateDialog.data(), &CCoordinateDialog::changedCoordinate, this, &CWeatherComponent::updateWeatherInformation);
|
||||
connect(ui->cb_UseOwnAcftPosition, &QCheckBox::toggled, this, &CWeatherComponent::toggleUseOwnAircraftPosition);
|
||||
connect(&m_weatherUpdateTimer, &QTimer::timeout, this, &CWeatherComponent::updateWeatherInformation);
|
||||
connect(ui->cb_UseOwnAcftPosition, &QCheckBox::toggled, this, &CWeatherComponent::toggleUseOwnAircraftPosition);
|
||||
connect(ui->pb_ActivateWeather, &QPushButton::clicked, this, &CWeatherComponent::toggleWeatherActivation);
|
||||
|
||||
// Context connections
|
||||
|
||||
@@ -65,7 +65,9 @@ namespace BlackGui
|
||||
void setCavok();
|
||||
|
||||
void updateWeatherInfoLine();
|
||||
void updateWeatherInformation();
|
||||
void updateWeatherInformationForced() { this->updateWeatherInformation(true); }
|
||||
void updateWeatherInformationChecked() { this->updateWeatherInformation(false); }
|
||||
void updateWeatherInformation(bool forceRealWeatherReload);
|
||||
void onWeatherGridReceived(const BlackMisc::Weather::CWeatherGrid &weatherGrid, const BlackMisc::CIdentifier &identifier);
|
||||
|
||||
void setupConnections();
|
||||
@@ -78,7 +80,7 @@ namespace BlackGui
|
||||
QScopedPointer<Ui::CWeatherComponent> ui;
|
||||
QScopedPointer<CCoordinateDialog> m_coordinateDialog { new CCoordinateDialog(this) };
|
||||
QVector<BlackMisc::Weather::CWeatherScenario> m_weatherScenarios;
|
||||
QTimer m_weatherUpdateTimer;
|
||||
QTimer m_weatherUpdateTimer; //!< this is the timer for weather updates
|
||||
BlackMisc::Geo::CCoordinateGeodetic m_lastOwnAircraftPosition;
|
||||
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TSelectedWeatherScenario> m_weatherScenarioSetting { this, &CWeatherComponent::onScenarioChanged };
|
||||
BlackCore::CActionBindings m_hotkeyBindings; //!< allow binding of hotkey
|
||||
|
||||
@@ -34,27 +34,52 @@
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_weatherControl">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Weather Control</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_WeatherComponent">
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<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>
|
||||
<string>activate</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QLabel" name="lbl_WeatherEngineInfo">
|
||||
<property name="text">
|
||||
<string>info goes here</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="pb_Update">
|
||||
<property name="text">
|
||||
<string>update</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -100,7 +125,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show Position</string>
|
||||
<string>show Position</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -267,6 +292,17 @@
|
||||
<header>blackgui/views/windlayerview.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>cb_weatherScenario</tabstop>
|
||||
<tabstop>pb_ActivateWeather</tabstop>
|
||||
<tabstop>pb_Update</tabstop>
|
||||
<tabstop>cb_UseOwnAcftPosition</tabstop>
|
||||
<tabstop>pb_SetPosition</tabstop>
|
||||
<tabstop>tw_weatherGrid</tabstop>
|
||||
<tabstop>tvp_TemperatureLayers</tabstop>
|
||||
<tabstop>tvp_CloudLayers</tabstop>
|
||||
<tabstop>tvp_WindLayers</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
Reference in New Issue
Block a user