From 69c13c353f65ea6f53e68f55fb9020e136f84cdb Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 22 Jul 2019 01:39:11 +0200 Subject: [PATCH] Ref T659, UI changed for modelstring/livery and checkboxes to decide if those are sent --- .../components/ownaircraftcomponent.cpp | 39 ++- .../components/ownaircraftcomponent.h | 40 ++- .../components/ownaircraftcomponent.ui | 304 ++++++++++-------- 3 files changed, 225 insertions(+), 158 deletions(-) diff --git a/src/blackgui/components/ownaircraftcomponent.cpp b/src/blackgui/components/ownaircraftcomponent.cpp index e1ac6a640..ab8d6eaac 100644 --- a/src/blackgui/components/ownaircraftcomponent.cpp +++ b/src/blackgui/components/ownaircraftcomponent.cpp @@ -22,7 +22,7 @@ #include "blackmisc/logmessage.h" #include "blackconfig/buildconfig.h" -#include +#include using namespace BlackConfig; using namespace BlackMisc; @@ -46,6 +46,9 @@ namespace BlackGui ui->selector_AircraftIcao->displayMode(CDbAircraftIcaoSelectorComponent::DisplayIcaoAndId); ui->selector_AirlineIcao->displayMode(CDbAirlineIcaoSelectorComponent::DisplayVDesignatorAndId); + ui->cb_Model->setChecked(true); + ui->cb_Livery->setChecked(true); + // own aircraft ui->lblp_AircraftCombinedType->setToolTips("ok", "wrong"); ui->lblp_AirlineIcao->setToolTips("ok", "wrong"); @@ -62,18 +65,20 @@ namespace BlackGui ui->le_AircraftCombinedType->setMaxLength(3); ui->le_AircraftCombinedType->setValidator(new CUpperCaseValidator(this)); ui->comp_ModelStringCompleter->setSourceVisible(CAircraftModelStringCompleter::OwnModels, false); + ui->comp_ModelStringCompleter->selectSource(CAircraftModelStringCompleter::ModelSet); connect(ui->le_Callsign, &QLineEdit::editingFinished, this, &COwnAircraftComponent::validate); connect(ui->comp_ModelStringCompleter, &CAircraftModelStringCompleter::modelStringChanged, this, &COwnAircraftComponent::onModelStringSendChanged); connect(ui->le_AircraftCombinedType, &QLineEdit::editingFinished, this, &COwnAircraftComponent::validate); connect(ui->selector_AircraftIcao, &CDbAircraftIcaoSelectorComponent::changedAircraftIcao, this, &COwnAircraftComponent::changedAircraftIcao, Qt::QueuedConnection); - connect(ui->selector_AirlineIcao, &CDbAirlineIcaoSelectorComponent::changedAirlineIcao, this, &COwnAircraftComponent::changedAirlineIcao, Qt::QueuedConnection); - connect(ui->pb_SimulatorLookup, &QToolButton::clicked, this, &COwnAircraftComponent::lookupOwnAircraftModel); - connect(ui->pb_MappingWizard, &QToolButton::clicked, this, &COwnAircraftComponent::mappingWizard, Qt::QueuedConnection); + connect(ui->selector_AirlineIcao, &CDbAirlineIcaoSelectorComponent::changedAirlineIcao, this, &COwnAircraftComponent::changedAirlineIcao, Qt::QueuedConnection); + connect(ui->pb_SimulatorLookup, &QPushButton::clicked, this, &COwnAircraftComponent::lookupOwnAircraftModel); + connect(ui->pb_MappingWizard, &QPushButton::clicked, this, &COwnAircraftComponent::mappingWizard, Qt::QueuedConnection); + connect(ui->pb_Clear, &QPushButton::clicked, this, &COwnAircraftComponent::clearLivery, Qt::QueuedConnection); if (sGui && sGui->getIContextSimulator()) { - connect(sGui->getIContextSimulator(), &IContextSimulator::ownAircraftModelChanged, this, &COwnAircraftComponent::onSimulatorModelChanged, Qt::QueuedConnection); + connect(sGui->getIContextSimulator(), &IContextSimulator::ownAircraftModelChanged, this, &COwnAircraftComponent::onSimulatorModelChanged, Qt::QueuedConnection); connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged, this, &COwnAircraftComponent::onSimulatorStatusChanged, Qt::QueuedConnection); } @@ -143,6 +148,7 @@ namespace BlackGui if (!this->hasValidContexts()) { return; } if (!sGui->hasWebDataServices()) { return; } const QString modelString = ui->comp_ModelStringCompleter->getModelString(); + if (modelString.isEmpty()) { return; } // keep last values const CAircraftModel model = sGui->getWebDataServices()->getModelForModelString(modelString); this->setGuiIcaoValues(model, false); } @@ -208,10 +214,12 @@ namespace BlackGui 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.ownAircraftCombinedType = ui->le_AircraftCombinedType->text().trimmed().toUpper(); values.ownAircraftSimulatorModelString = ui->le_SimulatorModel->text().trimmed().toUpper(); - values.ownAircraftModelStringSend = ui->comp_ModelStringCompleter->getModelString().toUpper(); - values.ownLivery = ui->le_SendLivery->text().trimmed().toUpper(); + values.ownAircraftModelStringSend = ui->comp_ModelStringCompleter->getModelString().toUpper(); + values.ownLiverySend = ui->le_SendLivery->text().trimmed().toUpper(); + values.useLivery = ui->cb_Livery->isChecked(); + values.useModelString = ui->cb_Model->isChecked(); return values; } @@ -248,6 +256,16 @@ namespace BlackGui changed = true; } } + if (!onlyIfEmpty || ui->le_SendLivery->text().trimmed().isEmpty()) + { + const QString ls(model.getSwiftLiveryString()); + if (ui->le_SendLivery->text() != ls) + { + ui->le_SendLivery->setText(ls); + changed = true; + } + } + const bool valid = this->validate().isSuccess(); return valid ? changed : false; } @@ -270,6 +288,11 @@ namespace BlackGui return true; } + void COwnAircraftComponent::clearLivery() + { + ui->le_SendLivery->clear(); + } + CAircraftModel COwnAircraftComponent::getPrefillModel() const { const CAircraftModel model = m_lastAircraftModel.get(); diff --git a/src/blackgui/components/ownaircraftcomponent.h b/src/blackgui/components/ownaircraftcomponent.h index c9daa62a3..1dc49b6db 100644 --- a/src/blackgui/components/ownaircraftcomponent.h +++ b/src/blackgui/components/ownaircraftcomponent.h @@ -34,6 +34,20 @@ namespace BlackGui Q_OBJECT public: + //! GUI aircraft values, formatted + struct CGuiAircraftValues + { + BlackMisc::Aviation::CCallsign ownCallsign; //!< own aircraft callsign + BlackMisc::Aviation::CAircraftIcaoCode ownAircraftIcao; //!< ICAO aircraft + BlackMisc::Aviation::CAirlineIcaoCode ownAirlineIcao; //!< ICAO airline + QString ownAircraftCombinedType; //!< own aircraft combined type + QString ownAircraftSimulatorModelString; //!< own aircraft model string + QString ownAircraftModelStringSend; //!< send model string + QString ownLiverySend; //!< send livery + bool useModelString = true; //! use model string + bool useLivery = true; //! use livery + }; + //! Constructor explicit COwnAircraftComponent(QWidget *parent = nullptr); @@ -46,32 +60,24 @@ namespace BlackGui //! Set a user void setUser(const BlackMisc::Network::CUser &user); - //! Own model and ICAO data for GUI and own aircraft - void setOwnModelAndIcaoValues(const BlackMisc::Simulation::CAircraftModel &ownModel = {}); - //! Values from GUI BlackMisc::Aviation::CCallsign getCallsignFromGui() const; + //! Own model and ICAO data for GUI and own aircraft + void setOwnModelAndIcaoValues(const BlackMisc::Simulation::CAircraftModel &ownModel = {}); + //! Update own ICAO values (own aircraft from what is set in the GUI) //! \return changed? bool updateOwnAircaftIcaoValuesFromGuiValues(); + //! Values from GUI + CGuiAircraftValues getAircraftValuesFromGui() const; + signals: //! Changed values void aircraftDataChanged(); private: - //! GUI aircraft values, formatted - struct CGuiAircraftValues - { - BlackMisc::Aviation::CCallsign ownCallsign; - BlackMisc::Aviation::CAircraftIcaoCode ownAircraftIcao; - BlackMisc::Aviation::CAirlineIcaoCode ownAirlineIcao; - QString ownAircraftCombinedType; - QString ownAircraftSimulatorModelString; - QString ownAircraftModelStringSend; - QString ownLivery; - }; //! Launch mapping wizard void mappingWizard(); @@ -88,9 +94,6 @@ namespace BlackGui //! Status has changed void onSimulatorStatusChanged(int status); - //! Values from GUI - CGuiAircraftValues getAircraftValuesFromGui() const; - //! Set ICAO values //! \return changed values? bool setGuiIcaoValues(const BlackMisc::Simulation::CAircraftModel &model, bool onlyIfEmpty); @@ -107,6 +110,9 @@ namespace BlackGui //! Has contexts? bool hasValidContexts() const; + //! Clear livery + void clearLivery(); + //! Get a prefill model BlackMisc::Simulation::CAircraftModel getPrefillModel() const; diff --git a/src/blackgui/components/ownaircraftcomponent.ui b/src/blackgui/components/ownaircraftcomponent.ui index 3ca63420f..457ddbec2 100644 --- a/src/blackgui/components/ownaircraftcomponent.ui +++ b/src/blackgui/components/ownaircraftcomponent.ui @@ -6,14 +6,14 @@ 0 0 - 266 + 261 132 - Frame + Own aircraft - + 2 @@ -26,137 +26,27 @@ 2 - - + + - Model send + + + + true - - - - Livery sent - - - - - + + - ICAO code e.g. B737, A320, F18 + Aircraft type e.g. L2J, L1P, .... - Aircraft + Type - - - - ICAO code e.g. DLH, LHA, ... - - - Airline - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 75 - 0 - - - - Qt::StrongFocus - - - - - - - Callsign - - - - - - - Launch - - - Model - - - - - - - e.g. L2J - - - - - - - - - 3 - - - e.g. "L2J" - - - - - - - - 75 - 0 - - - - Qt::StrongFocus - - - - - - - - 0 - 0 - - - - - - - - + e.g. DEMBZ @@ -172,17 +62,30 @@ - - - - Aircraft type e.g. L2J, L1P, .... + + + + + 75 + 0 + - - Type + + Qt::StrongFocus - + + + + ICAO code e.g. B737, A320, F18 + + + Aircraft + + + + @@ -190,9 +93,12 @@ 20 + + Qt::StrongFocus + - + @@ -254,13 +160,141 @@ - + + + + + 75 + 0 + + + + Qt::StrongFocus + + + + + + + e.g. L2J + + + + + + + + + 3 + + + e.g. "L2J" + + + + + + + Livery send + + + + + + + + + + + + + + + + + + livery string send + + + + Launch + + + Model + + + + + + + Callsign + + + + + + + Model send + + + + + + + + 0 + 0 + + + + + + + + + + + ICAO code e.g. DLH, LHA, ... + + + Airline + + + + + + + + + + true + + + + + + + + + + + + + + clear livery + + + + :/diagona/icons/diagona/icons/cross.png:/diagona/icons/diagona/icons/cross.png + + + @@ -292,7 +326,11 @@ le_SimulatorModel pb_SimulatorLookup pb_MappingWizard + cb_Model + comp_ModelStringCompleter + cb_Livery le_SendLivery + pb_Clear le_Callsign selector_AircraftIcao le_AircraftCombinedType