feat: Allow to tune STBY frequency from context menu

Fixes #274
This commit is contained in:
Lars Toenning
2025-11-16 23:39:49 +01:00
parent 27a5b3aae8
commit c830b862be
12 changed files with 91 additions and 23 deletions

View File

@@ -135,11 +135,16 @@ namespace swift::core::context
//! Set XPDR mode //! Set XPDR mode
virtual bool setTransponderMode(swift::misc::aviation::CTransponder::TransponderMode mode) = 0; virtual bool setTransponderMode(swift::misc::aviation::CTransponder::TransponderMode mode) = 0;
//! Tune in a COM frequency //! Tune in a COM frequency (active)
virtual bool updateActiveComFrequency(const swift::misc::physical_quantities::CFrequency &frequency, virtual bool updateActiveComFrequency(const swift::misc::physical_quantities::CFrequency &frequency,
swift::misc::aviation::CComSystem::ComUnit comUnit, swift::misc::aviation::CComSystem::ComUnit comUnit,
const swift::misc::CIdentifier &originator) = 0; const swift::misc::CIdentifier &originator) = 0;
//! Tune in a COM frequency (standby)
virtual bool updateStandbyComFrequency(const swift::misc::physical_quantities::CFrequency &frequency,
swift::misc::aviation::CComSystem::ComUnit comUnit,
const swift::misc::CIdentifier &originator) = 0;
//! Set current pilot //! Set current pilot
virtual bool updateOwnAircraftPilot(const swift::misc::network::CUser &pilot) = 0; virtual bool updateOwnAircraftPilot(const swift::misc::network::CUser &pilot) = 0;

View File

@@ -100,6 +100,18 @@ namespace swift::core::context
return false; return false;
} }
//! \copydoc IContextOwnAircraft::updateStandbyComFrequency
bool updateStandbyComFrequency(const swift::misc::physical_quantities::CFrequency &frequency,
swift::misc::aviation::CComSystem::ComUnit comUnit,
const swift::misc::CIdentifier &originator) override
{
Q_UNUSED(frequency);
Q_UNUSED(comUnit);
Q_UNUSED(originator);
logEmptyContextWarning(Q_FUNC_INFO);
return false;
}
//! \copydoc IContextOwnAircraft::updateOwnAircraftPilot //! \copydoc IContextOwnAircraft::updateOwnAircraftPilot
bool updateOwnAircraftPilot(const swift::misc::network::CUser &pilot) override bool updateOwnAircraftPilot(const swift::misc::network::CUser &pilot) override
{ {

View File

@@ -330,6 +330,26 @@ namespace swift::core::context
return changed; return changed;
} }
bool CContextOwnAircraft::updateStandbyComFrequency(const CFrequency &frequency, CComSystem::ComUnit unit,
const CIdentifier &originator)
{
if (unit != CComSystem::Com1 && unit != CComSystem::Com2) { return false; }
if (!CComSystem::isValidComFrequency(frequency)) { return false; }
CComSystem com1, com2;
CTransponder xpdr;
{
QReadLocker l(&m_lockAircraft);
com1 = m_ownAircraft.getCom1System();
com2 = m_ownAircraft.getCom2System();
xpdr = m_ownAircraft.getTransponder();
}
if (unit == CComSystem::Com1) { com1.setFrequencyStandby(frequency); }
else { com2.setFrequencyStandby(frequency); }
const bool changed = this->updateCockpit(com1, com2, xpdr, originator);
return changed;
}
bool CContextOwnAircraft::updateOwnAircraftPilot(const CUser &pilot) bool CContextOwnAircraft::updateOwnAircraftPilot(const CUser &pilot)
{ {
{ {

View File

@@ -175,6 +175,11 @@ namespace swift::core
swift::misc::aviation::CComSystem::ComUnit comUnit, swift::misc::aviation::CComSystem::ComUnit comUnit,
const swift::misc::CIdentifier &originator) override; const swift::misc::CIdentifier &originator) override;
//! \copydoc IContextOwnAircraft::updateStandbyComFrequency
bool updateStandbyComFrequency(const swift::misc::physical_quantities::CFrequency &frequency,
swift::misc::aviation::CComSystem::ComUnit comUnit,
const swift::misc::CIdentifier &originator) override;
//! \copydoc IContextOwnAircraft::updateOwnAircraftPilot //! \copydoc IContextOwnAircraft::updateOwnAircraftPilot
bool updateOwnAircraftPilot(const swift::misc::network::CUser &pilot) override; bool updateOwnAircraftPilot(const swift::misc::network::CUser &pilot) override;

View File

@@ -111,6 +111,14 @@ namespace swift::core::context
originator); originator);
} }
bool CContextOwnAircraftProxy::updateStandbyComFrequency(const physical_quantities::CFrequency &frequency,
swift::misc::aviation::CComSystem::ComUnit comUnit,
const CIdentifier &originator)
{
return m_dBusInterface->callDBusRet<bool>(QLatin1String("updateStandbyComFrequency"), frequency, comUnit,
originator);
}
bool CContextOwnAircraftProxy::updateOwnAircraftPilot(const swift::misc::network::CUser &pilot) bool CContextOwnAircraftProxy::updateOwnAircraftPilot(const swift::misc::network::CUser &pilot)
{ {
return m_dBusInterface->callDBusRet<bool>(QLatin1String("updateOwnAircraftPilot"), pilot); return m_dBusInterface->callDBusRet<bool>(QLatin1String("updateOwnAircraftPilot"), pilot);

View File

@@ -89,6 +89,11 @@ namespace swift::core
swift::misc::aviation::CComSystem::ComUnit comUnit, swift::misc::aviation::CComSystem::ComUnit comUnit,
const swift::misc::CIdentifier &originator) override; const swift::misc::CIdentifier &originator) override;
//! \copydoc swift::core::context::IContextOwnAircraft::updateStandbyComFrequency
bool updateStandbyComFrequency(const swift::misc::physical_quantities::CFrequency &frequency,
swift::misc::aviation::CComSystem::ComUnit comUnit,
const swift::misc::CIdentifier &originator) override;
//! \copydoc swift::core::context::IContextOwnAircraft::updateOwnAircraftPilot //! \copydoc swift::core::context::IContextOwnAircraft::updateOwnAircraftPilot
bool updateOwnAircraftPilot(const swift::misc::network::CUser &pilot) override; bool updateOwnAircraftPilot(const swift::misc::network::CUser &pilot) override;

