Ref T246, first model UI no longer experimental

This commit is contained in:
Klaus Basan
2018-07-17 01:28:52 +02:00
parent 0fcec6dad6
commit 74cdbc9506
3 changed files with 60 additions and 21 deletions

View File

@@ -11,6 +11,7 @@
#include "ui_firstmodelsetcomponent.h" #include "ui_firstmodelsetcomponent.h"
#include "blackgui/views/distributorview.h" #include "blackgui/views/distributorview.h"
#include "blackgui/guiapplication.h" #include "blackgui/guiapplication.h"
#include "blackcore/webdataservices.h"
#include "blackmisc/directoryutils.h" #include "blackmisc/directoryutils.h"
#include "dbownmodelsdialog.h" #include "dbownmodelsdialog.h"
#include "dbownmodelscomponent.h" #include "dbownmodelscomponent.h"
@@ -85,7 +86,7 @@ namespace BlackGui
// kind of hack, but simplest solution // kind of hack, but simplest solution
// we us the loader of the components directly, // we us the loader of the components directly,
// avoid to fully init a loader logic here // avoid to fully init a loader logic here
static const QString modelInfo("Models already indexed: %1"); static const QString modelInfo("Models indexed: %1");
static const QString modelsNo("No models so far"); static const QString modelsNo("No models so far");
const int modelsCount = this->modelLoader()->getAircraftModelsCount(); const int modelsCount = this->modelLoader()->getAircraftModelsCount();
ui->le_ModelsInfo->setText(modelsCount > 0 ? modelInfo.arg(modelsCount) : modelsNo); ui->le_ModelsInfo->setText(modelsCount > 0 ? modelInfo.arg(modelsCount) : modelsNo);
@@ -145,17 +146,37 @@ namespace BlackGui
void CFirstModelSetComponent::openOwnModelsDialog() void CFirstModelSetComponent::openOwnModelsDialog()
{ {
m_modelsDialog->setSimulator(ui->comp_SimulatorSelector->getValue()); if (!sGui || sGui->isShuttingDown() || !sGui->getWebDataServices()) { return; }
m_modelsDialog->show();
const bool reload = (QObject::sender() == ui->pb_ModelsTriggerReload); const bool reload = (QObject::sender() == ui->pb_ModelsTriggerReload);
if (reload) { m_modelsDialog->requestModelsInBackground(ui->comp_SimulatorSelector->getValue(), true); }
if (reload)
{
if (!sGui->getWebDataServices()->hasDbModelData())
{
const QMessageBox::StandardButton reply = QMessageBox::warning(this->mainWindow(), "DB data", "No DB data, models cannot be consolidated. Load anyway?", QMessageBox::Yes | QMessageBox::No);
if (reply != QMessageBox::Yes) { return; }
}
const CSimulatorInfo simulator = ui->comp_SimulatorSelector->getValue();
m_modelsDialog->requestModelsInBackground(simulator, true);
}
const CSimulatorInfo simulator = ui->comp_SimulatorSelector->getValue();
m_modelsDialog->setSimulator(simulator);
m_modelsDialog->exec();
// force UI update
this->triggerSettingsChanged(simulator);
} }
void CFirstModelSetComponent::openOwnModelSetDialog() void CFirstModelSetComponent::openOwnModelSetDialog()
{ {
m_modelSetDialog->setSimulator(ui->comp_SimulatorSelector->getValue()); const CSimulatorInfo simulator = ui->comp_SimulatorSelector->getValue();
m_modelSetDialog->setSimulator(simulator);
m_modelSetDialog->enableButtons(false); m_modelSetDialog->enableButtons(false);
m_modelSetDialog->show(); m_modelSetDialog->exec();
// force UI update
this->triggerSettingsChanged(simulator);
} }
void CFirstModelSetComponent::changeModelDirectory() void CFirstModelSetComponent::changeModelDirectory()
@@ -171,10 +192,8 @@ namespace BlackGui
} }
else else
{ {
QWidget *pw = sGui->mainApplicationWidget();
if (!pw) { pw = this; }
const QString dirOld = settings.getFirstModelDirectoryOrDefault(); const QString dirOld = settings.getFirstModelDirectoryOrDefault();
const QString newDir = QFileDialog::getExistingDirectory(pw, tr("Open model directory"), dirOld, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); const QString newDir = QFileDialog::getExistingDirectory(this->mainWindow(), tr("Open model directory"), dirOld, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if (newDir.isEmpty() || CDirectoryUtils::isSameExistingDirectory(dirOld, newDir)) { return; } if (newDir.isEmpty() || CDirectoryUtils::isSameExistingDirectory(dirOld, newDir)) { return; }
settings.addModelDirectory(newDir); settings.addModelDirectory(newDir);
} }
@@ -192,13 +211,6 @@ namespace BlackGui
void CFirstModelSetComponent::createModelSet() void CFirstModelSetComponent::createModelSet()
{ {
if (!ui->comp_Distributors->hasSelectedDistributors())
{
static const CStatusMessage msg = CStatusMessage(this).validationError("No distributors selected");
this->showOverlayMessage(msg, 4000);
return;
}
const int modelsCount = this->modelLoader()->getAircraftModelsCount(); const int modelsCount = this->modelLoader()->getAircraftModelsCount();
if (modelsCount < 1) if (modelsCount < 1)
{ {
@@ -207,15 +219,39 @@ namespace BlackGui
return; return;
} }
const CSimulatorInfo sim = ui->comp_SimulatorSelector->getValue(); bool useAllModels = false;
const CDistributorList distributors = ui->comp_Distributors->getSelectedDistributors(); if (!ui->comp_Distributors->hasSelectedDistributors())
{
const QMessageBox::StandardButton reply = QMessageBox::question(this->mainWindow(), "Models", "No distributors selected, use all model?", QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::Yes)
{
useAllModels = true;
}
else
{
static const CStatusMessage msg = CStatusMessage(this).validationError("No distributors selected");
this->showOverlayMessage(msg, 4000);
return;
}
}
CAircraftModelList modelsForSet = this->modelLoader()->getAircraftModels(); CAircraftModelList modelsForSet = this->modelLoader()->getAircraftModels();
modelsForSet = modelsForSet.findByDistributors(distributors); if (!useAllModels)
m_modelSetDialog->modelSetComponent()->setModelSet(modelsForSet, sim); {
const CDistributorList distributors = ui->comp_Distributors->getSelectedDistributors();
modelsForSet = modelsForSet.findByDistributors(distributors);
}
const CSimulatorInfo sim = ui->comp_SimulatorSelector->getValue();
m_modelSetDialog->modelSetComponent()->setModelSet(modelsForSet, sim);
ui->pb_ModelSet->click(); ui->pb_ModelSet->click();
} }
QWidget *CFirstModelSetComponent::mainWindow()
{
QWidget *pw = sGui->mainApplicationWidget();
return pw ? pw : this;
}
bool CFirstModelSetWizardPage::validatePage() bool CFirstModelSetWizardPage::validatePage()
{ {
return true; return true;

View File

@@ -89,6 +89,9 @@ namespace BlackGui
//! Create the model set //! Create the model set
void createModelSet(); void createModelSet();
//! Main window or this
QWidget *mainWindow();
}; };
//! Wizard page for CFirstModelSetComponent //! Wizard page for CFirstModelSetComponent

View File

@@ -27,7 +27,7 @@
<item> <item>
<widget class="QLabel" name="lbl_Explaination"> <widget class="QLabel" name="lbl_Explaination">
<property name="text"> <property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:9pt; font-weight:600; color:#ff0000;&quot;&gt;WORK IN PROGRESS (experimental) &lt;/span&gt;&lt;span style=&quot; font-size:9pt;&quot;&gt;The model set defines which aircraft you will use in the simulator. From all models you have installed on your disk you can select a subset actually being used.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:9pt;&quot;&gt;The model set defines which aircraft you will use in the simulator. From all models you have installed on your disk you can select a subset actually being used.&lt;br/&gt;&lt;br/&gt;1) Reload your models if not already done&lt;br/&gt;2) Create your model set and SAVE the model set&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="textFormat"> <property name="textFormat">
<enum>Qt::RichText</enum> <enum>Qt::RichText</enum>