refs #648, change existing context menus

This commit is contained in:
Klaus Basan
2016-04-29 17:46:58 +02:00
parent acc1d4fd74
commit 2da14e3b62
17 changed files with 312 additions and 249 deletions

View File

@@ -95,6 +95,7 @@ namespace BlackGui
this->ui->tw_ModelsToBeMapped->setTabIcon(TabStash, CIcons::appDbStash16()); this->ui->tw_ModelsToBeMapped->setTabIcon(TabStash, CIcons::appDbStash16());
this->ui->tw_ModelsToBeMapped->setTabIcon(TabOwnModels, CIcons::appModels16()); this->ui->tw_ModelsToBeMapped->setTabIcon(TabOwnModels, CIcons::appModels16());
this->ui->tw_ModelsToBeMapped->setTabIcon(TabOwnModelSet, CIcons::appModels16());
// custom menu // custom menu
this->setContextMenuPolicy(Qt::CustomContextMenu); this->setContextMenuPolicy(Qt::CustomContextMenu);
@@ -734,18 +735,17 @@ namespace BlackGui
this->ui->comp_StashAircraft->replaceModelsUnvalidated(models); this->ui->comp_StashAircraft->replaceModelsUnvalidated(models);
} }
void CDbMappingComponent::CMappingVPilotMenu::customMenu(QMenu &menu) const void CDbMappingComponent::CMappingVPilotMenu::customMenu(CMenuActions &menuActions)
{ {
CDbMappingComponent *mapComp = qobject_cast<CDbMappingComponent *>(this->parent()); CDbMappingComponent *mapComp = qobject_cast<CDbMappingComponent *>(this->parent());
Q_ASSERT_X(mapComp, Q_FUNC_INFO, "Cannot access mapping component"); Q_ASSERT_X(mapComp, Q_FUNC_INFO, "Cannot access mapping component");
bool canUseVPilot = mappingComponent()->withVPilot(); const bool canUseVPilot = mappingComponent()->withVPilot();
if (canUseVPilot) if (canUseVPilot)
{ {
this->addSeparator(menu); this->m_menuAction = menuActions.addAction(this->m_menuAction, CIcons::appMappings16(), "Load vPilot Rules", CMenuAction::pathVPilot(), this, { mapComp, &CDbMappingComponent::ps_loadVPilotData });
menu.addAction(CIcons::appMappings16(), "Load vPilot Rules", mapComp, &CDbMappingComponent::ps_loadVPilotData);
} }
this->nestedCustomMenu(menu); this->nestedCustomMenu(menuActions);
} }
CDbMappingComponent *CDbMappingComponent::CMappingVPilotMenu::mappingComponent() const CDbMappingComponent *CDbMappingComponent::CMappingVPilotMenu::mappingComponent() const
@@ -757,56 +757,37 @@ namespace BlackGui
BlackGui::Menus::IMenuDelegate(mappingComponent, separator) BlackGui::Menus::IMenuDelegate(mappingComponent, separator)
{} {}
void CDbMappingComponent::CModelStashToolsMenu::customMenu(QMenu &menu) const void CDbMappingComponent::CModelStashToolsMenu::customMenu(CMenuActions &menuActions)
{ {
CDbMappingComponent *mapComp = mappingComponent(); CDbMappingComponent *mapComp = mappingComponent();
Q_ASSERT_X(mapComp, Q_FUNC_INFO, "no mapping component"); Q_ASSERT_X(mapComp, Q_FUNC_INFO, "no mapping component");
const bool canConnectDb = sGui->getWebDataServices()->canConnectSwiftDb(); 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)) if (!mapComp->currentModelView()->isEmpty() && mapComp->currentModelView()->getMenu().testFlag(CViewBaseNonTemplate::MenuCanStashModels))
{ {
QMenu *stashMenu = new QMenu("Stash tools", &menu); menuActions.addMenuStash();
int dbModels = sGui->getWebDataServices()->getModelsCount();
// 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) if (dbModels > 0)
{ {
// we have keys and data by which we could delete them from view // 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()); 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"); this->m_autoStashing = menuActions.addAction(this->m_autoStashing, CIcons::appDbStash16(), "Auto stashing", CMenuAction::pathStash(), this, { mapComp, &CDbMappingComponent::ps_displayAutoStashingDialog });
stashMenu->addAction(CIcons::appDbStash16(), msgAutoStash, mapComp, &CDbMappingComponent::ps_displayAutoStashingDialog);
if (mapComp->m_autoStashDialog && mapComp->m_autoStashDialog->isCompleted()) if (mapComp->m_autoStashDialog && mapComp->m_autoStashDialog->isCompleted())
{ {
stashMenu->addAction(CIcons::appDbStash16(), "Last auto stash run", mapComp->m_autoStashDialog.data(), &CDbAutoStashingComponent::showLastResults); menuActions.addAction(CIcons::appDbStash16(), "Last auto stash run", CMenuAction::pathStash(), nullptr, { 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());
} }
} }
this->nestedCustomMenu(menu); this->nestedCustomMenu(menuActions);
}
void CDbMappingComponent::CModelStashToolsMenu::addSeparator(QMenu &menu) const
{
if (this->previousMenuItemContains("Stash", menu, Qt::CaseInsensitive)) { return; }
IMenuDelegate::addSeparator(menu);
} }
CDbMappingComponent *CDbMappingComponent::CModelStashToolsMenu::mappingComponent() const CDbMappingComponent *CDbMappingComponent::CModelStashToolsMenu::mappingComponent() const
@@ -814,16 +795,16 @@ namespace BlackGui
return qobject_cast<CDbMappingComponent *>(this->parent()); return qobject_cast<CDbMappingComponent *>(this->parent());
} }
void CDbMappingComponent::COwnModelSetMenu::customMenu(QMenu &menu) const void CDbMappingComponent::COwnModelSetMenu::customMenu(CMenuActions &menuActions)
{ {
CDbMappingComponent *mapComp = mappingComponent(); CDbMappingComponent *mapComp = mappingComponent();
Q_ASSERT_X(mapComp, Q_FUNC_INFO, "no mapping component"); Q_ASSERT_X(mapComp, Q_FUNC_INFO, "no mapping component");
if (mapComp->currentTabIndex() == CDbMappingComponent::TabOwnModels && mapComp->currentModelView()->hasSelection()) if (mapComp->currentTabIndex() == CDbMappingComponent::TabOwnModels && mapComp->currentModelView()->hasSelection())
{ {
this->addSeparator(menu); menuActions.addMenuModelSet();
menu.addAction(CIcons::appAircraft16(), "Add to own model set", mapComp, &CDbMappingComponent::ps_addToOwnModelSet); 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 CDbMappingComponent *CDbMappingComponent::COwnModelSetMenu::mappingComponent() const
@@ -831,41 +812,31 @@ namespace BlackGui
return qobject_cast<CDbMappingComponent *>(this->parent()); return qobject_cast<CDbMappingComponent *>(this->parent());
} }
void CDbMappingComponent::CApplyDbDataMenu::customMenu(QMenu &menu) const void CDbMappingComponent::CApplyDbDataMenu::customMenu(CMenuActions &menuActions)
{ {
CDbMappingComponent *mapComp = mappingComponent(); CDbMappingComponent *mapComp = mappingComponent();
Q_ASSERT_X(mapComp, Q_FUNC_INFO, "no mapping component"); Q_ASSERT_X(mapComp, Q_FUNC_INFO, "no mapping component");
if (mapComp->currentTabIndex() == CDbMappingComponent::TabStash && mapComp->currentModelView()->hasSelection()) if (mapComp->currentTabIndex() == CDbMappingComponent::TabStash && mapComp->currentModelView()->hasSelection())
{ {
this->addSeparator(menu); if (this->m_menuActions.isEmpty()) { this->m_menuActions = QList<QAction *>({ nullptr, nullptr, nullptr, nullptr }); }
// stash view and selection // stash view and selection
QMenu *subMenu = menu.addMenu(CIcons::database16(), "Apply editor DB data (to selected)"); menuActions.addMenuStashEditor();
QAction *a = nullptr;
a = subMenu->addAction(CIcons::appAircraftIcao16(), "Current aircraft ICAO", mapComp, &CDbMappingComponent::ps_applyDbData); this->m_menuActions[0] = menuActions.addAction(this->m_menuActions[0], CIcons::appAircraftIcao16(), "Current aircraft ICAO", CMenuAction::pathStashEditor(), this, { mapComp, &CDbMappingComponent::ps_applyDbData });
a->setData(CAircraftIcaoCode().getClassName()); this->m_menuActions[0]->setData(CAircraftIcaoCode().getClassName());
a = subMenu->addAction(CIcons::appDistributors16(), "Current distributor", mapComp, &CDbMappingComponent::ps_applyDbData); this->m_menuActions[1] = menuActions.addAction(this->m_menuActions[1], CIcons::appDistributors16(), "Current distributor", CMenuAction::pathStashEditor(), this, { mapComp, &CDbMappingComponent::ps_applyDbData });
a->setData(CDistributor().getClassName()); this->m_menuActions[1]->setData(CDistributor().getClassName());
a = subMenu->addAction(CIcons::appLiveries16(), "Current livery", mapComp, &CDbMappingComponent::ps_applyDbData); this->m_menuActions[2] = menuActions.addAction(this->m_menuActions[2], CIcons::appLiveries16(), "Current livery", CMenuAction::pathStashEditor(), this, { mapComp, &CDbMappingComponent::ps_applyDbData });
a->setData(CLivery().getClassName()); this->m_menuActions[2]->setData(CLivery().getClassName());
// a = subMenu->addAction(CIcons::appAirlineIcao16(), "Current airline ICAO", mapComp, &CDbMappingComponent::ps_applyDbData); this->m_menuActions[3] = menuActions.addAction(this->m_menuActions[3], CIcons::databaseTable16(), "Modify DB model data", CMenuAction::pathStashEditor(), this, { mapComp, &CDbMappingComponent::ps_applyDbData });
// a->setData(CAirlineIcaoCode().getClassName()); this->m_menuActions[3]->setData(CAircraftModel().getClassName());
menu.addAction(CIcons::databaseTable16(), "Modify DB model data", mapComp, &CDbMappingComponent::ps_applyDbData);
a->setData(CAircraftModel().getClassName());
} }
this->nestedCustomMenu(menu); this->nestedCustomMenu(menuActions);
}
void CDbMappingComponent::CApplyDbDataMenu::addSeparator(QMenu &menu) const
{
if (this->previousMenuItemContains("DB", menu)) { return; }
IMenuDelegate::addSeparator(menu);
} }
CDbMappingComponent *CDbMappingComponent::CApplyDbDataMenu::mappingComponent() const CDbMappingComponent *CDbMappingComponent::CApplyDbDataMenu::mappingComponent() const
@@ -879,23 +850,24 @@ namespace BlackGui
Q_ASSERT_X(mappingComponent, Q_FUNC_INFO, "Missing vPilot reader"); 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 CAircraftModelView *mv = mappingComponent()->ui->comp_OwnAircraftModels->view();
const CSimulatorInfo sim = mappingComponent()->ui->comp_OwnAircraftModels->getOwnModelsSimulator(); const CSimulatorInfo sim = mappingComponent()->ui->comp_OwnAircraftModels->getOwnModelsSimulator();
if (!mappingComponent()->withVPilot() || mv->isEmpty() || !sim.isSingleSimulator() || !sim.isMicrosoftOrPrepare3DSimulator()) if (!mappingComponent()->withVPilot() || mv->isEmpty() || !sim.isSingleSimulator() || !sim.isMicrosoftOrPrepare3DSimulator())
{ {
this->nestedCustomMenu(menu); this->nestedCustomMenu(menuActions);
return; return;
} }
this->addSeparator(menu);
QMenu *mm = menu.addMenu("Merge with vPilot data"); if (this->m_menuActions.isEmpty()) { this->m_menuActions = QList<QAction *>({ nullptr, nullptr }); }
mm->addAction("All", mappingComponent(), &CDbMappingComponent::ps_mergeWithVPilotModels); 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()) 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 CDbMappingComponent *CDbMappingComponent::CMergeWithVPilotMenu::mappingComponent() const

View File

@@ -269,11 +269,12 @@ namespace BlackGui
{} {}
//! \copydoc IMenuDelegate::customMenu //! \copydoc IMenuDelegate::customMenu
virtual void customMenu(QMenu &menu) const override; virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override;
private: private:
//! Mapping component //! Mapping component
CDbMappingComponent *mappingComponent() const; CDbMappingComponent *mappingComponent() const;
QAction *m_menuAction = nullptr;
}; };
//! Menu for tools: //! Menu for tools:
@@ -288,15 +289,14 @@ namespace BlackGui
CModelStashToolsMenu(CDbMappingComponent *mappingComponent, bool separator = true); CModelStashToolsMenu(CDbMappingComponent *mappingComponent, bool separator = true);
//! \copydoc IMenuDelegate::customMenu //! \copydoc IMenuDelegate::customMenu
virtual void customMenu(QMenu &menu) const override; virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override;
protected:
//! \copydoc IMenuDelegate::addSeparator
virtual void addSeparator(QMenu &menu) const override;
private: private:
//! Mapping component //! Mapping component
CDbMappingComponent *mappingComponent() const; CDbMappingComponent *mappingComponent() const;
QAction *m_autoStashing = nullptr;
QAction *m_stashFiltering = nullptr;
}; };
//! Menu for own model sets //! Menu for own model sets
@@ -309,11 +309,13 @@ namespace BlackGui
{} {}
//! \copydoc IMenuDelegate::customMenu //! \copydoc IMenuDelegate::customMenu
virtual void customMenu(QMenu &menu) const override; virtual void customMenu(Menus::CMenuActions &menuActions) override;
private: private:
//! Mapping component //! Mapping component
CDbMappingComponent *mappingComponent() const; CDbMappingComponent *mappingComponent() const;
QAction *m_menuAction = nullptr;
}; };
//! Apply DB data to selected models //! Apply DB data to selected models
@@ -326,15 +328,13 @@ namespace BlackGui
{} {}
//! \copydoc IMenuDelegate::customMenu //! \copydoc IMenuDelegate::customMenu
virtual void customMenu(QMenu &menu) const override; virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override;
protected:
//! \copydoc IMenuDelegate::addSeparator
virtual void addSeparator(QMenu &menu) const override;
private: private:
//! Mapping component //! Mapping component
CDbMappingComponent *mappingComponent() const; CDbMappingComponent *mappingComponent() const;
QList<QAction *> m_menuActions;
}; };
//! Merge with vPilot data //! Merge with vPilot data
@@ -345,10 +345,13 @@ namespace BlackGui
CMergeWithVPilotMenu(CDbMappingComponent *mappingComponent, bool separator = true); CMergeWithVPilotMenu(CDbMappingComponent *mappingComponent, bool separator = true);
//! \copydoc IMenuDelegate::customMenu //! \copydoc IMenuDelegate::customMenu
virtual void customMenu(QMenu &menu) const override; virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override;
//! Mapping component //! Mapping component
CDbMappingComponent *mappingComponent() const; CDbMappingComponent *mappingComponent() const;
private:
QList<QAction *> m_menuActions;
}; };
}; };
} // ns } // ns