View File

@@ -330,11 +330,12 @@ namespace swift::gui::components
} }
void CAtcStationComponent::setComFrequency(const physical_quantities::CFrequency &frequency, void CAtcStationComponent::setComFrequency(const physical_quantities::CFrequency &frequency,
CComSystem::ComUnit unit) CComSystem::ComUnit unit, bool active)
{ {
if (unit != CComSystem::Com1 && unit != CComSystem::Com2) { return; } if (unit != CComSystem::Com1 && unit != CComSystem::Com2) { return; }
if (!CComSystem::isValidComFrequency(frequency)) { return; } if (!CComSystem::isValidComFrequency(frequency)) { return; }
sGui->getIContextOwnAircraft()->updateActiveComFrequency(frequency, unit, identifier()); if (active) { sGui->getIContextOwnAircraft()->updateActiveComFrequency(frequency, unit, identifier()); }
else { sGui->getIContextOwnAircraft()->updateStandbyComFrequency(frequency, unit, identifier()); }
} }
void CAtcStationComponent::settingsChanged() void CAtcStationComponent::settingsChanged()

View File

@@ -122,7 +122,7 @@ namespace swift::gui
//! Set COM frequency //! Set COM frequency
void setComFrequency(const swift::misc::physical_quantities::CFrequency &frequency, void setComFrequency(const swift::misc::physical_quantities::CFrequency &frequency,
swift::misc::aviation::CComSystem::ComUnit unit); swift::misc::aviation::CComSystem::ComUnit unit, bool active);
//! Airports read from web readers //! Airports read from web readers
void airportsRead(); void airportsRead();

View File

