diff --git a/src/blackgui/components/dbownmodelscomponent.cpp b/src/blackgui/components/dbownmodelscomponent.cpp index 136636c1e..cf76f229d 100644 --- a/src/blackgui/components/dbownmodelscomponent.cpp +++ b/src/blackgui/components/dbownmodelscomponent.cpp @@ -52,6 +52,7 @@ namespace BlackGui connect(ui->tvp_OwnAircraftModels, &CAircraftModelView::requestUpdate, this, &CDbOwnModelsComponent::requestOwnModelsUpdate); connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &CDbOwnModelsComponent::onSimulatorSelectorChanged); connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(), &CMultiAircraftModelLoaderProvider::loadingFinished, this, &CDbOwnModelsComponent::onOwnModelsLoadingFinished, Qt::QueuedConnection); + connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(), &CMultiAircraftModelLoaderProvider::diskLoadingStarted, this, &CDbOwnModelsComponent::onOwnModelsDiskLoadingStarted, Qt::QueuedConnection); // Last selection isPinned -> no sync needed ui->comp_SimulatorSelector->setRememberSelectionAndSetToLastSelection(); @@ -477,26 +478,44 @@ namespace BlackGui void CDbOwnModelsComponent::loadInstalledModels(const CSimulatorInfo &simulator, IAircraftModelLoader::LoadMode mode, const QStringList &modelDirectories) { if (!m_modelLoader) { return; } + + // here m_modelLoader is still the "current" loader if (m_modelLoader->isLoadingInProgress()) { - CLogMessage(this).info("Loading for '%1' already in progress") << simulator.toQString(); - return; + if (m_modelLoader->supportsSimulator(simulator)) + { + const CStatusMessage msg = CLogMessage(this).warning("Loading for '%1' already in progress, will NOT load.") << simulator.toQString(); + this->showOverlayMessage(msg); + return; + } + else + { + const CStatusMessage msg = CLogMessage(this).warning("Loading for another simulator '%1' already in progress. Loading might be slow.") << simulator.toQString(); + this->showOverlayMessage(msg); + } } if (!this->initModelLoader(simulator)) { - CLogMessage(this).error("Cannot init model loader for %1") << simulator.toQString(); + const CStatusMessage msg = CLogMessage(this).error("Cannot init model loader for %1") << simulator.toQString(); + this->showOverlayMessage(msg); return; } // Do not check for empty models die here, as depending on mode we could still load // will be checked in model loader - CLogMessage(this).info("Starting loading for '%1'") << simulator.toQString(); + CLogMessage(this).info("Starting loading for '%1' in mode '%2'") << simulator.toQString() << IAircraftModelLoader::enumToString(mode); ui->tvp_OwnAircraftModels->showLoadIndicator(); Q_ASSERT_X(sGui && sGui->getWebDataServices(), Q_FUNC_INFO, "missing web data services"); m_modelLoader->startLoading(mode, static_cast(&CDatabaseUtils::consolidateModelsWithDbData), modelDirectories); } + void CDbOwnModelsComponent::onOwnModelsDiskLoadingStarted(const CSimulatorInfo &simulator, IAircraftModelLoader::LoadMode mode) + { + const CStatusMessage msg = CLogMessage(this).info("Started disk loading for '%1' in mode '%2'") << simulator.toQString(true) << IAircraftModelLoader::enumToString(mode); + this->showOverlayMessage(msg, 5000); + } + void CDbOwnModelsComponent::onOwnModelsLoadingFinished(const CStatusMessageList &statusMessages, const CSimulatorInfo &simulator, IAircraftModelLoader::LoadFinishedInfo info) { Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Expect single simulator"); diff --git a/src/blackgui/components/dbownmodelscomponent.h b/src/blackgui/components/dbownmodelscomponent.h index e2f6b8ae7..de6e61462 100644 --- a/src/blackgui/components/dbownmodelscomponent.h +++ b/src/blackgui/components/dbownmodelscomponent.h @@ -136,6 +136,9 @@ namespace BlackGui //! Load the models void loadInstalledModels(const BlackMisc::Simulation::CSimulatorInfo &simulator, BlackMisc::Simulation::IAircraftModelLoader::LoadMode mode, const QStringList &modelDirectories = {}); + //! On disk loading started + void onOwnModelsDiskLoadingStarted(const BlackMisc::Simulation::CSimulatorInfo &simulator, BlackMisc::Simulation::IAircraftModelLoader::LoadMode mode); + //! Model loading finished void onOwnModelsLoadingFinished(const BlackMisc::CStatusMessageList &statusMessages, const BlackMisc::Simulation::CSimulatorInfo &simulator, BlackMisc::Simulation::IAircraftModelLoader::LoadFinishedInfo info); diff --git a/src/blackmisc/simulation/aircraftmodelloader.cpp b/src/blackmisc/simulation/aircraftmodelloader.cpp index 7c1eead95..e35068e2b 100644 --- a/src/blackmisc/simulation/aircraftmodelloader.cpp +++ b/src/blackmisc/simulation/aircraftmodelloader.cpp @@ -255,6 +255,7 @@ namespace BlackMisc { IAircraftModelLoader *loader = IAircraftModelLoader::createModelLoader(simulator, this); connect(loader, &IAircraftModelLoader::loadingFinished, this, &CMultiAircraftModelLoaderProvider::loadingFinished); + connect(loader, &IAircraftModelLoader::diskLoadingStarted, this, &CMultiAircraftModelLoaderProvider::diskLoadingStarted); return loader; } } // ns diff --git a/src/blackmisc/simulation/aircraftmodelloader.h b/src/blackmisc/simulation/aircraftmodelloader.h index 6a6211dab..e2a12a81e 100644 --- a/src/blackmisc/simulation/aircraftmodelloader.h +++ b/src/blackmisc/simulation/aircraftmodelloader.h @@ -129,6 +129,10 @@ namespace BlackMisc static IAircraftModelLoader *createModelLoader(const CSimulatorInfo &simulator, QObject *parent = nullptr); signals: + //! Disk loading started + //! \remark will only indicate loading from disk, not cache loading + void diskLoadingStarted(const CSimulatorInfo &simulator, LoadMode loadMode); + //! Parsing is finished or cache has been loaded //! \remark does to fire if the cache has been changed elsewhere and it has just been reloaded here! void loadingFinished(const CStatusMessageList &status, const CSimulatorInfo &simulator, LoadFinishedInfo info); @@ -186,6 +190,9 @@ namespace BlackMisc //! \copydoc IAircraftModelLoader::loadingFinished void loadingFinished(const CStatusMessageList &status, const CSimulatorInfo &simulator, IAircraftModelLoader::LoadFinishedInfo info); + //! \copydoc IAircraftModelLoader::diskLoadingStarted + void diskLoadingStarted(const CSimulatorInfo &simulator, IAircraftModelLoader::LoadMode mode); + private: IAircraftModelLoader *m_loaderFsx = nullptr; IAircraftModelLoader *m_loaderP3D = nullptr;