mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 12:35:43 +08:00
Issue #122 Block network connect without simulator
This commit is contained in:
@@ -174,7 +174,7 @@ namespace BlackGui::Components
|
|||||||
connect(ui->pb_OverrideCredentialsVatsim, &QPushButton::clicked, this, &CLoginComponent::overrideCredentialsToPilot);
|
connect(ui->pb_OverrideCredentialsVatsim, &QPushButton::clicked, this, &CLoginComponent::overrideCredentialsToPilot);
|
||||||
connect(ui->pb_OverrideCredentialsOtherServers, &QPushButton::clicked, this, &CLoginComponent::overrideCredentialsToPilot);
|
connect(ui->pb_OverrideCredentialsOtherServers, &QPushButton::clicked, this, &CLoginComponent::overrideCredentialsToPilot);
|
||||||
|
|
||||||
this->setUiLoginState(false);
|
this->updateUiConnectState();
|
||||||
|
|
||||||
const int tab = m_networkSetup.wasLastUsedWithOtherServer() ? LoginOthers : LoginVATSIM;
|
const int tab = m_networkSetup.wasLastUsedWithOtherServer() ? LoginOthers : LoginVATSIM;
|
||||||
ui->tw_Network->setCurrentIndex(tab);
|
ui->tw_Network->setCurrentIndex(tab);
|
||||||
@@ -200,8 +200,8 @@ namespace BlackGui::Components
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->setOwnModelAndIcaoValues();
|
this->setOwnModelAndIcaoValues();
|
||||||
const bool isConnected = sGui->getIContextNetwork()->isConnected();
|
m_networkConnected = sGui->getIContextNetwork()->isConnected();
|
||||||
this->setUiLoginState(isConnected);
|
this->updateUiConnectState();
|
||||||
this->blinkConnectButton();
|
this->blinkConnectButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,12 +235,12 @@ namespace BlackGui::Components
|
|||||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||||
if (!sGui->getIContextNetwork() || !sGui->getIContextAudio()) { return; }
|
if (!sGui->getIContextNetwork() || !sGui->getIContextAudio()) { return; }
|
||||||
|
|
||||||
const bool isConnected = sGui && sGui->getIContextNetwork()->isConnected();
|
m_networkConnected = sGui && sGui->getIContextNetwork()->isConnected();
|
||||||
const bool vatsimLogin = this->isVatsimNetworkTabSelected();
|
const bool vatsimLogin = this->isVatsimNetworkTabSelected();
|
||||||
m_networkSetup.setAutoLogoff(ui->cb_AutoLogoff->isChecked());
|
m_networkSetup.setAutoLogoff(ui->cb_AutoLogoff->isChecked());
|
||||||
|
|
||||||
ui->form_Pilot->setVatsimValidation(vatsimLogin);
|
ui->form_Pilot->setVatsimValidation(vatsimLogin);
|
||||||
this->setUiLoginState(isConnected);
|
this->updateUiConnectState();
|
||||||
|
|
||||||
// reset time
|
// reset time
|
||||||
this->setLogoffCountdown();
|
this->setLogoffCountdown();
|
||||||
@@ -248,7 +248,7 @@ namespace BlackGui::Components
|
|||||||
CServer currentServer; // used for login
|
CServer currentServer; // used for login
|
||||||
CSimulatedAircraft ownAircraft; // used own aircraft
|
CSimulatedAircraft ownAircraft; // used own aircraft
|
||||||
CStatusMessage msg;
|
CStatusMessage msg;
|
||||||
if (!isConnected)
|
if (!m_networkConnected)
|
||||||
{
|
{
|
||||||
if (!this->validateAircraftValues())
|
if (!this->validateAircraftValues())
|
||||||
{
|
{
|
||||||
@@ -413,9 +413,11 @@ namespace BlackGui::Components
|
|||||||
{
|
{
|
||||||
ISimulator::SimulatorStatus s = static_cast<ISimulator::SimulatorStatus>(status);
|
ISimulator::SimulatorStatus s = static_cast<ISimulator::SimulatorStatus>(status);
|
||||||
if (!this->hasValidContexts()) { return; }
|
if (!this->hasValidContexts()) { return; }
|
||||||
|
m_simulatorConnected = s.testFlag(ISimulator::Connected);
|
||||||
|
this->updateUiConnectState();
|
||||||
if (sGui->getIContextNetwork()->isConnected())
|
if (sGui->getIContextNetwork()->isConnected())
|
||||||
{
|
{
|
||||||
if (!s.testFlag(ISimulator::Connected))
|
if (!m_simulatorConnected)
|
||||||
{
|
{
|
||||||
// sim NOT connected but network connected
|
// sim NOT connected but network connected
|
||||||
this->autoLogoffDetection();
|
this->autoLogoffDetection();
|
||||||
@@ -428,7 +430,8 @@ namespace BlackGui::Components
|
|||||||
Q_UNUSED(from)
|
Q_UNUSED(from)
|
||||||
if (to != CConnectionStatus::Connected) { return; }
|
if (to != CConnectionStatus::Connected) { return; }
|
||||||
|
|
||||||
this->setUiLoginState(true);
|
m_networkConnected = true;
|
||||||
|
this->updateUiConnectState();
|
||||||
this->updateGui();
|
this->updateGui();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -807,17 +810,21 @@ namespace BlackGui::Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLoginComponent::setUiLoginState(bool connected)
|
void CLoginComponent::updateUiConnectState()
|
||||||
{
|
{
|
||||||
ui->fr_LoginDisconnected->setVisible(!connected);
|
ui->fr_LoginDisconnected->setVisible(!m_networkConnected);
|
||||||
ui->fr_LogoffConfirmationConnected->setVisible(connected);
|
ui->fr_LogoffConfirmationConnected->setVisible(m_networkConnected);
|
||||||
|
|
||||||
const QString s = connected ? QStringLiteral("disconnect") : QStringLiteral("connect");
|
const QString s = m_networkConnected ? QStringLiteral("disconnect") : QStringLiteral("connect");
|
||||||
ui->pb_Ok->setText(s);
|
ui->pb_Ok->setText(s);
|
||||||
|
|
||||||
|
if (m_networkConnected) { ui->pb_Ok->setDisabled(false); }
|
||||||
|
else { ui->pb_Ok->setDisabled(!m_simulatorConnected); }
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLoginComponent::blinkConnectButton()
|
void CLoginComponent::blinkConnectButton()
|
||||||
{
|
{
|
||||||
|
if (!ui->pb_Ok->isEnabled()) { return; }
|
||||||
ui->pb_Ok->setProperty("blinkOn", true);
|
ui->pb_Ok->setProperty("blinkOn", true);
|
||||||
static constexpr int blinkLength = 100;
|
static constexpr int blinkLength = 100;
|
||||||
static constexpr int blinkTimes = 10;
|
static constexpr int blinkTimes = 10;
|
||||||
@@ -921,14 +928,13 @@ namespace BlackGui::Components
|
|||||||
|
|
||||||
void CLoginComponent::updateGui()
|
void CLoginComponent::updateGui()
|
||||||
{
|
{
|
||||||
|
if (!m_networkConnected) { return; }
|
||||||
if (!this->hasValidContexts()) { return; }
|
if (!this->hasValidContexts()) { return; }
|
||||||
if (!sGui->getIContextNetwork()) { return; }
|
if (!sGui->getIContextNetwork()) { return; }
|
||||||
const IContextNetwork *nwc = sGui->getIContextNetwork();
|
const IContextNetwork *nwc = sGui->getIContextNetwork();
|
||||||
const bool connected = nwc->isConnected();
|
|
||||||
if (!connected) { return; }
|
|
||||||
const CSimulatedAircraft ownAircraft = sGui->getIContextOwnAircraft()->getOwnAircraft();
|
const CSimulatedAircraft ownAircraft = sGui->getIContextOwnAircraft()->getOwnAircraft();
|
||||||
this->setGuiLoginAsValues(ownAircraft);
|
this->setGuiLoginAsValues(ownAircraft);
|
||||||
this->setUiLoginState(connected);
|
this->updateUiConnectState();
|
||||||
this->setOwnModelAndIcaoValues();
|
this->setOwnModelAndIcaoValues();
|
||||||
const CServer server = nwc->getConnectedServer();
|
const CServer server = nwc->getConnectedServer();
|
||||||
ui->le_LoginHomeBase->setText(server.getUser().getHomeBase().asString());
|
ui->le_LoginHomeBase->setText(server.getUser().getHomeBase().asString());
|
||||||
|
|||||||
@@ -192,8 +192,8 @@ namespace BlackGui::Components
|
|||||||
//! Pause/Continue timeout
|
//! Pause/Continue timeout
|
||||||
void toggleTimeout();
|
void toggleTimeout();
|
||||||
|
|
||||||
//! Show / hide elements for UI depending on login state
|
//! Show / hide elements for UI depending on login/simulator state
|
||||||
void setUiLoginState(bool connected);
|
void updateUiConnectState();
|
||||||
|
|
||||||
//! Make disconnect button flash briefly to catch the user's attention
|
//! Make disconnect button flash briefly to catch the user's attention
|
||||||
void blinkConnectButton();
|
void blinkConnectButton();
|
||||||
@@ -248,6 +248,8 @@ namespace BlackGui::Components
|
|||||||
BlackMisc::CDigestSignal m_changedLoginDataDigestSignal { this, &CLoginComponent::loginDataChangedDigest, 1500, 10 };
|
BlackMisc::CDigestSignal m_changedLoginDataDigestSignal { this, &CLoginComponent::loginDataChangedDigest, 1500, 10 };
|
||||||
bool m_autoPopupWizard = false; //!< automatically popup wizard if mapping is needed
|
bool m_autoPopupWizard = false; //!< automatically popup wizard if mapping is needed
|
||||||
bool m_updatePilotOnServerChanges = true;
|
bool m_updatePilotOnServerChanges = true;
|
||||||
|
bool m_networkConnected = false;
|
||||||
|
bool m_simulatorConnected = false;
|
||||||
const QIcon m_iconPlay {":/famfamfam/icons/famfamfam/icons/silk/control_play_blue.png"};
|
const QIcon m_iconPlay {":/famfamfam/icons/famfamfam/icons/silk/control_play_blue.png"};
|
||||||
const QIcon m_iconPause {":/famfamfam/icons/famfamfam/icons/silk/control_pause_blue.png"};
|
const QIcon m_iconPause {":/famfamfam/icons/famfamfam/icons/silk/control_pause_blue.png"};
|
||||||
int m_logoffIntervalSeconds = LogoffIntervalSeconds;
|
int m_logoffIntervalSeconds = LogoffIntervalSeconds;
|
||||||
|
|||||||
Reference in New Issue
Block a user