mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-15 01:05:35 +08:00
Ref T731, adjusted audio settings for AFV and added functions in UI component
This commit is contained in:
committed by
Mat Sutcliffe
parent
d944d0f6ee
commit
4a578110b0
@@ -38,6 +38,8 @@ namespace BlackGui
|
||||
ui(new Ui::CAudioDeviceVolumeSetupComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->hs_VolumeIn, &QSlider::valueChanged, this, &CAudioDeviceVolumeSetupComponent::onVolumeSliderChanged);
|
||||
connect(ui->hs_VolumeOut, &QSlider::valueChanged, this, &CAudioDeviceVolumeSetupComponent::onVolumeSliderChanged);
|
||||
|
||||
// deferred init, because in a distributed swift system
|
||||
// it takes a moment until the settings are sychronized
|
||||
@@ -64,7 +66,7 @@ namespace BlackGui
|
||||
|
||||
if (audio)
|
||||
{
|
||||
ui->le_ExtraInfo->setText(audio ? sGui->getIContextAudio()->audioRunsWhereInfo() : "No audio, cannot change.");
|
||||
ui->le_Info->setText(audio ? sGui->getIContextAudio()->audioRunsWhereInfo() : "No audio, cannot change.");
|
||||
|
||||
this->initAudioDeviceLists();
|
||||
|
||||
@@ -89,9 +91,76 @@ namespace BlackGui
|
||||
CAudioDeviceVolumeSetupComponent::~CAudioDeviceVolumeSetupComponent()
|
||||
{ }
|
||||
|
||||
int CAudioDeviceVolumeSetupComponent::getInValue(int from, int to) const
|
||||
{
|
||||
const double r = ui->hs_VolumeIn->maximum() - ui->hs_VolumeIn->minimum();
|
||||
const double tr = to - from;
|
||||
return qRound(ui->hs_VolumeIn->value() / r * tr);
|
||||
}
|
||||
|
||||
int CAudioDeviceVolumeSetupComponent::getOutValue(int from, int to) const
|
||||
{
|
||||
const double r = ui->hs_VolumeOut->maximum() - ui->hs_VolumeOut->minimum();
|
||||
const double tr = to - from;
|
||||
return qRound(ui->hs_VolumeOut->value() / r * tr);
|
||||
}
|
||||
|
||||
void CAudioDeviceVolumeSetupComponent::setInValue(int value, int from, int to)
|
||||
{
|
||||
if (value > to) { value = to; }
|
||||
if (value < from) { value = from; }
|
||||
const double r = ui->hs_VolumeIn->maximum() - ui->hs_VolumeIn->minimum();
|
||||
const double tr = to - from;
|
||||
ui->hs_VolumeIn->setValue(qRound(value / tr * r));
|
||||
}
|
||||
|
||||
void CAudioDeviceVolumeSetupComponent::setOutValue(int value, int from, int to)
|
||||
{
|
||||
if (value > to) { value = to; }
|
||||
if (value < from) { value = from; }
|
||||
const double r = ui->hs_VolumeOut->maximum() - ui->hs_VolumeOut->minimum();
|
||||
const double tr = to - from;
|
||||
ui->hs_VolumeOut->setValue(qRound(value / tr * r));
|
||||
}
|
||||
|
||||
void CAudioDeviceVolumeSetupComponent::setInLevel(int value, int from, int to)
|
||||
{
|
||||
if (value > to) { value = to; }
|
||||
if (value < from) { value = from; }
|
||||
const double r = ui->pb_LevelIn->maximum() - ui->pb_LevelIn->minimum();
|
||||
const double tr = to - from;
|
||||
ui->pb_LevelIn->setValue(qRound(value / tr * r));
|
||||
}
|
||||
|
||||
void CAudioDeviceVolumeSetupComponent::setOutLevel(int value, int from, int to)
|
||||
{
|
||||
if (value > to) { value = to; }
|
||||
if (value < from) { value = from; }
|
||||
const double r = ui->pb_LevelOut->maximum() - ui->pb_LevelOut->minimum();
|
||||
const double tr = to - from;
|
||||
ui->pb_LevelOut->setValue(qRound(value / tr * r));
|
||||
}
|
||||
|
||||
void CAudioDeviceVolumeSetupComponent::setInfo(const QString &info)
|
||||
{
|
||||
ui->le_Info->setText(info);
|
||||
}
|
||||
|
||||
void CAudioDeviceVolumeSetupComponent::setTransmitReceive(bool tx1, bool rec1, bool tx2, bool rec2)
|
||||
{
|
||||
ui->cb_1Tx->setChecked(tx1);
|
||||
ui->cb_2Tx->setChecked(tx2);
|
||||
ui->cb_1Rec->setChecked(rec1);
|
||||
ui->cb_2Rec->setChecked(rec2);
|
||||
}
|
||||
|
||||
void CAudioDeviceVolumeSetupComponent::reloadSettings()
|
||||
{
|
||||
const CSettings as(m_audioSettings.getThreadLocal());
|
||||
ui->cb_DisableAudioEffects->setChecked(as.isAudioEffectsEnabled());
|
||||
|
||||
this->setInValue(as.getInVolume());
|
||||
this->setOutValue(as.getInVolume());
|
||||
}
|
||||
|
||||
void CAudioDeviceVolumeSetupComponent::initAudioDeviceLists()
|
||||
@@ -106,6 +175,23 @@ namespace BlackGui
|
||||
return sGui && sGui->getIContextAudio() && !sGui->getIContextAudio()->isEmptyObject();
|
||||
}
|
||||
|
||||
void CAudioDeviceVolumeSetupComponent::onVolumeSliderChanged(int v)
|
||||
{
|
||||
Q_UNUSED(v);
|
||||
m_volumeSliderChanged.inputSignal();
|
||||
}
|
||||
|
||||
void CAudioDeviceVolumeSetupComponent::saveVolumes()
|
||||
{
|
||||
CSettings as(m_audioSettings.getThreadLocal());
|
||||
const int i = this->getInValue();
|
||||
const int o = this->getOutValue();
|
||||
if (as.getInVolume() == i && as.getOutVolume() == o) { return; }
|
||||
as.setInVolume(i);
|
||||
as.setOutVolume(o);
|
||||
m_audioSettings.setAndSave(as);
|
||||
}
|
||||
|
||||
void CAudioDeviceVolumeSetupComponent::onAudioDeviceSelected(int index)
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextAudio()) { return; }
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "blackmisc/audio/audiosettings.h"
|
||||
#include "blackmisc/audio/audiodeviceinfolist.h"
|
||||
#include "blackmisc/settingscache.h"
|
||||
#include "blackmisc/digestsignal.h"
|
||||
|
||||
#include <QFrame>
|
||||
#include <QCheckBox>
|
||||
@@ -38,6 +39,27 @@ namespace BlackGui
|
||||
//! Destructor
|
||||
virtual ~CAudioDeviceVolumeSetupComponent() override;
|
||||
|
||||
//! Get input and output volume values @{
|
||||
int getInValue(int from = BlackMisc::Audio::CSettings::InMin, int to = BlackMisc::Audio::CSettings::InMax) const;
|
||||
int getOutValue(int from = BlackMisc::Audio::CSettings::OutMin, int to = BlackMisc::Audio::CSettings::OutMax) const;
|
||||
//! @}
|
||||
|
||||
//! Set input and output volume values @{
|
||||
void setInValue(int value, int from = BlackMisc::Audio::CSettings::InMin, int to = BlackMisc::Audio::CSettings::InMax);
|
||||
void setOutValue(int value, int from = BlackMisc::Audio::CSettings::OutMin, int to = BlackMisc::Audio::CSettings::OutMax);
|
||||
//! @}
|
||||
|
||||
//! Set input and output level values @{
|
||||
void setInLevel(int value, int from = BlackMisc::Audio::CSettings::InMin, int to = BlackMisc::Audio::CSettings::InMax);
|
||||
void setOutLevel(int value, int from = BlackMisc::Audio::CSettings::OutMin, int to = BlackMisc::Audio::CSettings::OutMax);
|
||||
//! @}
|
||||
|
||||
//! Info string
|
||||
void setInfo(const QString &info);
|
||||
|
||||
//! Transmit and receive state
|
||||
void setTransmitReceive(bool tx1, bool rec1, bool tx2, bool rec2);
|
||||
|
||||
private:
|
||||
//! Init
|
||||
void init();
|
||||
@@ -58,16 +80,20 @@ namespace BlackGui
|
||||
//! Loopback toggled
|
||||
void onLoopbackToggled(bool loopback);
|
||||
|
||||
//! Notification flags toggled
|
||||
void onNotificationsToggled(bool checked);
|
||||
|
||||
//! Audio device lists from settings
|
||||
void initAudioDeviceLists();
|
||||
|
||||
//! Audio is optional, check if available
|
||||
bool hasAudio() const;
|
||||
|
||||
//! Volume slider has been changed
|
||||
void onVolumeSliderChanged(int v);
|
||||
|
||||
//! Save the audio volumes
|
||||
void saveVolumes();
|
||||
|
||||
QScopedPointer<Ui::CAudioDeviceVolumeSetupComponent> ui;
|
||||
BlackMisc::CDigestSignal m_volumeSliderChanged { this, &CAudioDeviceVolumeSetupComponent::saveVolumes, 1000, 10 };
|
||||
BlackMisc::CSetting<BlackMisc::Audio::TSettings> m_audioSettings { this, &CAudioDeviceVolumeSetupComponent::reloadSettings };
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>194</width>
|
||||
<height>216</height>
|
||||
<width>307</width>
|
||||
<height>254</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -15,7 +15,7 @@
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="le_ExtraInfo">
|
||||
<widget class="QLineEdit" name="le_Info">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@@ -24,92 +24,27 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QProgressBar" name="pb_LevelOut">
|
||||
<property name="value">
|
||||
<number>24</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="cb_SetupAudioOutputDevice">
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="lbl_VolumeOut">
|
||||
<property name="text">
|
||||
<string>Out</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_SetupAudioInputDevice">
|
||||
<property name="text">
|
||||
<string>In</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_SetupAudioOutputDevice">
|
||||
<property name="text">
|
||||
<string>Out</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QSlider" name="hs_VolumeOut">
|
||||
<property name="value">
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QCheckBox" name="cb_DisableAudioEffects">
|
||||
<property name="text">
|
||||
<string>Disable realistic audio simulation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QCheckBox" name="cb_SetupAudioLoopback">
|
||||
<property name="text">
|
||||
<string>Loopback, test sound in- to output</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="cb_SetupAudioInputDevice">
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
|
||||
</property>
|
||||
<property name="frame">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QProgressBar" name="pb_LevelIn">
|
||||
<item row="9" column="1">
|
||||
<widget class="QProgressBar" name="pb_LevelOut">
|
||||
<property name="value">
|
||||
<number>24</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="lbl_VolumeIn">
|
||||
<property name="text">
|
||||
<string>In</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QSlider" name="hs_VolumeIn">
|
||||
<property name="value">
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_Info">
|
||||
<property name="text">
|
||||
@@ -117,27 +52,136 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="6" column="1">
|
||||
<widget class="QSlider" name="hs_VolumeIn">
|
||||
<property name="value">
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_SetupAudioInputDevice">
|
||||
<property name="text">
|
||||
<string>In</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="cb_SetupAudioOutputDevice">
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbl_SetupAudioOutputDevice">
|
||||
<property name="text">
|
||||
<string>Out</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="lbl_VolumeIn">
|
||||
<property name="text">
|
||||
<string>In</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="cb_SetupAudioInputDevice">
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
|
||||
</property>
|
||||
<property name="frame">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="lbl_SetupAudioLoopback">
|
||||
<property name="text">
|
||||
<string>Test</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="text">
|
||||
<string>Disable realistic audio simulation</string>
|
||||
<item row="7" column="1">
|
||||
<widget class="QProgressBar" name="pb_LevelIn">
|
||||
<property name="value">
|
||||
<number>50</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="lbl_VolumeOut">
|
||||
<property name="text">
|
||||
<string>Out</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QSlider" name="hs_VolumeOut">
|
||||
<property name="value">
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QFrame" name="fr_TxRec">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_1Tx">
|
||||
<property name="text">
|
||||
<string>Tx1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_1Rec">
|
||||
<property name="text">
|
||||
<string>Rec1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_2Tx">
|
||||
<property name="text">
|
||||
<string>Tx2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_2Rec">
|
||||
<property name="text">
|
||||
<string>Rec2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>le_ExtraInfo</tabstop>
|
||||
<tabstop>le_Info</tabstop>
|
||||
<tabstop>cb_1Tx</tabstop>
|
||||
<tabstop>cb_1Rec</tabstop>
|
||||
<tabstop>cb_2Tx</tabstop>
|
||||
<tabstop>cb_2Rec</tabstop>
|
||||
<tabstop>cb_SetupAudioInputDevice</tabstop>
|
||||
<tabstop>cb_SetupAudioOutputDevice</tabstop>
|
||||
<tabstop>checkBox</tabstop>
|
||||
<tabstop>cb_DisableAudioEffects</tabstop>
|
||||
<tabstop>cb_SetupAudioLoopback</tabstop>
|
||||
<tabstop>hs_VolumeIn</tabstop>
|
||||
<tabstop>hs_VolumeOut</tabstop>
|
||||
|
||||
Reference in New Issue
Block a user