@@ -118,18 +118,24 @@ namespace swift::gui::views
auto *menu = new QMenu(this); // menu auto *menu = new QMenu(this); // menu
auto *com1 = new QAction(CIcons::appCockpit16(), "Tune in COM1", this); auto *com1 = new QAction(CIcons::appCockpit16(), "Tune in COM1 (active)", this);
auto *com2 = new QAction(CIcons::appCockpit16(), "Tune in COM2", this); auto *com2 = new QAction(CIcons::appCockpit16(), "Tune in COM2 (active)", this);
auto *com1_stby = new QAction(CIcons::appCockpit16(), "Tune in COM1 (standby)", this);
auto *com2_stby = new QAction(CIcons::appCockpit16(), "Tune in COM2 (standby)", this);
auto *text = new QAction(CIcons::appTextMessages16(), "Show text messages", this); auto *text = new QAction(CIcons::appTextMessages16(), "Show text messages", this);
auto *resize = new QAction(CIcons::resize16(), "Resize", this); auto *resize = new QAction(CIcons::resize16(), "Resize", this);
connect(com1, &QAction::triggered, this, [this]() { tuneInAtc(CComSystem::Com1); }); connect(com1, &QAction::triggered, this, [this]() { tuneInAtc(CComSystem::Com1, true); });
connect(com2, &QAction::triggered, this, [this]() { tuneInAtc(CComSystem::Com2); }); connect(com2, &QAction::triggered, this, [this]() { tuneInAtc(CComSystem::Com2, true); });
connect(com1_stby, &QAction::triggered, this, [this]() { tuneInAtc(CComSystem::Com1, false); });
connect(com2_stby, &QAction::triggered, this, [this]() { tuneInAtc(CComSystem::Com2, false); });
connect(text, &QAction::triggered, this, &CAtcStationTreeView::requestTextMessage); connect(text, &QAction::triggered, this, &CAtcStationTreeView::requestTextMessage);
connect(resize, &QAction::triggered, this, &CAtcStationTreeView::fullResizeToContentsImpl); connect(resize, &QAction::triggered, this, &CAtcStationTreeView::fullResizeToContentsImpl);
menu->addAction(com1); menu->addAction(com1);
menu->addAction(com2); menu->addAction(com2);
menu->addAction(com1_stby);
menu->addAction(com2_stby);
menu->addAction(text); menu->addAction(text);
menu->addSeparator(); menu->addSeparator();
menu->addAction(resize); menu->addAction(resize);
@@ -160,11 +166,11 @@ namespace swift::gui::views
} }
} }
void CAtcStationTreeView::tuneInAtc(const misc::aviation::CComSystem::ComUnit unit) void CAtcStationTreeView::tuneInAtc(const misc::aviation::CComSystem::ComUnit unit, const bool active)
{ {
const CAtcStation s(this->selectedObject()); const CAtcStation s(this->selectedObject());
if (s.getCallsign().isEmpty()) { return; } if (s.getCallsign().isEmpty()) { return; }
emit this->requestComFrequency(s.getFrequency(), unit); emit this->requestComFrequency(s.getFrequency(), unit, active);
} }
void CAtcStationTreeView::requestTextMessage() void CAtcStationTreeView::requestTextMessage()

View File

@@ -63,7 +63,7 @@ namespace swift::gui
//! Request COM frequency //! Request COM frequency
void requestComFrequency(const swift::misc::physical_quantities::CFrequency &frequency, void requestComFrequency(const swift::misc::physical_quantities::CFrequency &frequency,
swift::misc::aviation::CComSystem::ComUnit unit); swift::misc::aviation::CComSystem::ComUnit unit, bool active);
//! Request a text message to //! Request a text message to
void requestTextMessageWidget(const swift::misc::aviation::CCallsign &callsign); void requestTextMessageWidget(const swift::misc::aviation::CCallsign &callsign);
@@ -107,7 +107,7 @@ namespace swift::gui
//! @{ //! @{
//! Tune in/invoke //! Tune in/invoke
void tuneInAtc(misc::aviation::CComSystem::ComUnit unit); void tuneInAtc(misc::aviation::CComSystem::ComUnit unit, bool active);
void requestTextMessage(); void requestTextMessage();
//! @} //! @}

View File

