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