mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-10 22:15:34 +08:00
refs #648, change existing context menus
This commit is contained in:
@@ -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<CDbMappingComponent *>(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<CDbMappingComponent *>(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<CDbMappingComponent *>(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<QAction *>({ 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<QAction *>({ 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
|
||||
|
||||
@@ -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<QAction *> 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<QAction *> m_menuActions;
|
||||
};
|
||||
};
|
||||
} // ns
|
||||
|
||||
@@ -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<CDbOwnModelsComponent *>(this->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())
|
||||
{
|
||||
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<QAction *>({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()
|
||||
|
||||
@@ -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<QAction *> m_loadActions; //!< load actions
|
||||
QList<QAction *> m_reloadActions; //!< reload actions
|
||||
};
|
||||
};
|
||||
} // ns
|
||||
|
||||
@@ -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<CDbOwnModelSetComponent *>(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
|
||||
|
||||
@@ -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<QAction *> m_setActions;
|
||||
QList<QAction *> m_setNewActions;
|
||||
};
|
||||
};
|
||||
} // ns
|
||||
|
||||
@@ -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<CLogComponent *>(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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user