mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-01 06:35:41 +08:00
UI, grouped ATC and model context menus
This commit is contained in:
@@ -22,7 +22,6 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackGui;
|
|
||||||
|
|
||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
{
|
{
|
||||||
@@ -96,6 +95,24 @@ namespace BlackGui
|
|||||||
return subdir;
|
return subdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CMenuAction &CMenuAction::subMenuCom()
|
||||||
|
{
|
||||||
|
static const CMenuAction subdir(CIcons::appAtc16(), "COM", CMenuAction::pathClientCom());
|
||||||
|
return subdir;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CMenuAction &CMenuAction::subMenuDisplayModels()
|
||||||
|
{
|
||||||
|
static const CMenuAction subdir(CIcons::appAircraft16(), "Display models", CMenuAction::pathClientSimulationDisplay());
|
||||||
|
return subdir;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CMenuAction &CMenuAction::subMenuDataTransfer()
|
||||||
|
{
|
||||||
|
static const CMenuAction subdir(CIcons::appAircraft16(), "Data transfer", CMenuAction::pathClientSimulationTransfer());
|
||||||
|
return subdir;
|
||||||
|
}
|
||||||
|
|
||||||
const CMenuAction &CMenuAction::subMenuSimulator()
|
const CMenuAction &CMenuAction::subMenuSimulator()
|
||||||
{
|
{
|
||||||
static const CMenuAction subdir(CIcons::appSimulator16(), "Simulator", CMenuAction::pathSimulator());
|
static const CMenuAction subdir(CIcons::appSimulator16(), "Simulator", CMenuAction::pathSimulator());
|
||||||
@@ -252,25 +269,25 @@ namespace BlackGui
|
|||||||
return menuActions;
|
return menuActions;
|
||||||
}
|
}
|
||||||
|
|
||||||
CMenuAction CMenuActions::addAction(QAction *action, const QString &text, const QString &path, const BlackMisc::CSlot<void ()> &slot, const QKeySequence &shortcut)
|
CMenuAction CMenuActions::addAction(QAction *action, const QString &text, const QString &path, const CSlot<void ()> &slot, const QKeySequence &shortcut)
|
||||||
{
|
{
|
||||||
if (action) { return this->addAction(action, path); }
|
if (action) { return this->addAction(action, path); }
|
||||||
return this->addAction(text, path, slot, shortcut);
|
return this->addAction(text, path, slot, shortcut);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMenuAction CMenuActions::addAction(QAction *action, const QString &text, const QString &path, QObject *actionOwner, const BlackMisc::CSlot<void ()> &slot, const QKeySequence &shortcut)
|
CMenuAction CMenuActions::addAction(QAction *action, const QString &text, const QString &path, QObject *actionOwner, const CSlot<void ()> &slot, const QKeySequence &shortcut)
|
||||||
{
|
{
|
||||||
if (action) { return this->addAction(action, path); }
|
if (action) { return this->addAction(action, path); }
|
||||||
return this->addAction(text, path, actionOwner, slot, shortcut);
|
return this->addAction(text, path, actionOwner, slot, shortcut);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMenuAction CMenuActions::addAction(QAction *action, const QIcon &icon, const QString &text, const QString &path, const BlackMisc::CSlot<void ()> &slot, const QKeySequence &shortcut)
|
CMenuAction CMenuActions::addAction(QAction *action, const QIcon &icon, const QString &text, const QString &path, const CSlot<void ()> &slot, const QKeySequence &shortcut)
|
||||||
{
|
{
|
||||||
if (action) { return this->addAction(action, path); }
|
if (action) { return this->addAction(action, path); }
|
||||||
return this->addAction(icon, text, path, slot, shortcut);
|
return this->addAction(icon, text, path, slot, shortcut);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMenuAction CMenuActions::addAction(QAction *action, const QIcon &icon, const QString &text, const QString &path, QObject *actionOwner, const BlackMisc::CSlot<void ()> &slot, const QKeySequence &shortcut)
|
CMenuAction CMenuActions::addAction(QAction *action, const QIcon &icon, const QString &text, const QString &path, QObject *actionOwner, const CSlot<void ()> &slot, const QKeySequence &shortcut)
|
||||||
{
|
{
|
||||||
if (action) { return this->addAction(action, path); }
|
if (action) { return this->addAction(action, path); }
|
||||||
Q_ASSERT_X(actionOwner, Q_FUNC_INFO, "Need action owner"); // in this case nullptr as actionOwner is not allowed
|
Q_ASSERT_X(actionOwner, Q_FUNC_INFO, "Need action owner"); // in this case nullptr as actionOwner is not allowed
|
||||||
@@ -290,7 +307,7 @@ namespace BlackGui
|
|||||||
return this->addAction(ma);
|
return this->addAction(ma);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMenuAction CMenuActions::addAction(const QIcon &actionIcon, const QString &text, const QString &path, QObject *actionOwner, const BlackMisc::CSlot<void ()> &slot, const QKeySequence &shortcut)
|
CMenuAction CMenuActions::addAction(const QIcon &actionIcon, const QString &text, const QString &path, QObject *actionOwner, const CSlot<void ()> &slot, const QKeySequence &shortcut)
|
||||||
{
|
{
|
||||||
CMenuAction action = this->addAction(actionIcon, text, path, actionOwner, shortcut);
|
CMenuAction action = this->addAction(actionIcon, text, path, actionOwner, shortcut);
|
||||||
QAction::connect(action.getQAction(), &QAction::triggered, [slot](bool checked)
|
QAction::connect(action.getQAction(), &QAction::triggered, [slot](bool checked)
|
||||||
@@ -306,17 +323,17 @@ namespace BlackGui
|
|||||||
return this->addAction(actionIcon, text, path, nullptr);
|
return this->addAction(actionIcon, text, path, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMenuAction CMenuActions::addAction(const QIcon &actionIcon, const QString &text, const QString &path, const BlackMisc::CSlot<void ()> &slot, const QKeySequence &shortcut)
|
CMenuAction CMenuActions::addAction(const QIcon &actionIcon, const QString &text, const QString &path, const CSlot<void ()> &slot, const QKeySequence &shortcut)
|
||||||
{
|
{
|
||||||
return this->addAction(actionIcon, text, path, slot.object(), slot, shortcut);
|
return this->addAction(actionIcon, text, path, slot.object(), slot, shortcut);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMenuAction CMenuActions::addAction(const QString &text, const QString &path, const BlackMisc::CSlot<void ()> &slot, const QKeySequence &shortcut)
|
CMenuAction CMenuActions::addAction(const QString &text, const QString &path, const CSlot<void ()> &slot, const QKeySequence &shortcut)
|
||||||
{
|
{
|
||||||
return this->addAction(QIcon(), text, path, slot.object(), slot, shortcut);
|
return this->addAction(QIcon(), text, path, slot.object(), slot, shortcut);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMenuAction CMenuActions::addAction(const QString &text, const QString &path, QObject *actionOwner, const BlackMisc::CSlot<void ()> &slot, const QKeySequence &shortcut)
|
CMenuAction CMenuActions::addAction(const QString &text, const QString &path, QObject *actionOwner, const CSlot<void ()> &slot, const QKeySequence &shortcut)
|
||||||
{
|
{
|
||||||
return this->addAction(QIcon(), text, path, actionOwner, slot, shortcut);
|
return this->addAction(QIcon(), text, path, actionOwner, slot, shortcut);
|
||||||
}
|
}
|
||||||
@@ -450,30 +467,38 @@ namespace BlackGui
|
|||||||
|
|
||||||
CMenuAction CMenuActions::addMenuDatabase()
|
CMenuAction CMenuActions::addMenuDatabase()
|
||||||
{
|
{
|
||||||
if (this->containsMenu(CMenuAction::pathViewDatabase())) { CMenuAction(); }
|
if (this->containsMenu(CMenuAction::pathViewDatabase())) { return CMenuAction(); }
|
||||||
return this->addMenu(CMenuAction::subMenuDatabase());
|
return this->addMenu(CMenuAction::subMenuDatabase());
|
||||||
}
|
}
|
||||||
|
|
||||||
CMenuAction CMenuActions::addMenuConsolidateModels()
|
CMenuAction CMenuActions::addMenuConsolidateModels()
|
||||||
{
|
{
|
||||||
if (this->containsMenu(CMenuAction::pathModelConsolidate())) { CMenuAction(); }
|
if (this->containsMenu(CMenuAction::pathModelConsolidate())) { return CMenuAction(); }
|
||||||
return this->addMenu(CMenuAction::subMenuConsolidateModels());
|
return this->addMenu(CMenuAction::subMenuConsolidateModels());
|
||||||
}
|
}
|
||||||
|
|
||||||
CMenuAction CMenuActions::addMenuModelSet()
|
CMenuAction CMenuActions::addMenuModelSet()
|
||||||
{
|
{
|
||||||
if (this->containsMenu(CMenuAction::pathModelSet())) { CMenuAction(); }
|
if (this->containsMenu(CMenuAction::pathModelSet())) { return CMenuAction(); }
|
||||||
return this->addMenu(CIcons::appModels16(), "Model set", CMenuAction::pathModelSet());
|
return this->addMenu(CIcons::appModels16(), "Model set", CMenuAction::pathModelSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
const CMenuActions &CMenuActions::predefinedSubmenus()
|
CMenuAction CMenuActions::addMenuCom()
|
||||||
{
|
{
|
||||||
static const CMenuActions pd(
|
if (this->containsMenu(CMenuAction::subMenuCom().getPath())) { return CMenuAction(); }
|
||||||
|
return this->addAction(CMenuAction::subMenuCom());
|
||||||
|
}
|
||||||
|
|
||||||
|
CMenuAction CMenuActions::addMenuDisplayModels()
|
||||||
{
|
{
|
||||||
CMenuAction::subMenuDatabase(),
|
if (this->containsMenu(CMenuAction::subMenuDisplayModels().getPath())) { return CMenuAction(); }
|
||||||
CMenuAction::subMenuSimulator()
|
return this->addAction(CMenuAction::subMenuDisplayModels());
|
||||||
});
|
}
|
||||||
return pd;
|
|
||||||
|
CMenuAction CMenuActions::addMenuDataTransfer()
|
||||||
|
{
|
||||||
|
if (this->containsMenu(CMenuAction::subMenuDataTransfer().getPath())) { return CMenuAction(); }
|
||||||
|
return this->addAction(CMenuAction::subMenuDataTransfer());
|
||||||
}
|
}
|
||||||
|
|
||||||
QMenu *CMenuActions::currentMenuForAction(QMenu &menu, const CMenuAction &menuAction, const QList<CMenuAction> &menus, QMap<QString, QMenu *> &subMenus, const QString &key, int pathDepth)
|
QMenu *CMenuActions::currentMenuForAction(QMenu &menu, const CMenuAction &menuAction, const QList<CMenuAction> &menus, QMap<QString, QMenu *> &subMenus, const QString &key, int pathDepth)
|
||||||
|
|||||||
@@ -158,10 +158,16 @@ namespace BlackGui
|
|||||||
// ---- client ----
|
// ---- client ----
|
||||||
|
|
||||||
//! Client COM related
|
//! Client COM related
|
||||||
static const QString &pathClientCom() { static const QString p("Client.ATC"); return p; }
|
static const QString &pathClientCom() { static const QString p("Client.ATC/COM"); return p; }
|
||||||
|
|
||||||
//! Client simulation related
|
//! Client simulation related
|
||||||
static const QString &pathClientSimulation() { static const QString p("Client.Simulation"); return p; }
|
static const QString &pathClientSimulation() { static const QString p("ClientSimulation"); return p; }
|
||||||
|
|
||||||
|
//! Client simulation/display related
|
||||||
|
static const QString &pathClientSimulationDisplay() { static const QString p("ClientSimulation.Display/Display"); return p; }
|
||||||
|
|
||||||
|
//! Client simulation/display related
|
||||||
|
static const QString &pathClientSimulationTransfer() { static const QString p("ClientSimulation.Transfer/Transfer"); return p; }
|
||||||
|
|
||||||
// ---- standard view paths --------
|
// ---- standard view paths --------
|
||||||
|
|
||||||
@@ -206,6 +212,9 @@ namespace BlackGui
|
|||||||
static const CMenuAction &subMenuDatabase();
|
static const CMenuAction &subMenuDatabase();
|
||||||
static const CMenuAction &subMenuSimulator();
|
static const CMenuAction &subMenuSimulator();
|
||||||
static const CMenuAction &subMenuConsolidateModels();
|
static const CMenuAction &subMenuConsolidateModels();
|
||||||
|
static const CMenuAction &subMenuCom();
|
||||||
|
static const CMenuAction &subMenuDisplayModels();
|
||||||
|
static const CMenuAction &subMenuDataTransfer();
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -349,10 +358,16 @@ namespace BlackGui
|
|||||||
//! Add ModelConverterX menu (optional)
|
//! Add ModelConverterX menu (optional)
|
||||||
CMenuAction addMenuModelConverterX();
|
CMenuAction addMenuModelConverterX();
|
||||||
|
|
||||||
//! @}
|
//! Add COM model menu
|
||||||
|
CMenuAction addMenuCom();
|
||||||
|
|
||||||
//! Predfefined sub menus
|
//! Add display model menu
|
||||||
static const CMenuActions &predefinedSubmenus();
|
CMenuAction addMenuDisplayModels();
|
||||||
|
|
||||||
|
//! Add data transfer menu
|
||||||
|
CMenuAction addMenuDataTransfer();
|
||||||
|
|
||||||
|
//! @}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMultiMap<QString, CMenuAction> m_actions; //!< actions sorted by path
|
QMultiMap<QString, CMenuAction> m_actions; //!< actions sorted by path
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include <QFlags>
|
#include <QFlags>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
using namespace BlackConfig;
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackMisc::Aviation;
|
using namespace BlackMisc::Aviation;
|
||||||
using namespace BlackGui::Models;
|
using namespace BlackGui::Models;
|
||||||
@@ -53,7 +54,8 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CAtcStationView::customMenu(CMenuActions &menuActions)
|
void CAtcStationView::customMenu(CMenuActions &menuActions)
|
||||||
{
|
{
|
||||||
if (BlackConfig::CBuildConfig::isDebugBuild())
|
menuActions.addMenuCom();
|
||||||
|
if (CBuildConfig::isDebugBuild())
|
||||||
{
|
{
|
||||||
if (m_debugActions.isEmpty()) { m_actions = QList<QAction *>({nullptr, nullptr}); }
|
if (m_debugActions.isEmpty()) { m_actions = QList<QAction *>({nullptr, nullptr}); }
|
||||||
m_actions[0] = menuActions.addAction(m_actions[0], CIcons::tableSheet16(), "Test: 1k ATC online stations", CMenuAction::pathClientCom(), { this, &CAtcStationView::emitTestRequest1kAtcOnlineDummies });
|
m_actions[0] = menuActions.addAction(m_actions[0], CIcons::tableSheet16(), "Test: 1k ATC online stations", CMenuAction::pathClientCom(), { this, &CAtcStationView::emitTestRequest1kAtcOnlineDummies });
|
||||||
|
|||||||
@@ -55,11 +55,14 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CSimulatedAircraftView::customMenu(CMenuActions &menuActions)
|
void CSimulatedAircraftView::customMenu(CMenuActions &menuActions)
|
||||||
{
|
{
|
||||||
if (m_withMenuEnableAircraft)
|
menuActions.addMenuDisplayModels();
|
||||||
|
menuActions.addMenuDataTransfer();
|
||||||
|
|
||||||
|
if (m_withMenuEnableAircraft && !this->isEmpty())
|
||||||
{
|
{
|
||||||
menuActions.addAction(CIcons::appAircraft16(), "Enable all aircraft", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::enableAllDisabledAircraft });
|
menuActions.addAction(CIcons::appAircraft16(), "Enable all aircraft", CMenuAction::pathClientSimulationDisplay(), { this, &CSimulatedAircraftView::enableAllDisabledAircraft });
|
||||||
menuActions.addAction(CIcons::appAircraft16(), "Disable all aircraft", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::disableAllEnabledAircraft });
|
menuActions.addAction(CIcons::appAircraft16(), "Disable all aircraft", CMenuAction::pathClientSimulationDisplay(), { this, &CSimulatedAircraftView::disableAllEnabledAircraft });
|
||||||
menuActions.addAction(CIcons::appAircraft16(), "Re-enable unrendered aircraft", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::reEnableAllUnrenderedAircraft });
|
menuActions.addAction(CIcons::appAircraft16(), "Re-enable unrendered aircraft", CMenuAction::pathClientSimulationDisplay(), { this, &CSimulatedAircraftView::reEnableAllUnrenderedAircraft });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->hasSelection())
|
if (this->hasSelection())
|
||||||
@@ -69,28 +72,30 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
CSimulatedAircraft aircraft(this->selectedObject());
|
CSimulatedAircraft aircraft(this->selectedObject());
|
||||||
Q_ASSERT(!aircraft.getCallsign().isEmpty());
|
Q_ASSERT(!aircraft.getCallsign().isEmpty());
|
||||||
|
menuActions.addMenuCom();
|
||||||
menuActions.addAction(CIcons::appTextMessages16(), "Show text messages", CMenuAction::pathClientCom(), { this, &CSimulatedAircraftView::requestTextMessage });
|
menuActions.addAction(CIcons::appTextMessages16(), "Show text messages", CMenuAction::pathClientCom(), { this, &CSimulatedAircraftView::requestTextMessage });
|
||||||
|
|
||||||
if (m_withMenuEnableAircraft)
|
if (m_withMenuEnableAircraft)
|
||||||
{
|
{
|
||||||
menuActions.addAction(CIcons::appAircraft16(), aircraft.isEnabled() ? "Disable aircraft" : "Enabled aircraft", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::toggleEnabledAircraft });
|
menuActions.addAction(CIcons::appAircraft16(), aircraft.isEnabled() ? "Disable aircraft" : "Enabled aircraft", CMenuAction::pathClientSimulationDisplay(), { this, &CSimulatedAircraftView::toggleEnabledAircraft });
|
||||||
}
|
}
|
||||||
if (m_withMenuHighlightAndFollow)
|
if (m_withMenuHighlightAndFollow)
|
||||||
{
|
{
|
||||||
menuActions.addAction(CIcons::appAircraft16(), "Follow in simulator", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::requestFollowInSimulator });
|
menuActions.addAction(CIcons::appAircraft16(), "Follow in simulator", CMenuAction::pathClientSimulationDisplay(), { this, &CSimulatedAircraftView::requestFollowInSimulator });
|
||||||
menuActions.addAction(CIcons::appSimulator16(), "Highlight in simulator", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::requestHighlightInSimulator });
|
menuActions.addAction(CIcons::appSimulator16(), "Highlight in simulator", CMenuAction::pathClientSimulationDisplay(), { this, &CSimulatedAircraftView::requestHighlightInSimulator });
|
||||||
}
|
}
|
||||||
if (m_withMenuEnableGndFlag)
|
if (m_withMenuEnableGndFlag)
|
||||||
{
|
{
|
||||||
menuActions.addAction(CIcons::geoPosition16(), aircraft.isSupportingGndFlag() ? "Disable gnd.flag" : "Enabled gnd.flag", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::toggleSupportingGndFlag });
|
menuActions.addAction(CIcons::geoPosition16(), aircraft.isSupportingGndFlag() ? "Disable gnd.flag" : "Enabled gnd.flag", CMenuAction::pathClientSimulationTransfer(), { this, &CSimulatedAircraftView::toggleSupportingGndFlag });
|
||||||
}
|
}
|
||||||
if (m_withMenuFastPosition)
|
if (m_withMenuFastPosition)
|
||||||
{
|
{
|
||||||
menuActions.addAction(CIcons::globe16(), aircraft.fastPositionUpdates() ? "Normal updates" : "Fast position updates", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::toggleFastPositionUpdates });
|
menuActions.addAction(CIcons::globe16(), aircraft.fastPositionUpdates() ? "Normal updates" : "Fast position updates", CMenuAction::pathClientSimulationTransfer(), { this, &CSimulatedAircraftView::toggleFastPositionUpdates });
|
||||||
}
|
}
|
||||||
const bool any = m_withMenuEnableAircraft || m_withMenuFastPosition || m_withMenuHighlightAndFollow || m_withMenuEnableGndFlag;
|
const bool any = m_withMenuEnableAircraft || m_withMenuFastPosition || m_withMenuHighlightAndFollow || m_withMenuEnableGndFlag;
|
||||||
if (any && (sApp && sApp->isDeveloperFlagSet()))
|
if (any && (sApp && sApp->isDeveloperFlagSet()))
|
||||||
{
|
{
|
||||||
menuActions.addAction(CIcons::appSimulator16(), "Show position log.", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::showPositionLogInSimulator });
|
menuActions.addAction(CIcons::appSimulator16(), "Show position log.", CMenuAction::pathClientSimulationDisplay(), { this, &CSimulatedAircraftView::showPositionLogInSimulator });
|
||||||
}
|
}
|
||||||
} // contexts
|
} // contexts
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user