View File

@@ -160,80 +160,130 @@ namespace BlackGui
this->ui->tvp_OwnAircraftModels->setSaveFileName(n); this->ui->tvp_OwnAircraftModels->setSaveFileName(n);
} }
void CDbOwnModelsComponent::CLoadModelsMenu::customMenu(QMenu &menu) const void CDbOwnModelsComponent::CLoadModelsMenu::customMenu(CMenuActions &menuActions)
{ {
CSimulatorInfo sims = CSimulatorInfo::getLocallyInstalledSimulators(); const CSimulatorInfo sims = CSimulatorInfo::getLocallyInstalledSimulators();
bool noSims = sims.isNoSimulator() || sims.isUnspecified(); const bool noSims = sims.isNoSimulator() || sims.isUnspecified();
if (!noSims) if (!noSims)
{ {
this->addSeparator(menu);
QMenu *load = menu.addMenu(CIcons::appModels16(), "Load installed models");
CDbOwnModelsComponent *ownModelsComp = qobject_cast<CDbOwnModelsComponent *>(this->parent()); CDbOwnModelsComponent *ownModelsComp = qobject_cast<CDbOwnModelsComponent *>(this->parent());
Q_ASSERT_X(ownModelsComp, Q_FUNC_INFO, "Cannot access parent"); Q_ASSERT_X(ownModelsComp, Q_FUNC_INFO, "Cannot access parent");
if (this->m_loadActions.isEmpty()) { this->m_loadActions = QList<QAction *>({nullptr, nullptr, nullptr, nullptr}); }
menuActions.addMenuSimulator();
if (sims.fsx()) if (sims.fsx())
{ {
load->addAction(CIcons::appModels16(), "FSX models", ownModelsComp, [ownModelsComp]() if (!this->m_loadActions[0])
{ {
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); ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::FSX), IAircraftModelLoader::InBackgroundWithCache);
}); });
} }
menuActions.addAction(this->m_loadActions[0], CMenuAction::pathSimulator());
}
if (sims.p3d()) if (sims.p3d())
{ {
load->addAction(CIcons::appModels16(), "P3D models", ownModelsComp, [ownModelsComp]() if (!this->m_loadActions[1])
{ {
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); ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::P3D), IAircraftModelLoader::InBackgroundWithCache);
}); });
} }
menuActions.addAction(this->m_loadActions[1], CMenuAction::pathSimulator());
}
if (sims.fs9()) if (sims.fs9())
{ {
load->addAction(CIcons::appModels16(), "FS9 models", ownModelsComp, [ownModelsComp]() if (!this->m_loadActions[2])
{ {
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); ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::FS9), IAircraftModelLoader::InBackgroundWithCache);
}); });
} }
menuActions.addAction(this->m_loadActions[2], CMenuAction::pathSimulator());
}
if (sims.xplane()) if (sims.xplane())
{ {
load->addAction(CIcons::appModels16(), "XP models", ownModelsComp, [ownModelsComp]() if (!this->m_loadActions[3])
{ {
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); ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::XPLANE), IAircraftModelLoader::InBackgroundWithCache);
}); });
} }
menuActions.addAction(this->m_loadActions[3], CMenuAction::pathSimulator());
}
// with models loaded I allow a refresh reload // with models loaded I allow a refresh reload
if (sGui->getWebDataServices() && sGui->getWebDataServices()->getModelsCount() > 0) if (sGui->getWebDataServices() && sGui->getWebDataServices()->getModelsCount() > 0)
{ {
QMenu *reloadMenu = load->addMenu("Force reload"); if (this->m_reloadActions.isEmpty()) { this->m_reloadActions = QList<QAction *>({nullptr, nullptr, nullptr, nullptr}); }
menuActions.addMenu(CIcons::refresh16(), "Force model reload", CMenuAction::pathSimulatorModelsReload());
if (sims.fsx()) if (sims.fsx())
{ {
reloadMenu->addAction(CIcons::appModels16(), "FSX models", ownModelsComp, [ownModelsComp]() if (!this->m_reloadActions[0])
{ {
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); ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::FSX), IAircraftModelLoader::InBackgroundNoCache);
}); });
} }
menuActions.addAction(this->m_reloadActions[0], CMenuAction::pathSimulatorModelsReload());
}
if (sims.p3d()) if (sims.p3d())
{ {
reloadMenu->addAction(CIcons::appModels16(), "P3D models", ownModelsComp, [ownModelsComp]() if (!this->m_reloadActions[1])
{ {
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); ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::P3D), IAircraftModelLoader::InBackgroundNoCache);
}); });
} }
menuActions.addAction(this->m_reloadActions[1], CMenuAction::pathSimulatorModelsReload());
}
if (sims.fs9()) if (sims.fs9())
{ {
reloadMenu->addAction(CIcons::appModels16(), "FS9 models", ownModelsComp, [ownModelsComp]() if (!this->m_reloadActions[2])
{ {
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); ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::FS9), IAircraftModelLoader::InBackgroundNoCache);
}); });
} }
menuActions.addAction(this->m_reloadActions[2], CMenuAction::pathSimulatorModelsReload());
}
if (sims.xplane()) if (sims.xplane())
{ {
reloadMenu->addAction(CIcons::appModels16(), "XP models", ownModelsComp, [ownModelsComp]() if (!this->m_reloadActions[3])
{ {
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); 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() void CDbOwnModelsComponent::ps_requestOwnModelsUpdate()

View File

@@ -103,7 +103,11 @@ namespace BlackGui
{} {}
//! \copydoc IMenuDelegate::customMenu //! \copydoc IMenuDelegate::customMenu
virtual void customMenu(QMenu &menu) const override; virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override;
private:
QList<QAction *> m_loadActions; //!< load actions
QList<QAction *> m_reloadActions; //!< reload actions
}; };
}; };
} // ns } // ns

