mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Button for "force model reload", own models component
This commit is contained in:
committed by
Mat Sutcliffe
parent
ab281649f8
commit
08fcc54695
@@ -51,7 +51,7 @@ namespace BlackGui
|
||||
ui->tvp_OwnAircraftModels->addFilterDialog();
|
||||
ui->tvp_OwnAircraftModels->setDisplayAutomatically(true);
|
||||
ui->tvp_OwnAircraftModels->setCustomMenu(new CLoadModelsMenu(this));
|
||||
ui->tvp_OwnAircraftModels->setSimulatorForLoading(ui->comp_SimulatorSelector->getValue());
|
||||
ui->tvp_OwnAircraftModels->setCorrespondingSimulator(ui->comp_SimulatorSelector->getValue());
|
||||
|
||||
bool c = connect(ui->tvp_OwnAircraftModels, &CAircraftModelView::requestUpdate, this, &CDbOwnModelsComponent::requestOwnModelsUpdate);
|
||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
|
||||
@@ -67,14 +67,16 @@ namespace BlackGui
|
||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
|
||||
c = connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(), &CMultiAircraftModelLoaderProvider::cacheChanged, this, &CDbOwnModelsComponent::onCacheChanged, Qt::QueuedConnection);
|
||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
|
||||
c = connect(ui->pb_ForceReload, &QPushButton::released, this, &CDbOwnModelsComponent::confirmedForcedReloadCurrentSimulator, Qt::QueuedConnection);
|
||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
|
||||
|
||||
// Last selection isPinned -> no sync needed
|
||||
ui->comp_SimulatorSelector->setRememberSelectionAndSetToLastSelection();
|
||||
const CSimulatorInfo simulator = ui->comp_SimulatorSelector->getValue();
|
||||
if (simulator.isSingleSimulator())
|
||||
{
|
||||
ui->le_Simulator->setText(simulator.toQString(true));
|
||||
m_simulator = simulator;
|
||||
this->setUiSimulatorString(simulator);
|
||||
const bool success = this->initModelLoader(simulator, IAircraftModelLoader::CacheOnly);
|
||||
if (!success)
|
||||
{
|
||||
@@ -152,8 +154,8 @@ namespace BlackGui
|
||||
m_simulator = simulator;
|
||||
this->requestSimulatorModelsWithCacheInBackground(simulator);
|
||||
ui->comp_SimulatorSelector->setValue(simulator);
|
||||
ui->le_Simulator->setText(simulator.toQString());
|
||||
ui->tvp_OwnAircraftModels->setSimulatorForLoading(simulator);
|
||||
this->setUiSimulatorString(simulator);
|
||||
ui->tvp_OwnAircraftModels->setCorrespondingSimulator(simulator);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -255,6 +257,31 @@ namespace BlackGui
|
||||
return dir;
|
||||
}
|
||||
|
||||
void CDbOwnModelsComponent::setUiSimulatorString(const CSimulatorInfo &simulatorInfo)
|
||||
{
|
||||
const QString s = simulatorInfo.toQString(true);
|
||||
ui->le_Simulator->setText(s);
|
||||
ui->pb_ForceReload->setText(QStringLiteral("force reload '%1'").arg(s));
|
||||
}
|
||||
|
||||
void CDbOwnModelsComponent::confirmedForcedReloadCurrentSimulator()
|
||||
{
|
||||
this->confirmedForcedReload(m_simulator);
|
||||
}
|
||||
|
||||
void CDbOwnModelsComponent::confirmedForcedReload(const CSimulatorInfo &simulator)
|
||||
{
|
||||
QMessageBox msgBox(QMessageBox::Question, "Reload models from disk",
|
||||
QStringLiteral("Completely reload '%1' models from disk?").arg(simulator.toQString(true)),
|
||||
QMessageBox::Ok | QMessageBox::Cancel, this);
|
||||
msgBox.setDefaultButton(QMessageBox::Cancel);
|
||||
const QMessageBox::StandardButton reply = static_cast<QMessageBox::StandardButton>(msgBox.exec());
|
||||
if (reply != QMessageBox::Ok) { return; }
|
||||
|
||||
QPointer<CDbOwnModelsComponent> ownModelsComp(qobject_cast<CDbOwnModelsComponent *>(this->parent()));
|
||||
ownModelsComp->requestSimulatorModels(simulator, IAircraftModelLoader::InBackgroundNoCache);
|
||||
}
|
||||
|
||||
void CDbOwnModelsComponent::CLoadModelsMenu::customMenu(CMenuActions &menuActions)
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
|
||||
@@ -175,6 +175,15 @@ namespace BlackGui
|
||||
//! Directory selector for given simulator
|
||||
QString directorySelector(const BlackMisc::Simulation::CSimulatorInfo &simulatorInfo);
|
||||
|
||||
//! Simulator string
|
||||
void setUiSimulatorString(const BlackMisc::Simulation::CSimulatorInfo &simulatorInfo);
|
||||
|
||||
//! Confirmed forced reload
|
||||
void confirmedForcedReloadCurrentSimulator();
|
||||
|
||||
//! Confirmed forced reload
|
||||
void confirmedForcedReload(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
//! The menu for loading and handling own models for mapping tasks
|
||||
//! \note This is specific for that very component
|
||||
//! \fixme MS 2018-12 Move to namespace scope and add Q_OBJECT
|
||||
|
||||
@@ -89,6 +89,13 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_ForceReload">
|
||||
<property name="text">
|
||||
<string>force reload</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_Simulator">
|
||||
<property name="text">
|
||||
@@ -104,6 +111,9 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Simulator</string>
|
||||
</property>
|
||||
|
||||
Reference in New Issue
Block a user