diff --git a/src/blackgui/components/dbmappingcomponent.cpp b/src/blackgui/components/dbmappingcomponent.cpp index 586d28371..cbb386492 100644 --- a/src/blackgui/components/dbmappingcomponent.cpp +++ b/src/blackgui/components/dbmappingcomponent.cpp @@ -95,6 +95,7 @@ namespace BlackGui this->ui->tw_ModelsToBeMapped->setTabIcon(TabStash, CIcons::appDbStash16()); this->ui->tw_ModelsToBeMapped->setTabIcon(TabOwnModels, CIcons::appModels16()); + this->ui->tw_ModelsToBeMapped->setTabIcon(TabOwnModelSet, CIcons::appModels16()); // custom menu this->setContextMenuPolicy(Qt::CustomContextMenu); @@ -734,18 +735,17 @@ namespace BlackGui this->ui->comp_StashAircraft->replaceModelsUnvalidated(models); } - void CDbMappingComponent::CMappingVPilotMenu::customMenu(QMenu &menu) const + void CDbMappingComponent::CMappingVPilotMenu::customMenu(CMenuActions &menuActions) { CDbMappingComponent *mapComp = qobject_cast(this->parent()); Q_ASSERT_X(mapComp, Q_FUNC_INFO, "Cannot access mapping component"); - bool canUseVPilot = mappingComponent()->withVPilot(); + const bool canUseVPilot = mappingComponent()->withVPilot(); if (canUseVPilot) { - this->addSeparator(menu); - menu.addAction(CIcons::appMappings16(), "Load vPilot Rules", mapComp, &CDbMappingComponent::ps_loadVPilotData); + this->m_menuAction = menuActions.addAction(this->m_menuAction, CIcons::appMappings16(), "Load vPilot Rules", CMenuAction::pathVPilot(), this, { mapComp, &CDbMappingComponent::ps_loadVPilotData }); } - this->nestedCustomMenu(menu); + this->nestedCustomMenu(menuActions); } CDbMappingComponent *CDbMappingComponent::CMappingVPilotMenu::mappingComponent() const @@ -757,56 +757,37 @@ namespace BlackGui BlackGui::Menus::IMenuDelegate(mappingComponent, separator) {} - void CDbMappingComponent::CModelStashToolsMenu::customMenu(QMenu &menu) const + void CDbMappingComponent::CModelStashToolsMenu::customMenu(CMenuActions &menuActions) { CDbMappingComponent *mapComp = mappingComponent(); Q_ASSERT_X(mapComp, Q_FUNC_INFO, "no mapping component"); const bool canConnectDb = sGui->getWebDataServices()->canConnectSwiftDb(); - if (!canConnectDb) { this->nestedCustomMenu(menu); return; } + if (!canConnectDb) { this->nestedCustomMenu(menuActions); return; } if (!mapComp->currentModelView()->isEmpty() && mapComp->currentModelView()->getMenu().testFlag(CViewBaseNonTemplate::MenuCanStashModels)) { - QMenu *stashMenu = new QMenu("Stash tools", &menu); - int dbModels = sGui->getWebDataServices()->getModelsCount(); + menuActions.addMenuStash(); + + // auto filter in DB views + this->m_stashFiltering = menuActions.addAction(this->m_stashFiltering, CIcons::filter16(), "Auto filtering in DB views (on/off)", CMenuAction::pathStash(), this, { mapComp, &CDbMappingComponent::ps_toggleAutoFiltering }); + this->m_stashFiltering->setCheckable(true); + this->m_stashFiltering->setChecked(mapComp->m_autoFilterInDbViews); + + const int dbModels = sGui->getWebDataServices()->getModelsCount(); if (dbModels > 0) { // we have keys and data by which we could delete them from view const QString msgDelete("Delete " + QString::number(dbModels) + " DB model(s) from " + mapComp->currentTabText()); - stashMenu->addAction(CIcons::delete16(), msgDelete, mapComp, &CDbMappingComponent::ps_removeDbModelsFromView); + menuActions.addAction(CIcons::delete16(), msgDelete, CMenuAction::pathStash(), nullptr, { mapComp, &CDbMappingComponent::ps_removeDbModelsFromView}); } - const QString msgAutoStash("Auto stashing"); - stashMenu->addAction(CIcons::appDbStash16(), msgAutoStash, mapComp, &CDbMappingComponent::ps_displayAutoStashingDialog); - + this->m_autoStashing = menuActions.addAction(this->m_autoStashing, CIcons::appDbStash16(), "Auto stashing", CMenuAction::pathStash(), this, { mapComp, &CDbMappingComponent::ps_displayAutoStashingDialog }); if (mapComp->m_autoStashDialog && mapComp->m_autoStashDialog->isCompleted()) { - stashMenu->addAction(CIcons::appDbStash16(), "Last auto stash run", mapComp->m_autoStashDialog.data(), &CDbAutoStashingComponent::showLastResults); - } - - // auto filter in DB views - QAction *a = stashMenu->addAction(CIcons::filter16(), "Auto filtering in DB views (on/off)", mapComp, &CDbMappingComponent::ps_toggleAutoFiltering); - a->setCheckable(true); - a->setChecked(mapComp->m_autoFilterInDbViews); - - // add menu - if (stashMenu->isEmpty()) - { - menu.deleteLater(); - } - else - { - this->addSeparator(menu); - menu.addMenu(stashMenu); - stashMenu->setIcon(CIcons::appDbStash16()); + menuActions.addAction(CIcons::appDbStash16(), "Last auto stash run", CMenuAction::pathStash(), nullptr, { mapComp->m_autoStashDialog.data(), &CDbAutoStashingComponent::showLastResults }); } } - this->nestedCustomMenu(menu); - } - - void CDbMappingComponent::CModelStashToolsMenu::addSeparator(QMenu &menu) const - { - if (this->previousMenuItemContains("Stash", menu, Qt::CaseInsensitive)) { return; } - IMenuDelegate::addSeparator(menu); + this->nestedCustomMenu(menuActions); } CDbMappingComponent *CDbMappingComponent::CModelStashToolsMenu::mappingComponent() const @@ -814,16 +795,16 @@ namespace BlackGui return qobject_cast(this->parent()); } - void CDbMappingComponent::COwnModelSetMenu::customMenu(QMenu &menu) const + void CDbMappingComponent::COwnModelSetMenu::customMenu(CMenuActions &menuActions) { CDbMappingComponent *mapComp = mappingComponent(); Q_ASSERT_X(mapComp, Q_FUNC_INFO, "no mapping component"); if (mapComp->currentTabIndex() == CDbMappingComponent::TabOwnModels && mapComp->currentModelView()->hasSelection()) { - this->addSeparator(menu); - menu.addAction(CIcons::appAircraft16(), "Add to own model set", mapComp, &CDbMappingComponent::ps_addToOwnModelSet); + menuActions.addMenuModelSet(); + this->m_menuAction = menuActions.addAction(this->m_menuAction, CIcons::appModels16(), "Add to own model set", CMenuAction::pathModelSet(), this, { mapComp, &CDbMappingComponent::ps_addToOwnModelSet }); } - this->nestedCustomMenu(menu); + this->nestedCustomMenu(menuActions); } CDbMappingComponent *CDbMappingComponent::COwnModelSetMenu::mappingComponent() const @@ -831,41 +812,31 @@ namespace BlackGui return qobject_cast(this->parent()); } - void CDbMappingComponent::CApplyDbDataMenu::customMenu(QMenu &menu) const + void CDbMappingComponent::CApplyDbDataMenu::customMenu(CMenuActions &menuActions) { CDbMappingComponent *mapComp = mappingComponent(); Q_ASSERT_X(mapComp, Q_FUNC_INFO, "no mapping component"); if (mapComp->currentTabIndex() == CDbMappingComponent::TabStash && mapComp->currentModelView()->hasSelection()) { - this->addSeparator(menu); + if (this->m_menuActions.isEmpty()) { this->m_menuActions = QList({ nullptr, nullptr, nullptr, nullptr }); } // stash view and selection - QMenu *subMenu = menu.addMenu(CIcons::database16(), "Apply editor DB data (to selected)"); - QAction *a = nullptr; + menuActions.addMenuStashEditor(); - a = subMenu->addAction(CIcons::appAircraftIcao16(), "Current aircraft ICAO", mapComp, &CDbMappingComponent::ps_applyDbData); - a->setData(CAircraftIcaoCode().getClassName()); + this->m_menuActions[0] = menuActions.addAction(this->m_menuActions[0], CIcons::appAircraftIcao16(), "Current aircraft ICAO", CMenuAction::pathStashEditor(), this, { mapComp, &CDbMappingComponent::ps_applyDbData }); + this->m_menuActions[0]->setData(CAircraftIcaoCode().getClassName()); - a = subMenu->addAction(CIcons::appDistributors16(), "Current distributor", mapComp, &CDbMappingComponent::ps_applyDbData); - a->setData(CDistributor().getClassName()); + this->m_menuActions[1] = menuActions.addAction(this->m_menuActions[1], CIcons::appDistributors16(), "Current distributor", CMenuAction::pathStashEditor(), this, { mapComp, &CDbMappingComponent::ps_applyDbData }); + this->m_menuActions[1]->setData(CDistributor().getClassName()); - a = subMenu->addAction(CIcons::appLiveries16(), "Current livery", mapComp, &CDbMappingComponent::ps_applyDbData); - a->setData(CLivery().getClassName()); + this->m_menuActions[2] = menuActions.addAction(this->m_menuActions[2], CIcons::appLiveries16(), "Current livery", CMenuAction::pathStashEditor(), this, { mapComp, &CDbMappingComponent::ps_applyDbData }); + this->m_menuActions[2]->setData(CLivery().getClassName()); - // a = subMenu->addAction(CIcons::appAirlineIcao16(), "Current airline ICAO", mapComp, &CDbMappingComponent::ps_applyDbData); - // a->setData(CAirlineIcaoCode().getClassName()); - - menu.addAction(CIcons::databaseTable16(), "Modify DB model data", mapComp, &CDbMappingComponent::ps_applyDbData); - a->setData(CAircraftModel().getClassName()); + this->m_menuActions[3] = menuActions.addAction(this->m_menuActions[3], CIcons::databaseTable16(), "Modify DB model data", CMenuAction::pathStashEditor(), this, { mapComp, &CDbMappingComponent::ps_applyDbData }); + this->m_menuActions[3]->setData(CAircraftModel().getClassName()); } - this->nestedCustomMenu(menu); - } - - void CDbMappingComponent::CApplyDbDataMenu::addSeparator(QMenu &menu) const - { - if (this->previousMenuItemContains("DB", menu)) { return; } - IMenuDelegate::addSeparator(menu); + this->nestedCustomMenu(menuActions); } CDbMappingComponent *CDbMappingComponent::CApplyDbDataMenu::mappingComponent() const @@ -879,23 +850,24 @@ namespace BlackGui Q_ASSERT_X(mappingComponent, Q_FUNC_INFO, "Missing vPilot reader"); } - void CDbMappingComponent::CMergeWithVPilotMenu::customMenu(QMenu &menu) const + void CDbMappingComponent::CMergeWithVPilotMenu::customMenu(CMenuActions &menuActions) { const CAircraftModelView *mv = mappingComponent()->ui->comp_OwnAircraftModels->view(); const CSimulatorInfo sim = mappingComponent()->ui->comp_OwnAircraftModels->getOwnModelsSimulator(); if (!mappingComponent()->withVPilot() || mv->isEmpty() || !sim.isSingleSimulator() || !sim.isMicrosoftOrPrepare3DSimulator()) { - this->nestedCustomMenu(menu); + this->nestedCustomMenu(menuActions); return; } - this->addSeparator(menu); - QMenu *mm = menu.addMenu("Merge with vPilot data"); - mm->addAction("All", mappingComponent(), &CDbMappingComponent::ps_mergeWithVPilotModels); + + if (this->m_menuActions.isEmpty()) { this->m_menuActions = QList({ nullptr, nullptr }); } + menuActions.addMenu("Merge with vPilot data", CMenuAction::pathVPilot()); + this->m_menuActions[0] = menuActions.addAction(this->m_menuActions[0], "All", CMenuAction::pathVPilot(), this, { mappingComponent(), &CDbMappingComponent::ps_mergeWithVPilotModels }); if (mv->hasSelection()) { - mm->addAction("Selected only", mappingComponent(), &CDbMappingComponent::ps_mergeSelectedWithVPilotModels); + this->m_menuActions[1] = menuActions.addAction(this->m_menuActions[1], "Selected only", CMenuAction::pathVPilot(), this, { mappingComponent(), &CDbMappingComponent::ps_mergeSelectedWithVPilotModels }); } - this->nestedCustomMenu(menu); + this->nestedCustomMenu(menuActions); } CDbMappingComponent *CDbMappingComponent::CMergeWithVPilotMenu::mappingComponent() const diff --git a/src/blackgui/components/dbmappingcomponent.h b/src/blackgui/components/dbmappingcomponent.h index c2dbce467..456ef05bf 100644 --- a/src/blackgui/components/dbmappingcomponent.h +++ b/src/blackgui/components/dbmappingcomponent.h @@ -269,11 +269,12 @@ namespace BlackGui {} //! \copydoc IMenuDelegate::customMenu - virtual void customMenu(QMenu &menu) const override; + virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override; private: //! Mapping component CDbMappingComponent *mappingComponent() const; + QAction *m_menuAction = nullptr; }; //! Menu for tools: @@ -288,15 +289,14 @@ namespace BlackGui CModelStashToolsMenu(CDbMappingComponent *mappingComponent, bool separator = true); //! \copydoc IMenuDelegate::customMenu - virtual void customMenu(QMenu &menu) const override; - - protected: - //! \copydoc IMenuDelegate::addSeparator - virtual void addSeparator(QMenu &menu) const override; + virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override; private: //! Mapping component CDbMappingComponent *mappingComponent() const; + + QAction *m_autoStashing = nullptr; + QAction *m_stashFiltering = nullptr; }; //! Menu for own model sets @@ -309,11 +309,13 @@ namespace BlackGui {} //! \copydoc IMenuDelegate::customMenu - virtual void customMenu(QMenu &menu) const override; + virtual void customMenu(Menus::CMenuActions &menuActions) override; private: //! Mapping component CDbMappingComponent *mappingComponent() const; + + QAction *m_menuAction = nullptr; }; //! Apply DB data to selected models @@ -326,15 +328,13 @@ namespace BlackGui {} //! \copydoc IMenuDelegate::customMenu - virtual void customMenu(QMenu &menu) const override; - - protected: - //! \copydoc IMenuDelegate::addSeparator - virtual void addSeparator(QMenu &menu) const override; + virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override; private: //! Mapping component CDbMappingComponent *mappingComponent() const; + + QList m_menuActions; }; //! Merge with vPilot data @@ -345,10 +345,13 @@ namespace BlackGui CMergeWithVPilotMenu(CDbMappingComponent *mappingComponent, bool separator = true); //! \copydoc IMenuDelegate::customMenu - virtual void customMenu(QMenu &menu) const override; + virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override; //! Mapping component CDbMappingComponent *mappingComponent() const; + + private: + QList m_menuActions; }; }; } // ns diff --git a/src/blackgui/components/dbownmodelscomponent.cpp b/src/blackgui/components/dbownmodelscomponent.cpp index a8c5f8042..68894ba3c 100644 --- a/src/blackgui/components/dbownmodelscomponent.cpp +++ b/src/blackgui/components/dbownmodelscomponent.cpp @@ -160,80 +160,130 @@ namespace BlackGui this->ui->tvp_OwnAircraftModels->setSaveFileName(n); } - void CDbOwnModelsComponent::CLoadModelsMenu::customMenu(QMenu &menu) const + void CDbOwnModelsComponent::CLoadModelsMenu::customMenu(CMenuActions &menuActions) { - CSimulatorInfo sims = CSimulatorInfo::getLocallyInstalledSimulators(); - bool noSims = sims.isNoSimulator() || sims.isUnspecified(); + const CSimulatorInfo sims = CSimulatorInfo::getLocallyInstalledSimulators(); + const bool noSims = sims.isNoSimulator() || sims.isUnspecified(); if (!noSims) { - this->addSeparator(menu); - QMenu *load = menu.addMenu(CIcons::appModels16(), "Load installed models"); CDbOwnModelsComponent *ownModelsComp = qobject_cast(this->parent()); Q_ASSERT_X(ownModelsComp, Q_FUNC_INFO, "Cannot access parent"); + + if (this->m_loadActions.isEmpty()) { this->m_loadActions = QList({nullptr, nullptr, nullptr, nullptr}); } + menuActions.addMenuSimulator(); if (sims.fsx()) { - load->addAction(CIcons::appModels16(), "FSX models", ownModelsComp, [ownModelsComp]() + if (!this->m_loadActions[0]) { - ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::FSX), IAircraftModelLoader::InBackgroundWithCache); - }); + this->m_loadActions[0] = new QAction(CIcons::appModels16(), "FSX models", this); + connect(this->m_loadActions[0], &QAction::triggered, ownModelsComp, [ownModelsComp](bool checked) + { + Q_UNUSED(checked); + ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::FSX), IAircraftModelLoader::InBackgroundWithCache); + }); + } + menuActions.addAction(this->m_loadActions[0], CMenuAction::pathSimulator()); } if (sims.p3d()) { - load->addAction(CIcons::appModels16(), "P3D models", ownModelsComp, [ownModelsComp]() + if (!this->m_loadActions[1]) { - ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::P3D), IAircraftModelLoader::InBackgroundWithCache); - }); + this->m_loadActions[1] = new QAction(CIcons::appModels16(), "P3D models", this); + connect(this->m_loadActions[1], &QAction::triggered, ownModelsComp, [ownModelsComp](bool checked) + { + Q_UNUSED(checked); + ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::P3D), IAircraftModelLoader::InBackgroundWithCache); + }); + } + menuActions.addAction(this->m_loadActions[1], CMenuAction::pathSimulator()); } if (sims.fs9()) { - load->addAction(CIcons::appModels16(), "FS9 models", ownModelsComp, [ownModelsComp]() + if (!this->m_loadActions[2]) { - ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::FS9), IAircraftModelLoader::InBackgroundWithCache); - }); + this->m_loadActions[2] = new QAction(CIcons::appModels16(), "FS9 models", this); + connect(this->m_loadActions[2], &QAction::triggered, ownModelsComp, [ownModelsComp](bool checked) + { + Q_UNUSED(checked); + ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::FS9), IAircraftModelLoader::InBackgroundWithCache); + }); + } + menuActions.addAction(this->m_loadActions[2], CMenuAction::pathSimulator()); } if (sims.xplane()) { - load->addAction(CIcons::appModels16(), "XP models", ownModelsComp, [ownModelsComp]() + if (!this->m_loadActions[3]) { - ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::XPLANE), IAircraftModelLoader::InBackgroundWithCache); - }); + this->m_loadActions[3] = new QAction(CIcons::appModels16(), "XPlane models", this); + connect(this->m_loadActions[3], &QAction::triggered, ownModelsComp, [ownModelsComp](bool checked) + { + Q_UNUSED(checked); + ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::XPLANE), IAircraftModelLoader::InBackgroundWithCache); + }); + } + menuActions.addAction(this->m_loadActions[3], CMenuAction::pathSimulator()); } // with models loaded I allow a refresh reload if (sGui->getWebDataServices() && sGui->getWebDataServices()->getModelsCount() > 0) { - QMenu *reloadMenu = load->addMenu("Force reload"); + if (this->m_reloadActions.isEmpty()) { this->m_reloadActions = QList({nullptr, nullptr, nullptr, nullptr}); } + menuActions.addMenu(CIcons::refresh16(), "Force model reload", CMenuAction::pathSimulatorModelsReload()); if (sims.fsx()) { - reloadMenu->addAction(CIcons::appModels16(), "FSX models", ownModelsComp, [ownModelsComp]() + if (!this->m_reloadActions[0]) { - ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::FSX), IAircraftModelLoader::InBackgroundNoCache); - }); + this->m_reloadActions[0] = new QAction(CIcons::appModels16(), "FSX models", this); + connect(this->m_reloadActions[0], &QAction::triggered, ownModelsComp, [ownModelsComp](bool checked) + { + Q_UNUSED(checked); + ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::FSX), IAircraftModelLoader::InBackgroundNoCache); + }); + } + menuActions.addAction(this->m_reloadActions[0], CMenuAction::pathSimulatorModelsReload()); } if (sims.p3d()) { - reloadMenu->addAction(CIcons::appModels16(), "P3D models", ownModelsComp, [ownModelsComp]() + if (!this->m_reloadActions[1]) { - ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::P3D), IAircraftModelLoader::InBackgroundNoCache); - }); + this->m_reloadActions[1] = new QAction(CIcons::appModels16(), "P3D models", this); + connect(this->m_reloadActions[1], &QAction::triggered, ownModelsComp, [ownModelsComp](bool checked) + { + Q_UNUSED(checked); + ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::P3D), IAircraftModelLoader::InBackgroundNoCache); + }); + } + menuActions.addAction(this->m_reloadActions[1], CMenuAction::pathSimulatorModelsReload()); } if (sims.fs9()) { - reloadMenu->addAction(CIcons::appModels16(), "FS9 models", ownModelsComp, [ownModelsComp]() + if (!this->m_reloadActions[2]) { - ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::FS9), IAircraftModelLoader::InBackgroundNoCache); - }); + this->m_reloadActions[2] = new QAction(CIcons::appModels16(), "FS9 models", this); + connect(this->m_reloadActions[2], &QAction::triggered, ownModelsComp, [ownModelsComp](bool checked) + { + Q_UNUSED(checked); + ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::FS9), IAircraftModelLoader::InBackgroundNoCache); + }); + } + menuActions.addAction(this->m_reloadActions[2], CMenuAction::pathSimulatorModelsReload()); } if (sims.xplane()) { - reloadMenu->addAction(CIcons::appModels16(), "XP models", ownModelsComp, [ownModelsComp]() + if (!this->m_reloadActions[3]) { - ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::XPLANE), IAircraftModelLoader::InBackgroundNoCache); - }); + this->m_reloadActions[3] = new QAction(CIcons::appModels16(), "XPlane models", this); + connect(this->m_reloadActions[3], &QAction::triggered, ownModelsComp, [ownModelsComp](bool checked) + { + Q_UNUSED(checked); + ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::XPLANE), IAircraftModelLoader::InBackgroundNoCache); + }); + } + menuActions.addAction(this->m_reloadActions[3], CMenuAction::pathSimulatorModelsReload()); } } } - this->nestedCustomMenu(menu); + this->nestedCustomMenu(menuActions); } void CDbOwnModelsComponent::ps_requestOwnModelsUpdate() diff --git a/src/blackgui/components/dbownmodelscomponent.h b/src/blackgui/components/dbownmodelscomponent.h index 38359fb1f..2f5fce2f2 100644 --- a/src/blackgui/components/dbownmodelscomponent.h +++ b/src/blackgui/components/dbownmodelscomponent.h @@ -103,7 +103,11 @@ namespace BlackGui {} //! \copydoc IMenuDelegate::customMenu - virtual void customMenu(QMenu &menu) const override; + virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override; + + private: + QList m_loadActions; //!< load actions + QList m_reloadActions; //!< reload actions }; }; } // ns diff --git a/src/blackgui/components/dbownmodelsetcomponent.cpp b/src/blackgui/components/dbownmodelsetcomponent.cpp index e9401ce57..93cd6b617 100644 --- a/src/blackgui/components/dbownmodelsetcomponent.cpp +++ b/src/blackgui/components/dbownmodelsetcomponent.cpp @@ -296,76 +296,94 @@ namespace BlackGui } } - void CDbOwnModelSetComponent::CLoadModelsMenu::customMenu(QMenu &menu) const + void CDbOwnModelSetComponent::CLoadModelsMenu::customMenu(CMenuActions &menuActions) { const CSimulatorInfo sims = CSimulatorInfo::getLocallyInstalledSimulators(); - bool noSims = sims.isNoSimulator() || sims.isUnspecified(); + const bool noSims = sims.isNoSimulator() || sims.isUnspecified(); if (!noSims) { - this->addSeparator(menu); - QMenu *load = menu.addMenu(CIcons::appModels16(), "Model set"); CDbOwnModelSetComponent *ownModelSetComp = qobject_cast(this->parent()); Q_ASSERT_X(ownModelSetComp, Q_FUNC_INFO, "Cannot access parent"); - if (sims.fsx()) + if (this->m_setActions.isEmpty()) { - load->addAction(CIcons::appModels16(), "FSX models", ownModelSetComp, [ownModelSetComp]() + if (sims.fsx()) { - ownModelSetComp->ps_changeSimulator(CSimulatorInfo(CSimulatorInfo::FSX)); - }); - } - if (sims.p3d()) - { - load->addAction(CIcons::appModels16(), "P3D models", ownModelSetComp, [ownModelSetComp]() - { - ownModelSetComp->ps_changeSimulator(CSimulatorInfo(CSimulatorInfo::P3D)); - }); - } - if (sims.fs9()) - { - load->addAction(CIcons::appModels16(), "FS9 models", ownModelSetComp, [ownModelSetComp]() - { - ownModelSetComp->ps_changeSimulator(CSimulatorInfo(CSimulatorInfo::FS9)); - }); - } - if (sims.xplane()) - { - load->addAction(CIcons::appModels16(), "XP models", ownModelSetComp, [ownModelSetComp]() - { - ownModelSetComp->ps_changeSimulator(CSimulatorInfo(CSimulatorInfo::XPLANE)); - }); - } + QAction *a = new QAction(CIcons::appModels16(), "FSX models", this); + connect(a, &QAction::triggered, ownModelSetComp, [ownModelSetComp](bool checked) + { + Q_UNUSED(checked); + ownModelSetComp->ps_changeSimulator(CSimulatorInfo(CSimulatorInfo::FSX)); + }); + this->m_setActions.append(a); - QMenu *emptySetMenu = load->addMenu("New empty set"); - if (sims.fsx()) - { - emptySetMenu->addAction(CIcons::appModels16(), "FSX models", ownModelSetComp, [ownModelSetComp]() + a = new QAction(CIcons::appModels16(), "New set FSX models", this); + connect(a, &QAction::triggered, ownModelSetComp, [ownModelSetComp](bool checked) + { + Q_UNUSED(checked); + ownModelSetComp->setModelSet(CAircraftModelList(), CSimulatorInfo(CSimulatorInfo::FSX)); + }); + this->m_setNewActions.append(a); + } + if (sims.p3d()) { - ownModelSetComp->setModelSet(CAircraftModelList(), CSimulatorInfo(CSimulatorInfo::FSX)); - }); - } - if (sims.p3d()) - { - emptySetMenu->addAction(CIcons::appModels16(), "P3D models", ownModelSetComp, [ownModelSetComp]() + QAction *a = new QAction(CIcons::appModels16(), "P3D models", this); + connect(a, &QAction::triggered, ownModelSetComp, [ownModelSetComp](bool checked) + { + Q_UNUSED(checked); + ownModelSetComp->ps_changeSimulator(CSimulatorInfo(CSimulatorInfo::P3D)); + }); + this->m_setActions.append(a); + + a = new QAction(CIcons::appModels16(), "New set P3D models", this); + connect(a, &QAction::triggered, ownModelSetComp, [ownModelSetComp](bool checked) + { + Q_UNUSED(checked); + ownModelSetComp->setModelSet(CAircraftModelList(), CSimulatorInfo(CSimulatorInfo::P3D)); + }); + this->m_setNewActions.append(a); + } + if (sims.fs9()) { - ownModelSetComp->setModelSet(CAircraftModelList(), CSimulatorInfo(CSimulatorInfo::P3D)); - }); - } - if (sims.fs9()) - { - emptySetMenu->addAction(CIcons::appModels16(), "FS9 models", ownModelSetComp, [ownModelSetComp]() + QAction *a = new QAction(CIcons::appModels16(), "FS9 models", this); + connect(a, &QAction::triggered, ownModelSetComp, [ownModelSetComp](bool checked) + { + Q_UNUSED(checked); + ownModelSetComp->ps_changeSimulator(CSimulatorInfo(CSimulatorInfo::FS9)); + }); + this->m_setActions.append(a); + + a = new QAction(CIcons::appModels16(), "New set FS9 models", this); + connect(a, &QAction::triggered, ownModelSetComp, [ownModelSetComp](bool checked) + { + Q_UNUSED(checked); + ownModelSetComp->setModelSet(CAircraftModelList(), CSimulatorInfo(CSimulatorInfo::FS9)); + }); + this->m_setNewActions.append(a); + } + if (sims.xplane()) { - ownModelSetComp->setModelSet(CAircraftModelList(), CSimulatorInfo(CSimulatorInfo::FS9)); - }); - } - if (sims.xplane()) - { - emptySetMenu->addAction(CIcons::appModels16(), "XP models", ownModelSetComp, [ownModelSetComp]() - { - ownModelSetComp->setModelSet(CAircraftModelList(), CSimulatorInfo(CSimulatorInfo::XPLANE)); - }); + QAction *a = new QAction(CIcons::appModels16(), "XPlane models", this); + connect(a, &QAction::triggered, ownModelSetComp, [ownModelSetComp](bool checked) + { + Q_UNUSED(checked); + ownModelSetComp->ps_changeSimulator(CSimulatorInfo(CSimulatorInfo::XPLANE)); + }); + this->m_setActions.append(a); + + a = new QAction(CIcons::appModels16(), "New set XPlane models", this); + connect(a, &QAction::triggered, ownModelSetComp, [ownModelSetComp](bool checked) + { + Q_UNUSED(checked); + ownModelSetComp->setModelSet(CAircraftModelList(), CSimulatorInfo(CSimulatorInfo::XPLANE)); + }); + this->m_setNewActions.append(a); + } } + menuActions.addMenuModelSet(); + menuActions.addActions(this->m_setActions, CMenuAction::pathModelSet()); + menuActions.addActions(this->m_setNewActions, CMenuAction::pathModelSetNew()); } - this->nestedCustomMenu(menu); + this->nestedCustomMenu(menuActions); } } // ns } // ns diff --git a/src/blackgui/components/dbownmodelsetcomponent.h b/src/blackgui/components/dbownmodelsetcomponent.h index 8cb9edcef..94c108ebd 100644 --- a/src/blackgui/components/dbownmodelsetcomponent.h +++ b/src/blackgui/components/dbownmodelsetcomponent.h @@ -138,7 +138,11 @@ namespace BlackGui {} //! \copydoc IMenuDelegate::customMenu - virtual void customMenu(QMenu &menu) const override; + virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override; + + private: + QList m_setActions; + QList m_setNewActions; }; }; } // ns diff --git a/src/blackgui/components/logcomponent.cpp b/src/blackgui/components/logcomponent.cpp index 51b25c0c2..4168f1f65 100644 --- a/src/blackgui/components/logcomponent.cpp +++ b/src/blackgui/components/logcomponent.cpp @@ -14,6 +14,7 @@ using namespace BlackMisc; using namespace BlackGui; using namespace BlackGui::Views; +using namespace BlackGui::Menus; namespace BlackGui { @@ -50,13 +51,13 @@ namespace BlackGui void CLogComponent::displayLog(bool attention) { this->ui->tw_StatusPage->setCurrentIndex(0); - if(attention) { emit requestAttention(); } + if (attention) { emit requestAttention(); } } void CLogComponent::displayConsole(bool attention) { this->ui->tw_StatusPage->setCurrentIndex(1); - if(attention) { emit requestAttention(); } + if (attention) { emit requestAttention(); } } void CLogComponent::appendStatusMessageToConsole(const CStatusMessage &statusMessage) @@ -82,16 +83,17 @@ namespace BlackGui this->ui->tvp_StatusMessages->insert(statusMessages); } - void CLogComponent::CLogMenu::customMenu(QMenu &menu) const + void CLogComponent::CLogMenu::customMenu(CMenuActions &menuActions) { CLogComponent *logComp = qobject_cast(this->parent()); Q_ASSERT_X(logComp, Q_FUNC_INFO, "Missing parent"); bool v = logComp->ui->form_StatusMessage->isVisible(); QString formString(v ? "Hide log details" : "Show log details"); - QAction *a = menu.addAction(BlackMisc::CIcons::databaseTable16(), formString, logComp->ui->form_StatusMessage, SLOT(toggleVisibility())); - a->setCheckable(true); - a->setChecked(v); + this->m_action = menuActions.addAction(this->m_action, BlackMisc::CIcons::databaseTable16(), formString, + CMenuAction::pathLog(), { logComp->ui->form_StatusMessage, &CStatusMessageForm::toggleVisibility}); + this->m_action->setCheckable(true); + this->m_action->setChecked(v); } } } // namespace diff --git a/src/blackgui/components/logcomponent.h b/src/blackgui/components/logcomponent.h index 62a98b837..acdfe8630 100644 --- a/src/blackgui/components/logcomponent.h +++ b/src/blackgui/components/logcomponent.h @@ -86,7 +86,11 @@ namespace BlackGui CLogMenu(CLogComponent *parent) : IMenuDelegate(parent) {} //! \copydoc IMenuDelegate::customMenu - virtual void customMenu(QMenu &menu) const override; + virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override; + + private: + QAction *m_action = nullptr; + }; }; } // ns diff --git a/src/blackgui/menus/aircraftmodelmenus.cpp b/src/blackgui/menus/aircraftmodelmenus.cpp index ff9386f41..9206dfe45 100644 --- a/src/blackgui/menus/aircraftmodelmenus.cpp +++ b/src/blackgui/menus/aircraftmodelmenus.cpp @@ -49,7 +49,7 @@ namespace BlackGui IAircraftModelViewMenu(modelView, separator), m_messageFrame(messageFrame) { } - void CShowSimulatorFileMenu::customMenu(QMenu &menu) const + void CShowSimulatorFileMenu::customMenu(CMenuActions &menuActions) { CAircraftModelView *mv = modelView(); Q_ASSERT_X(mv, Q_FUNC_INFO, "no view"); @@ -59,23 +59,22 @@ namespace BlackGui const CAircraftModel model(mv->selectedObject()); if (model.hasFileName() || (!model.getIconPath().isEmpty() && this->m_messageFrame)) { - this->addSeparator(menu); + menuActions.addMenuSimulator(); if (this->m_messageFrame) { const CAircraftModel model(mv->selectedObject()); if (!model.getIconPath().isEmpty()) { - this->addSeparator(menu); - menu.addAction(CIcons::appAircraft16(), "Display icon", this, &CShowSimulatorFileMenu::ps_displayIcon); + this->m_iconAction = menuActions.addAction(this->m_iconAction, CIcons::appAircraft16(), "Display icon", CMenuAction::pathSimulator(), { this, &CShowSimulatorFileMenu::ps_displayIcon }); } } - menu.addAction(CIcons::text16(), "Open simulator file", this, &CShowSimulatorFileMenu::ps_showSimulatorFile); + this->m_fileAction = menuActions.addAction(this->m_fileAction, CIcons::text16(), "Open simulator file", CMenuAction::pathSimulator(), { this, &CShowSimulatorFileMenu::ps_showSimulatorFile }); } } - this->nestedCustomMenu(menu); + this->nestedCustomMenu(menuActions); } - void CShowSimulatorFileMenu::ps_showSimulatorFile() const + void CShowSimulatorFileMenu::ps_showSimulatorFile() { const CAircraftModelView *mv = modelView(); if (!mv->hasSingleSelectedRow()) { return; } @@ -118,20 +117,21 @@ namespace BlackGui } } - void CMergeWithDbDataMenu::customMenu(QMenu &menu) const + void CMergeWithDbDataMenu::customMenu(CMenuActions &menuActions) { const CAircraftModelView *mv = modelView(); - if (mv->isEmpty()) { this->nestedCustomMenu(menu); return; } - if (!sGui->hasWebDataServices()) { this->nestedCustomMenu(menu); return; } + if (mv->isEmpty()) { this->nestedCustomMenu(menuActions); return; } + if (!sGui->hasWebDataServices()) { this->nestedCustomMenu(menuActions); return; } - this->addSeparator(menu); - QMenu *mm = menu.addMenu(CIcons::databaseEdit16(), "Merge with DB data"); - mm->addAction("All", this, &CMergeWithDbDataMenu::ps_mergeData); + menuActions.addMenuDatabase(); + menuActions.addMenu(CIcons::databaseEdit16(), "Merge with DB data", CMenuAction::pathViewDatabaseMerge()); + + this->m_mergeAll = menuActions.addAction(this->m_mergeAll, "All", CMenuAction::pathViewDatabaseMerge(), { this, &CMergeWithDbDataMenu::ps_mergeData }); if (mv->hasSelection()) { - mm->addAction("Selected only", this, &CMergeWithDbDataMenu::ps_mergeSelectedData); + this->m_mergeSelected = menuActions.addAction(this->m_mergeSelected, "Selected only", CMenuAction::pathViewDatabaseMerge(), { this, &CMergeWithDbDataMenu::ps_mergeSelectedData }); } - this->nestedCustomMenu(menu); + this->nestedCustomMenu(menuActions); } void CMergeWithDbDataMenu::ps_mergeData() @@ -164,14 +164,6 @@ namespace BlackGui } } - void CMergeWithDbDataMenu::addSeparator(QMenu &menu) const - { - // when the menu before us is a DB menu, we ignore the separator - if (!this->m_separator) { return; } - if (this->previousMenuItemContains("DB", menu)) { return; } - IAircraftModelViewMenu::addSeparator(menu); - } - IModelsSetable *CMergeWithDbDataMenu::modelsTargetSetable() const { return qobject_cast(this->m_modelsTarget); diff --git a/src/blackgui/menus/aircraftmodelmenus.h b/src/blackgui/menus/aircraftmodelmenus.h index 85fbef900..e96e93b34 100644 --- a/src/blackgui/menus/aircraftmodelmenus.h +++ b/src/blackgui/menus/aircraftmodelmenus.h @@ -52,14 +52,16 @@ namespace BlackGui CShowSimulatorFileMenu(BlackGui::Views::CAircraftModelView *modelView, BlackGui::COverlayMessagesFrame *messageFrame, bool separator = true); //! \copydoc IMenuDelegate::customMenu - virtual void customMenu(QMenu &menu) const override; + virtual void customMenu(CMenuActions &menuActions) override; private slots: - void ps_showSimulatorFile() const; //!< simulator file - void ps_displayIcon(); //!< aircraft icon if any + void ps_showSimulatorFile(); //!< simulator file + void ps_displayIcon(); //!< aircraft icon if any private: BlackGui::COverlayMessagesFrame *m_messageFrame = nullptr; + QAction *m_fileAction = nullptr; + QAction *m_iconAction = nullptr; }; //! Merge with DB data @@ -75,20 +77,18 @@ namespace BlackGui CMergeWithDbDataMenu(BlackGui::Views::CAircraftModelView *modelView, QObject *modelsTarget, bool separator = true); //! \copydoc IMenuDelegate::customMenu - virtual void customMenu(QMenu &menu) const override; + virtual void customMenu(CMenuActions &menuActions) override; private slots: void ps_mergeData(); void ps_mergeSelectedData(); - protected: - //! \copydoc IMenuDelegate::addSeparator - virtual void addSeparator(QMenu &menu) const override; - private: BlackMisc::Simulation::IModelsSetable *modelsTargetSetable() const; BlackMisc::Simulation::IModelsUpdatable *modelsTargetUpdatable() const; - QObject *m_modelsTarget = nullptr; //!< optional target for setting/updating the models + QObject *m_modelsTarget = nullptr; //!< optional target for setting/updating the models + QAction *m_mergeAll = nullptr; + QAction *m_mergeSelected = nullptr; }; } // ns } // ns diff --git a/src/blackgui/views/aircraftmodelview.cpp b/src/blackgui/views/aircraftmodelview.cpp index 642f951b2..2488db211 100644 --- a/src/blackgui/views/aircraftmodelview.cpp +++ b/src/blackgui/views/aircraftmodelview.cpp @@ -27,6 +27,7 @@ using namespace BlackMisc::Simulation; using namespace BlackMisc::Aviation; using namespace BlackGui::Models; using namespace BlackGui::Filters; +using namespace BlackGui::Menus; namespace BlackGui { @@ -266,33 +267,39 @@ namespace BlackGui } // valid mime? } - void CAircraftModelView::customMenu(QMenu &menu) const + void CAircraftModelView::customMenu(CMenuActions &menuActions) { - QMenu *stashMenu = new QMenu("Stash", &menu); + bool used = false; if (this->m_menus.testFlag(MenuCanStashModels)) { - stashMenu->addAction(CIcons::appDbStash16(), "Stash", this, &CAircraftModelView::ps_requestStash); - QAction *a = stashMenu->addAction(CIcons::appDbStash16(), "Stashing clears selection (on/off)", this, &CAircraftModelView::ps_stashingClearsSelection); - a->setCheckable(true); + if (!this->m_menuFlagActions.contains(MenuCanStashModels)) + { + CMenuActions ma; + ma.addAction(CIcons::appDbStash16(), "Stash selectied", CMenuAction::pathStash(), { this, &CAircraftModelView::ps_requestStash }); + QAction *added = ma.addAction(CIcons::appDbStash16(), "Stashing clears selection (on/off)", CMenuAction::pathStash(), { this, &CAircraftModelView::ps_stashingClearsSelection }); + added->setCheckable(true); + this->m_menuFlagActions.insert(MenuCanStashModels, ma); + } + QAction *a = menuActions.addActions(initMenuActions(MenuCanStashModels)).last(); a->setChecked(m_stashingClearsSelection); + used = true; } if (this->m_menus.testFlag(MenuHighlightStashed)) { // this function requires that someone provides the model strings to be highlighted - QAction *a = stashMenu->addAction(CIcons::appDbStash16(), "Highlight stashed (on/off)", this, &CAircraftModelView::ps_toggleHighlightStashedModels); - a->setCheckable(true); + if (!this->m_menuFlagActions.contains(MenuHighlightStashed)) + { + CMenuActions ma; + QAction *added = ma.addAction(CIcons::appDbStash16(), "Highlight stashed (on/off)", CMenuAction::pathStash(), { this, &CAircraftModelView::ps_toggleHighlightStashedModels }); + added->setCheckable(true); + this->m_menuFlagActions.insert(MenuHighlightStashed, ma); + } + QAction *a = menuActions.addActions(initMenuActions(CViewBaseNonTemplate::MenuHighlightStashed)).first(); a->setChecked(this->derivedModel()->highlightModelStrings()); + used = true; } - if (stashMenu->isEmpty()) - { - stashMenu->deleteLater(); - } - else - { - menu.addMenu(stashMenu); - stashMenu->setIcon(CIcons::appDbStash16()); - } - COrderableViewWithDbObjects::customMenu(menu); + if (used) { menuActions.addMenuStash();} + COrderableViewWithDbObjects::customMenu(menuActions); } CStatusMessage CAircraftModelView::modifyLoadedJsonData(CAircraftModelList &models) const diff --git a/src/blackgui/views/aircraftmodelview.h b/src/blackgui/views/aircraftmodelview.h index 4ec59736b..19346d3f3 100644 --- a/src/blackgui/views/aircraftmodelview.h +++ b/src/blackgui/views/aircraftmodelview.h @@ -110,7 +110,7 @@ namespace BlackGui //! \name View base class overrides //! @{ - virtual void customMenu(QMenu &menu) const override; + virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override; virtual BlackMisc::CStatusMessage modifyLoadedJsonData(BlackMisc::Simulation::CAircraftModelList &models) const override; virtual BlackMisc::CStatusMessage validateLoadedJsonData(const BlackMisc::Simulation::CAircraftModelList &models) const override; virtual void jsonLoadedAndModelUpdated(const BlackMisc::Simulation::CAircraftModelList &models) override; diff --git a/src/blackgui/views/atcstationview.cpp b/src/blackgui/views/atcstationview.cpp index 800568348..328da196b 100644 --- a/src/blackgui/views/atcstationview.cpp +++ b/src/blackgui/views/atcstationview.cpp @@ -16,6 +16,8 @@ using namespace BlackMisc; using namespace BlackMisc::Aviation; using namespace BlackGui::Models; +using namespace BlackGui::Menus; + namespace BlackGui { @@ -40,23 +42,24 @@ namespace BlackGui this->resizeToContents(); } - void CAtcStationView::customMenu(QMenu &menu) const + void CAtcStationView::customMenu(CMenuActions &menuActions) { if (BlackMisc::CBuildConfig::isDebugBuild()) { - menu.addAction(CIcons::tableSheet16(), "Test: 1k ATC online stations", this, SLOT(ps_testRequest1kAtcOnlineDummies())); - menu.addAction(CIcons::tableSheet16(), "Test: 3k ATC online stations", this, SLOT(ps_testRequest3kAtcOnlineDummies())); - menu.addSeparator(); + if (this->m_debugActions.isEmpty()) { this->m_actions = QList({nullptr, nullptr}); } + this->m_actions[0] = menuActions.addAction(this->m_actions[0], CIcons::tableSheet16(), "Test: 1k ATC online stations", CMenuAction::pathClientCom(), { this, &CAtcStationView::ps_testRequest1kAtcOnlineDummies }); + this->m_actions[1] = menuActions.addAction(this->m_actions[1], CIcons::tableSheet16(), "Test: 3k ATC online stations", CMenuAction::pathClientCom(), { this, &CAtcStationView::ps_testRequest1kAtcOnlineDummies }); } if (this->hasSelection()) { - menu.addAction(CIcons::appCockpit16(), "Tune in COM1", this, SLOT(ps_tuneInAtcCom1())); - menu.addAction(CIcons::appCockpit16(), "Tune in COM2", this, SLOT(ps_tuneInAtcCom2())); - menu.addAction(CIcons::appTextMessages16(), "Show text messages", this, SLOT(ps_requestTextMessage())); - menu.addSeparator(); + if (this->m_debugActions.isEmpty()) { this->m_debugActions = QList({nullptr, nullptr, nullptr}); } + + this->m_debugActions[0] = menuActions.addAction(this->m_debugActions[0], CIcons::appCockpit16(), "Tune in COM1", CMenuAction::pathClientCom(), { this, &CAtcStationView::ps_tuneInAtcCom1 }); + this->m_debugActions[1] = menuActions.addAction(this->m_debugActions[1], CIcons::appCockpit16(), "Tune in COM2", CMenuAction::pathClientCom(), { this, &CAtcStationView::ps_tuneInAtcCom2 }); + this->m_debugActions[2] = menuActions.addAction(this->m_debugActions[2], CIcons::appTextMessages16(), "Show text messages", CMenuAction::pathClientCom(), { this, &CAtcStationView::ps_requestTextMessage }); } - CViewBase::customMenu(menu); + CViewBase::customMenu(menuActions); } void CAtcStationView::ps_tuneInAtcCom1() diff --git a/src/blackgui/views/atcstationview.h b/src/blackgui/views/atcstationview.h index 6faac8134..1df43d8d9 100644 --- a/src/blackgui/views/atcstationview.h +++ b/src/blackgui/views/atcstationview.h @@ -48,7 +48,7 @@ namespace BlackGui protected: //! \copydoc CViewBase::customMenu - virtual void customMenu(QMenu &menu) const override; + virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override; private slots: void ps_testRequest1kAtcOnlineDummies() { emit this->testRequestDummyAtcOnlineStations(1000); } @@ -56,6 +56,10 @@ namespace BlackGui void ps_tuneInAtcCom1(); void ps_tuneInAtcCom2(); void ps_requestTextMessage(); + + private: + QList m_actions; + QList m_debugActions; }; } } diff --git a/src/blackgui/views/simulatedaircraftview.cpp b/src/blackgui/views/simulatedaircraftview.cpp index f0ca1f139..c021032fc 100644 --- a/src/blackgui/views/simulatedaircraftview.cpp +++ b/src/blackgui/views/simulatedaircraftview.cpp @@ -14,6 +14,7 @@ using namespace BlackMisc; using namespace BlackMisc::Simulation; using namespace BlackGui::Models; +using namespace BlackGui::Menus; namespace BlackGui { @@ -39,7 +40,7 @@ namespace BlackGui this->m_withMenuHighlight = menuHighlight; } - void CSimulatedAircraftView::customMenu(QMenu &menu) const + void CSimulatedAircraftView::customMenu(CMenuActions &menuActions) { if (BlackMisc::CBuildConfig::isDebugBuild()) { @@ -50,13 +51,12 @@ namespace BlackGui { CSimulatedAircraft aircraft(selectedObject()); Q_ASSERT(!aircraft.getCallsign().isEmpty()); - menu.addAction(CIcons::appTextMessages16(), "Show text messages", this, SLOT(ps_requestTextMessage())); - if (m_withMenuEnable) { menu.addAction(CIcons::appAircraft16(), aircraft.isEnabled() ? "Disable aircraft" : "Enabled aircraft", this, SLOT(ps_enableAircraft())); } - if (m_withMenuHighlight) { menu.addAction(CIcons::appSimulator16(), "Highlight in simulator", this, SLOT(ps_highlightInSimulator())); } - if (m_withMenuFastPosition) { menu.addAction(CIcons::globe16(), aircraft.fastPositionUpdates() ? "Normal updates" : "Fast position updates", this, SLOT(ps_fastPositionUpdates())); } - menu.addSeparator(); + menuActions.addAction(CIcons::appTextMessages16(), "Show text messages", CMenuAction::pathClientCom(), { this, &CSimulatedAircraftView::ps_requestTextMessage }); + if (m_withMenuEnable) { menuActions.addAction(CIcons::appAircraft16(), aircraft.isEnabled() ? "Disable aircraft" : "Enabled aircraft", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::ps_enableAircraft }); } + if (m_withMenuHighlight) { menuActions.addAction(CIcons::appSimulator16(), "Highlight in simulator", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::ps_highlightInSimulator }); } + if (m_withMenuFastPosition) { menuActions.addAction(CIcons::globe16(), aircraft.fastPositionUpdates() ? "Normal updates" : "Fast position updates", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::ps_fastPositionUpdates }); } } - CViewBase::customMenu(menu); + CViewBase::customMenu(menuActions); } void CSimulatedAircraftView::ps_requestTextMessage() diff --git a/src/blackgui/views/simulatedaircraftview.h b/src/blackgui/views/simulatedaircraftview.h index 594c2ee5d..ba2dad97c 100644 --- a/src/blackgui/views/simulatedaircraftview.h +++ b/src/blackgui/views/simulatedaircraftview.h @@ -51,7 +51,7 @@ namespace BlackGui protected: //! \copydoc CViewBase::customMenu - virtual void customMenu(QMenu &menu) const override; + virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override; private slots: void ps_requestTextMessage(); diff --git a/src/blackmisc/icons.cpp b/src/blackmisc/icons.cpp index 9c4214f30..0d3a27ea7 100644 --- a/src/blackmisc/icons.cpp +++ b/src/blackmisc/icons.cpp @@ -609,7 +609,7 @@ namespace BlackMisc const QPixmap &CIcons::appModels16() { - return appMappings16(); + return appAircraft16(); } const QPixmap &CIcons::appCountries16()