mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 11:05:33 +08:00
refs #892, disable audio settings when no audio context is available
* Info for which machine audio setup is displayed * Obtain audio "location" * Remark: Audio can run on core and in GUI which is different from other contexts
This commit is contained in:
committed by
Mathew Sutcliffe
parent
891b67eccc
commit
7203655a05
@@ -39,14 +39,35 @@ namespace BlackGui
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
Q_ASSERT_X(sGui, Q_FUNC_INFO, "Missing sGui");
|
||||
Q_ASSERT_X(sGui->getIContextAudio(), Q_FUNC_INFO, "Missing Audio context");
|
||||
|
||||
// audio is optional
|
||||
const bool audio = this->hasAudio();
|
||||
this->setEnabled(audio);
|
||||
if (!audio)
|
||||
{
|
||||
ui->lbl_ExtraInfo->setText("No audio, cannot change.");
|
||||
}
|
||||
else if (sGui->getIContextAudio()->isUsingImplementingObject())
|
||||
{
|
||||
const CIdentifier i = sGui->getIContextAudio()->audioRunsWhere();
|
||||
const QString info = QString("Local audio on '%1', '%2'.").arg(i.getMachineName(), i.getProcessName());
|
||||
ui->lbl_ExtraInfo->setText(info);
|
||||
}
|
||||
else
|
||||
{
|
||||
const CIdentifier i = sGui->getIContextAudio()->audioRunsWhere();
|
||||
const QString info = QString("Remote audio on '%1', '%2'.").arg(i.getMachineName(), i.getProcessName());
|
||||
ui->lbl_ExtraInfo->setText(info);
|
||||
}
|
||||
|
||||
bool c = connect(ui->tb_ExpandNotificationSounds, &QToolButton::toggled, this, &CAudioSetupComponent::ps_onToggleNotificationSoundsVisibility);
|
||||
Q_ASSERT(c);
|
||||
Q_UNUSED(c);
|
||||
c = connect(ui->cb_SetupAudioLoopback, &QCheckBox::toggled, this, &CAudioSetupComponent::ps_onLoopbackToggled);
|
||||
Q_ASSERT(c);
|
||||
Q_UNUSED(c);
|
||||
|
||||
if (sGui->getIContextAudio())
|
||||
if (audio)
|
||||
{
|
||||
this->initAudioDeviceLists();
|
||||
|
||||
@@ -56,18 +77,18 @@ namespace BlackGui
|
||||
// the connects depend on initAudioDeviceLists
|
||||
c = this->connect(ui->cb_SetupAudioInputDevice, static_cast<void (QComboBox::*)(int)> (&QComboBox::currentIndexChanged), this, &CAudioSetupComponent::ps_audioDeviceSelected);
|
||||
Q_ASSERT(c);
|
||||
Q_UNUSED(c);
|
||||
|
||||
c = this->connect(ui->cb_SetupAudioOutputDevice, static_cast<void (QComboBox::*)(int)> (&QComboBox::currentIndexChanged), this, &CAudioSetupComponent::ps_audioDeviceSelected);
|
||||
Q_ASSERT(c);
|
||||
Q_UNUSED(c);
|
||||
|
||||
// context
|
||||
this->connect(sGui->getIContextAudio(), &IContextAudio::changedAudioDevices, this, &CAudioSetupComponent::ps_onAudioDevicesChanged);
|
||||
this->connect(sGui->getIContextAudio(), &IContextAudio::changedSelectedAudioDevices, this, &CAudioSetupComponent::ps_onCurrentAudioDevicesChanged);
|
||||
c = this->connect(sGui->getIContextAudio(), &IContextAudio::changedAudioDevices, this, &CAudioSetupComponent::ps_onAudioDevicesChanged);
|
||||
Q_ASSERT(c);
|
||||
c = this->connect(sGui->getIContextAudio(), &IContextAudio::changedSelectedAudioDevices, this, &CAudioSetupComponent::ps_onCurrentAudioDevicesChanged);
|
||||
Q_ASSERT(c);
|
||||
}
|
||||
this->ps_reloadSettings();
|
||||
ui->tb_ExpandNotificationSounds->setChecked(false); // collapse
|
||||
Q_UNUSED(c);
|
||||
}
|
||||
|
||||
CAudioSetupComponent::~CAudioSetupComponent()
|
||||
@@ -88,11 +109,16 @@ namespace BlackGui
|
||||
|
||||
void CAudioSetupComponent::initAudioDeviceLists()
|
||||
{
|
||||
if (!sGui->getIContextAudio()) { return; }
|
||||
if (!this->hasAudio()) { return; }
|
||||
this->ps_onAudioDevicesChanged(sGui->getIContextAudio()->getAudioDevices());
|
||||
this->ps_onCurrentAudioDevicesChanged(sGui->getIContextAudio()->getCurrentAudioDevices());
|
||||
}
|
||||
|
||||
bool CAudioSetupComponent::hasAudio() const
|
||||
{
|
||||
return sGui && sGui->getIContextAudio() && !sGui->getIContextAudio()->isEmptyObject();
|
||||
}
|
||||
|
||||
bool CAudioSetupComponent::playNotificationSounds() const
|
||||
{
|
||||
return ui->cb_SetupAudioPlayNotificationSounds->isChecked();
|
||||
@@ -162,6 +188,5 @@ namespace BlackGui
|
||||
if (sGui->getIContextAudio()->isAudioLoopbackEnabled() == loopback) { return; }
|
||||
sGui->getIContextAudio()->enableAudioLoopback(loopback);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
class QWidget;
|
||||
|
||||
namespace Ui { class CAudioSetupComponent; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
@@ -40,7 +39,7 @@ namespace BlackGui
|
||||
explicit CAudioSetupComponent(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CAudioSetupComponent();
|
||||
virtual ~CAudioSetupComponent();
|
||||
|
||||
//! Play notification sounds (at all)
|
||||
bool playNotificationSounds() const;
|
||||
@@ -49,10 +48,8 @@ namespace BlackGui
|
||||
//! Reload settings
|
||||
void ps_reloadSettings();
|
||||
|
||||
/*!
|
||||
* \brief Audio device selected
|
||||
* \param index audio device index (COM1, COM2)
|
||||
*/
|
||||
//! Audio device selected
|
||||
//! \param index audio device index (COM1, COM2)
|
||||
void ps_audioDeviceSelected(int index);
|
||||
|
||||
//! Current audio devices changed
|
||||
@@ -71,6 +68,9 @@ namespace BlackGui
|
||||
//! Audio device lists from settings
|
||||
void initAudioDeviceLists();
|
||||
|
||||
//! Audio is optional, check if available
|
||||
bool hasAudio() const;
|
||||
|
||||
QScopedPointer<Ui::CAudioSetupComponent> ui;
|
||||
BlackMisc::CSetting<BlackCore::Audio::TSettings> m_audioSettings { this, &CAudioSetupComponent::ps_reloadSettings };
|
||||
|
||||
|
||||
@@ -2,6 +2,14 @@
|
||||
<ui version="4.0">
|
||||
<class>CAudioSetupComponent</class>
|
||||
<widget class="QFrame" name="CAudioSetupComponent">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>264</width>
|
||||
<height>359</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Audio setup</string>
|
||||
</property>
|
||||
@@ -27,6 +35,22 @@
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QWidget" name="wi_ExtraInfo" native="true">
|
||||
<layout class="QVBoxLayout" name="vl_ExtraInfo">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_ExtraInfo">
|
||||
<property name="text">
|
||||
<string>Extra info goes here</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="fl_SetupAudio">
|
||||
<property name="sizeConstraint">
|
||||
@@ -112,7 +136,7 @@
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="cb_SetupAudioLoopback">
|
||||
<property name="text">
|
||||
<string>Loopback, test sound input to output loop</string>
|
||||
<string>Loopback, test sound in- to output</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -120,6 +144,18 @@
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gl_NotificationSounds">
|
||||
<property name="leftMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="lbl_NotificationSounds">
|
||||
<property name="text">
|
||||
|
||||
Reference in New Issue
Block a user