From 0760a67138ae092f49a35196ade98f24b7aa23fb Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Fri, 13 Mar 2015 20:56:04 +0100 Subject: [PATCH] Handle users joining and leaving properly in audio context and gui Before this change signals when users were joining or leaving the voice room were not properly handled. A new signal in audio context is emitted now and gui will rebuild the user list when it is emitted. --- src/blackcore/context_audio.h | 3 +++ src/blackcore/context_audio_impl.cpp | 14 ++++++++++++++ src/blackcore/context_audio_impl.h | 6 ++++++ src/blackgui/components/voiceroomscomponent.cpp | 5 +++-- src/blackgui/components/voiceroomscomponent.h | 6 +++--- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/blackcore/context_audio.h b/src/blackcore/context_audio.h index eb9ce5f70..43f282c93 100644 --- a/src/blackcore/context_audio.h +++ b/src/blackcore/context_audio.h @@ -84,6 +84,9 @@ namespace BlackCore //! \details the flag indicates, whether a room got connected or disconnected void changedVoiceRooms(const BlackMisc::Audio::CVoiceRoomList &voiceRooms, bool connected); + //! Voice room members changed + void changedVoiceRoomMembers(); + //! Audio volume changed //! \sa setVoiceOutputVolume void changedAudioVolume(int volume); diff --git a/src/blackcore/context_audio_impl.cpp b/src/blackcore/context_audio_impl.cpp index 11d66221a..727ebf88b 100644 --- a/src/blackcore/context_audio_impl.cpp +++ b/src/blackcore/context_audio_impl.cpp @@ -49,9 +49,13 @@ namespace BlackCore m_channel1 = m_voice->createVoiceChannel(); m_channel1->setMyAircraftCallsign(ownCallsign); connect(m_channel1.data(), &IVoiceChannel::connectionStatusChanged, this, &CContextAudio::ps_connectionStatusChanged); + connect(m_channel1.data(), &IVoiceChannel::userJoinedRoom, this, &CContextAudio::ps_userJoinedRoom); + connect(m_channel1.data(), &IVoiceChannel::userLeftRoom, this, &CContextAudio::ps_userLeftRoom); m_channel2 = m_voice->createVoiceChannel(); m_channel2->setMyAircraftCallsign(ownCallsign); connect(m_channel2.data(), &IVoiceChannel::connectionStatusChanged, this, &CContextAudio::ps_connectionStatusChanged); + connect(m_channel1.data(), &IVoiceChannel::userJoinedRoom, this, &CContextAudio::ps_userJoinedRoom); + connect(m_channel1.data(), &IVoiceChannel::userLeftRoom, this, &CContextAudio::ps_userLeftRoom); m_voiceInputDevice = m_voice->createInputDevice(); m_voiceOutputDevice = m_voice->createOutputDevice(); @@ -546,6 +550,16 @@ namespace BlackCore } } + void CContextAudio::ps_userJoinedRoom(const CCallsign & /**callsign**/) + { + emit this->changedVoiceRoomMembers(); + } + + void CContextAudio::ps_userLeftRoom(const CCallsign & /**callsign**/) + { + emit this->changedVoiceRoomMembers(); + } + QSharedPointer CContextAudio::getVoiceChannelBy(const CVoiceRoom &voiceRoom) { QSharedPointer voiceChannel; diff --git a/src/blackcore/context_audio_impl.h b/src/blackcore/context_audio_impl.h index 02066cf4c..4f5081c97 100644 --- a/src/blackcore/context_audio_impl.h +++ b/src/blackcore/context_audio_impl.h @@ -139,6 +139,12 @@ namespace BlackCore void ps_setVoiceTransmission(bool enable); + //! User joined the room + void ps_userJoinedRoom(const BlackMisc::Aviation::CCallsign &callsign); + + //! User left the room + void ps_userLeftRoom(const BlackMisc::Aviation::CCallsign &callsign); + private: const int MinUnmuteVolume = 20; //!< minimum volume when unmuted diff --git a/src/blackgui/components/voiceroomscomponent.cpp b/src/blackgui/components/voiceroomscomponent.cpp index e4c3e6ca6..938da2d8a 100644 --- a/src/blackgui/components/voiceroomscomponent.cpp +++ b/src/blackgui/components/voiceroomscomponent.cpp @@ -40,6 +40,7 @@ namespace BlackGui void CVoiceRoomsComponent::runtimeHasBeenSet() { this->connect(this->getIContextAudio(), &IContextAudio::changedVoiceRooms, this, &CVoiceRoomsComponent::ps_updateAudioVoiceRoomsFromContext); + this->connect(this->getIContextAudio(), &IContextAudio::changedVoiceRoomMembers, this, &CVoiceRoomsComponent::ps_updateVoiceRoomMembers); } void CVoiceRoomsComponent::ps_onVoiceRoomOverrideChanged(bool checked) @@ -102,7 +103,7 @@ namespace BlackGui } if (changedUrl1 || changedUrl2) { - this->updateVoiceRoomMembers(); + this->ps_updateVoiceRoomMembers(); // notify if (this->getIContextAudio()) @@ -115,7 +116,7 @@ namespace BlackGui } } - void CVoiceRoomsComponent::updateVoiceRoomMembers() + void CVoiceRoomsComponent::ps_updateVoiceRoomMembers() { if (!this->getIContextAudio()) { return; } if (!this->ui->le_CockpitVoiceRoomCom1->text().trimmed().isEmpty()) diff --git a/src/blackgui/components/voiceroomscomponent.h b/src/blackgui/components/voiceroomscomponent.h index b94c04d52..80d055443 100644 --- a/src/blackgui/components/voiceroomscomponent.h +++ b/src/blackgui/components/voiceroomscomponent.h @@ -51,13 +51,13 @@ namespace BlackGui //! Set the voice room url fields (checkboxes, line edits) void ps_updateAudioVoiceRoomsFromContext(const BlackMisc::Audio::CVoiceRoomList &selectedVoiceRooms, bool connected); + //! Update voice room views + void ps_updateVoiceRoomMembers(); + private: //! Set the URL fields void setVoiceRoomUrlFieldsReadOnlyState(); - //! Update voice room views - void updateVoiceRoomMembers(); - QScopedPointer ui; };