mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
Preparation for 2 COM keys and increase/decrease volume hotkeys
Ref T672, Ref T642
This commit is contained in:
committed by
Mat Sutcliffe
parent
d509b1eb09
commit
50412aa0d1
@@ -290,6 +290,8 @@ namespace BlackCore
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << volume; }
|
||||
|
||||
bool wasMuted = isMuted();
|
||||
volume = qMin(CSettings::MaxAudioVolume, volume);
|
||||
|
||||
bool changedVoiceOutput = m_voiceOutputDevice->getOutputVolume() != volume;
|
||||
if (changedVoiceOutput)
|
||||
{
|
||||
@@ -588,9 +590,11 @@ namespace BlackCore
|
||||
return false;
|
||||
}
|
||||
|
||||
void CContextAudio::setVoiceTransmission(bool enable)
|
||||
void CContextAudio::setVoiceTransmission(bool enable, COM com)
|
||||
{
|
||||
// FIXME: Use the 'active' channel instead of hardcoded COM1
|
||||
// FIXME: Use com
|
||||
Q_UNUSED(com);
|
||||
if (!m_voiceChannelMapping.contains(CComSystem::Com1)) { return; }
|
||||
QSharedPointer<IVoiceChannel> voiceChannelCom1 = m_voiceChannelMapping.value(CComSystem::Com1);
|
||||
IAudioMixer::OutputPort mixerOutputPort = m_voiceChannelOutputPortMapping.value(voiceChannelCom1);
|
||||
@@ -606,6 +610,21 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void CContextAudio::setVoiceTransmissionCom1(bool enabled)
|
||||
{
|
||||
this->setVoiceTransmission(enabled, COM1);
|
||||
}
|
||||
|
||||
void CContextAudio::setVoiceTransmissionCom2(bool enabled)
|
||||
{
|
||||
this->setVoiceTransmission(enabled, COM2);
|
||||
}
|
||||
|
||||
void CContextAudio::setVoiceTransmissionComActive(bool enabled)
|
||||
{
|
||||
this->setVoiceTransmission(enabled, COMActive);
|
||||
}
|
||||
|
||||
void CContextAudio::onConnectionStatusChanged(BlackCore::IVoiceChannel::ConnectionStatus oldStatus,
|
||||
BlackCore::IVoiceChannel::ConnectionStatus newStatus)
|
||||
{
|
||||
@@ -677,6 +696,20 @@ namespace BlackCore
|
||||
this->setVoiceOutputVolume(s.getAudioVolume());
|
||||
}
|
||||
|
||||
void CContextAudio::audioIncreaseVolume(bool enabled)
|
||||
{
|
||||
if (!enabled) { return; }
|
||||
const int v = qRound(this->getVoiceOutputVolume() * 1.2);
|
||||
this->setVoiceOutputVolume(v);
|
||||
}
|
||||
|
||||
void CContextAudio::audioDecreaseVolume(bool enabled)
|
||||
{
|
||||
if (!enabled) { return; }
|
||||
const int v = qRound(this->getVoiceOutputVolume() / 1.2);
|
||||
this->setVoiceOutputVolume(v);
|
||||
}
|
||||
|
||||
QSharedPointer<IVoiceChannel> CContextAudio::getVoiceChannelBy(const CVoiceRoom &voiceRoom)
|
||||
{
|
||||
QSharedPointer<IVoiceChannel> voiceChannel;
|
||||
|
||||
@@ -121,6 +121,15 @@ namespace BlackCore
|
||||
CContextAudio *registerWithDBus(BlackMisc::CDBusServer *server);
|
||||
|
||||
private:
|
||||
// Voice COM channel
|
||||
enum COM
|
||||
{
|
||||
COM1,
|
||||
COM2,
|
||||
COMActive,
|
||||
COMUnspecified
|
||||
};
|
||||
|
||||
void initVoiceChannels();
|
||||
void initInputDevice();
|
||||
void initOutputDevice();
|
||||
@@ -131,8 +140,12 @@ namespace BlackCore
|
||||
//! \sa IContextAudio::changedVoiceRooms
|
||||
void onConnectionStatusChanged(IVoiceChannel::ConnectionStatus oldStatus, IVoiceChannel::ConnectionStatus newStatus);
|
||||
|
||||
//! Enable/disable voice transmission
|
||||
void setVoiceTransmission(bool enable);
|
||||
//! Enable/disable voice transmission @{
|
||||
void setVoiceTransmission(bool enable, COM com);
|
||||
void setVoiceTransmissionCom1(bool enabled);
|
||||
void setVoiceTransmissionCom2(bool enabled);
|
||||
void setVoiceTransmissionComActive(bool enabled);
|
||||
//! @}
|
||||
|
||||
//! User joined the room
|
||||
void onUserJoinedRoom(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
@@ -149,20 +162,29 @@ namespace BlackCore
|
||||
//! Changed audio settings
|
||||
void onChangedAudioSettings();
|
||||
|
||||
//! Audio increase/decrease @{
|
||||
void audioIncreaseVolume(bool enabled);
|
||||
void audioDecreaseVolume(bool enabled);
|
||||
//! @}
|
||||
|
||||
//! Voice channel by room
|
||||
QSharedPointer<IVoiceChannel> getVoiceChannelBy(const BlackMisc::Audio::CVoiceRoom &voiceRoom);
|
||||
|
||||
CActionBind m_actionPtt { BlackMisc::Input::pttHotkeyAction(), BlackMisc::Input::pttHotkeyIcon(), this, &CContextAudio::setVoiceTransmission };
|
||||
CActionBind m_actionPtt { BlackMisc::Input::pttHotkeyAction(), BlackMisc::Input::pttHotkeyIcon(), this, &CContextAudio::setVoiceTransmissionComActive };
|
||||
CActionBind m_actionPttCom1 { BlackMisc::Input::pttCom1HotkeyAction(), BlackMisc::Input::pttHotkeyIcon(), this, &CContextAudio::setVoiceTransmissionCom1 };
|
||||
CActionBind m_actionPttCom2 { BlackMisc::Input::pttCom2HotkeyAction(), BlackMisc::Input::pttHotkeyIcon(), this, &CContextAudio::setVoiceTransmissionCom2 };
|
||||
CActionBind m_actionAudioVolumeIncrease { BlackMisc::Input::audioVolumeIncreaseHotkeyAction(), BlackMisc::Input::audioVolumeIncreaseHotkeyIcon(), this, &CContextAudio::audioIncreaseVolume };
|
||||
CActionBind m_actionAudioVolumeDecrease { BlackMisc::Input::audioVolumeDecreaseHotkeyAction(), BlackMisc::Input::audioVolumeDecreaseHotkeyIcon(), this, &CContextAudio::audioDecreaseVolume };
|
||||
|
||||
std::unique_ptr<IVoice> m_voice; //!< underlying voice lib
|
||||
std::unique_ptr<IAudioMixer> m_audioMixer;
|
||||
const int MinUnmuteVolume = 20; //!< minimum volume when unmuted
|
||||
int m_outVolumeBeforeMute = 90;
|
||||
static constexpr int MinUnmuteVolume = 20; //!< minimum volume when unmuted
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
#ifdef Q_OS_MAC
|
||||
BlackMisc::CMacOSMicrophoneAccess m_micAccess;
|
||||
void delayedInitMicrophone();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// For easy access.
|
||||
QSharedPointer<IVoiceChannel> m_channel1;
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace BlackCore
|
||||
if (!m_availableActions.contains(action))
|
||||
{
|
||||
m_availableActions.insert(action, icon);
|
||||
emit hotkeyActionRegistered({ action });
|
||||
emit this->hotkeyActionRegistered({ action });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace BlackCore
|
||||
if (!m_availableActions.contains(action))
|
||||
{
|
||||
m_availableActions.insert(action, {});
|
||||
emit hotkeyActionRegistered({ action });
|
||||
emit this->hotkeyActionRegistered({ action });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ namespace BlackGui
|
||||
CIdentifierList CSettingsHotkeyComponent::getAllIdentifiers() const
|
||||
{
|
||||
CIdentifierList identifiers;
|
||||
if (!sGui) { return identifiers; }
|
||||
if (!sGui || !sGui->getIContextApplication()) { return identifiers; }
|
||||
if (sGui->getIContextApplication()) { identifiers = sGui->getIContextApplication()->getRegisteredApplications(); }
|
||||
|
||||
// add local application
|
||||
@@ -188,7 +188,7 @@ namespace BlackGui
|
||||
{
|
||||
if (keyDown)
|
||||
{
|
||||
QMessageBox* msgBox = new QMessageBox(this);
|
||||
QMessageBox *msgBox = new QMessageBox(this);
|
||||
msgBox->setAttribute(Qt::WA_DeleteOnClose);
|
||||
msgBox->setStandardButtons(QMessageBox::Ok);
|
||||
msgBox->setWindowTitle("Test");
|
||||
|
||||
@@ -22,5 +22,39 @@ namespace BlackMisc
|
||||
{
|
||||
return CIcons::radio16();
|
||||
}
|
||||
|
||||
const QString &pttCom1HotkeyAction()
|
||||
{
|
||||
static const QString s("/Voice/Activate push-to-talk COM1");
|
||||
return s;
|
||||
}
|
||||
|
||||
const QString &pttCom2HotkeyAction()
|
||||
{
|
||||
static const QString s("/Voice/Activate push-to-talk COM2");
|
||||
return s;
|
||||
}
|
||||
|
||||
const QPixmap &audioVolumeDecreaseHotkeyIcon()
|
||||
{
|
||||
return CIcons::volumeLow16();
|
||||
}
|
||||
|
||||
const QPixmap &audioVolumeIncreaseHotkeyIcon()
|
||||
{
|
||||
return CIcons::volumeHigh16();
|
||||
}
|
||||
|
||||
const QString &audioVolumeDecreaseHotkeyAction()
|
||||
{
|
||||
static const QString s("/Audio/Volume decrease");
|
||||
return s;
|
||||
}
|
||||
|
||||
const QString &audioVolumeIncreaseHotkeyAction()
|
||||
{
|
||||
static const QString s("/Audio/Volume increase");
|
||||
return s;
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -23,8 +23,27 @@ namespace BlackMisc
|
||||
//! PTT key
|
||||
BLACKMISC_EXPORT const QString &pttHotkeyAction();
|
||||
|
||||
//! PTT key COM1 only
|
||||
BLACKMISC_EXPORT const QString &pttCom1HotkeyAction();
|
||||
|
||||
//! PTT key COM2 only
|
||||
BLACKMISC_EXPORT const QString &pttCom2HotkeyAction();
|
||||
|
||||
//! PTT key
|
||||
BLACKMISC_EXPORT const QPixmap &pttHotkeyIcon();
|
||||
|
||||
//! Audio volume + key
|
||||
BLACKMISC_EXPORT const QString &audioVolumeIncreaseHotkeyAction();
|
||||
|
||||
//! Audio volume - key
|
||||
BLACKMISC_EXPORT const QString &audioVolumeDecreaseHotkeyAction();
|
||||
|
||||
//! Audio icon volume +
|
||||
BLACKMISC_EXPORT const QPixmap &audioVolumeIncreaseHotkeyIcon();
|
||||
|
||||
//! Audio icon volume -
|
||||
BLACKMISC_EXPORT const QPixmap &audioVolumeDecreaseHotkeyIcon();
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
|
||||
Reference in New Issue
Block a user