refactor(ui): Reuse existing components for login component

This commit is contained in:
Lars Toenning
2024-08-24 00:01:54 +02:00
parent 3310c74993
commit feeafd4afd
3 changed files with 66 additions and 760 deletions

View File

@@ -69,30 +69,13 @@ namespace BlackGui::Components
ui(new Ui::CLoginComponent)
{
ui->setupUi(this);
ui->tw_Details->setCurrentWidget(ui->tb_LoginMode);
m_logoffCountdownTimer.setObjectName("CLoginComponent:m_logoffCountdownTimer");
ui->tw_Network->setCurrentIndex(0);
ui->selector_AircraftIcao->displayWithIcaoDescription(false);
ui->selector_AirlineIcao->displayWithIcaoDescription(false);
ui->selector_AircraftIcao->displayMode(CDbAircraftIcaoSelectorComponent::DisplayIcaoAndId);
ui->selector_AirlineIcao->displayMode(CDbAirlineIcaoSelectorComponent::DisplayVDesignatorAndId);
this->setLogoffCountdown();
connect(&m_logoffCountdownTimer, &QTimer::timeout, this, &CLoginComponent::logoffCountdown);
connect(ui->comp_OtherServers, &CServerListSelector::serverChanged, this, &CLoginComponent::onSelectedServerChanged);
connect(ui->comp_VatsimServers, &CServerListSelector::serverChanged, this, &CLoginComponent::onSelectedServerChanged);
connect(ui->pb_RefreshOtherServers, &QToolButton::clicked, this, &CLoginComponent::reloadOtherServersSetup);
connect(ui->tw_Network, &QTabWidget::currentChanged, this, &CLoginComponent::onServerTabWidgetChanged);
connect(ui->pb_Cancel, &QPushButton::clicked, this, &CLoginComponent::loginCancelled, Qt::QueuedConnection);
connect(ui->pb_Ok, &QPushButton::clicked, this, &CLoginComponent::toggleNetworkConnection, Qt::QueuedConnection);
connect(ui->pb_OtherServersGotoSettings, &QPushButton::pressed, this, &CLoginComponent::requestNetworkSettings);
connect(&m_networkSetup, &CNetworkSetup::setupChanged, this, &CLoginComponent::reloadOtherServersSetup, Qt::QueuedConnection);
ui->lblp_AircraftCombinedType->setToolTips("ok", "wrong");
ui->lblp_AirlineIcao->setToolTips("ok", "wrong");
ui->lblp_AircraftIcao->setToolTips("ok", "wrong");
ui->lblp_Callsign->setToolTips("ok", "wrong");
connect(ui->comp_NetworkDetails, &CNetworkDetailsComponent::requestNetworkSettings, this, &CLoginComponent::requestNetworkSettings, Qt::QueuedConnection);
// overlay
this->setOverlaySizeFactors(0.8, 0.5);
@@ -106,21 +89,6 @@ namespace BlackGui::Components
// Remark: The validators affect the signals such as returnPressed, editingFinished
// So I use no ranges in the CUpperCaseValidators, as this disables the signals for invalid values
// own aircraft
constexpr int MaxLength = 10;
constexpr int MinLength = 0;
CUpperCaseValidator *ucv = new CUpperCaseValidator(MinLength, MaxLength, ui->le_Callsign);
// ucv->setAllowedCharacters09AZ();
ui->le_Callsign->setMaxLength(MaxLength);
ui->le_Callsign->setValidator(ucv);
connect(ui->le_Callsign, &QLineEdit::editingFinished, this, &CLoginComponent::validateAircraftValues);
ui->le_AircraftCombinedType->setMaxLength(3);
ui->le_AircraftCombinedType->setValidator(new CUpperCaseValidator(this));
connect(ui->le_AircraftCombinedType, &QLineEdit::editingFinished, this, &CLoginComponent::validateAircraftValues);
connect(ui->selector_AircraftIcao, &CDbAircraftIcaoSelectorComponent::changedAircraftIcao, this, &CLoginComponent::onChangedAircraftIcao, Qt::QueuedConnection);
connect(ui->selector_AirlineIcao, &CDbAirlineIcaoSelectorComponent::changedAirlineIcao, this, &CLoginComponent::onChangedAirlineIcao, Qt::QueuedConnection);
if (sGui && sGui->getIContextSimulator())
{
connect(sGui->getIContextSimulator(), &IContextSimulator::ownAircraftModelChanged, this, &CLoginComponent::onSimulatorModelChanged, Qt::QueuedConnection);
@@ -140,31 +108,16 @@ namespace BlackGui::Components
ui->tb_Timeout->setIcon(m_iconPause);
connect(ui->tb_Timeout, &QToolButton::clicked, this, &CLoginComponent::toggleTimeout);
// web service data
if (sGui && sGui->getWebDataServices())
{
connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CLoginComponent::onWebServiceDataRead, Qt::QueuedConnection);
}
// inital setup, if data already available
this->validateAircraftValues();
ui->form_Pilot->validate();
this->onWebServiceDataRead(CEntityFlags::VatsimDataFile, CEntityFlags::ReadFinished, -1, {});
this->reloadOtherServersSetup();
if (sGui && sGui->getIContextSimulator())
{
this->onSimulatorStatusChanged(sGui->getIContextSimulator()->getSimulatorStatus());
}
connect(ui->pb_OverrideCredentialsVatsim, &QPushButton::clicked, this, &CLoginComponent::overrideCredentialsToPilot);
connect(ui->pb_OverrideCredentialsOtherServers, &QPushButton::clicked, this, &CLoginComponent::overrideCredentialsToPilot);
this->updateUiConnectState();
const int tab = m_networkSetup.wasLastUsedWithOtherServer() ? LoginOthers : LoginVATSIM;
ui->tw_Network->setCurrentIndex(tab);
QPointer<CLoginComponent> myself(this);
QTimer::singleShot(5000, this, [=] {
if (!myself) { return; }
@@ -184,7 +137,7 @@ namespace BlackGui::Components
}
else
{
this->setOwnModelAndIcaoValues();
ui->comp_OwnAircraft->setOwnModelAndIcaoValues();
m_networkConnected = sGui->getIContextNetwork()->isConnected();
this->updateUiConnectState();
this->blinkConnectButton();
@@ -228,7 +181,8 @@ namespace BlackGui::Components
CStatusMessage msg;
if (!m_networkConnected)
{
if (!this->validateAircraftValues())
const CStatusMessageList aircraftMsgs = ui->comp_OwnAircraft->validate();
if (aircraftMsgs.isFailure())
{
this->showOverlayHTMLMessage(CStatusMessage(this).validationWarning(u"Invalid aircraft data, login not possible"), OverlayMessageMs);
return;
@@ -242,11 +196,12 @@ namespace BlackGui::Components
}
// sync values with GUI values
const COwnAircraftComponent::CGuiAircraftValues values = ui->comp_OwnAircraft->getAircraftValuesFromGui();
this->updateOwnAircraftCallsignAndPilotFromGuiValues();
this->updateOwnAircaftIcaoValuesFromGuiValues();
ui->comp_OwnAircraft->updateOwnAircaftIcaoValuesFromGuiValues();
// Login mode
const CLoginMode mode = ui->frp_LoginMode->getLoginMode();
const CLoginMode mode = ui->comp_NetworkDetails->getLoginMode();
if (mode.isObserver()) { CLogMessage(this).info(u"Login in observer mode"); }
// Server
@@ -260,8 +215,27 @@ namespace BlackGui::Components
// set own aircraft from all values
ownAircraft = sGui->getIContextOwnAircraft()->getOwnAircraft();
// check the copilot stuff
CCallsign partnerCs;
if (ui->comp_NetworkDetails->hasPartnerCallsign())
{
partnerCs = ui->comp_NetworkDetails->getPartnerCallsign();
if (partnerCs == ownAircraft.getCallsign())
{
this->showOverlayHTMLMessage("Your callsign and the pilot/copilot callsign must be NOT the same", OverlayMessageMs);
return;
}
const bool ok = (partnerCs.asString().startsWith(ownAircraft.getCallsignAsString(), Qt::CaseInsensitive) || ownAircraft.getCallsignAsString().startsWith(partnerCs.asString(), Qt::CaseInsensitive));
if (!ok)
{
this->showOverlayHTMLMessage("Callsign and the pilot/copilot callsign appear not to be synchronized", OverlayMessageMs);
return;
}
}
// Login
msg = sGui->getIContextNetwork()->connectToNetwork(currentServer, {}, true, {}, true, {}, mode);
msg = sGui->getIContextNetwork()->connectToNetwork(currentServer, values.ownLiverySend, values.useLivery, values.ownAircraftModelStringSend, values.useModelString, partnerCs, mode);
if (msg.isSuccess())
{
Q_ASSERT_X(currentServer.isValidForLogin(), Q_FUNC_INFO, "invalid server");
@@ -303,63 +277,12 @@ namespace BlackGui::Components
}
}
void CLoginComponent::onWebServiceDataRead(CEntityFlags::Entity entity, CEntityFlags::ReadState state, int number, const QUrl &url)
{
if (!CEntityFlags::isFinishedReadState(state)) { return; }
if (!sGui || !sGui->getIContextNetwork() || sGui->isShuttingDown()) { return; }
Q_UNUSED(number)
Q_UNUSED(url)
if (entity == CEntityFlags::VatsimDataFile)
{
CServerList vatsimFsdServers = sGui->getIContextNetwork()->getVatsimFsdServers();
if (vatsimFsdServers.isEmpty()) { return; }
vatsimFsdServers.sortBy(&CServer::getName);
const CServer currentServer = m_networkSetup.getLastVatsimServer();
ui->comp_VatsimServers->setServers(vatsimFsdServers, true);
ui->comp_VatsimServers->preSelect(currentServer.getName());
}
}
void CLoginComponent::loadRememberedUserData()
{
const CServer lastServer = m_networkSetup.getLastServer();
if (!lastServer.isNull())
{
ui->tw_Network->setCurrentWidget(
lastServer.getServerType() == CServer::FSDServerVatsim ?
ui->tb_NetworkVatsim :
ui->tb_OtherServers);
}
const CUser lastUser = lastServer.getUser();
ui->form_Pilot->setUser(lastUser);
if (lastUser.hasCallsign())
{
ui->le_Callsign->setText(lastUser.getCallsign().asString());
}
else if (CBuildConfig::isLocalDeveloperDebugBuild())
{
ui->le_Callsign->setText("SWIFT");
}
}
void CLoginComponent::overrideCredentialsToPilot()
{
CServer server;
const QObject *s = QObject::sender();
if (s == ui->pb_OverrideCredentialsOtherServers)
{
server = this->getCurrentOtherServer();
}
else if (s == ui->pb_OverrideCredentialsVatsim)
{
// the VATSIM server selected has no valid user credentials
server = m_networkSetup.getLastVatsimServer();
}
else { return; }
ui->form_Pilot->setUser(server.getUser(), true);
ui->comp_OwnAircraft->setUser(lastUser);
}
void CLoginComponent::onSelectedServerChanged(const CServer &server)
@@ -415,39 +338,16 @@ namespace BlackGui::Components
return true;
}
void CLoginComponent::setServerButtonsVisible(bool visible)
{
ui->wi_OtherServersButtons->setVisible(visible);
ui->wi_VatsimButtons->setVisible(visible);
}
CLoginComponent::CGuiAircraftValues CLoginComponent::getAircraftValuesFromGui() const
{
CGuiAircraftValues values;
values.ownCallsign = CCallsign(ui->le_Callsign->text().trimmed().toUpper());
values.ownAircraftIcao = ui->selector_AircraftIcao->getAircraftIcao();
values.ownAirlineIcao = ui->selector_AirlineIcao->getAirlineIcao();
values.ownAircraftCombinedType = ui->le_AircraftCombinedType->text().trimmed().toUpper();
values.ownAircraftSimulatorModel = ui->le_SimulatorModel->text().trimmed().toUpper();
return values;
}
CUser CLoginComponent::getUserFromPilotGuiValues() const
{
CUser user = ui->form_Pilot->getUser();
user.setCallsign(this->getCallsignFromGui());
user.setCallsign(ui->comp_OwnAircraft->getCallsignFromGui());
return user;
}
CCallsign CLoginComponent::getCallsignFromGui() const
{
const CCallsign cs(ui->le_Callsign->text().trimmed().toUpper());
return cs;
}
CServer CLoginComponent::getCurrentVatsimServer() const
{
CServer server = ui->comp_VatsimServers->currentServer();
CServer server = ui->comp_NetworkDetails->getCurrentVatsimServer();
if (!server.getUser().hasValidVatsimId())
{
// normally VATSIM server have no valid user associated
@@ -459,7 +359,7 @@ namespace BlackGui::Components
CServer CLoginComponent::getCurrentOtherServer() const
{
return ui->comp_OtherServers->currentServer();
return ui->comp_NetworkDetails->getCurrentOtherServer();
}
CServer CLoginComponent::getCurrentServer() const
@@ -475,91 +375,6 @@ namespace BlackGui::Components
ui->fr_TimeoutConnected->show();
}
void CLoginComponent::setOwnModelAndIcaoValues(const CAircraftModel &ownModel)
{
if (!this->hasValidContexts()) { return; }
CAircraftModel model = ownModel;
const bool simulating = sGui->getIContextSimulator() &&
(sGui->getIContextSimulator()->getSimulatorStatus() & ISimulator::Simulating);
// fill simulator related values
if (simulating)
{
if (!model.hasModelString())
{
model = sGui->getIContextOwnAircraft()->getOwnAircraft().getModel();
}
const QString modelAndKey(model.getModelStringAndDbKey());
ui->le_SimulatorModel->setText(modelAndKey);
ui->le_SimulatorModel->home(false);
this->highlightModelField(model);
const CSimulatorInfo sim = sGui->getIContextSimulator()->getSimulatorPluginInfo().getSimulator();
const CSimulatorInternals simulatorInternals = sGui->getIContextSimulator()->getSimulatorInternals();
const QString simStr = sim.toQString() + QStringLiteral(" ") + simulatorInternals.getSimulatorVersion();
CCrashHandler::instance()->crashAndLogInfoSimulator(simStr);
}
else
{
ui->le_SimulatorModel->clear();
this->highlightModelField();
}
ui->le_SimulatorModel->setToolTip(model.asHtmlSummary());
// reset the model
bool changedOwnAircraftIcaoValues = false;
if (model.isLoadedFromDb() || (model.getAircraftIcaoCode().isLoadedFromDb() && model.getLivery().isLoadedFromDb()))
{
// full model from DB, take all values
this->setGuiIcaoValues(model, false);
}
else
{
// we have a model, which is not from DB
model = this->getPrefillModel(); // manually entered values
if (model.getLivery().hasValidDbKey() && model.getLivery().isColorLivery())
{
// special case for color liveries/NO airline
ui->selector_AirlineIcao->clear();
}
this->setGuiIcaoValues(model, true);
changedOwnAircraftIcaoValues = this->updateOwnAircaftIcaoValuesFromGuiValues();
}
const bool changedOwnAircraftCallsignPilot = this->updateOwnAircraftCallsignAndPilotFromGuiValues();
if (changedOwnAircraftIcaoValues || changedOwnAircraftCallsignPilot)
{
m_changedLoginDataDigestSignal.inputSignal();
}
}
bool CLoginComponent::setGuiIcaoValues(const CAircraftModel &model, bool onlyIfEmpty)
{
bool changed = false;
if (!onlyIfEmpty || !ui->selector_AircraftIcao->isSet())
{
changed = ui->selector_AircraftIcao->setAircraftIcao(model.getAircraftIcaoCode());
}
if (!onlyIfEmpty || !ui->selector_AirlineIcao->isSet())
{
const bool c = ui->selector_AirlineIcao->setAirlineIcao(model.getAirlineIcaoCode());
changed |= c;
}
if (!onlyIfEmpty || ui->le_AircraftCombinedType->text().trimmed().isEmpty())
{
const QString combined(model.getAircraftIcaoCode().getCombinedType());
if (ui->le_AircraftCombinedType->text() != combined)
{
ui->le_AircraftCombinedType->setText(combined);
changed = true;
}
}
const bool valid = this->validateAircraftValues();
return valid ? changed : false;
}
void CLoginComponent::setGuiLoginAsValues(const CSimulatedAircraft &ownAircraft)
{
const QString ac(
@@ -571,56 +386,6 @@ namespace BlackGui::Components
ui->le_LoginAsAircaft->setText(ac);
ui->le_LoginAsAircaft->home(false);
ui->le_LoginCallsign->setText(cs);
if (!cs.isEmpty()) { ui->le_Callsign->setText(cs); }
}
bool CLoginComponent::validateAircraftValues()
{
CGuiAircraftValues values = this->getAircraftValuesFromGui();
// fill in combined type if empty
if (ui->le_AircraftCombinedType->text().isEmpty() && values.ownAircraftIcao.isLoadedFromDb())
{
ui->le_AircraftCombinedType->setText(values.ownAircraftIcao.getCombinedType());
values.ownAircraftCombinedType = values.ownAircraftIcao.getCombinedType();
}
const bool validCombinedType = CAircraftIcaoCode::isValidCombinedType(values.ownAircraftCombinedType);
ui->lblp_AircraftCombinedType->setTicked(validCombinedType);
// airline is optional, e.g. C172 has no airline
const bool validAirlineDesignator = values.ownAirlineIcao.hasValidDesignator() || values.ownAirlineIcao.getDesignator().isEmpty();
ui->lblp_AirlineIcao->setTicked(validAirlineDesignator);
const bool validAircraftDesignator = values.ownAircraftIcao.hasValidDesignator();
ui->lblp_AircraftIcao->setTicked(validAircraftDesignator);
const bool validCallsign = CCallsign::isValidAircraftCallsign(values.ownCallsign);
ui->lblp_Callsign->setTicked(validCallsign);
// model intentionally ignored
return validCombinedType && validAirlineDesignator && validAircraftDesignator && validCallsign;
}
void CLoginComponent::onChangedAircraftIcao(const CAircraftIcaoCode &icao)
{
if (icao.isLoadedFromDb())
{
ui->le_AircraftCombinedType->setText(icao.getCombinedType());
}
this->validateAircraftValues();
}
void CLoginComponent::onChangedAirlineIcao(const CAirlineIcaoCode &icao)
{
Q_UNUSED(icao)
this->validateAircraftValues();
}
void CLoginComponent::reloadOtherServersSetup()
{
const CServerList otherServers(m_networkSetup.getOtherServersPlusPredefinedServers());
ui->comp_OtherServers->setServers(otherServers);
}
void CLoginComponent::logoffCountdown()
@@ -689,7 +454,7 @@ namespace BlackGui::Components
CLogMessage(this).validationInfo(u"Hint: Are you using the emulated driver? Set a model if so!");
return;
}
this->setOwnModelAndIcaoValues(reverseModel);
ui->comp_OwnAircraft->setOwnModelAndIcaoValues(reverseModel);
// check state of own aircraft
this->updateOwnAircraftCallsignAndPilotFromGuiValues();
@@ -750,17 +515,9 @@ namespace BlackGui::Components
timer->start(blinkLength);
}
void CLoginComponent::highlightModelField(const CAircraftModel &model)
{
if (!model.hasModelString()) { ui->le_SimulatorModel->setProperty("validation", "error"); }
else if (!model.isLoadedFromDb()) { ui->le_SimulatorModel->setProperty("validation", "warning"); }
else { ui->le_SimulatorModel->setProperty("validation", "ok"); }
ui->le_SimulatorModel->setStyleSheet(""); // force update
}
bool CLoginComponent::isVatsimNetworkTabSelected() const
{
return (ui->tw_Network->currentWidget() == ui->tb_NetworkVatsim);
return ui->comp_NetworkDetails->isVatsimServerSelected();
}
CAircraftModel CLoginComponent::getPrefillModel() const
@@ -774,13 +531,12 @@ namespace BlackGui::Components
{
if (!this->hasValidContexts()) { return false; }
CSimulatedAircraft ownAircraft(sGui->getIContextOwnAircraft()->getOwnAircraft());
const QString cs(ui->le_Callsign->text().trimmed().toUpper());
const CCallsign cs = ui->comp_OwnAircraft->getCallsignFromGui();
bool changedCallsign = false;
if (!cs.isEmpty() && ownAircraft.getCallsignAsString() != cs)
{
const CCallsign callsign(cs, CCallsign::Aircraft);
sGui->getIContextOwnAircraft()->updateOwnCallsign(callsign);
ownAircraft.setCallsign(callsign); // also update
sGui->getIContextOwnAircraft()->updateOwnCallsign(cs);
ownAircraft.setCallsign(cs); // also update
changedCallsign = true;
}
CUser pilot = ownAircraft.getPilot();
@@ -798,35 +554,6 @@ namespace BlackGui::Components
return changedCallsign || changedPilot;
}
bool CLoginComponent::updateOwnAircaftIcaoValuesFromGuiValues()
{
if (!this->hasValidContexts()) { return false; }
const CSimulatedAircraft ownAircraft(sGui->getIContextOwnAircraft()->getOwnAircraft());
const CGuiAircraftValues aircraftValues = this->getAircraftValuesFromGui();
CAircraftIcaoCode aircraftCode(ownAircraft.getAircraftIcaoCode());
CAirlineIcaoCode airlineCode(ownAircraft.getAirlineIcaoCode());
bool changedIcaoCodes = false;
if (aircraftValues.ownAircraftIcao.hasValidDesignator() && aircraftValues.ownAircraftIcao != aircraftCode)
{
aircraftCode = aircraftValues.ownAircraftIcao;
changedIcaoCodes = true;
}
if (aircraftValues.ownAirlineIcao.hasValidDesignator() && aircraftValues.ownAirlineIcao != airlineCode)
{
airlineCode = aircraftValues.ownAirlineIcao;
changedIcaoCodes = true;
}
if (changedIcaoCodes)
{
sGui->getIContextOwnAircraft()->updateOwnIcaoCodes(aircraftCode, airlineCode);
}
return changedIcaoCodes;
}
void CLoginComponent::updateGui()
{
if (!m_networkConnected) { return; }
@@ -836,10 +563,10 @@ namespace BlackGui::Components
const CSimulatedAircraft ownAircraft = sGui->getIContextOwnAircraft()->getOwnAircraft();
this->setGuiLoginAsValues(ownAircraft);
this->updateUiConnectState();
this->setOwnModelAndIcaoValues();
ui->comp_OwnAircraft->setOwnModelAndIcaoValues();
const CServer server = nwc->getConnectedServer();
ui->le_LoginHomeBase->setText(server.getUser().getHomeBase().asString());
ui->frp_CurrentServer->setServer(server);
ui->frp_LoginMode->setLoginMode(nwc->getLoginMode());
ui->comp_NetworkDetails->setLoginMode(nwc->getLoginMode());
}
} // namespace

View File

@@ -94,44 +94,20 @@ namespace BlackGui::Components
void loginDataChangedDigest();
private:
//! GUI aircraft values, formatted
struct CGuiAircraftValues
{
BlackMisc::Aviation::CCallsign ownCallsign;
BlackMisc::Aviation::CAircraftIcaoCode ownAircraftIcao;
BlackMisc::Aviation::CAirlineIcaoCode ownAirlineIcao;
QString ownAircraftCombinedType;
QString ownAircraftSimulatorModel;
};
// -------------- values from GUI -----------------
//! Values from GUI
CGuiAircraftValues getAircraftValuesFromGui() const;
//! User from VATSIM data
BlackMisc::Network::CUser getUserFromPilotGuiValues() const;
//! Callsign from GUI
BlackMisc::Aviation::CCallsign getCallsignFromGui() const;
//! Update own callsign (own aircraft from what is set in the GUI)
//! \return changed?
bool updateOwnAircraftCallsignAndPilotFromGuiValues();
//! Update own ICAO values (own aircraft from what is set in the GUI)
//! \return changed?
bool updateOwnAircaftIcaoValuesFromGuiValues();
// -------------- values to GUI -----------------
//! Update GUI values
void updateGui();
//! Set ICAO values
//! \return changed values?
bool setGuiIcaoValues(const BlackMisc::Simulation::CAircraftModel &model, bool onlyIfEmpty);
//! Set the "login as" values
void setGuiLoginAsValues(const BlackMisc::Simulation::CSimulatedAircraft &ownAircraft);
@@ -152,21 +128,6 @@ namespace BlackGui::Components
//! Login cancelled
void loginCancelled();
//! VATSIM data file was loaded
void onWebServiceDataRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState state, int number, const QUrl &url);
//! Validate aircaft
bool validateAircraftValues();
//! Aircraft ICAO code has been changed
void onChangedAircraftIcao(const BlackMisc::Aviation::CAircraftIcaoCode &icao);
//! Airline ICAO code has been changed
void onChangedAirlineIcao(const BlackMisc::Aviation::CAirlineIcaoCode &icao);
//! Settings have been changed
void reloadOtherServersSetup();
//! Logoff countdown
void logoffCountdown();
@@ -188,27 +149,18 @@ namespace BlackGui::Components
//! Make disconnect button flash briefly to catch the user's attention
void blinkConnectButton();
//! Own model and ICAO data for GUI and own aircraft
void setOwnModelAndIcaoValues(const BlackMisc::Simulation::CAircraftModel &ownModel = {});
//! Set OK button string
void setOkButtonString(bool connected);
//! Logoff countdown
void startLogoffTimerCountdown();
//! Highlight model field according to model data
void highlightModelField(const BlackMisc::Simulation::CAircraftModel &model = {});
//! Is the VATSIM network tab selected?
bool isVatsimNetworkTabSelected() const;
//! Load from settings
void loadRememberedUserData();
//! Copy credentials to pilot
void overrideCredentialsToPilot();
//! Server changed
void onSelectedServerChanged(const BlackMisc::Network::CServer &server);
@@ -224,9 +176,6 @@ namespace BlackGui::Components
//! Has contexts?
bool hasValidContexts() const;
//! Set the server buttons visible
void setServerButtonsVisible(bool visible);
static constexpr int OverlayMessageMs = 5000;
static constexpr int LogoffIntervalSeconds = 20; //!< time before logoff

