From f8ee2acf5dc3760431347da2f367c9decf5797d4 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 15 Jan 2019 11:09:34 +0100 Subject: [PATCH] Ref T430, context menus in mapping tool for FG --- src/blackconfig/buildconfig.cpp | 9 +++ src/blackconfig/buildconfig.h | 9 ++- src/blackconfig/buildconfig_gen.inc.in | 9 +++ .../components/dbownmodelscomponent.cpp | 63 ++++++++++++++++++- src/blackgui/components/simulatorselector.cpp | 2 +- 5 files changed, 87 insertions(+), 5 deletions(-) diff --git a/src/blackconfig/buildconfig.cpp b/src/blackconfig/buildconfig.cpp index 3e9aa4f50..7dd5419df 100644 --- a/src/blackconfig/buildconfig.cpp +++ b/src/blackconfig/buildconfig.cpp @@ -123,6 +123,7 @@ namespace BlackConfig if (CBuildConfig::isCompiledWithFsxSupport()) { sl << "FSX"; } if (CBuildConfig::isCompiledWithXPlaneSupport()) { sl << "XPlane"; } if (CBuildConfig::isCompiledWithP3DSupport()) { sl << "P3D"; } + if (CBuildConfig::isCompiledWithFGSupport()) { sl << "FG"; } infoShort = sl.join(", "); if (infoShort.isEmpty()) { infoShort = ""; } } @@ -142,6 +143,7 @@ namespace BlackConfig infoLong = infoLong.append(" FSX: ").append(boolToYesNo(isCompiledWithFsxSupport())); infoLong = infoLong.append(" P3D: ").append(boolToYesNo(isCompiledWithP3DSupport())); infoLong = infoLong.append(" XPlane: ").append(boolToYesNo(isCompiledWithXPlaneSupport())); + infoLong = infoLong.append(" FG: ").append(boolToYesNo(isCompiledWithFGSupport())); } return infoLong; } @@ -250,6 +252,13 @@ namespace BlackConfig static const int bws = Private::buildWordSizeImpl(); return bws; } + + bool CBuildConfig::supportFlightGear() + { + // for testing set to "true", never commit with TRUE before FG is completed + // this will be removed when FG is fully productive + return false; // && isLocalDeveloperDebugBuild(); + } } // ns //! \endcond diff --git a/src/blackconfig/buildconfig.h b/src/blackconfig/buildconfig.h index 953f3d37c..b94bf7191 100644 --- a/src/blackconfig/buildconfig.h +++ b/src/blackconfig/buildconfig.h @@ -41,7 +41,10 @@ namespace BlackConfig //! with P3D support? static constexpr bool isCompiledWithP3DSupport(); // defined in buildconfig_gen.inc.in - //! with Fsuipc support? + //! with FG support? + static constexpr bool isCompiledWithFGSupport(); // defined in buildconfig_gen.inc.in + + //! with FSUIPC support? static constexpr bool isCompiledWithFsuipcSupport(); // defined in buildconfig_gen.inc.in //! Compiled with any MS Flight Simulator support (P3D, FSX, FS9) @@ -147,6 +150,10 @@ namespace BlackConfig //! \returns 32, 64 or -1 (in case no info is possible) static int buildWordSize(); + //! Ref T430 FG preparations, will be removed later + //! \fixme KB 2019-01 remove after FG is fully implemented + static bool supportFlightGear(); + private: //! Major version static constexpr int versionMajor(); // defined in buildconfig_gen.inc.in diff --git a/src/blackconfig/buildconfig_gen.inc.in b/src/blackconfig/buildconfig_gen.inc.in index 3507c9c5c..c8c573b8e 100644 --- a/src/blackconfig/buildconfig_gen.inc.in +++ b/src/blackconfig/buildconfig_gen.inc.in @@ -83,6 +83,15 @@ constexpr bool BlackConfig::CBuildConfig::isCompiledWithXPlaneSupport() !!ENDIF } +constexpr bool BlackConfig::CBuildConfig::isCompiledWithFGSupport() +{ +!!IF swiftConfig(sims.fg) + return true; +!!ELSE + return false; +!!ENDIF +} + constexpr bool BlackConfig::CBuildConfig::isCompiledWithGui() { !!IF swiftConfig(libs.blackgui) diff --git a/src/blackgui/components/dbownmodelscomponent.cpp b/src/blackgui/components/dbownmodelscomponent.cpp index 68334cda3..eea1e4093 100644 --- a/src/blackgui/components/dbownmodelscomponent.cpp +++ b/src/blackgui/components/dbownmodelscomponent.cpp @@ -19,6 +19,7 @@ #include "blackmisc/icons.h" #include "blackmisc/logmessage.h" #include "blackmisc/statusmessage.h" +#include "blackconfig/buildconfig.h" #include "ui_dbownmodelscomponent.h" #include @@ -29,6 +30,7 @@ #include #include +using namespace BlackConfig; using namespace BlackMisc; using namespace BlackMisc::Simulation; using namespace BlackCore::Db; @@ -257,7 +259,7 @@ namespace BlackGui QPointer ownModelsComp(qobject_cast(this->parent())); Q_ASSERT_X(ownModelsComp, Q_FUNC_INFO, "Cannot access parent"); - if (m_loadActions.isEmpty()) { m_loadActions = QList({nullptr, nullptr, nullptr, nullptr}); } + if (m_loadActions.isEmpty()) { m_loadActions = QList({nullptr, nullptr, nullptr, nullptr, nullptr}); } menuActions.addMenuSimulator(); if (sims.isFSX()) { @@ -315,12 +317,26 @@ namespace BlackGui } menuActions.addAction(m_loadActions[3], CMenuAction::pathSimulator()); } + if (CBuildConfig::supportFlightGear() && sims.isFG()) + { + if (!m_loadActions[4]) + { + m_loadActions[4] = new QAction(CIcons::appModels16(), "FG models", this); + connect(m_loadActions[4], &QAction::triggered, ownModelsComp, [ownModelsComp](bool checked) + { + if (!ownModelsComp) { return; } + Q_UNUSED(checked); + ownModelsComp->requestSimulatorModelsWithCacheInBackground(CSimulatorInfo::fg()); + }); + } + menuActions.addAction(m_loadActions[4], CMenuAction::pathSimulator()); + } // with models loaded I allow a refresh reload // I need those models because I want to merge with DB data in the loader if (sGui && sGui->getWebDataServices() && sGui->getWebDataServices()->getModelsCount() > 0) { - if (m_reloadActions.isEmpty()) { m_reloadActions = QList({nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}); } + if (m_reloadActions.isEmpty()) { m_reloadActions = QList({nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}); } menuActions.addMenu(CIcons::refresh16(), "Force model reload", CMenuAction::pathSimulatorModelsReload()); if (sims.isFSX()) { @@ -434,6 +450,33 @@ namespace BlackGui menuActions.addAction(m_reloadActions[7], CMenuAction::pathSimulatorModelsReload()); } + if (CBuildConfig::supportFlightGear() && sims.isFG()) + { + if (!m_reloadActions[8]) + { + m_reloadActions[8] = new QAction(CIcons::appModels16(), "FG models", this); + connect(m_reloadActions[8], &QAction::triggered, ownModelsComp, [ownModelsComp](bool checked) + { + if (!ownModelsComp) { return; } + Q_UNUSED(checked); + ownModelsComp->requestSimulatorModels(CSimulatorInfo::fg(), IAircraftModelLoader::InBackgroundNoCache); + }); + m_reloadActions[9] = new QAction(CIcons::appModels16(), "FG models from directoy", this); + connect(m_reloadActions[9], &QAction::triggered, ownModelsComp, [ownModelsComp](bool checked) + { + if (!ownModelsComp) { return; } + Q_UNUSED(checked); + const CSimulatorInfo sim(CSimulatorInfo::FG); + const QString dir = ownModelsComp->directorySelector(sim); + if (!dir.isEmpty()) + { + ownModelsComp->requestSimulatorModels(sim, IAircraftModelLoader::InBackgroundNoCache, QStringList(dir)); + } + }); + } + menuActions.addAction(m_reloadActions[8], CMenuAction::pathSimulatorModelsReload()); + menuActions.addAction(m_reloadActions[9], CMenuAction::pathSimulatorModelsReload()); + } } else { @@ -442,7 +485,7 @@ namespace BlackGui a.setActionEnabled(false); // gray out } - if (m_clearCacheActions.isEmpty()) { m_clearCacheActions = QList({nullptr, nullptr, nullptr, nullptr}); } + if (m_clearCacheActions.isEmpty()) { m_clearCacheActions = QList({nullptr, nullptr, nullptr, nullptr, nullptr}); } menuActions.addMenu(CIcons::delete16(), "Clear model caches", CMenuAction::pathSimulatorModelsClearCache()); if (sims.isFSX()) { @@ -500,6 +543,20 @@ namespace BlackGui } menuActions.addAction(m_clearCacheActions[3], CMenuAction::pathSimulatorModelsClearCache()); } + if (CBuildConfig::supportFlightGear() && sims.isFG()) + { + if (!m_clearCacheActions[4]) + { + m_clearCacheActions[4] = new QAction(CIcons::appModels16(), "Clear FG cache", this); + connect(m_clearCacheActions[3], &QAction::triggered, ownModelsComp, [ownModelsComp](bool checked) + { + if (!ownModelsComp) { return; } + Q_UNUSED(checked); + ownModelsComp->clearSimulatorCache(CSimulatorInfo::fg()); + }); + } + menuActions.addAction(m_clearCacheActions[4], CMenuAction::pathSimulatorModelsClearCache()); + } } this->nestedCustomMenu(menuActions); } diff --git a/src/blackgui/components/simulatorselector.cpp b/src/blackgui/components/simulatorselector.cpp index 67960a80c..db9f7ee26 100644 --- a/src/blackgui/components/simulatorselector.cpp +++ b/src/blackgui/components/simulatorselector.cpp @@ -37,7 +37,7 @@ namespace BlackGui { ui->setupUi(this); - const bool withFG = false; // CBuildConfig::isLocalDeveloperDebugBuild(); + const bool withFG = CBuildConfig::supportFlightGear(); this->enableFG(withFG); this->addComboxBoxValues();