View File

@@ -296,76 +296,94 @@ namespace BlackGui
} }
} }
void CDbOwnModelSetComponent::CLoadModelsMenu::customMenu(QMenu &menu) const void CDbOwnModelSetComponent::CLoadModelsMenu::customMenu(CMenuActions &menuActions)
{ {
const CSimulatorInfo sims = CSimulatorInfo::getLocallyInstalledSimulators(); const CSimulatorInfo sims = CSimulatorInfo::getLocallyInstalledSimulators();
bool noSims = sims.isNoSimulator() || sims.isUnspecified(); const bool noSims = sims.isNoSimulator() || sims.isUnspecified();
if (!noSims) if (!noSims)
{ {
this->addSeparator(menu);
QMenu *load = menu.addMenu(CIcons::appModels16(), "Model set");
CDbOwnModelSetComponent *ownModelSetComp = qobject_cast<CDbOwnModelSetComponent *>(this->parent()); CDbOwnModelSetComponent *ownModelSetComp = qobject_cast<CDbOwnModelSetComponent *>(this->parent());
Q_ASSERT_X(ownModelSetComp, Q_FUNC_INFO, "Cannot access parent"); Q_ASSERT_X(ownModelSetComp, Q_FUNC_INFO, "Cannot access parent");
if (this->m_setActions.isEmpty())
{
if (sims.fsx()) if (sims.fsx())
{ {
load->addAction(CIcons::appModels16(), "FSX models", ownModelSetComp, [ownModelSetComp]() 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)); ownModelSetComp->ps_changeSimulator(CSimulatorInfo(CSimulatorInfo::FSX));
}); });
} this->m_setActions.append(a);
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));
});
}
QMenu *emptySetMenu = load->addMenu("New empty set"); a = new QAction(CIcons::appModels16(), "New set FSX models", this);
if (sims.fsx()) connect(a, &QAction::triggered, ownModelSetComp, [ownModelSetComp](bool checked)
{
emptySetMenu->addAction(CIcons::appModels16(), "FSX models", ownModelSetComp, [ownModelSetComp]()
{ {
Q_UNUSED(checked);
ownModelSetComp->setModelSet(CAircraftModelList(), CSimulatorInfo(CSimulatorInfo::FSX)); ownModelSetComp->setModelSet(CAircraftModelList(), CSimulatorInfo(CSimulatorInfo::FSX));
}); });
this->m_setNewActions.append(a);
} }
if (sims.p3d()) 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)); ownModelSetComp->setModelSet(CAircraftModelList(), CSimulatorInfo(CSimulatorInfo::P3D));
}); });
this->m_setNewActions.append(a);
} }
if (sims.fs9()) 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)); ownModelSetComp->setModelSet(CAircraftModelList(), CSimulatorInfo(CSimulatorInfo::FS9));
}); });
this->m_setNewActions.append(a);
} }
if (sims.xplane()) if (sims.xplane())
{ {
emptySetMenu->addAction(CIcons::appModels16(), "XP models", ownModelSetComp, [ownModelSetComp]() 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)); ownModelSetComp->setModelSet(CAircraftModelList(), CSimulatorInfo(CSimulatorInfo::XPLANE));
}); });
this->m_setNewActions.append(a);
} }
} }
this->nestedCustomMenu(menu); menuActions.addMenuModelSet();
menuActions.addActions(this->m_setActions, CMenuAction::pathModelSet());
menuActions.addActions(this->m_setNewActions, CMenuAction::pathModelSetNew());
}
this->nestedCustomMenu(menuActions);
} }
} // ns } // ns
} // ns } // ns

