mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-08 03:35:35 +08:00
This should be further improved with #417
This commit is contained in:
@@ -75,7 +75,7 @@ namespace BlackGui
|
||||
this->ui->tvp_AircraftInRange->updateContainer(this->getIContextNetwork()->getAircraftInRange());
|
||||
}
|
||||
}
|
||||
if (this->getIContextSimulator()->isConnected())
|
||||
if (this->getIContextSimulator()->getSimulatorStatus() > 0)
|
||||
{
|
||||
bool visible = (this->isVisibleWidget() && this->currentWidget() == this->ui->tb_AirportsInRange);
|
||||
if (this->countAirportsInRange() < 1 || visible)
|
||||
|
||||
@@ -81,8 +81,7 @@ namespace BlackGui
|
||||
|
||||
// initial values
|
||||
this->ps_onMapperReady();
|
||||
bool connected = this->getIContextSimulator()->isConnected();
|
||||
this->ps_onSimulatorStatusChanged(connected ? ISimulator::Connected : ISimulator::Disconnected);
|
||||
this->ps_onSimulatorStatusChanged(this->getIContextSimulator()->getSimulatorStatus());
|
||||
}
|
||||
|
||||
if (this->getIContextNetwork())
|
||||
@@ -116,7 +115,7 @@ namespace BlackGui
|
||||
this->ui->led_Simulator->setTriState();
|
||||
this->ui->led_Simulator->setTriStateToolTip(s);
|
||||
}
|
||||
else if (status & ISimulator::Running)
|
||||
else if (status & ISimulator::Simulating)
|
||||
{
|
||||
this->ui->led_Simulator->setOn(true);
|
||||
this->ui->led_Simulator->setOnToolTip(s);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "blackcore/context_audio.h"
|
||||
#include "blackcore/context_simulator.h"
|
||||
#include "blackcore/network.h"
|
||||
#include "blackcore/simulator.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/aviation/aircrafticaodata.h"
|
||||
#include "../uppercasevalidator.h"
|
||||
@@ -355,8 +356,9 @@ namespace BlackGui
|
||||
|
||||
CAircraftIcaoData icao;
|
||||
|
||||
bool simConnected = this->getIContextSimulator() && this->getIContextSimulator()->isSimulating();
|
||||
if (simConnected)
|
||||
bool simulating = this->getIContextSimulator() &&
|
||||
(this->getIContextSimulator()->getSimulatorStatus() & ISimulator::Simulating);
|
||||
if (simulating)
|
||||
{
|
||||
CAircraftModel model = this->getIContextOwnAircraft()->getOwnAircraft().getModel();
|
||||
this->ui->le_SimulatorModel->setText(model.getModelString());
|
||||
@@ -381,7 +383,6 @@ namespace BlackGui
|
||||
{
|
||||
this->setGuiIcaoValues(icao, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CLoginComponent::setGuiIcaoValues(const CAircraftIcaoData &icao, bool onlyIfEmpty)
|
||||
|
||||
@@ -386,7 +386,7 @@ namespace BlackGui
|
||||
Q_ASSERT_X(getIContextNetwork(), Q_FUNC_INFO, "missing network context");
|
||||
Q_ASSERT_X(getIContextSimulator(), Q_FUNC_INFO, "missing simulator context");
|
||||
if (this->isVisibleWidget()) { return; }
|
||||
if (getIContextSimulator()->isConnected())
|
||||
if (getIContextSimulator()->getSimulatorStatus() > 0)
|
||||
{
|
||||
const CSimulatedAircraftList aircraft(getIContextNetwork()->getAircraftInRange());
|
||||
this->ui->tvp_SimulatedAircraft->updateContainer(aircraft);
|
||||
|
||||
@@ -62,17 +62,20 @@ namespace BlackGui
|
||||
|
||||
void CSimulatorComponent::update()
|
||||
{
|
||||
Q_ASSERT(getIContextSimulator());
|
||||
Q_ASSERT_X(getIContextSimulator(), Q_FUNC_INFO, "No simulator context");
|
||||
|
||||
if (!this->isVisibleWidget()) return; // no updates on invisible widgets
|
||||
if (!this->getIContextOwnAircraft()) return;
|
||||
|
||||
if (!this->getIContextSimulator()->isConnected()) {
|
||||
int simualtorStatus = this->getIContextSimulator()->getSimulatorStatus();
|
||||
if (simualtorStatus == 0)
|
||||
{
|
||||
addOrUpdateByName("info", tr("No simulator available"), CIcons::StandardIconWarning16);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this->getIContextSimulator()->isSimulating()) {
|
||||
if (!(simualtorStatus & ISimulator::Simulating))
|
||||
{
|
||||
this->addOrUpdateByName("info",
|
||||
tr("Simulator (%1) not yet running").arg(
|
||||
getIContextSimulator()->getSimulatorPluginInfo().getSimulator()
|
||||
@@ -109,12 +112,12 @@ namespace BlackGui
|
||||
|
||||
void CSimulatorComponent::runtimeHasBeenSet()
|
||||
{
|
||||
Q_ASSERT(this->getIContextSimulator());
|
||||
if (!this->getIContextSimulator()) return;
|
||||
Q_ASSERT_X(this->getIContextSimulator(), Q_FUNC_INFO, "Missing simulator context");
|
||||
if (!this->getIContextSimulator()) { return; }
|
||||
QObject::connect(this->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged, this, &CSimulatorComponent::ps_onSimulatorStatusChanged);
|
||||
|
||||
this->setUpdateInterval(getUpdateIntervalMs());
|
||||
if (!getIContextSimulator()->isConnected())
|
||||
if (getIContextSimulator()->getSimulatorStatus() == 0)
|
||||
{
|
||||
this->stopTimer();
|
||||
}
|
||||
@@ -122,10 +125,13 @@ namespace BlackGui
|
||||
|
||||
void CSimulatorComponent::ps_onSimulatorStatusChanged(int status)
|
||||
{
|
||||
if (status & ISimulator::Connected) {
|
||||
if (status & ISimulator::Connected)
|
||||
{
|
||||
int intervalMs = getUpdateIntervalMs();
|
||||
this->m_updateTimer->startTimer(intervalMs);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->stopTimer();
|
||||
clear();
|
||||
update();
|
||||
|
||||
Reference in New Issue
Block a user