mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 02:06:08 +08:00
refs #661, improved model set dialog
* allow to change simulator * consider distributor preferences for new model set * error messages in dialog, therefor use CForm as base class
This commit is contained in:
@@ -785,11 +785,22 @@ namespace BlackGui
|
||||
return this->ui->comp_OwnAircraftModels->getOwnModelsSimulator();
|
||||
}
|
||||
|
||||
void CDbMappingComponent::setOwnModelsSimulator(const CSimulatorInfo &simulator)
|
||||
{
|
||||
this->ui->comp_OwnAircraftModels->setSimulator(simulator);
|
||||
}
|
||||
|
||||
int CDbMappingComponent::getOwnModelsCount() const
|
||||
{
|
||||
return this->ui->comp_OwnAircraftModels->getOwnModelsCount();
|
||||
}
|
||||
|
||||
void CDbMappingComponent::setOwnModelSetSimulator(const CSimulatorInfo &simulator)
|
||||
{
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||
this->ui->comp_OwnModelSet->setModelSetSimulator(simulator);
|
||||
}
|
||||
|
||||
CStatusMessage CDbMappingComponent::stashModel(const CAircraftModel &model, bool replace)
|
||||
{
|
||||
return this->ui->comp_StashAircraft->stashModel(model, replace);
|
||||
|
||||
@@ -50,7 +50,6 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
namespace Ui { class CDbMappingComponent; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Menus { class CMenuActions; }
|
||||
@@ -93,7 +92,7 @@ namespace BlackGui
|
||||
//! Graceful shutdown
|
||||
void gracefulShutdown();
|
||||
|
||||
//! With vPilot rules
|
||||
//! With vPilot rules?
|
||||
bool withVPilot() const { return m_vPilotEnabled; }
|
||||
|
||||
//! Any models which can be stashed?
|
||||
@@ -115,6 +114,8 @@ namespace BlackGui
|
||||
//! \note not guaranteed to be valid, just a snapshot of its current editor state
|
||||
BlackMisc::Simulation::CAircraftModel getEditorAircraftModel() const;
|
||||
|
||||
// ---------------- stash -----------------
|
||||
|
||||
//! \name Models from BlackGui::Components::CDbStashComponent
|
||||
//! @{
|
||||
//! Stashed models
|
||||
@@ -124,6 +125,8 @@ namespace BlackGui
|
||||
QStringList getStashedModelStrings() const;
|
||||
//! @}
|
||||
|
||||
// ---------------- own models -----------------
|
||||
|
||||
//! \name Own models from BlackGui::Components::CDbOwnModelsComponent
|
||||
//! @{
|
||||
//! Own models
|
||||
@@ -138,10 +141,18 @@ namespace BlackGui
|
||||
//! Own models for simulator
|
||||
const BlackMisc::Simulation::CSimulatorInfo getOwnModelsSimulator() const;
|
||||
|
||||
//! Set simulator for own models
|
||||
void setOwnModelsSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
//! Number of own models
|
||||
int getOwnModelsCount() const;
|
||||
//! @}
|
||||
|
||||
// ---------------- own models -----------------
|
||||
|
||||
//! Set simulator for own models
|
||||
void setOwnModelSetSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
public slots:
|
||||
//! \copydoc CDbStashComponent::stashModel
|
||||
BlackMisc::CStatusMessage stashModel(const BlackMisc::Simulation::CAircraftModel &model, bool replace = false);
|
||||
@@ -376,7 +387,7 @@ namespace BlackGui
|
||||
//! Mapping component
|
||||
CDbMappingComponent *mappingComponent() const;
|
||||
|
||||
QList<QAction *> m_menuActions;
|
||||
QList<QAction *> m_menuActions; //!< actions, kept when once initialized
|
||||
};
|
||||
|
||||
//! Merge with vPilot data
|
||||
@@ -393,7 +404,7 @@ namespace BlackGui
|
||||
CDbMappingComponent *mappingComponent() const;
|
||||
|
||||
private:
|
||||
QList<QAction *> m_menuActions;
|
||||
QList<QAction *> m_menuActions; //!< actions, kept when once initialized
|
||||
};
|
||||
};
|
||||
} // ns
|
||||
|
||||
@@ -105,6 +105,12 @@ namespace BlackGui
|
||||
return this->m_modelLoader->getSimulator();
|
||||
}
|
||||
|
||||
void CDbOwnModelsComponent::setSimulator(const CSimulatorInfo &simulator)
|
||||
{
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||
this->ps_loadInstalledModels(simulator, IAircraftModelLoader::InBackgroundWithCache);
|
||||
}
|
||||
|
||||
int CDbOwnModelsComponent::getOwnModelsCount() const
|
||||
{
|
||||
if (!this->m_modelLoader) { return 0; }
|
||||
|
||||
@@ -67,6 +67,9 @@ namespace BlackGui
|
||||
//! Own models for simulator
|
||||
const BlackMisc::Simulation::CSimulatorInfo getOwnModelsSimulator() const;
|
||||
|
||||
//! Change current simulator for own models
|
||||
void setSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
//! Number of own models
|
||||
int getOwnModelsCount() const;
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace BlackGui
|
||||
void CDbOwnModelSetComponent::setModelSet(const CAircraftModelList &models, const CSimulatorInfo &simulator)
|
||||
{
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||
this->setSimulator(simulator);
|
||||
this->setModelSetSimulator(simulator);
|
||||
if (models.isEmpty())
|
||||
{
|
||||
this->ui->tvp_OwnModelSet->clear();
|
||||
@@ -153,7 +153,7 @@ namespace BlackGui
|
||||
if (!this->getModelSetSimulator().isSingleSimulator())
|
||||
{
|
||||
// no sim yet, we set it
|
||||
this->setSimulator(simulator);
|
||||
this->setModelSetSimulator(simulator);
|
||||
}
|
||||
if (simulator != this->getModelSetSimulator())
|
||||
{
|
||||
@@ -235,7 +235,7 @@ namespace BlackGui
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||
if (this->getModelSetSimulator() == simulator) { return; } // avoid endless loops
|
||||
|
||||
this->setSimulator(simulator);
|
||||
this->setModelSetSimulator(simulator);
|
||||
const CAircraftModelList models(this->m_modelSetLoader.getAircraftModels());
|
||||
ui->tvp_OwnModelSet->updateContainerMaybeAsync(models);
|
||||
}
|
||||
@@ -269,7 +269,7 @@ namespace BlackGui
|
||||
{
|
||||
if (simulator.isSingleSimulator())
|
||||
{
|
||||
this->setSimulator(simulator);
|
||||
this->setModelSetSimulator(simulator);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ namespace BlackGui
|
||||
this->ui->tvp_OwnModelSet->setSaveFileName(name);
|
||||
}
|
||||
|
||||
void CDbOwnModelSetComponent::setSimulator(const CSimulatorInfo &simulator)
|
||||
void CDbOwnModelSetComponent::setModelSetSimulator(const CSimulatorInfo &simulator)
|
||||
{
|
||||
if (this->m_modelSetLoader.getSimulator() == simulator) { return; } // avoid unnecessary signals
|
||||
this->m_modelSetLoader.changeSimulator(simulator);
|
||||
|
||||
@@ -82,6 +82,9 @@ namespace BlackGui
|
||||
//! Model set is for simulator
|
||||
const BlackMisc::Simulation::CSimulatorInfo getModelSetSimulator() const;
|
||||
|
||||
//! Simulator
|
||||
void setModelSetSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
//! \copydoc CDbMappingComponentAware::setMappingComponent
|
||||
virtual void setMappingComponent(CDbMappingComponent *component) override;
|
||||
|
||||
@@ -94,10 +97,10 @@ namespace BlackGui
|
||||
//! @}
|
||||
|
||||
public slots:
|
||||
//! Set the model set
|
||||
//! Set the model set for a given simulator
|
||||
void setModelSet(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
//! Replace or add models provided
|
||||
//! Replace or add models provided for a given simulator
|
||||
void replaceOrAddModelSet(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
private slots:
|
||||
@@ -129,9 +132,6 @@ namespace BlackGui
|
||||
//! Default file name
|
||||
void setSaveFileName(const BlackMisc::Simulation::CSimulatorInfo &sim);
|
||||
|
||||
//! Simulator
|
||||
void setSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
//! Update distributor order
|
||||
void updateDistributorOrder(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackCore;
|
||||
using namespace BlackGui::Editors;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
@@ -43,6 +44,7 @@ namespace BlackGui
|
||||
ui->setupUi(this);
|
||||
connect(ui->pb_Cancel, &QPushButton::clicked, this, &CDbOwnModelSetDialog::ps_buttonClicked);
|
||||
connect(ui->pb_Ok, &QPushButton::clicked, this, &CDbOwnModelSetDialog::ps_buttonClicked);
|
||||
connect(ui->form_OwnModelSet, &COwnModelSetForm::simulatorChanged, this, &CDbOwnModelSetDialog::ps_simulatorChanged);
|
||||
}
|
||||
|
||||
CDbOwnModelSetDialog::~CDbOwnModelSetDialog()
|
||||
@@ -52,14 +54,17 @@ namespace BlackGui
|
||||
|
||||
void CDbOwnModelSetDialog::reloadData()
|
||||
{
|
||||
this->m_simulatorInfo = this->getMappingComponent()->getOwnModelsSimulator();
|
||||
Q_ASSERT_X(this->m_simulatorInfo.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||
ui->form_OwnModelSet->setSimulator(this->m_simulatorInfo);
|
||||
this->ui->form_OwnModelSet->reloadData();
|
||||
}
|
||||
|
||||
int CDbOwnModelSetDialog::exec()
|
||||
{
|
||||
Q_ASSERT_X(this->getMappingComponent(), Q_FUNC_INFO, "missing mapping component");
|
||||
this->m_simulatorInfo = this->getMappingComponent()->getOwnModelsSimulator();
|
||||
this->setWindowTitle("Create model set for " + this->m_simulatorInfo.toQString(true));
|
||||
this->setSimulator(this->getMappingComponent()->getOwnModelsSimulator());
|
||||
this->checkData();
|
||||
return QDialog::exec();
|
||||
}
|
||||
|
||||
@@ -77,6 +82,37 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CDbOwnModelSetDialog::ps_simulatorChanged(const CSimulatorInfo &simulator)
|
||||
{
|
||||
Q_ASSERT_X(this->getMappingComponent(), Q_FUNC_INFO, "missing mapping component");
|
||||
this->setSimulator(simulator);
|
||||
this->getMappingComponent()->setOwnModelsSimulator(simulator);
|
||||
this->getMappingComponent()->setOwnModelSetSimulator(simulator);
|
||||
this->checkData();
|
||||
}
|
||||
|
||||
bool CDbOwnModelSetDialog::checkData()
|
||||
{
|
||||
// models
|
||||
Q_ASSERT_X(this->m_simulatorInfo.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||
const int c = this->getMappingComponent()->getOwnModelsCount();
|
||||
if (c < 1)
|
||||
{
|
||||
const CStatusMessage m = CStatusMessage(this).error("No models for %1") << this->m_simulatorInfo.toQString(true);
|
||||
ui->form_OwnModelSet->showOverlayMessage(m);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDbOwnModelSetDialog::setSimulator(const CSimulatorInfo &simulator)
|
||||
{
|
||||
Q_ASSERT_X(this->m_simulatorInfo.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||
this->m_simulatorInfo = simulator;
|
||||
ui->form_OwnModelSet->setSimulator(this->m_simulatorInfo);
|
||||
this->setWindowTitle("Create model set for " + this->m_simulatorInfo.toQString(true));
|
||||
}
|
||||
|
||||
CAircraftModelList CDbOwnModelSetDialog::buildSet(const CSimulatorInfo &simulator, const CAircraftModelList ¤tSet)
|
||||
{
|
||||
Q_ASSERT_X(this->getMappingComponent(), Q_FUNC_INFO, "missing mapping component");
|
||||
|
||||
@@ -64,11 +64,20 @@ namespace BlackGui
|
||||
//! Button clicked
|
||||
void ps_buttonClicked();
|
||||
|
||||
//! Simulator changed
|
||||
void ps_simulatorChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CDbOwnModelSetDialog> ui;
|
||||
BlackMisc::Simulation::CAircraftModelList m_modelSet;
|
||||
BlackMisc::Simulation::CSimulatorInfo m_simulatorInfo;
|
||||
|
||||
//! Check data
|
||||
bool checkData();
|
||||
|
||||
//! Set current simulator
|
||||
void setSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
//! Build the set
|
||||
BlackMisc::Simulation::CAircraftModelList buildSet(const BlackMisc::Simulation::CSimulatorInfo &simulator, const BlackMisc::Simulation::CAircraftModelList ¤tSet = {});
|
||||
};
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace BlackGui
|
||||
void ps_deferredInit();
|
||||
|
||||
private:
|
||||
BlackGui::COverlayMessagesFrame *m_overlayMessageFrame = nullptr;
|
||||
BlackGui::COverlayMessagesFrame *m_overlayMessageFrame = nullptr;
|
||||
QScopedPointer<Ui::CDistributorPreferencesComponent> ui;
|
||||
BlackMisc::Simulation::CAircraftModelSetLoader m_modelSetLoader { BlackMisc::Simulation::CSimulatorInfo(BlackMisc::Simulation::CSimulatorInfo::FSX), this };
|
||||
BlackMisc::CSetting<BlackCore::Settings::Simulation::DistributorListPreferences> m_distributorPreferences { this, &CDistributorPreferencesComponent::ps_preferencesChanged };
|
||||
|
||||
@@ -145,6 +145,17 @@ namespace BlackGui
|
||||
return c;
|
||||
}
|
||||
|
||||
void CSimulatorSelector::setLeftMargin(int margin)
|
||||
{
|
||||
QMargins m = ui->hl_RadioButtons->contentsMargins();
|
||||
m.setLeft(margin);
|
||||
ui->hl_RadioButtons->setContentsMargins(m);
|
||||
|
||||
m = ui->hl_CheckBoxes->contentsMargins();
|
||||
m.setLeft(margin);
|
||||
ui->hl_CheckBoxes->setContentsMargins(m);
|
||||
}
|
||||
|
||||
void CSimulatorSelector::ps_RadioButtonChanged(bool checked)
|
||||
{
|
||||
if (this->m_mode != RadioButtons) { return; }
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace BlackGui
|
||||
namespace Components
|
||||
{
|
||||
/*!
|
||||
* Select simulator
|
||||
* Select simulator (as radio buttons or checkboxes)
|
||||
*/
|
||||
class BLACKGUI_EXPORT CSimulatorSelector : public QFrame
|
||||
{
|
||||
@@ -67,6 +67,9 @@ namespace BlackGui
|
||||
//! All selected
|
||||
bool areAllSelected() const;
|
||||
|
||||
//! Set left margin
|
||||
void setLeftMargin(int margin);
|
||||
|
||||
signals:
|
||||
//! Value has been changed
|
||||
void changed(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
Reference in New Issue
Block a user