View File

@@ -138,7 +138,11 @@ namespace BlackGui
{} {}
//! \copydoc IMenuDelegate::customMenu //! \copydoc IMenuDelegate::customMenu
virtual void customMenu(QMenu &menu) const override; virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override;
private:
QList<QAction *> m_setActions;
QList<QAction *> m_setNewActions;
}; };
}; };
} // ns } // ns

View File

@@ -14,6 +14,7 @@
using namespace BlackMisc; using namespace BlackMisc;
using namespace BlackGui; using namespace BlackGui;
using namespace BlackGui::Views; using namespace BlackGui::Views;
using namespace BlackGui::Menus;
namespace BlackGui namespace BlackGui
{ {
@@ -50,13 +51,13 @@ namespace BlackGui
void CLogComponent::displayLog(bool attention) void CLogComponent::displayLog(bool attention)
{ {
this->ui->tw_StatusPage->setCurrentIndex(0); this->ui->tw_StatusPage->setCurrentIndex(0);
if(attention) { emit requestAttention(); } if (attention) { emit requestAttention(); }
} }
void CLogComponent::displayConsole(bool attention) void CLogComponent::displayConsole(bool attention)
{ {
this->ui->tw_StatusPage->setCurrentIndex(1); this->ui->tw_StatusPage->setCurrentIndex(1);
if(attention) { emit requestAttention(); } if (attention) { emit requestAttention(); }
} }
void CLogComponent::appendStatusMessageToConsole(const CStatusMessage &statusMessage) void CLogComponent::appendStatusMessageToConsole(const CStatusMessage &statusMessage)
@@ -82,16 +83,17 @@ namespace BlackGui
this->ui->tvp_StatusMessages->insert(statusMessages); this->ui->tvp_StatusMessages->insert(statusMessages);
} }
void CLogComponent::CLogMenu::customMenu(QMenu &menu) const void CLogComponent::CLogMenu::customMenu(CMenuActions &menuActions)
{ {
CLogComponent *logComp = qobject_cast<CLogComponent *>(this->parent()); CLogComponent *logComp = qobject_cast<CLogComponent *>(this->parent());
Q_ASSERT_X(logComp, Q_FUNC_INFO, "Missing parent"); Q_ASSERT_X(logComp, Q_FUNC_INFO, "Missing parent");
bool v = logComp->ui->form_StatusMessage->isVisible(); bool v = logComp->ui->form_StatusMessage->isVisible();
QString formString(v ? "Hide log details" : "Show log details"); QString formString(v ? "Hide log details" : "Show log details");
QAction *a = menu.addAction(BlackMisc::CIcons::databaseTable16(), formString, logComp->ui->form_StatusMessage, SLOT(toggleVisibility())); this->m_action = menuActions.addAction(this->m_action, BlackMisc::CIcons::databaseTable16(), formString,
a->setCheckable(true); CMenuAction::pathLog(), { logComp->ui->form_StatusMessage, &CStatusMessageForm::toggleVisibility});
a->setChecked(v); this->m_action->setCheckable(true);
this->m_action->setChecked(v);
} }
} }
} // namespace } // namespace