@@ -57,26 +57,32 @@ namespace swift::gui::views
if (this->hasSelection()) if (this->hasSelection())
{ {
if (m_actions.isEmpty()) { m_actions = QList<QAction *>({ nullptr, nullptr, nullptr }); } if (m_actions.isEmpty()) { m_actions = QList<QAction *>({ nullptr, nullptr, nullptr, nullptr, nullptr }); }
m_actions[0] = menuActions.addAction(m_actions[0], CIcons::appCockpit16(), "Tune in COM1", m_actions[0] = menuActions.addAction(m_actions[0], CIcons::appCockpit16(), "Tune in COM1 (active)",
CMenuAction::pathClientCom(), CMenuAction::pathClientCom(),
{ this, [this]() { tuneInAtc(CComSystem::Com1); } }); { this, [this]() { tuneInAtc(CComSystem::Com1, true); } });
m_actions[1] = menuActions.addAction(m_actions[1], CIcons::appCockpit16(), "Tune in COM2", m_actions[1] = menuActions.addAction(m_actions[1], CIcons::appCockpit16(), "Tune in COM2 (active)",
CMenuAction::pathClientCom(), CMenuAction::pathClientCom(),
{ this, [this]() { tuneInAtc(CComSystem::Com2); } }); { this, [this]() { tuneInAtc(CComSystem::Com2, true); } });
m_actions[2] = m_actions[2] = menuActions.addAction(m_actions[2], CIcons::appCockpit16(), "Tune in COM1 (standby)",
menuActions.addAction(m_actions[2], CIcons::appTextMessages16(), "Show text messages", CMenuAction::pathClientCom(),
{ this, [this]() { tuneInAtc(CComSystem::Com1, false); } });
m_actions[3] = menuActions.addAction(m_actions[3], CIcons::appCockpit16(), "Tune in COM2 (standby)",
CMenuAction::pathClientCom(),
{ this, [this]() { tuneInAtc(CComSystem::Com2, false); } });
m_actions[4] =
menuActions.addAction(m_actions[4], CIcons::appTextMessages16(), "Show text messages",
CMenuAction::pathClientCom(), { this, &CAtcStationView::requestTextMessage }); CMenuAction::pathClientCom(), { this, &CAtcStationView::requestTextMessage });
} }
CViewBase::customMenu(menuActions); CViewBase::customMenu(menuActions);
} }
void CAtcStationView::tuneInAtc(const misc::aviation::CComSystem::ComUnit unit) void CAtcStationView::tuneInAtc(const misc::aviation::CComSystem::ComUnit unit, const bool active)
{ {
const CAtcStation s(this->selectedObject()); const CAtcStation s(this->selectedObject());
if (s.getCallsign().isEmpty()) { return; } if (s.getCallsign().isEmpty()) { return; }
emit this->requestComFrequency(s.getFrequency(), unit); emit this->requestComFrequency(s.getFrequency(), unit, active);
} }
void CAtcStationView::requestTextMessage() void CAtcStationView::requestTextMessage()

View File

@@ -52,7 +52,7 @@ namespace swift::gui
//! Request COM frequency //! Request COM frequency
void requestComFrequency(const swift::misc::physical_quantities::CFrequency &frequency, void requestComFrequency(const swift::misc::physical_quantities::CFrequency &frequency,
swift::misc::aviation::CComSystem::ComUnit unit); swift::misc::aviation::CComSystem::ComUnit unit, bool active);
//! Request a text message to //! Request a text message to
void requestTextMessageWidget(const swift::misc::aviation::CCallsign &callsign); void requestTextMessageWidget(const swift::misc::aviation::CCallsign &callsign);
@@ -64,7 +64,7 @@ namespace swift::gui
private: private:
void emitTestRequest1kAtcOnlineDummies() { emit this->testRequestDummyAtcOnlineStations(1000); } void emitTestRequest1kAtcOnlineDummies() { emit this->testRequestDummyAtcOnlineStations(1000); }
void emitTestRequest3kAtcOnlineDummies() { emit this->testRequestDummyAtcOnlineStations(3000); } void emitTestRequest3kAtcOnlineDummies() { emit this->testRequestDummyAtcOnlineStations(3000); }
void tuneInAtc(misc::aviation::CComSystem::ComUnit unit); void tuneInAtc(misc::aviation::CComSystem::ComUnit unit, bool active);
void requestTextMessage(); void requestTextMessage();
QList<QAction *> m_actions; //!< real actions QList<QAction *> m_actions; //!< real actions