mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 15:15:50 +08:00
[AFV] Ref T739, use the Audio base class with the shared CAfvClient functions
This commit is contained in:
@@ -77,7 +77,7 @@ namespace BlackGui
|
||||
|
||||
void CAudioDeviceVolumeSetupComponent::init()
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextAudio()) { return; }
|
||||
if (!sGui || sGui->isShuttingDown() || !sGui->getCContextAudioBase()) { return; }
|
||||
|
||||
// audio is optional
|
||||
const bool audio = this->hasAudio();
|
||||
@@ -91,14 +91,14 @@ namespace BlackGui
|
||||
|
||||
if (audio)
|
||||
{
|
||||
const QString ai = audio ? sGui->getIContextAudio()->audioRunsWhereInfo() : "No audio, cannot change.";
|
||||
const QString ai = sGui->getCContextAudioBase()->audioRunsWhereInfo();
|
||||
ui->le_Info->setText(ai);
|
||||
ui->le_Info->setPlaceholderText(ai);
|
||||
|
||||
this->initAudioDeviceLists();
|
||||
|
||||
// default
|
||||
ui->cb_SetupAudioLoopback->setChecked(sGui->getIContextAudio()->isAudioLoopbackEnabled());
|
||||
ui->cb_SetupAudioLoopback->setChecked(sGui->getCContextAudioBase()->isAudioLoopbackEnabled());
|
||||
|
||||
// the connects depend on initAudioDeviceLists
|
||||
c = connect(ui->cb_SetupAudioInputDevice, qOverload<int>(&QComboBox::currentIndexChanged), this, &CAudioDeviceVolumeSetupComponent::onAudioDeviceSelected);
|
||||
@@ -107,21 +107,21 @@ namespace BlackGui
|
||||
Q_ASSERT(c);
|
||||
|
||||
// context
|
||||
c = connect(sGui->getIContextAudio(), &IContextAudio::changedAudioDevices, this, &CAudioDeviceVolumeSetupComponent::onAudioDevicesChanged, Qt::QueuedConnection);
|
||||
c = connect(sGui->getCContextAudioBase(), &CContextAudioBase::changedAudioDevices, this, &CAudioDeviceVolumeSetupComponent::onAudioDevicesChanged, Qt::QueuedConnection);
|
||||
Q_ASSERT(c);
|
||||
c = connect(sGui->getIContextAudio(), &IContextAudio::startedAudio, this, &CAudioDeviceVolumeSetupComponent::onAudioStarted, Qt::QueuedConnection);
|
||||
c = connect(sGui->getCContextAudioBase(), &CContextAudioBase::startedAudio, this, &CAudioDeviceVolumeSetupComponent::onAudioStarted, Qt::QueuedConnection);
|
||||
Q_ASSERT(c);
|
||||
|
||||
c = connect(sGui->getIContextAudio(), &IContextAudio::outputVolumePeakVU, this, &CAudioDeviceVolumeSetupComponent::onOutputVU, Qt::QueuedConnection);
|
||||
c = connect(sGui->getCContextAudioBase(), &CContextAudioBase::outputVolumePeakVU, this, &CAudioDeviceVolumeSetupComponent::onOutputVU, Qt::QueuedConnection);
|
||||
Q_ASSERT(c);
|
||||
|
||||
c = connect(sGui->getIContextAudio(), &IContextAudio::inputVolumePeakVU, this, &CAudioDeviceVolumeSetupComponent::onInputVU, Qt::QueuedConnection);
|
||||
c = connect(sGui->getCContextAudioBase(), &CContextAudioBase::inputVolumePeakVU, this, &CAudioDeviceVolumeSetupComponent::onInputVU, Qt::QueuedConnection);
|
||||
Q_ASSERT(c);
|
||||
|
||||
c = connect(sGui->getIContextAudio(), &IContextAudio::receivingCallsignsChanged, this, &CAudioDeviceVolumeSetupComponent::onReceivingCallsignsChanged, Qt::QueuedConnection);
|
||||
c = connect(sGui->getCContextAudioBase(), &CContextAudioBase::receivingCallsignsChanged, this, &CAudioDeviceVolumeSetupComponent::onReceivingCallsignsChanged, Qt::QueuedConnection);
|
||||
Q_ASSERT(c);
|
||||
|
||||
c = connect(sGui->getIContextAudio(), &IContextAudio::updatedFromOwnAircraftCockpit, this, &CAudioDeviceVolumeSetupComponent::onUpdatedClientWithCockpitData, Qt::QueuedConnection);
|
||||
c = connect(sGui->getCContextAudioBase(), &CContextAudioBase::updatedFromOwnAircraftCockpit, this, &CAudioDeviceVolumeSetupComponent::onUpdatedClientWithCockpitData, Qt::QueuedConnection);
|
||||
Q_ASSERT(c);
|
||||
|
||||
this->onUpdatedClientWithCockpitData();
|
||||
@@ -194,11 +194,11 @@ namespace BlackGui
|
||||
void CAudioDeviceVolumeSetupComponent::setTransmitReceiveInUiFromVoiceClient()
|
||||
{
|
||||
if (!this->hasAudio()) { return; }
|
||||
const bool com1Enabled = sGui->getIContextAudio()->isEnabledComUnit(CComSystem::Com1);
|
||||
const bool com2Enabled = sGui->getIContextAudio()->isEnabledComUnit(CComSystem::Com2);
|
||||
const bool com1Enabled = sGui->getCContextAudioBase()->isEnabledComUnit(CComSystem::Com1);
|
||||
const bool com2Enabled = sGui->getCContextAudioBase()->isEnabledComUnit(CComSystem::Com2);
|
||||
|
||||
const bool com1Tx = com1Enabled && sGui->getIContextAudio()->isTransmittingComUnit(CComSystem::Com1);
|
||||
const bool com2Tx = com2Enabled && sGui->getIContextAudio()->isTransmittingComUnit(CComSystem::Com2);
|
||||
const bool com1Tx = com1Enabled && sGui->getCContextAudioBase()->isTransmittingComUnit(CComSystem::Com1);
|
||||
const bool com2Tx = com2Enabled && sGui->getCContextAudioBase()->isTransmittingComUnit(CComSystem::Com2);
|
||||
|
||||
// we do not have receiving
|
||||
const bool com1Rx = com1Enabled;
|
||||
@@ -218,14 +218,14 @@ namespace BlackGui
|
||||
void CAudioDeviceVolumeSetupComponent::initAudioDeviceLists()
|
||||
{
|
||||
if (!this->hasAudio()) { return; }
|
||||
this->onAudioDevicesChanged(sGui->getIContextAudio()->getAudioDevices());
|
||||
const CAudioDeviceInfoList currentDevices = sGui->getIContextAudio()->getCurrentAudioDevices();
|
||||
this->onAudioDevicesChanged(sGui->getCContextAudioBase()->getAudioDevices());
|
||||
const CAudioDeviceInfoList currentDevices = sGui->getCContextAudioBase()->getCurrentAudioDevices();
|
||||
this->onAudioStarted(currentDevices.getInputDevices().frontOrDefault(), currentDevices.getOutputDevices().frontOrDefault());
|
||||
}
|
||||
|
||||
bool CAudioDeviceVolumeSetupComponent::hasAudio() const
|
||||
{
|
||||
return sGui && sGui->getIContextAudio() && !sGui->getIContextAudio()->isEmptyObject();
|
||||
return sGui && sGui->getCContextAudioBase();
|
||||
}
|
||||
|
||||
void CAudioDeviceVolumeSetupComponent::onVolumeSliderChanged(int v)
|
||||
@@ -261,7 +261,7 @@ namespace BlackGui
|
||||
this->initAudioDeviceLists();
|
||||
const CAudioDeviceInfo i = this->getSelectedInputDevice();
|
||||
const CAudioDeviceInfo o = this->getSelectedInputDevice();
|
||||
sGui->getIContextAudio()->setCurrentAudioDevices(i, o);
|
||||
sGui->getCContextAudioBase()->setCurrentAudioDevices(i, o);
|
||||
}
|
||||
|
||||
void CAudioDeviceVolumeSetupComponent::onResetVolumeIn()
|
||||
@@ -287,14 +287,14 @@ namespace BlackGui
|
||||
CAudioDeviceInfo CAudioDeviceVolumeSetupComponent::getSelectedInputDevice() const
|
||||
{
|
||||
if (!hasAudio()) { return CAudioDeviceInfo(); }
|
||||
const CAudioDeviceInfoList devices = sGui->getIContextAudio()->getAudioInputDevices();
|
||||
const CAudioDeviceInfoList devices = sGui->getCContextAudioBase()->getAudioInputDevices();
|
||||
return devices.findByName(ui->cb_SetupAudioInputDevice->currentText());
|
||||
}
|
||||
|
||||
CAudioDeviceInfo CAudioDeviceVolumeSetupComponent::getSelectedOutputDevice() const
|
||||
{
|
||||
if (!hasAudio()) { return CAudioDeviceInfo(); }
|
||||
const CAudioDeviceInfoList devices = sGui->getIContextAudio()->getAudioOutputDevices();
|
||||
const CAudioDeviceInfoList devices = sGui->getCContextAudioBase()->getAudioOutputDevices();
|
||||
return devices.findByName(ui->cb_SetupAudioOutputDevice->currentText());
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ namespace BlackGui
|
||||
|
||||
const CAudioDeviceInfo in = this->getSelectedInputDevice();
|
||||
const CAudioDeviceInfo out = this->getSelectedOutputDevice();
|
||||
sGui->getIContextAudio()->setCurrentAudioDevices(in, out);
|
||||
sGui->getCContextAudioBase()->setCurrentAudioDevices(in, out);
|
||||
}
|
||||
|
||||
void CAudioDeviceVolumeSetupComponent::onAudioStarted(const CAudioDeviceInfo &input, const CAudioDeviceInfo &output)
|
||||
@@ -341,8 +341,8 @@ namespace BlackGui
|
||||
void CAudioDeviceVolumeSetupComponent::onLoopbackToggled(bool loopback)
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextAudio()) { return; }
|
||||
if (sGui->getIContextAudio()->isAudioLoopbackEnabled() == loopback) { return; }
|
||||
sGui->getIContextAudio()->enableAudioLoopback(loopback);
|
||||
if (sGui->getCContextAudioBase()->isAudioLoopbackEnabled() == loopback) { return; }
|
||||
sGui->getCContextAudioBase()->enableAudioLoopback(loopback);
|
||||
}
|
||||
|
||||
void CAudioDeviceVolumeSetupComponent::onDisableAudioEffectsToggled(bool disabled)
|
||||
|
||||
@@ -150,10 +150,10 @@ namespace BlackGui
|
||||
CLogMessage(this).preformatted(msg);
|
||||
|
||||
const QCheckBox *sender = qobject_cast<const QCheckBox *>(QObject::sender());
|
||||
if (checked && sGui && sGui->getIContextAudio() && sender)
|
||||
if (checked && sGui && sGui->getCContextAudioBase() && sender)
|
||||
{
|
||||
const CNotificationSounds::NotificationFlag f = this->checkBoxToFlag(sender);
|
||||
sGui->getIContextAudio()->playNotification(f, false, as.getNotificationVolume());
|
||||
sGui->getCContextAudioBase()->playNotification(f, false, as.getNotificationVolume());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace BlackGui
|
||||
{
|
||||
ui->setupUi(this);
|
||||
const int volume = sGui && sGui->getIContextAudio() ?
|
||||
sGui->getIContextAudio()->getVoiceOutputVolume() :
|
||||
sGui->getCContextAudioBase()->getVoiceOutputVolume() :
|
||||
100;
|
||||
ui->hs_Volume->setValue(volumeToSliderValue(volume));
|
||||
ui->sb_Volume->setValue(volume);
|
||||
@@ -53,15 +53,15 @@ namespace BlackGui
|
||||
Q_ASSERT(c);
|
||||
Q_UNUSED(c)
|
||||
|
||||
c = connect(sGui->getIContextAudio(), &IContextAudio::changedMute, this, &CAudioVolumeComponent::onMuteChanged);
|
||||
c = connect(sGui->getCContextAudioBase(), &CContextAudioBase::changedMute, this, &CAudioVolumeComponent::onMuteChanged);
|
||||
Q_ASSERT(c);
|
||||
Q_UNUSED(c)
|
||||
connect(sGui->getIContextAudio(), &IContextAudio::changedAudioVolume, this, &CAudioVolumeComponent::onOutputVolumeChanged);
|
||||
connect(sGui->getCContextAudioBase(), &CContextAudioBase::changedAudioVolume, this, &CAudioVolumeComponent::onOutputVolumeChanged);
|
||||
Q_ASSERT(c);
|
||||
Q_UNUSED(c)
|
||||
|
||||
// to audio audio context
|
||||
c = connect(ui->pb_Mute, &QPushButton::toggled, sGui->getIContextAudio(), &IContextAudio::setMute);
|
||||
c = connect(ui->pb_Mute, &QPushButton::toggled, sGui->getCContextAudioBase(), &CContextAudioBase::setMute);
|
||||
Q_ASSERT(c);
|
||||
Q_UNUSED(c)
|
||||
|
||||
@@ -129,9 +129,9 @@ namespace BlackGui
|
||||
}
|
||||
ui->hs_Volume->setToolTip(QString::number(volume));
|
||||
|
||||
if (sGui->getIContextAudio()->getVoiceOutputVolume() != volume)
|
||||
if (sGui->getCContextAudioBase()->getVoiceOutputVolume() != volume)
|
||||
{
|
||||
sGui->getIContextAudio()->setVoiceOutputVolume(volume);
|
||||
sGui->getCContextAudioBase()->setVoiceOutputVolume(volume);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,9 +140,9 @@ namespace BlackGui
|
||||
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextAudio()) { return; }
|
||||
ui->sb_Volume->setToolTip(QString::number(volume));
|
||||
Q_ASSERT(sGui->getIContextAudio());
|
||||
if (sGui->getIContextAudio()->getVoiceOutputVolume() != volume)
|
||||
if (sGui->getCContextAudioBase()->getVoiceOutputVolume() != volume)
|
||||
{
|
||||
sGui->getIContextAudio()->setVoiceOutputVolume(volume);
|
||||
sGui->getCContextAudioBase()->setVoiceOutputVolume(volume);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -141,9 +141,9 @@ namespace BlackGui
|
||||
{
|
||||
CLogMessage().validationWarning(u"Invalid SELCAL code");
|
||||
}
|
||||
else if (sGui->getIContextAudio())
|
||||
else if (sGui->getCContextAudioBase())
|
||||
{
|
||||
sGui->getIContextAudio()->playSelcalTone(selcal);
|
||||
sGui->getCContextAudioBase()->playSelcalTone(selcal);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -78,10 +78,10 @@ namespace BlackGui
|
||||
ui->led_DBus->setOn(sGui->getIContextApplication()->isUsingImplementingObject());
|
||||
}
|
||||
|
||||
if (sGui->getIContextAudio())
|
||||
if (sGui->getCContextAudioBase())
|
||||
{
|
||||
ui->led_Audio->setOn(!sGui->getIContextAudio()->isMuted());
|
||||
connect(sGui->getIContextAudio(), &IContextAudio::changedMute, this, &CInfoBarStatusComponent::onMuteChanged);
|
||||
ui->led_Audio->setOn(!sGui->getCContextAudioBase()->isMuted());
|
||||
connect(sGui->getCContextAudioBase(), &CContextAudioBase::changedMute, this, &CInfoBarStatusComponent::onMuteChanged);
|
||||
}
|
||||
|
||||
QPointer<CInfoBarStatusComponent> myself(this);
|
||||
@@ -224,7 +224,7 @@ namespace BlackGui
|
||||
const QList<QAction *> actions = menuAudio.actions();
|
||||
if (selectedItem == actions.at(0))
|
||||
{
|
||||
sGui->getIContextAudio()->setMute(!sGui->getIContextAudio()->isMuted());
|
||||
sGui->getCContextAudioBase()->setMute(!sGui->getCContextAudioBase()->isMuted());
|
||||
}
|
||||
else if (actions.size() > 1 && selectedItem == actions.at(1))
|
||||
{
|
||||
@@ -280,8 +280,8 @@ namespace BlackGui
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
|
||||
IContextSimulator *simCon = sGui->getIContextSimulator();
|
||||
if (sGui->getIContextSimulator())
|
||||
const IContextSimulator *simCon = sGui->getIContextSimulator();
|
||||
if (simCon)
|
||||
{
|
||||
|
||||
this->onSimulatorStatusChanged(simCon->getSimulatorStatus());
|
||||
@@ -302,9 +302,9 @@ namespace BlackGui
|
||||
}
|
||||
|
||||
// audio context can be empty depending on which side it is called
|
||||
if (sGui->getIContextAudio() && !sGui->getIContextAudio()->isEmptyObject())
|
||||
if (sGui->getCContextAudioBase())
|
||||
{
|
||||
ui->led_Audio->setOn(!sGui->getIContextAudio()->isMuted());
|
||||
ui->led_Audio->setOn(!sGui->getCContextAudioBase()->isMuted());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -217,9 +217,9 @@ namespace BlackGui
|
||||
}
|
||||
|
||||
// Login
|
||||
if (sGui && sGui->getIContextAudio())
|
||||
if (sGui && sGui->getCContextAudioBase())
|
||||
{
|
||||
sGui->getIContextAudio()->setVoiceSetup(currentServer.getVoiceSetup());
|
||||
sGui->getCContextAudioBase()->setVoiceSetup(currentServer.getVoiceSetup());
|
||||
}
|
||||
|
||||
msg = sGui->getIContextNetwork()->connectToNetwork(currentServer, values.ownLiverySend, values.useLivery, values.ownAircraftModelStringSend, values.useModelString, partnerCs, mode);
|
||||
|
||||
@@ -317,9 +317,9 @@ namespace BlackGui
|
||||
ownAircraft = sGui->getIContextOwnAircraft()->getOwnAircraft();
|
||||
|
||||
// Login
|
||||
if (sGui->getIContextAudio())
|
||||
if (sGui->getCContextAudioBase())
|
||||
{
|
||||
sGui->getIContextAudio()->setVoiceSetup(currentServer.getVoiceSetup());
|
||||
sGui->getCContextAudioBase()->setVoiceSetup(currentServer.getVoiceSetup());
|
||||
}
|
||||
|
||||
msg = sGui->getIContextNetwork()->connectToNetwork(currentServer, {}, true, {}, true, {}, mode);
|
||||
|
||||
@@ -71,9 +71,9 @@ namespace BlackGui
|
||||
connect(ui->lep_CommandLineInput, &CCommandInput::commandEntered, this, &CMainKeypadAreaComponent::commandEntered);
|
||||
connect(ui->lep_CommandLineInput, &CCommandInput::textEntered, this, &CMainKeypadAreaComponent::textEntered);
|
||||
|
||||
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CMainKeypadAreaComponent::connectionStatusChanged);
|
||||
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CMainKeypadAreaComponent::connectionStatusChanged);
|
||||
connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, this, &CMainKeypadAreaComponent::ownAircraftCockpitChanged);
|
||||
connect(sGui->getIContextAudio(), &IContextAudio::changedMute, this, &CMainKeypadAreaComponent::muteChanged);
|
||||
connect(sGui->getCContextAudioBase(), &CContextAudioBase::changedMute, this, &CMainKeypadAreaComponent::muteChanged);
|
||||
connect(this, &CMainKeypadAreaComponent::commandEntered, sGui->getCoreFacade(), &CCoreFacade::parseCommandLine);
|
||||
|
||||
QPointer<CMainKeypadAreaComponent> myself(this);
|
||||
@@ -138,12 +138,12 @@ namespace BlackGui
|
||||
}
|
||||
else if (senderButton == ui->pb_SoundMaxVolume && sGui->getIContextAudio())
|
||||
{
|
||||
sGui->getIContextAudio()->setVoiceOutputVolume(100);
|
||||
sGui->getCContextAudioBase()->setVoiceOutputVolume(100);
|
||||
}
|
||||
else if (senderButton == ui->pb_SoundMute && sGui->getIContextAudio())
|
||||
{
|
||||
const bool mute = sGui->getIContextAudio()->isMuted();
|
||||
sGui->getIContextAudio()->setMute(!mute);
|
||||
const bool mute = sGui->getCContextAudioBase()->isMuted();
|
||||
sGui->getCContextAudioBase()->setMute(!mute);
|
||||
}
|
||||
else if (senderButton == ui->pb_Connect)
|
||||
{
|
||||
@@ -176,7 +176,7 @@ namespace BlackGui
|
||||
|
||||
void CMainKeypadAreaComponent::ownAircraftCockpitChanged(const CSimulatedAircraft &aircraft, const CIdentifier &originator)
|
||||
{
|
||||
Q_UNUSED(originator);
|
||||
Q_UNUSED(originator)
|
||||
bool ident = aircraft.getTransponder().getTransponderMode() == CTransponder::StateIdent;
|
||||
|
||||
//check state to avoid undelibarate signals
|
||||
@@ -268,9 +268,9 @@ namespace BlackGui
|
||||
void CMainKeypadAreaComponent::update()
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown() || !sGui->supportsContexts()) { return; }
|
||||
if (sGui->getIContextAudio() && !sGui->getIContextAudio()->isEmptyObject())
|
||||
if (sGui->getCContextAudioBase())
|
||||
{
|
||||
this->muteChanged(sGui->getIContextAudio()->isMuted());
|
||||
this->muteChanged(sGui->getCContextAudioBase()->isMuted());
|
||||
}
|
||||
|
||||
if (sGui->getIContextNetwork() && sGui->getIContextNetwork()->isConnected())
|
||||
|
||||
@@ -196,7 +196,7 @@ namespace BlackGui
|
||||
// this is SELCAL for me
|
||||
if (playNotification)
|
||||
{
|
||||
sGui->getIContextAudio()->playSelcalTone(message.getSelcalCode());
|
||||
sGui->getCContextAudioBase()->playSelcalTone(message.getSelcalCode());
|
||||
}
|
||||
|
||||
if (msgSettings.popupSelcalMessages())
|
||||
@@ -231,7 +231,7 @@ namespace BlackGui
|
||||
// callsign mentioned notification
|
||||
if (relevantForMe && audioCsMentioned && ownAircraft.hasCallsign() && message.mentionsCallsign(ownAircraft.getCallsign()))
|
||||
{
|
||||
sGui->getIContextAudio()->playNotification(CNotificationSounds::NotificationTextCallsignMentioned, false);
|
||||
sGui->getCContextAudioBase()->playNotification(CNotificationSounds::NotificationTextCallsignMentioned, false);
|
||||
}
|
||||
}
|
||||
else if (message.isPrivateMessage() && !message.isServerMessage())
|
||||
@@ -536,11 +536,11 @@ namespace BlackGui
|
||||
const CSettings settings = m_audioSettings.get();
|
||||
if (textMessage.isSupervisorMessage() && settings.textMessageSupervisor())
|
||||
{
|
||||
sGui->getIContextAudio()->playNotification(CNotificationSounds::NotificationTextMessageSupervisor, true);
|
||||
sGui->getCContextAudioBase()->playNotification(CNotificationSounds::NotificationTextMessageSupervisor, true);
|
||||
}
|
||||
else if (textMessage.isPrivateMessage() && settings.textMessagePrivate())
|
||||
{
|
||||
sGui->getIContextAudio()->playNotification(CNotificationSounds::NotificationTextMessagePrivate, true);
|
||||
sGui->getCContextAudioBase()->playNotification(CNotificationSounds::NotificationTextMessagePrivate, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user