mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-28 11:45:40 +08:00
Issue #100 Add slider for master output volume
This commit is contained in:
@@ -48,11 +48,13 @@ namespace BlackGui
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->hs_VolumeIn, &QSlider::valueChanged, this, &CAudioDeviceVolumeSetupComponent::onVolumeSliderChanged);
|
||||
connect(ui->hs_VolumeOut, &QSlider::valueChanged, this, &CAudioDeviceVolumeSetupComponent::onVolumeSliderChanged);
|
||||
connect(ui->hs_VolumeOutCom1, &QSlider::valueChanged, this, &CAudioDeviceVolumeSetupComponent::onVolumeSliderChanged);
|
||||
connect(ui->hs_VolumeOutCom2, &QSlider::valueChanged, this, &CAudioDeviceVolumeSetupComponent::onVolumeSliderChanged);
|
||||
connect(ui->tb_RefreshInDevice, &QToolButton::released, this, &CAudioDeviceVolumeSetupComponent::onReloadDevices, Qt::QueuedConnection);
|
||||
connect(ui->tb_RefreshOutDevice, &QToolButton::released, this, &CAudioDeviceVolumeSetupComponent::onReloadDevices, Qt::QueuedConnection);
|
||||
connect(ui->tb_ResetInVolume, &QToolButton::released, this, &CAudioDeviceVolumeSetupComponent::onResetVolumeIn, Qt::QueuedConnection);
|
||||
connect(ui->tb_ResetOutVolume, &QToolButton::released, this, &CAudioDeviceVolumeSetupComponent::onResetVolumeOut, Qt::QueuedConnection);
|
||||
connect(ui->tb_ResetOutVolumeCom1, &QToolButton::released, this, &CAudioDeviceVolumeSetupComponent::onResetVolumeOutCom1, Qt::QueuedConnection);
|
||||
connect(ui->tb_ResetOutVolumeCom2, &QToolButton::released, this, &CAudioDeviceVolumeSetupComponent::onResetVolumeOutCom2, Qt::QueuedConnection);
|
||||
|
||||
@@ -64,6 +66,8 @@ namespace BlackGui
|
||||
|
||||
ui->hs_VolumeIn->setMaximum(CSettings::InMax);
|
||||
ui->hs_VolumeIn->setMinimum(CSettings::InMin);
|
||||
ui->hs_VolumeOut->setMaximum(CSettings::OutMax);
|
||||
ui->hs_VolumeOut->setMinimum(CSettings::OutMin);
|
||||
ui->hs_VolumeOutCom1->setMaximum(CSettings::OutMax);
|
||||
ui->hs_VolumeOutCom1->setMinimum(CSettings::OutMin);
|
||||
ui->hs_VolumeOutCom2->setMaximum(CSettings::OutMax);
|
||||
@@ -71,9 +75,11 @@ namespace BlackGui
|
||||
|
||||
const CSettings as(m_audioSettings.getThreadLocal());
|
||||
const int i = this->getInValue();
|
||||
const int o = this->getOutValue();
|
||||
const int o1 = this->getOutValueCom1();
|
||||
const int o2 = this->getOutValueCom2();
|
||||
ui->hs_VolumeIn->setValue(i);
|
||||
ui->hs_VolumeOut->setValue(o);
|
||||
ui->hs_VolumeOutCom1->setValue(o1);
|
||||
ui->hs_VolumeOutCom2->setValue(o2);
|
||||
ui->cb_SetupAudioLoopback->setChecked(false);
|
||||
@@ -97,6 +103,7 @@ namespace BlackGui
|
||||
});
|
||||
|
||||
this->setCheckBoxesReadOnly(this->isComIntegrated());
|
||||
this->setVolumeSlidersReadOnly(this->isComIntegrated());
|
||||
}
|
||||
|
||||
void CAudioDeviceVolumeSetupComponent::init()
|
||||
@@ -189,6 +196,13 @@ namespace BlackGui
|
||||
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);
|
||||
}
|
||||
|
||||
int CAudioDeviceVolumeSetupComponent::getOutValueCom1(int from, int to) const
|
||||
{
|
||||
const double r = ui->hs_VolumeOutCom1->maximum() - ui->hs_VolumeOutCom1->minimum();
|
||||
@@ -212,6 +226,15 @@ namespace BlackGui
|
||||
ui->hs_VolumeIn->setValue(qRound(value / tr * r));
|
||||
}
|
||||
|
||||
void CAudioDeviceVolumeSetupComponent::setOutValue(int value, int from, int to)
|
||||
{
|
||||
if (value > to) { value = to; }
|
||||
else 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::setOutValueCom1(int value, int from, int to)
|
||||
{
|
||||
if (value > to) { value = to; }
|
||||
@@ -255,6 +278,7 @@ namespace BlackGui
|
||||
this->setRxTxCheckboxes(rec1, tx1, rec2, tx2);
|
||||
ui->cb_IntegratedWithCom->setChecked(integrated);
|
||||
this->setCheckBoxesReadOnly(integrated);
|
||||
this->setVolumeSlidersReadOnly(integrated);
|
||||
}
|
||||
|
||||
void CAudioDeviceVolumeSetupComponent::setTransmitReceiveInUiFromVoiceClient()
|
||||
@@ -282,10 +306,13 @@ namespace BlackGui
|
||||
this->setTransmitReceiveInUi(com1Tx, com1Rx, com2Tx, com2Rx, integrated);
|
||||
|
||||
// Set transmit volume in GUI
|
||||
const int vol1 = sGui->getCContextAudioBase()->getVoiceOutputVolume(CComSystem::Com1);
|
||||
const int vol2 = sGui->getCContextAudioBase()->getVoiceOutputVolume(CComSystem::Com2);
|
||||
ui->hs_VolumeOutCom1->setValue(vol1);
|
||||
ui->hs_VolumeOutCom2->setValue(vol2);
|
||||
if (integrated)
|
||||
{
|
||||
const int vol1 = sGui->getCContextAudioBase()->getComOutputVolume(CComSystem::Com1);
|
||||
const int vol2 = sGui->getCContextAudioBase()->getComOutputVolume(CComSystem::Com2);
|
||||
ui->hs_VolumeOutCom1->setValue(vol1);
|
||||
ui->hs_VolumeOutCom2->setValue(vol2);
|
||||
}
|
||||
}
|
||||
|
||||
void CAudioDeviceVolumeSetupComponent::setCheckBoxesReadOnly(bool readonly)
|
||||
@@ -297,6 +324,23 @@ namespace BlackGui
|
||||
CGuiUtility::checkBoxReadOnly(ui->cb_2Rec, readonly);
|
||||
}
|
||||
|
||||
void CAudioDeviceVolumeSetupComponent::setVolumeSlidersReadOnly(bool readonly)
|
||||
{
|
||||
ui->hs_VolumeOutCom1->setDisabled(readonly);
|
||||
ui->hs_VolumeOutCom2->setDisabled(readonly);
|
||||
if (readonly)
|
||||
{
|
||||
// \fixme hardcoded stylesheet setting, should come from stylesheet")
|
||||
ui->hs_VolumeOutCom1->setStyleSheet("background: rgb(40,40,40)");
|
||||
ui->hs_VolumeOutCom2->setStyleSheet("background: rgb(40,40,40)");
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->hs_VolumeOutCom1->setStyleSheet("");
|
||||
ui->hs_VolumeOutCom2->setStyleSheet("");
|
||||
}
|
||||
}
|
||||
|
||||
CAfvClient *CAudioDeviceVolumeSetupComponent::afvClient()
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown() || !sGui->getCContextAudioBase()) { return nullptr; }
|
||||
@@ -308,6 +352,7 @@ namespace BlackGui
|
||||
const CSettings as(m_audioSettings.getThreadLocal());
|
||||
ui->cb_DisableAudioEffects->setChecked(!as.isAudioEffectsEnabled());
|
||||
this->setInValue(as.getInVolume());
|
||||
this->setOutValue(as.getOutVolume());
|
||||
this->setOutValueCom1(as.getOutVolumeCom1());
|
||||
this->setOutValueCom2(as.getOutVolumeCom2());
|
||||
}
|
||||
@@ -341,10 +386,13 @@ namespace BlackGui
|
||||
{
|
||||
CSettings as(m_audioSettings.getThreadLocal());
|
||||
const int i = this->getInValue();
|
||||
const int o = this->getOutValue();
|
||||
const int o1 = this->getOutValueCom1();
|
||||
const int o2 = this->getOutValueCom2();
|
||||
if (as.getInVolume() == i && as.getOutVolumeCom1() == o1 && as.getOutVolumeCom2() == o2) { return; }
|
||||
if (as.getInVolume() == i && o == as.getOutVolume() &&
|
||||
as.getOutVolumeCom1() == o1 && as.getOutVolumeCom2() == o2) { return; }
|
||||
as.setInVolume(i);
|
||||
as.setOutVolume(o);
|
||||
as.setOutVolumeCom1(o1);
|
||||
as.setOutVolumeCom2(o2);
|
||||
m_audioSettings.setAndSave(as);
|
||||
@@ -374,14 +422,19 @@ namespace BlackGui
|
||||
ui->hs_VolumeIn->setValue((ui->hs_VolumeIn->maximum() - ui->hs_VolumeIn->minimum()) / 2);
|
||||
}
|
||||
|
||||
void CAudioDeviceVolumeSetupComponent::onResetVolumeOut()
|
||||
{
|
||||
ui->hs_VolumeOut->setValue((ui->hs_VolumeOut->maximum() - ui->hs_VolumeOut->minimum()) / 2);
|
||||
}
|
||||
|
||||
void CAudioDeviceVolumeSetupComponent::onResetVolumeOutCom1()
|
||||
{
|
||||
ui->hs_VolumeOutCom1->setValue((ui->hs_VolumeOutCom1->maximum() - ui->hs_VolumeOutCom1->minimum()) / 2);
|
||||
ui->hs_VolumeOutCom1->setValue(ui->hs_VolumeOutCom1->maximum());
|
||||
}
|
||||
|
||||
void CAudioDeviceVolumeSetupComponent::onResetVolumeOutCom2()
|
||||
{
|
||||
ui->hs_VolumeOutCom2->setValue((ui->hs_VolumeOutCom2->maximum() - ui->hs_VolumeOutCom2->minimum()) / 2);
|
||||
ui->hs_VolumeOutCom2->setValue(ui->hs_VolumeOutCom2->maximum());
|
||||
}
|
||||
|
||||
void CAudioDeviceVolumeSetupComponent::setAudioRunsWhere()
|
||||
@@ -397,6 +450,7 @@ namespace BlackGui
|
||||
if (ui->cb_IntegratedWithCom->isChecked() == integrate) { return integrate; }
|
||||
ui->cb_IntegratedWithCom->setChecked(integrate);
|
||||
this->setCheckBoxesReadOnly(integrate);
|
||||
this->setVolumeSlidersReadOnly(integrate);
|
||||
return integrate;
|
||||
}
|
||||
|
||||
@@ -441,6 +495,7 @@ namespace BlackGui
|
||||
{
|
||||
if (!this->hasAudio()) { return; }
|
||||
this->setCheckBoxesReadOnly(checked);
|
||||
this->setVolumeSlidersReadOnly(checked);
|
||||
|
||||
if (!this->hasSimulator()) { return; }
|
||||
if (!sGui->getIContextSimulator()->isSimulatorAvailable()) { return; }
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace BlackGui
|
||||
//! 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;
|
||||
int getOutValueCom1(int from = BlackMisc::Audio::CSettings::OutMin, int to = BlackMisc::Audio::CSettings::OutMax) const;
|
||||
int getOutValueCom2(int from = BlackMisc::Audio::CSettings::OutMin, int to = BlackMisc::Audio::CSettings::OutMax) const;
|
||||
//! @}
|
||||
@@ -52,6 +53,7 @@ namespace BlackGui
|
||||
//! 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::InMin, int to = BlackMisc::Audio::CSettings::InMax);
|
||||
void setOutValueCom1(int value, int from = BlackMisc::Audio::CSettings::OutMin, int to = BlackMisc::Audio::CSettings::OutMax);
|
||||
void setOutValueCom2(int value, int from = BlackMisc::Audio::CSettings::OutMin, int to = BlackMisc::Audio::CSettings::OutMax);
|
||||
//! @}
|
||||
@@ -114,6 +116,7 @@ namespace BlackGui
|
||||
|
||||
void onReloadDevices();
|
||||
void onResetVolumeIn();
|
||||
void onResetVolumeOut();
|
||||
void onResetVolumeOutCom1();
|
||||
void onResetVolumeOutCom2();
|
||||
|
||||
@@ -142,6 +145,9 @@ namespace BlackGui
|
||||
//! Checkboxes readonly?
|
||||
void setCheckBoxesReadOnly(bool readonly);
|
||||
|
||||
//! Volume sliders readlonly?
|
||||
void setVolumeSlidersReadOnly(bool readonly);
|
||||
|
||||
//! Direct access to client
|
||||
static BlackCore::Afv::Clients::CAfvClient *afvClient();
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="3">
|
||||
<widget class="QToolButton" name="tb_ResetOutVolumeCom1">
|
||||
<widget class="QToolButton" name="tb_ResetOutVolume">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
@@ -136,6 +136,17 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="3">
|
||||
<widget class="QToolButton" name="tb_ResetOutVolumeCom1">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../blackmisc/blackmisc.qrc">
|
||||
<normaloff>:/pastel/icons/pastel/16/undo.png</normaloff>:/pastel/icons/pastel/16/undo.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="3">
|
||||
<widget class="QToolButton" name="tb_ResetOutVolumeCom2">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
@@ -147,13 +158,20 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<widget class="QLabel" name="lbl_VolumeOut">
|
||||
<property name="text">
|
||||
<string>Out Master</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0">
|
||||
<widget class="QLabel" name="lbl_VolumeOutCom1">
|
||||
<property name="text">
|
||||
<string>Out COM1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0">
|
||||
<item row="13" column="0">
|
||||
<widget class="QLabel" name="lbl_VolumeOutCom2">
|
||||
<property name="text">
|
||||
<string>Out COM2</string>
|
||||
@@ -303,7 +321,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="1">
|
||||
<widget class="QSlider" name="hs_VolumeOutCom1">
|
||||
<widget class="QSlider" name="hs_VolumeOut">
|
||||
<property name="value">
|
||||
<number>50</number>
|
||||
</property>
|
||||
@@ -313,6 +331,16 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="1">
|
||||
<widget class="QSlider" name="hs_VolumeOutCom1">
|
||||
<property name="value">
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="1">
|
||||
<widget class="QSlider" name="hs_VolumeOutCom2">
|
||||
<property name="value">
|
||||
<number>50</number>
|
||||
@@ -322,14 +350,14 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="0">
|
||||
<item row="14" column="0">
|
||||
<widget class="QLabel" name="lbl_OutLevelMeter">
|
||||
<property name="text">
|
||||
<string>Output</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="1">
|
||||
<item row="14" column="1">
|
||||
<widget class="BlackGui::CLevelMeter" name="wip_OutLevelMeter">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
|
||||
@@ -144,8 +144,7 @@ namespace BlackGui
|
||||
}
|
||||
else if (senderButton == ui->pb_SoundMaxVolume && sGui->getIContextAudio())
|
||||
{
|
||||
sGui->getCContextAudioBase()->setVoiceOutputVolume(CComSystem::Com1, 100);
|
||||
sGui->getCContextAudioBase()->setVoiceOutputVolume(CComSystem::Com2, 100);
|
||||
sGui->getCContextAudioBase()->setMasterOutputVolume(100);
|
||||
}
|
||||
else if (senderButton == ui->pb_SoundMute && sGui->getIContextAudio())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user