mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-14 08:45:36 +08:00
refs #648, change existing context menus
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<QAction *>({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<QAction *>({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()
|
||||
|
||||
@@ -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<QAction *> m_actions;
|
||||
QList<QAction *> m_debugActions;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user