diff --git a/src/blackcore/airspacemonitor.cpp b/src/blackcore/airspacemonitor.cpp index 01ed11b9e..6360b1994 100644 --- a/src/blackcore/airspacemonitor.cpp +++ b/src/blackcore/airspacemonitor.cpp @@ -617,6 +617,8 @@ namespace BlackCore { Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this)); if (!this->isConnectedAndNotShuttingDown()) { return; } + + // URL const QString trimmedUrl = url.trimmed(); CPropertyIndexVariantMap vm({ CAtcStation::IndexVoiceRoom, CVoiceRoom::IndexUrl }, trimmedUrl); const int changedOnline = this->updateOnlineStation(callsign, vm, true, true); diff --git a/src/blackcore/context/contextaudioimpl.cpp b/src/blackcore/context/contextaudioimpl.cpp index a642e429e..885582410 100644 --- a/src/blackcore/context/contextaudioimpl.cpp +++ b/src/blackcore/context/contextaudioimpl.cpp @@ -232,7 +232,7 @@ namespace BlackCore if (changed) { - emit changedSelectedAudioDevices(this->getCurrentAudioDevices()); + emit this->changedSelectedAudioDevices(this->getCurrentAudioDevices()); } } @@ -304,7 +304,7 @@ namespace BlackCore Q_ASSERT(getIContextOwnAircraft()); if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << newRooms; } - CVoiceRoomList currentRooms = getComVoiceRooms(); + CVoiceRoomList currentRooms = this->getComVoiceRooms(); CVoiceRoom currentRoomCom1 = currentRooms[0]; CVoiceRoom currentRoomCom2 = currentRooms[1]; CVoiceRoom newRoomCom1 = newRooms[0]; @@ -313,13 +313,13 @@ namespace BlackCore bool changed = false; - // changed rooms? But only compare on "URL", not status as connected etc. + // changed rooms? But only compare on "URL", not status as connected etc. if (currentRoomCom1.getVoiceRoomUrl() != newRoomCom1.getVoiceRoomUrl()) { - QSharedPointer oldVoiceChannel = m_voiceChannelMapping.value(BlackMisc::Aviation::CComSystem::Com1); + QSharedPointer oldVoiceChannel = m_voiceChannelMapping.value(CComSystem::Com1); if (oldVoiceChannel) { - m_voiceChannelMapping.remove(BlackMisc::Aviation::CComSystem::Com1); + m_voiceChannelMapping.remove(CComSystem::Com1); // If the voice channel is not used by anybody else if (!m_voiceChannelMapping.values().contains(oldVoiceChannel)) @@ -329,13 +329,13 @@ namespace BlackCore } else { - emit this->changedVoiceRooms(getComVoiceRooms(), false); + emit this->changedVoiceRooms(this->getComVoiceRooms(), false); } } if (newRoomCom1.isValid()) { - QSharedPointer newVoiceChannel = getVoiceChannelBy(newRoomCom1); + QSharedPointer newVoiceChannel = this->getVoiceChannelBy(newRoomCom1); newVoiceChannel->setOwnAircraftCallsign(ownCallsign); bool inUse = m_voiceChannelMapping.values().contains(newVoiceChannel); m_voiceChannelMapping.insert(BlackMisc::Aviation::CComSystem::Com1, newVoiceChannel); @@ -356,10 +356,10 @@ namespace BlackCore // changed rooms? But only compare on "URL", not status as connected etc. if (currentRoomCom2.getVoiceRoomUrl() != newRoomCom2.getVoiceRoomUrl()) { - auto oldVoiceChannel = m_voiceChannelMapping.value(BlackMisc::Aviation::CComSystem::Com2); + auto oldVoiceChannel = m_voiceChannelMapping.value(CComSystem::Com2); if (oldVoiceChannel) { - m_voiceChannelMapping.remove(BlackMisc::Aviation::CComSystem::Com2); + m_voiceChannelMapping.remove(CComSystem::Com2); // If the voice channel is not used by anybody else if (!m_voiceChannelMapping.values().contains(oldVoiceChannel)) @@ -369,7 +369,7 @@ namespace BlackCore } else { - emit this->changedVoiceRooms(getComVoiceRooms(), false); + emit this->changedVoiceRooms(this->getComVoiceRooms(), false); } } diff --git a/src/blackcore/context/contextownaircraftimpl.cpp b/src/blackcore/context/contextownaircraftimpl.cpp index 11cc6cfc8..9ff52c600 100644 --- a/src/blackcore/context/contextownaircraftimpl.cpp +++ b/src/blackcore/context/contextownaircraftimpl.cpp @@ -151,15 +151,12 @@ namespace BlackCore // voice rooms, if network is already available if (this->getIContextNetwork()) { - this->resolveVoiceRooms(); + this->resolveVoiceRooms(); // init own aircraft } } void CContextOwnAircraft::resolveVoiceRooms() { - Q_ASSERT(this->getIContextAudio()); - Q_ASSERT(this->getIContextNetwork()); - Q_ASSERT(this->getIContextApplication()); if (!this->getIContextNetwork() || !this->getIContextAudio() || !this->getIContextApplication()) { return; } // no chance to resolve rooms if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } @@ -168,11 +165,11 @@ namespace BlackCore // requires correct frequencies set // but local network uses exactly this object here, so if frequencies are set here, - // they are for network context as well + // they are set for network context as well CVoiceRoomList rooms = this->getIContextNetwork()->getSelectedVoiceRooms(); - if (!m_voiceRoom1UrlOverride.isEmpty()) rooms[0] = CVoiceRoom(m_voiceRoom1UrlOverride); - if (!m_voiceRoom2UrlOverride.isEmpty()) rooms[1] = CVoiceRoom(m_voiceRoom2UrlOverride); + if (!m_voiceRoom1UrlOverride.isEmpty()) { rooms[0] = CVoiceRoom(m_voiceRoom1UrlOverride); } + if (!m_voiceRoom2UrlOverride.isEmpty()) { rooms[1] = CVoiceRoom(m_voiceRoom2UrlOverride); } // set the rooms emit this->getIContextApplication()->fakedSetComVoiceRoom(rooms); @@ -233,7 +230,7 @@ namespace BlackCore return changed; } - bool CContextOwnAircraft::updateCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder, const CIdentifier &originator) + bool CContextOwnAircraft::updateCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const CTransponder &transponder, const CIdentifier &originator) { if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << com1 << com2 << transponder; } bool changed; @@ -245,7 +242,7 @@ namespace BlackCore if (changed) { emit this->changedAircraftCockpit(m_ownAircraft, originator); - this->resolveVoiceRooms(); + this->resolveVoiceRooms(); // cockpit COM changed } return changed; } @@ -326,9 +323,13 @@ namespace BlackCore { // any of our active frequencies? Q_UNUSED(connected); - CSimulatedAircraft myAircraft(getOwnAircraft()); - if (atcStation.getFrequency() != myAircraft.getCom1System().getFrequencyActive() && atcStation.getFrequency() != myAircraft.getCom2System().getFrequencyActive()) { return; } - this->resolveVoiceRooms(); + const CSimulatedAircraft myAircraft(this->getOwnAircraft()); + + // relevant frequency + if (myAircraft.getCom1System().isActiveFrequencyWithin8_33kHzChannel(atcStation.getFrequency()) || myAircraft.getCom2System().isActiveFrequencyWithin8_33kHzChannel(atcStation.getFrequency())) + { + this->resolveVoiceRooms(); // online status changed + } } void CContextOwnAircraft::xCtxChangedSimulatorModel(const CAircraftModel &model) @@ -347,7 +348,7 @@ namespace BlackCore if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << voiceRoom1Url << voiceRoom2Url; } m_voiceRoom1UrlOverride = voiceRoom1Url.trimmed(); m_voiceRoom2UrlOverride = voiceRoom2Url.trimmed(); - this->resolveVoiceRooms(); + this->resolveVoiceRooms(); // override } void CContextOwnAircraft::enableAutomaticVoiceRoomResolution(bool enable) diff --git a/src/blackcore/context/contextsimulatorimpl.cpp b/src/blackcore/context/contextsimulatorimpl.cpp index 576bab0ca..0e82fb227 100644 --- a/src/blackcore/context/contextsimulatorimpl.cpp +++ b/src/blackcore/context/contextsimulatorimpl.cpp @@ -629,7 +629,7 @@ namespace BlackCore void CContextSimulator::xCtxNetworkConnectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to) { Q_UNUSED(from); - BLACK_VERIFY_X(getIContextNetwork(), Q_FUNC_INFO, "Missing network context"); + BLACK_VERIFY_X(this->getIContextNetwork(), Q_FUNC_INFO, "Missing network context"); if (to == INetwork::Connected && this->getIContextNetwork()) { m_networkSessionId = this->getIContextNetwork()->getConnectedServer().getServerSessionId(); diff --git a/src/blackcore/corefacade.cpp b/src/blackcore/corefacade.cpp index f3731854f..87f74ffcd 100644 --- a/src/blackcore/corefacade.cpp +++ b/src/blackcore/corefacade.cpp @@ -261,8 +261,7 @@ namespace BlackCore { Q_ASSERT(m_contextApplication); Q_ASSERT(m_contextOwnAircraft); - c = connect(m_contextApplication, &IContextApplication::fakedSetComVoiceRoom, - this->getCContextAudio(), &CContextAudio::setComVoiceRooms); + c = connect(m_contextApplication, &IContextApplication::fakedSetComVoiceRoom, this->getCContextAudio(), &CContextAudio::setComVoiceRooms); Q_ASSERT(c); c = connect(m_contextOwnAircraft, &IContextOwnAircraft::changedCallsign, this->getCContextAudio(), &IContextAudio::setOwnCallsignForRooms); Q_ASSERT(c); diff --git a/src/blackgui/components/voiceroomscomponent.cpp b/src/blackgui/components/voiceroomscomponent.cpp index 25f75df4d..d44dbe3d5 100644 --- a/src/blackgui/components/voiceroomscomponent.cpp +++ b/src/blackgui/components/voiceroomscomponent.cpp @@ -37,6 +37,7 @@ namespace BlackGui QFrame(parent), ui(new Ui::CVoiceRoomsComponent) { + Q_ASSERT_X(sGui, Q_FUNC_INFO, "Need sGui"); ui->setupUi(this); this->setVoiceRoomUrlFieldsReadOnlyState(); connect(ui->cb_CockpitVoiceRoom1Override, &QCheckBox::toggled, this, &CVoiceRoomsComponent::onVoiceRoomOverrideChanged); diff --git a/src/blackgui/components/voiceroomscomponent.h b/src/blackgui/components/voiceroomscomponent.h index 14b8af801..c8ac6f518 100644 --- a/src/blackgui/components/voiceroomscomponent.h +++ b/src/blackgui/components/voiceroomscomponent.h @@ -19,17 +19,13 @@ #include #include -class QWidget; - namespace Ui { class CVoiceRoomsComponent; } - namespace BlackGui { namespace Components { //! Displays the voice rooms - class BLACKGUI_EXPORT CVoiceRoomsComponent : - public QFrame + class BLACKGUI_EXPORT CVoiceRoomsComponent : public QFrame { Q_OBJECT