mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 12:35:43 +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->addFilterDialog();
|
||||||
ui->tvp_OwnAircraftModels->setDisplayAutomatically(true);
|
ui->tvp_OwnAircraftModels->setDisplayAutomatically(true);
|
||||||
ui->tvp_OwnAircraftModels->setCustomMenu(new CLoadModelsMenu(this));
|
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);
|
bool c = connect(ui->tvp_OwnAircraftModels, &CAircraftModelView::requestUpdate, this, &CDbOwnModelsComponent::requestOwnModelsUpdate);
|
||||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
|
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
|
||||||
@@ -67,14 +67,16 @@ namespace BlackGui
|
|||||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
|
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
|
||||||
c = connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(), &CMultiAircraftModelLoaderProvider::cacheChanged, this, &CDbOwnModelsComponent::onCacheChanged, Qt::QueuedConnection);
|
c = connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(), &CMultiAircraftModelLoaderProvider::cacheChanged, this, &CDbOwnModelsComponent::onCacheChanged, Qt::QueuedConnection);
|
||||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
|
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
|
// Last selection isPinned -> no sync needed
|
||||||
ui->comp_SimulatorSelector->setRememberSelectionAndSetToLastSelection();
|
ui->comp_SimulatorSelector->setRememberSelectionAndSetToLastSelection();
|
||||||
const CSimulatorInfo simulator = ui->comp_SimulatorSelector->getValue();
|
const CSimulatorInfo simulator = ui->comp_SimulatorSelector->getValue();
|
||||||
if (simulator.isSingleSimulator())
|
if (simulator.isSingleSimulator())
|
||||||
{
|
{
|
||||||
ui->le_Simulator->setText(simulator.toQString(true));
|
|
||||||
m_simulator = simulator;
|
m_simulator = simulator;
|
||||||
|
this->setUiSimulatorString(simulator);
|
||||||
const bool success = this->initModelLoader(simulator, IAircraftModelLoader::CacheOnly);
|
const bool success = this->initModelLoader(simulator, IAircraftModelLoader::CacheOnly);
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
@@ -152,8 +154,8 @@ namespace BlackGui
|
|||||||
m_simulator = simulator;
|
m_simulator = simulator;
|
||||||
this->requestSimulatorModelsWithCacheInBackground(simulator);
|
this->requestSimulatorModelsWithCacheInBackground(simulator);
|
||||||
ui->comp_SimulatorSelector->setValue(simulator);
|
ui->comp_SimulatorSelector->setValue(simulator);
|
||||||
ui->le_Simulator->setText(simulator.toQString());
|
this->setUiSimulatorString(simulator);
|
||||||
ui->tvp_OwnAircraftModels->setSimulatorForLoading(simulator);
|
ui->tvp_OwnAircraftModels->setCorrespondingSimulator(simulator);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,6 +257,31 @@ namespace BlackGui
|
|||||||
return dir;
|
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)
|
void CDbOwnModelsComponent::CLoadModelsMenu::customMenu(CMenuActions &menuActions)
|
||||||
{
|
{
|
||||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||||
|
|||||||
@@ -175,6 +175,15 @@ namespace BlackGui
|
|||||||
//! Directory selector for given simulator
|
//! Directory selector for given simulator
|
||||||
QString directorySelector(const BlackMisc::Simulation::CSimulatorInfo &simulatorInfo);
|
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
|
//! The menu for loading and handling own models for mapping tasks
|
||||||
//! \note This is specific for that very component
|
//! \note This is specific for that very component
|
||||||
//! \fixme MS 2018-12 Move to namespace scope and add Q_OBJECT
|
//! \fixme MS 2018-12 Move to namespace scope and add Q_OBJECT
|
||||||
|
|||||||
@@ -89,6 +89,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pb_ForceReload">
|
||||||
|
<property name="text">
|
||||||
|
<string>force reload</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="lbl_Simulator">
|
<widget class="QLabel" name="lbl_Simulator">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -104,6 +111,9 @@
|
|||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
<property name="placeholderText">
|
<property name="placeholderText">
|
||||||
<string>Simulator</string>
|
<string>Simulator</string>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
Reference in New Issue
Block a user