diff --git a/src/blackgui/components/logincomponent.cpp b/src/blackgui/components/logincomponent.cpp index d0f445bee..69b61045e 100644 --- a/src/blackgui/components/logincomponent.cpp +++ b/src/blackgui/components/logincomponent.cpp @@ -129,6 +129,7 @@ namespace BlackGui connect(ui->selector_AircraftIcao, &CDbAircraftIcaoSelectorComponent::changedAircraftIcao, this, &CLoginComponent::changedAircraftIcao, Qt::QueuedConnection); connect(ui->selector_AirlineIcao, &CDbAirlineIcaoSelectorComponent::changedAirlineIcao, this, &CLoginComponent::changedAirlineIcao, Qt::QueuedConnection); connect(ui->tb_SimulatorIcaoReverseLookup, &QToolButton::clicked, this, &CLoginComponent::reverseLookupAircraftModel); + connect(ui->tw_Details, &QTabWidget::currentChanged, this, &CLoginComponent::onDetailsTabChanged); if (sGui && sGui->getIContextSimulator()) { @@ -142,7 +143,10 @@ namespace BlackGui connect(ui->tb_Timeout, &QToolButton::clicked, this, &CLoginComponent::toggleTimeout); // web service data - connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CLoginComponent::onWebServiceDataRead, Qt::QueuedConnection); + if (sGui && sGui->getWebDataServices()) + { + connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CLoginComponent::onWebServiceDataRead, Qt::QueuedConnection); + } // inital setup, if data already available this->validateAircraftValues(); @@ -223,6 +227,7 @@ namespace BlackGui void CLoginComponent::toggleNetworkConnection() { if (!sGui || sGui->isShuttingDown()) { return; } + if (!sGui->getIContextNetwork() || !sGui->getIContextAudio()) { return; } const bool isConnected = sGui && sGui->getIContextNetwork()->isConnected(); const bool vatsimLogin = this->isVatsimNetworkTabSelected(); @@ -262,9 +267,7 @@ namespace BlackGui } // Server - currentServer = vatsimLogin ? - this->getCurrentVatsimServer() : - this->getCurrentOtherServer(); + currentServer = vatsimLogin ? this->getCurrentVatsimServer() : this->getCurrentOtherServer(); const CUser user = this->getUserFromPilotGuiValues(); currentServer.setUser(user); @@ -304,7 +307,8 @@ namespace BlackGui m_networkSetup.setLastServer(currentServer); m_lastAircraftModel.set(ownAircraft.getModel()); - ui->le_HomeBase->setText(currentServer.getUser().getHomeBase().asString()); + ui->le_LoginCallsign->setText(ownAircraft.getCallsignAsString()); + ui->le_LoginHomeBase->setText(currentServer.getUser().getHomeBase().asString()); if (vatsimLogin) { m_networkSetup.setLastVatsimServer(currentServer); } } else @@ -376,8 +380,8 @@ namespace BlackGui void CLoginComponent::overrideCredentialsToPilot() { - const QObject *s = QObject::sender(); CServer server; + const QObject *s = QObject::sender(); if (s == ui->pb_OverrideCredentialsOtherServers) { server = this->getCurrentOtherServer(); @@ -408,7 +412,7 @@ namespace BlackGui ui->form_Pilot->setUser(server.getUser(), true); } - bool CLoginComponent::hasValidContexts() + bool CLoginComponent::hasValidContexts() const { if (!sGui || !sGui->supportsContexts()) { return false; } if (sGui->isShuttingDown()) { return false; } @@ -418,6 +422,21 @@ namespace BlackGui return true; } + void CLoginComponent::setServerButtonsVisible(bool visible) + { + ui->wi_OtherServersButtons->setVisible(visible); + ui->wi_VatsimButtons->setVisible(visible); + } + + void CLoginComponent::onDetailsTabChanged(int index) + { + Q_UNUSED(index); + const bool showNetwork = (ui->tw_Details->currentWidget() != ui->tb_FsdDetails); + ui->tw_Network->setVisible(showNetwork); + // this->setServerButtonsVisible(showNetwork); + ui->tw_Details->setMinimumHeight(showNetwork ? 0 : 125); + } + CLoginComponent::CGuiAircraftValues CLoginComponent::getAircraftValuesFromGui() const { CGuiAircraftValues values; @@ -538,11 +557,15 @@ namespace BlackGui void CLoginComponent::setGuiLoginAsValues(const CSimulatedAircraft &ownAircraft) { - QString ac(ownAircraft.getCallsignAsString() % QLatin1Char(' ') % ownAircraft.getAircraftIcaoCodeDesignator()); - if (ownAircraft.hasAirlineDesignator()) { ac += QLatin1Char(' ') % ownAircraft.getAirlineIcaoCodeDesignator(); } - if (!ownAircraft.getAircraftIcaoCombinedType().isEmpty()) { ac += QLatin1Char(' ') % ownAircraft.getAircraftIcaoCode().getCombinedType(); } + const QString ac( + ownAircraft.getAircraftIcaoCodeDesignator() % + (ownAircraft.hasAirlineDesignator() ? (QLatin1Char(' ') % ownAircraft.getAirlineIcaoCodeDesignator()) : QStringLiteral("")) % + (ownAircraft.hasModelString() ? (QLatin1Char(' ') % ownAircraft.getModelString()) : QStringLiteral("")) + ); ui->le_LoginSince->setText(QDateTime::currentDateTimeUtc().toString()); ui->le_LoginAsAircaft->setText(ac); + ui->le_LoginCallsign->setText(ownAircraft.getCallsignAsString()); + ui->le_LoginAsAircaft->home(false); } bool CLoginComponent::validateAircraftValues() @@ -771,14 +794,15 @@ namespace BlackGui void CLoginComponent::updateGui() { - if (!this->hasValidContexts()) { return; } + if (!this->hasValidContexts()) { return; } + if (!sGui->getIContextNetwork()) { return; } IContextNetwork *nwc = sGui->getIContextNetwork(); const bool connected = nwc->isConnected(); if (!connected) { return; } this->setUiLoginState(connected); this->setOwnModelAndIcaoValues(); const CServer server = nwc->getConnectedServer(); - ui->le_HomeBase->setText(server.getUser().getHomeBase().asString()); + ui->le_LoginHomeBase->setText(server.getUser().getHomeBase().asString()); ui->frp_CurrentServer->setServer(server); ui->frp_LoginMode->setLoginMode(nwc->getLoginMode()); const CSimulatedAircraft ownAircraft = sGui->getIContextOwnAircraft()->getOwnAircraft(); diff --git a/src/blackgui/components/logincomponent.ui b/src/blackgui/components/logincomponent.ui index 69b15c546..e2f405722 100644 --- a/src/blackgui/components/logincomponent.ui +++ b/src/blackgui/components/logincomponent.ui @@ -304,17 +304,17 @@ 3 - + true - + 0 0 253 - 55 + 45 @@ -755,36 +755,53 @@ - - - - true - - - - + Login since: - - + + + + Aircraft: + + + + + true - + + + Callsign/home + - Aircraft/home: + CS/home: + + + + + + + true + + + + + + + true - + true @@ -961,7 +978,7 @@ pb_OtherServersGotoSettings pb_OverrideCredentialsOtherServers tw_Details - scrollArea + sa_FsdDetails le_SimulatorModel tb_SimulatorIcaoReverseLookup tb_MappingWizard @@ -969,8 +986,8 @@ selector_AircraftIcao le_AircraftCombinedType selector_AirlineIcao + le_LoginCallsign le_LoginAsAircaft - le_HomeBase le_LoginSince tb_Timeout pb_Ok diff --git a/src/blackgui/editors/voicesetupform.ui b/src/blackgui/editors/voicesetupform.ui index 06449f778..c88ce6dd8 100644 --- a/src/blackgui/editors/voicesetupform.ui +++ b/src/blackgui/editors/voicesetupform.ui @@ -68,10 +68,10 @@ - + - set defaults + set defaults