View File

@@ -65,221 +65,11 @@
<property name="bottomMargin">
<number>3</number>
</property>
<item alignment="Qt::AlignTop">
<widget class="QTabWidget" name="tw_Network">
<property name="tabPosition">
<enum>QTabWidget::North</enum>
<item>
<widget class="BlackGui::Components::CNetworkDetailsComponent" name="comp_NetworkDetails">
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tb_NetworkVatsim">
<attribute name="title">
<string>VATSIM</string>
</attribute>
<layout class="QGridLayout" name="gl_NetworkVATSIM">
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<property name="horizontalSpacing">
<number>3</number>
</property>
<item row="1" column="0">
<widget class="QWidget" name="wi_VatsimButtons" native="true">
<layout class="QHBoxLayout" name="hl_VatsimButtons">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="hs_VatsimButtons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pb_OverrideCredentialsVatsim">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>copy credentials to pilot section</string>
</property>
<property name="text">
<string> override pilot </string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="BlackGui::Components::CServerListSelector" name="comp_VatsimServers"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tb_OtherServers">
<attribute name="title">
<string>Other servers</string>
</attribute>
<layout class="QGridLayout" name="gl_OtherServers">
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<property name="horizontalSpacing">
<number>3</number>
</property>
<item row="0" column="0">
<widget class="BlackGui::Components::CServerListSelector" name="comp_OtherServers"/>
</item>
<item row="1" column="0">
<widget class="QWidget" name="wi_OtherServersButtons" native="true">
<layout class="QHBoxLayout" name="hl_OtherServersButtons">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="hs_OtherServersButtons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pb_RefreshOtherServers">
<property name="text">
<string>reload</string>
</property>
<property name="icon">
<iconset>
<normaloff>:/diagona/icons/diagona/icons/arrow-circle-225.png</normaloff>:/diagona/icons/diagona/icons/arrow-circle-225.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_OtherServersGotoSettings">
<property name="text">
<string> goto settings </string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_OverrideCredentialsOtherServers">
<property name="toolTip">
<string>copy credentials to pilot section</string>
</property>
<property name="text">
<string> override pilot </string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item alignment="Qt::AlignTop">
<widget class="QTabWidget" name="tw_Details">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tb_LoginMode">
<attribute name="title">
<string>Mode</string>
</attribute>
<layout class="QVBoxLayout" name="vl_LoginMode">
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item alignment="Qt::AlignTop">
<widget class="BlackGui::CLoginModeButtons" name="frp_LoginMode"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tb_MatchingLog">
<attribute name="title">
<string>Matching log</string>
</attribute>
<layout class="QVBoxLayout" name="vl_MatchingLog">
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item alignment="Qt::AlignTop">
<widget class="BlackGui::Components::CModelMatcherLogEnable" name="comp_MatchingLogEnabled"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
@@ -333,186 +123,26 @@
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gl_OwnAircraft">
<layout class="QVBoxLayout" name="vl_OwnAircraft">
<property name="leftMargin">
<number>6</number>
<number>2</number>
</property>
<property name="topMargin">
<number>10</number>
<number>2</number>
</property>
<property name="rightMargin">
<number>6</number>
<number>2</number>
</property>
<property name="bottomMargin">
<number>3</number>
<number>2</number>
</property>
<item row="2" column="4">
<widget class="BlackGui::Components::CDbAirlineIcaoSelectorComponent" name="selector_AirlineIcao">
<property name="minimumSize">
<size>
<width>75</width>
<height>0</height>
</size>
<item>
<widget class="BlackGui::Components::COwnAircraftComponent" name="comp_OwnAircraft">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="BlackGui::Components::CDbAircraftIcaoSelectorComponent" name="selector_AircraftIcao">
<property name="minimumSize">
<size>
<width>75</width>
<height>0</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
</widget>
</item>
<item row="0" column="1" colspan="5">
<widget class="QWidget" name="wi_SimulatorModel" native="true">
<layout class="QHBoxLayout" name="hl_AircraftModel">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="le_SimulatorModel">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>unique model identifier</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="2">
<widget class="BlackGui::CTickLabel" name="lblp_Callsign">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lbl_Model">
<property name="toolTip">
<string>Launch </string>
</property>
<property name="text">
<string>Model</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_Callsign">
<property name="text">
<string>Callsign</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="lbl_AircraftIcaoDesignator">
<property name="toolTip">
<string>ICAO code e.g. B737, A320, F18</string>
</property>
<property name="text">
<string>Aircraft</string>
</property>
</widget>
</item>
<item row="2" column="5">
<widget class="BlackGui::CTickLabel" name="lblp_AirlineIcao">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLabel" name="lbl_AircraftIcaoAirline">
<property name="toolTip">
<string>ICAO code e.g. DLH, LHA, ...</string>
</property>
<property name="text">
<string>Airline</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="le_AircraftCombinedType">
<property name="toolTip">
<string>e.g. L2J</string>
</property>
<property name="inputMask">
<string/>
</property>
<property name="text">
<string/>
</property>
<property name="maxLength">
<number>3</number>
</property>
<property name="placeholderText">
<string>e.g. &quot;L2J&quot;</string>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="BlackGui::CTickLabel" name="lblp_AircraftIcao">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="le_Callsign">
<property name="toolTip">
<string>e.g. DEMBZ</string>
</property>
<property name="inputMethodHints">
<set>Qt::ImhUppercaseOnly</set>
</property>
<property name="maxLength">
<number>10</number>
</property>
<property name="placeholderText">
<string>e.g. DEMBZ</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lbl_AircraftCombinedType">
<property name="toolTip">
<string>Aircraft type e.g. L2J, L1P, ....</string>
</property>
<property name="text">
<string>Type</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="BlackGui::CTickLabel" name="lblp_AircraftCombinedType">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
@@ -769,6 +399,18 @@
<extends>QComboBox</extends>
<header>blackgui/components/serverlistselector.h</header>
</customwidget>
<customwidget>
<class>BlackGui::Components::CNetworkDetailsComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/networkdetailscomponent.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::COwnAircraftComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/ownaircraftcomponent.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::CLoginModeButtons</class>
<extends>QFrame</extends>
@@ -812,16 +454,8 @@
</customwidget>
</customwidgets>
<tabstops>
<tabstop>tw_Network</tabstop>
<tabstop>comp_VatsimServers</tabstop>
<tabstop>pb_OverrideCredentialsVatsim</tabstop>
<tabstop>tw_Details</tabstop>
<tabstop>comp_NetworkDetails</tabstop>
<tabstop>form_Pilot</tabstop>
<tabstop>le_SimulatorModel</tabstop>
<tabstop>le_Callsign</tabstop>
<tabstop>selector_AircraftIcao</tabstop>
<tabstop>le_AircraftCombinedType</tabstop>
<tabstop>selector_AirlineIcao</tabstop>
<tabstop>frp_CurrentServer</tabstop>
<tabstop>le_LoginCallsign</tabstop>
<tabstop>le_LoginHomeBase</tabstop>
@@ -830,10 +464,6 @@
<tabstop>tb_Timeout</tabstop>
<tabstop>pb_Ok</tabstop>
<tabstop>pb_Cancel</tabstop>
<tabstop>comp_OtherServers</tabstop>
<tabstop>pb_RefreshOtherServers</tabstop>
<tabstop>pb_OtherServersGotoSettings</tabstop>
<tabstop>pb_OverrideCredentialsOtherServers</tabstop>
</tabstops>
<resources/>
<connections/>