View File

@@ -86,7 +86,11 @@ namespace BlackGui
CLogMenu(CLogComponent *parent) : IMenuDelegate(parent) {} CLogMenu(CLogComponent *parent) : IMenuDelegate(parent) {}
//! \copydoc IMenuDelegate::customMenu //! \copydoc IMenuDelegate::customMenu
virtual void customMenu(QMenu &menu) const override; virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override;
private:
QAction *m_action = nullptr;
}; };
}; };
} // ns } // ns

View File

@@ -49,7 +49,7 @@ namespace BlackGui
IAircraftModelViewMenu(modelView, separator), m_messageFrame(messageFrame) IAircraftModelViewMenu(modelView, separator), m_messageFrame(messageFrame)
{ } { }
void CShowSimulatorFileMenu::customMenu(QMenu &menu) const void CShowSimulatorFileMenu::customMenu(CMenuActions &menuActions)
{ {
CAircraftModelView *mv = modelView(); CAircraftModelView *mv = modelView();
Q_ASSERT_X(mv, Q_FUNC_INFO, "no view"); Q_ASSERT_X(mv, Q_FUNC_INFO, "no view");
@@ -59,23 +59,22 @@ namespace BlackGui
const CAircraftModel model(mv->selectedObject()); const CAircraftModel model(mv->selectedObject());
if (model.hasFileName() || (!model.getIconPath().isEmpty() && this->m_messageFrame)) if (model.hasFileName() || (!model.getIconPath().isEmpty() && this->m_messageFrame))
{ {
this->addSeparator(menu); menuActions.addMenuSimulator();
if (this->m_messageFrame) if (this->m_messageFrame)
{ {
const CAircraftModel model(mv->selectedObject()); const CAircraftModel model(mv->selectedObject());
if (!model.getIconPath().isEmpty()) if (!model.getIconPath().isEmpty())
{ {
this->addSeparator(menu); this->m_iconAction = menuActions.addAction(this->m_iconAction, CIcons::appAircraft16(), "Display icon", CMenuAction::pathSimulator(), { this, &CShowSimulatorFileMenu::ps_displayIcon });
menu.addAction(CIcons::appAircraft16(), "Display icon", 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(); const CAircraftModelView *mv = modelView();
if (!mv->hasSingleSelectedRow()) { return; } 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(); const CAircraftModelView *mv = modelView();
if (mv->isEmpty()) { this->nestedCustomMenu(menu); return; } if (mv->isEmpty()) { this->nestedCustomMenu(menuActions); return; }
if (!sGui->hasWebDataServices()) { this->nestedCustomMenu(menu); return; } if (!sGui->hasWebDataServices()) { this->nestedCustomMenu(menuActions); return; }
this->addSeparator(menu); menuActions.addMenuDatabase();
QMenu *mm = menu.addMenu(CIcons::databaseEdit16(), "Merge with DB data"); menuActions.addMenu(CIcons::databaseEdit16(), "Merge with DB data", CMenuAction::pathViewDatabaseMerge());
mm->addAction("All", this, &CMergeWithDbDataMenu::ps_mergeData);
this->m_mergeAll = menuActions.addAction(this->m_mergeAll, "All", CMenuAction::pathViewDatabaseMerge(), { this, &CMergeWithDbDataMenu::ps_mergeData });
if (mv->hasSelection()) 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() 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 IModelsSetable *CMergeWithDbDataMenu::modelsTargetSetable() const
{ {
return qobject_cast<IModelsSetable *>(this->m_modelsTarget); return qobject_cast<IModelsSetable *>(this->m_modelsTarget);

View File

@@ -52,14 +52,16 @@ namespace BlackGui
CShowSimulatorFileMenu(BlackGui::Views::CAircraftModelView *modelView, BlackGui::COverlayMessagesFrame *messageFrame, bool separator = true); CShowSimulatorFileMenu(BlackGui::Views::CAircraftModelView *modelView, BlackGui::COverlayMessagesFrame *messageFrame, bool separator = true);
//! \copydoc IMenuDelegate::customMenu //! \copydoc IMenuDelegate::customMenu
virtual void customMenu(QMenu &menu) const override; virtual void customMenu(CMenuActions &menuActions) override;
private slots: private slots:
void ps_showSimulatorFile() const; //!< simulator file void ps_showSimulatorFile(); //!< simulator file
void ps_displayIcon(); //!< aircraft icon if any void ps_displayIcon(); //!< aircraft icon if any
private: private:
BlackGui::COverlayMessagesFrame *m_messageFrame = nullptr; BlackGui::COverlayMessagesFrame *m_messageFrame = nullptr;
QAction *m_fileAction = nullptr;
QAction *m_iconAction = nullptr;
}; };
//! Merge with DB data //! Merge with DB data
@@ -75,20 +77,18 @@ namespace BlackGui
CMergeWithDbDataMenu(BlackGui::Views::CAircraftModelView *modelView, QObject *modelsTarget, bool separator = true); CMergeWithDbDataMenu(BlackGui::Views::CAircraftModelView *modelView, QObject *modelsTarget, bool separator = true);
//! \copydoc IMenuDelegate::customMenu //! \copydoc IMenuDelegate::customMenu
virtual void customMenu(QMenu &menu) const override; virtual void customMenu(CMenuActions &menuActions) override;
private slots: private slots:
void ps_mergeData(); void ps_mergeData();
void ps_mergeSelectedData(); void ps_mergeSelectedData();
protected:
//! \copydoc IMenuDelegate::addSeparator
virtual void addSeparator(QMenu &menu) const override;
private: private:
BlackMisc::Simulation::IModelsSetable *modelsTargetSetable() const; BlackMisc::Simulation::IModelsSetable *modelsTargetSetable() const;
BlackMisc::Simulation::IModelsUpdatable *modelsTargetUpdatable() 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
} // ns } // ns

View File

@@ -27,6 +27,7 @@ using namespace BlackMisc::Simulation;
using namespace BlackMisc::Aviation; using namespace BlackMisc::Aviation;
using namespace BlackGui::Models; using namespace BlackGui::Models;
using namespace BlackGui::Filters; using namespace BlackGui::Filters;
using namespace BlackGui::Menus;
namespace BlackGui namespace BlackGui
{ {
@@ -266,33 +267,39 @@ namespace BlackGui
} // valid mime? } // 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)) if (this->m_menus.testFlag(MenuCanStashModels))
{ {
stashMenu->addAction(CIcons::appDbStash16(), "Stash", this, &CAircraftModelView::ps_requestStash); if (!this->m_menuFlagActions.contains(MenuCanStashModels))
QAction *a = stashMenu->addAction(CIcons::appDbStash16(), "Stashing clears selection (on/off)", this, &CAircraftModelView::ps_stashingClearsSelection); {
a->setCheckable(true); 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); a->setChecked(m_stashingClearsSelection);
used = true;
} }
if (this->m_menus.testFlag(MenuHighlightStashed)) if (this->m_menus.testFlag(MenuHighlightStashed))
{ {
// this function requires that someone provides the model strings to be highlighted // 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); if (!this->m_menuFlagActions.contains(MenuHighlightStashed))
a->setCheckable(true); {
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()); a->setChecked(this->derivedModel()->highlightModelStrings());
used = true;
} }
if (stashMenu->isEmpty()) if (used) { menuActions.addMenuStash();}
{ COrderableViewWithDbObjects::customMenu(menuActions);
stashMenu->deleteLater();
}
else
{
menu.addMenu(stashMenu);
stashMenu->setIcon(CIcons::appDbStash16());
}
COrderableViewWithDbObjects::customMenu(menu);
} }
CStatusMessage CAircraftModelView::modifyLoadedJsonData(CAircraftModelList &models) const CStatusMessage CAircraftModelView::modifyLoadedJsonData(CAircraftModelList &models) const

View File

@@ -110,7 +110,7 @@ namespace BlackGui
//! \name View base class overrides //! \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 modifyLoadedJsonData(BlackMisc::Simulation::CAircraftModelList &models) const override;
virtual BlackMisc::CStatusMessage validateLoadedJsonData(const 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; virtual void jsonLoadedAndModelUpdated(const BlackMisc::Simulation::CAircraftModelList &models) override;

View File

@@ -16,6 +16,8 @@
using namespace BlackMisc; using namespace BlackMisc;
using namespace BlackMisc::Aviation; using namespace BlackMisc::Aviation;
using namespace BlackGui::Models; using namespace BlackGui::Models;
using namespace BlackGui::Menus;
namespace BlackGui namespace BlackGui
{ {
@@ -40,23 +42,24 @@ namespace BlackGui
this->resizeToContents(); this->resizeToContents();
} }
void CAtcStationView::customMenu(QMenu &menu) const void CAtcStationView::customMenu(CMenuActions &menuActions)
{ {
if (BlackMisc::CBuildConfig::isDebugBuild()) if (BlackMisc::CBuildConfig::isDebugBuild())
{ {
menu.addAction(CIcons::tableSheet16(), "Test: 1k ATC online stations", this, SLOT(ps_testRequest1kAtcOnlineDummies())); if (this->m_debugActions.isEmpty()) { this->m_actions = QList<QAction *>({nullptr, nullptr}); }
menu.addAction(CIcons::tableSheet16(), "Test: 3k ATC online stations", this, SLOT(ps_testRequest3kAtcOnlineDummies())); this->m_actions[0] = menuActions.addAction(this->m_actions[0], CIcons::tableSheet16(), "Test: 1k ATC online stations", CMenuAction::pathClientCom(), { this, &CAtcStationView::ps_testRequest1kAtcOnlineDummies });
menu.addSeparator(); 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()) if (this->hasSelection())
{ {
menu.addAction(CIcons::appCockpit16(), "Tune in COM1", this, SLOT(ps_tuneInAtcCom1())); if (this->m_debugActions.isEmpty()) { this->m_debugActions = QList<QAction *>({nullptr, nullptr, nullptr}); }
menu.addAction(CIcons::appCockpit16(), "Tune in COM2", this, SLOT(ps_tuneInAtcCom2()));
menu.addAction(CIcons::appTextMessages16(), "Show text messages", this, SLOT(ps_requestTextMessage())); this->m_debugActions[0] = menuActions.addAction(this->m_debugActions[0], CIcons::appCockpit16(), "Tune in COM1", CMenuAction::pathClientCom(), { this, &CAtcStationView::ps_tuneInAtcCom1 });
menu.addSeparator(); 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() void CAtcStationView::ps_tuneInAtcCom1()

View File

@@ -48,7 +48,7 @@ namespace BlackGui
protected: protected:
//! \copydoc CViewBase::customMenu //! \copydoc CViewBase::customMenu
virtual void customMenu(QMenu &menu) const override; virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override;
private slots: private slots:
void ps_testRequest1kAtcOnlineDummies() { emit this->testRequestDummyAtcOnlineStations(1000); } void ps_testRequest1kAtcOnlineDummies() { emit this->testRequestDummyAtcOnlineStations(1000); }
@@ -56,6 +56,10 @@ namespace BlackGui
void ps_tuneInAtcCom1(); void ps_tuneInAtcCom1();
void ps_tuneInAtcCom2(); void ps_tuneInAtcCom2();
void ps_requestTextMessage(); void ps_requestTextMessage();
private:
QList<QAction *> m_actions;
QList<QAction *> m_debugActions;
}; };
} }
} }

View File

@@ -14,6 +14,7 @@
using namespace BlackMisc; using namespace BlackMisc;
using namespace BlackMisc::Simulation; using namespace BlackMisc::Simulation;
using namespace BlackGui::Models; using namespace BlackGui::Models;
using namespace BlackGui::Menus;
namespace BlackGui namespace BlackGui
{ {
@@ -39,7 +40,7 @@ namespace BlackGui
this->m_withMenuHighlight = menuHighlight; this->m_withMenuHighlight = menuHighlight;
} }
void CSimulatedAircraftView::customMenu(QMenu &menu) const void CSimulatedAircraftView::customMenu(CMenuActions &menuActions)
{ {
if (BlackMisc::CBuildConfig::isDebugBuild()) if (BlackMisc::CBuildConfig::isDebugBuild())
{ {
@@ -50,13 +51,12 @@ namespace BlackGui
{ {
CSimulatedAircraft aircraft(selectedObject()); CSimulatedAircraft aircraft(selectedObject());
Q_ASSERT(!aircraft.getCallsign().isEmpty()); Q_ASSERT(!aircraft.getCallsign().isEmpty());
menu.addAction(CIcons::appTextMessages16(), "Show text messages", this, SLOT(ps_requestTextMessage())); menuActions.addAction(CIcons::appTextMessages16(), "Show text messages", CMenuAction::pathClientCom(), { this, &CSimulatedAircraftView::ps_requestTextMessage });
if (m_withMenuEnable) { menu.addAction(CIcons::appAircraft16(), aircraft.isEnabled() ? "Disable aircraft" : "Enabled aircraft", this, SLOT(ps_enableAircraft())); } if (m_withMenuEnable) { menuActions.addAction(CIcons::appAircraft16(), aircraft.isEnabled() ? "Disable aircraft" : "Enabled aircraft", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::ps_enableAircraft }); }
if (m_withMenuHighlight) { menu.addAction(CIcons::appSimulator16(), "Highlight in simulator", this, SLOT(ps_highlightInSimulator())); } if (m_withMenuHighlight) { menuActions.addAction(CIcons::appSimulator16(), "Highlight in simulator", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::ps_highlightInSimulator }); }
if (m_withMenuFastPosition) { menu.addAction(CIcons::globe16(), aircraft.fastPositionUpdates() ? "Normal updates" : "Fast position updates", this, SLOT(ps_fastPositionUpdates())); } if (m_withMenuFastPosition) { menuActions.addAction(CIcons::globe16(), aircraft.fastPositionUpdates() ? "Normal updates" : "Fast position updates", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::ps_fastPositionUpdates }); }
menu.addSeparator();
} }
CViewBase::customMenu(menu); CViewBase::customMenu(menuActions);
} }
void CSimulatedAircraftView::ps_requestTextMessage() void CSimulatedAircraftView::ps_requestTextMessage()

View File

@@ -51,7 +51,7 @@ namespace BlackGui
protected: protected:
//! \copydoc CViewBase::customMenu //! \copydoc CViewBase::customMenu
virtual void customMenu(QMenu &menu) const override; virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override;
private slots: private slots:
void ps_requestTextMessage(); void ps_requestTextMessage();

View File

@@ -609,7 +609,7 @@ namespace BlackMisc
const QPixmap &CIcons::appModels16() const QPixmap &CIcons::appModels16()
{ {
return appMappings16(); return appAircraft16();
} }
const QPixmap &CIcons::appCountries16() const QPixmap &CIcons::appCountries16()