mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-09 13:35:34 +08:00
refs #780, fixes login/flightplan preset
* empty airline is valid * sync with flightplan (new signal to indicate changed login values) * better preset of own model
This commit is contained in:
@@ -59,6 +59,7 @@ namespace BlackGui
|
||||
ui(new Ui::CFlightPlanComponent)
|
||||
{
|
||||
Q_ASSERT_X(sGui, Q_FUNC_INFO, "missing sGui");
|
||||
Q_ASSERT_X(sGui->hasWebDataServices(), Q_FUNC_INFO, "missing web services");
|
||||
|
||||
// UI
|
||||
ui->setupUi(this);
|
||||
@@ -119,7 +120,10 @@ namespace BlackGui
|
||||
{
|
||||
if (this->m_flightPlan.wasSentOrLoaded()) { return; } // when loaded or sent do not override
|
||||
if (!sGui->getIContextOwnAircraft()) { return; }
|
||||
this->prefillWithAircraftData(sGui->getIContextOwnAircraft()->getOwnAircraft());
|
||||
|
||||
const CSimulatedAircraft ownAircraft(sGui->getIContextOwnAircraft()->getOwnAircraft());
|
||||
this->prefillWithAircraftData(ownAircraft);
|
||||
this->prefillWithUserData(ownAircraft.getPilot());
|
||||
}
|
||||
|
||||
void CFlightPlanComponent::prefillWithAircraftData(const BlackMisc::Simulation::CSimulatedAircraft &ownAircraft)
|
||||
@@ -139,6 +143,18 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CFlightPlanComponent::prefillWithUserData(const Network::CUser &user)
|
||||
{
|
||||
if (user.hasValidRealName())
|
||||
{
|
||||
ui->le_PilotsName->setText(user.getRealName());
|
||||
}
|
||||
if (user.hasHomeBase())
|
||||
{
|
||||
ui->le_PilotsHomeBase->setText(user.getHomeBase().getIcaoCode());
|
||||
}
|
||||
}
|
||||
|
||||
void CFlightPlanComponent::fillWithFlightPlanData(const BlackMisc::Aviation::CFlightPlan &flightPlan)
|
||||
{
|
||||
ui->le_AlternateAirport->setText(flightPlan.getAlternateAirportIcao().asString());
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackmisc/aviation/flightplan.h"
|
||||
#include "blackmisc/network/user.h"
|
||||
#include "blackmisc/identifier.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
|
||||
@@ -52,6 +53,9 @@ namespace BlackGui
|
||||
//! Prefill with aircraft data
|
||||
void prefillWithAircraftData(const BlackMisc::Simulation::CSimulatedAircraft &ownAircraft);
|
||||
|
||||
//! Prefill with user data
|
||||
void prefillWithUserData(const BlackMisc::Network::CUser &user);
|
||||
|
||||
//! Prefill with aircraft dara
|
||||
void fillWithFlightPlanData(const BlackMisc::Aviation::CFlightPlan &flightPlan);
|
||||
|
||||
|
||||
@@ -246,7 +246,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="lbl_PilotsNameAndHomebase">
|
||||
<widget class="QLabel" name="lbl_PilotsNameAndHomeBase">
|
||||
<property name="text">
|
||||
<string>14. Pilots name / homebase</string>
|
||||
</property>
|
||||
@@ -447,7 +447,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="3">
|
||||
<widget class="QLineEdit" name="le_PilotsHomebase"/>
|
||||
<widget class="QLineEdit" name="le_PilotsHomeBase"/>
|
||||
</item>
|
||||
<item row="6" column="3">
|
||||
<widget class="QLabel" name="lbl_AlternateAirport">
|
||||
@@ -1027,7 +1027,7 @@
|
||||
<tabstop>pb_RemarksGenerator</tabstop>
|
||||
<tabstop>pte_Remarks</tabstop>
|
||||
<tabstop>le_PilotsName</tabstop>
|
||||
<tabstop>le_PilotsHomebase</tabstop>
|
||||
<tabstop>le_PilotsHomeBase</tabstop>
|
||||
<tabstop>pb_Reset</tabstop>
|
||||
<tabstop>pb_Load</tabstop>
|
||||
<tabstop>pb_Send</tabstop>
|
||||
|
||||
@@ -248,7 +248,7 @@ namespace BlackGui
|
||||
if (ownAircraft.getCallsign() != aircraftValues.ownCallsign)
|
||||
{
|
||||
ownAircraft.setCallsign(aircraftValues.ownCallsign);
|
||||
sGui->getIContextOwnAircraft()->updateOwnCallsign(ownAircraft.getCallsign());
|
||||
this->updateOwnCallsignAndPilotFromGuiValue();
|
||||
}
|
||||
|
||||
if (setIcaoCodes)
|
||||
@@ -354,7 +354,7 @@ namespace BlackGui
|
||||
ui->le_Callsign->setText(lastUser.getCallsign().asString());
|
||||
ui->le_VatsimId->setText(lastUser.getId());
|
||||
ui->le_VatsimPassword->setText(lastUser.getPassword());
|
||||
ui->le_VatsimHomeAirport->setText(lastUser.getHomebase().asString());
|
||||
ui->le_VatsimHomeAirport->setText(lastUser.getHomeBase().asString());
|
||||
ui->le_VatsimRealName->setText(lastUser.getRealName());
|
||||
}
|
||||
else
|
||||
@@ -393,7 +393,7 @@ namespace BlackGui
|
||||
{
|
||||
CVatsimValues values = getVatsimValuesFromGui();
|
||||
CUser user(values.vatsimId, values.vatsimRealName, "", values.vatsimPassword, getCallsignFromGui());
|
||||
user.setHomebase(values.vatsimHomeAirport);
|
||||
user.setHomeBase(values.vatsimHomeAirport);
|
||||
return user;
|
||||
}
|
||||
|
||||
@@ -450,20 +450,29 @@ namespace BlackGui
|
||||
}
|
||||
else
|
||||
{
|
||||
static const CAircraftModel defaultModel(
|
||||
"", CAircraftModel::TypeOwnSimulatorModel, "default model",
|
||||
CAircraftIcaoCode("C172", "L1P", "Cessna", "172", "L", true, false, false, 0));
|
||||
model = this->m_currentAircraftModel.get();
|
||||
if (!model.hasAircraftDesignator()) { model = defaultModel; }
|
||||
model = this->getPrefillModel();
|
||||
ui->gbp_LoginMode->setLoginMode(INetwork::LoginNormal); //! \todo Set observer mode without simulator, currently not working in OBS mode
|
||||
ui->le_SimulatorModel->setText("");
|
||||
this->highlightModelField();
|
||||
}
|
||||
|
||||
if (model.hasAircraftDesignator())
|
||||
// reset the model
|
||||
if (model.isLoadedFromDb())
|
||||
{
|
||||
// full model from DB, take all values
|
||||
this->setGuiIcaoValues(model, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (model.hasAircraftDesignator())
|
||||
{
|
||||
// typed in model, override unempty values only
|
||||
this->setGuiIcaoValues(model, true);
|
||||
}
|
||||
}
|
||||
|
||||
this->updateOwnCallsignAndPilotFromGuiValue();
|
||||
this->triggerDataChangedSignal(1500);
|
||||
}
|
||||
|
||||
void CLoginComponent::setGuiIcaoValues(const CAircraftModel &model, bool onlyIfEmpty)
|
||||
@@ -491,7 +500,8 @@ namespace BlackGui
|
||||
const bool validCombinedType = CAircraftIcaoCode::isValidCombinedType(values.ownAircraftCombinedType);
|
||||
ui->lblp_AircraftCombinedType->setTicked(validCombinedType);
|
||||
|
||||
const bool validAirlineDesignator = values.ownAirlineIcao.hasValidDesignator();
|
||||
// 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();
|
||||
@@ -566,6 +576,7 @@ namespace BlackGui
|
||||
|
||||
void CLoginComponent::ps_simulatorModelChanged(const CAircraftModel &model)
|
||||
{
|
||||
Q_ASSERT_X(sGui && sGui->getIContextNetwork(), Q_FUNC_INFO, "Missing context");
|
||||
const bool isConnected = sGui && sGui->getIContextNetwork()->isConnected();
|
||||
if (isConnected) { return; }
|
||||
const QString modelStr(model.hasModelString() ? model.getModelString() : "<unknown>");
|
||||
@@ -581,6 +592,12 @@ namespace BlackGui
|
||||
{
|
||||
this->ps_mappingWizard();
|
||||
}
|
||||
|
||||
// check state of own aircraft
|
||||
this->updateOwnCallsignAndPilotFromGuiValue();
|
||||
|
||||
// let others know data changed
|
||||
this->triggerDataChangedSignal(1500);
|
||||
}
|
||||
|
||||
void CLoginComponent::ps_mappingWizard()
|
||||
@@ -647,5 +664,54 @@ namespace BlackGui
|
||||
static const QString sheet("background-color: %1;");
|
||||
ui->le_SimulatorModel->setStyleSheet(sheet.arg(color));
|
||||
}
|
||||
|
||||
void CLoginComponent::triggerDataChangedSignal(int deferTimeMs)
|
||||
{
|
||||
QTimer::singleShot(deferTimeMs, this, &CLoginComponent::loginDataChanged);
|
||||
}
|
||||
|
||||
CAircraftModel CLoginComponent::getPrefillModel() const
|
||||
{
|
||||
// if all fails
|
||||
static const CAircraftModel defaultModel(
|
||||
"", CAircraftModel::TypeOwnSimulatorModel, "default model",
|
||||
CAircraftIcaoCode("C172", "L1P", "Cessna", "172", "L", true, false, false, 0));
|
||||
|
||||
CAircraftModel model = this->m_currentAircraftModel.get();
|
||||
if (model.hasAircraftDesignator()) { return model; }
|
||||
|
||||
// create one from DB data
|
||||
if (sGui && sGui->hasWebDataServices())
|
||||
{
|
||||
const CAircraftIcaoCode icao = sGui->getWebDataServices()->getAircraftIcaoCodeForDesignator("C172");
|
||||
const CLivery livery = sGui->getWebDataServices()->getLiveryForCombinedCode("_CC_WHITE_WHITE");
|
||||
model = CAircraftModel("", CAircraftModel::TypeOwnSimulatorModel);
|
||||
model.setLivery(livery);
|
||||
model.setAircraftIcaoCode(icao);
|
||||
return model;
|
||||
}
|
||||
|
||||
return defaultModel;
|
||||
}
|
||||
|
||||
void CLoginComponent::updateOwnCallsignAndPilotFromGuiValue()
|
||||
{
|
||||
if (!sGui || !sGui->getIContextOwnAircraft()) { return; }
|
||||
const CSimulatedAircraft ownAircaft(sGui->getIContextOwnAircraft()->getOwnAircraft());
|
||||
const QString cs(ui->le_Callsign->text().trimmed().toUpper());
|
||||
if (!cs.isEmpty() && ownAircaft.getCallsignAsString() != cs)
|
||||
{
|
||||
sGui->getIContextOwnAircraft()->updateOwnCallsign(CCallsign(cs));
|
||||
}
|
||||
CUser pilot = ownAircaft.getPilot();
|
||||
pilot.setRealName(CUser::beautifyRealName(ui->le_VatsimRealName->text()));
|
||||
pilot.setHomeBase(CAirportIcaoCode(ui->le_VatsimHomeAirport->text()));
|
||||
pilot.setId(ui->le_VatsimId->text());
|
||||
pilot.setCallsign(CCallsign(cs));
|
||||
if (ownAircaft.getPilot() != pilot)
|
||||
{
|
||||
sGui->getIContextOwnAircraft()->updateOwnAircraftPilot(pilot);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -78,6 +78,9 @@ namespace BlackGui
|
||||
//! Request network settings
|
||||
void requestNetworkSettings();
|
||||
|
||||
//! Relevant login data changed
|
||||
void loginDataChanged();
|
||||
|
||||
public slots:
|
||||
//! Main info area chnaged
|
||||
void mainInfoAreaChanged(const QWidget *currentWidget);
|
||||
@@ -181,11 +184,20 @@ namespace BlackGui
|
||||
//! Highlight model field according to model data
|
||||
void highlightModelField(const BlackMisc::Simulation::CAircraftModel &model = {});
|
||||
|
||||
//! Trigger the signal that data have been changed
|
||||
void triggerDataChangedSignal(int deferTimeMs);
|
||||
|
||||
//! Get a prefill model
|
||||
BlackMisc::Simulation::CAircraftModel getPrefillModel() const;
|
||||
|
||||
//! Update own callsign (own aircraft from what is set in the GUI)
|
||||
void updateOwnCallsignAndPilotFromGuiValue();
|
||||
|
||||
QScopedPointer<Ui::CLoginComponent> ui;
|
||||
QScopedPointer<CDbQuickMappingWizard> m_mappingWizard;
|
||||
bool m_autoPopupWizard = false; //!< automatically popup wizard if mapping is needed
|
||||
bool m_visible = false; //!< is this component selected?
|
||||
const int LogoffIntervalSeconds = 10; //!< time before logoff
|
||||
const int LogoffIntervalSeconds = 20; //!< time before logoff
|
||||
QTimer *m_logoffCountdownTimer { nullptr }; //!< timer used logoff countdown
|
||||
BlackMisc::CSettingReadOnly<BlackCore::Vatsim::TTrafficServers> m_otherTrafficNetworkServers { this, &CLoginComponent::ps_reloadSettings };
|
||||
BlackMisc::CSetting<BlackGui::Settings::TOwnAircraftModel> m_currentAircraftModel { this }; //!< current settings of aircraft
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace BlackGui
|
||||
if (aircraft.hasValidRealName())
|
||||
{
|
||||
i += " - ";
|
||||
i += aircraft.getPilotRealname();
|
||||
i += aircraft.getPilotRealName();
|
||||
}
|
||||
items.append(i);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user