mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix(audio): actually disable the audio in/out device in settings, when selected
As esecially the "Disabled" text is translated, the audio device will change from "disabled" to "default", just by changing the language. In contrast to video devices, an audio device is either always available, or sound will be disabled. So "Disabled" is the correct term to use here.
This commit is contained in:
parent
81df534c9a
commit
9694d6b6d4
|
@ -320,7 +320,7 @@ bool Audio::autoInitOutput()
|
|||
|
||||
bool Audio::initInput(const QString& deviceName)
|
||||
{
|
||||
if (deviceName.toLower() == QStringLiteral("none"))
|
||||
if (!Settings::getInstance().getAudioInDevEnabled())
|
||||
return false;
|
||||
|
||||
qDebug() << "Opening audio input" << deviceName;
|
||||
|
@ -363,7 +363,7 @@ bool Audio::initOutput(const QString& deviceName)
|
|||
outSources.clear();
|
||||
|
||||
outputInitialized = false;
|
||||
if (deviceName.toLower() == QStringLiteral("none"))
|
||||
if (!Settings::getInstance().getAudioOutDevEnabled())
|
||||
return false;
|
||||
|
||||
qDebug() << "Opening audio output" << deviceName;
|
||||
|
|
|
@ -242,7 +242,9 @@ void Settings::loadGlobal()
|
|||
|
||||
s.beginGroup("Audio");
|
||||
inDev = s.value("inDev", "").toString();
|
||||
audioInDevEnabled = s.value("audioInDevEnabled", true).toBool();
|
||||
outDev = s.value("outDev", "").toString();
|
||||
audioOutDevEnabled = s.value("audioOutDevEnabled", true).toBool();
|
||||
audioInGainDecibel = s.value("inGain", 0).toReal();
|
||||
outVolume = s.value("outVolume", 100).toInt();
|
||||
s.endGroup();
|
||||
|
@ -478,7 +480,9 @@ void Settings::saveGlobal()
|
|||
|
||||
s.beginGroup("Audio");
|
||||
s.setValue("inDev", inDev);
|
||||
s.setValue("audioInDevEnabled", audioInDevEnabled);
|
||||
s.setValue("outDev", outDev);
|
||||
s.setValue("audioOutDevEnabled", audioOutDevEnabled);
|
||||
s.setValue("inGain", audioInGainDecibel);
|
||||
s.setValue("outVolume", outVolume);
|
||||
s.endGroup();
|
||||
|
@ -1389,6 +1393,18 @@ void Settings::setInDev(const QString& deviceSpecifier)
|
|||
inDev = deviceSpecifier;
|
||||
}
|
||||
|
||||
bool Settings::getAudioInDevEnabled() const
|
||||
{
|
||||
QMutexLocker locker(&bigLock);
|
||||
return audioInDevEnabled;
|
||||
}
|
||||
|
||||
void Settings::setAudioInDevEnabled(bool enabled)
|
||||
{
|
||||
QMutexLocker locker(&bigLock);
|
||||
audioInDevEnabled = enabled;
|
||||
}
|
||||
|
||||
qreal Settings::getAudioInGain() const
|
||||
{
|
||||
QMutexLocker locker{&bigLock};
|
||||
|
@ -1425,6 +1441,18 @@ void Settings::setOutDev(const QString& deviceSpecifier)
|
|||
outDev = deviceSpecifier;
|
||||
}
|
||||
|
||||
bool Settings::getAudioOutDevEnabled() const
|
||||
{
|
||||
QMutexLocker locker(&bigLock);
|
||||
return audioOutDevEnabled;
|
||||
}
|
||||
|
||||
void Settings::setAudioOutDevEnabled(bool enabled)
|
||||
{
|
||||
QMutexLocker locker(&bigLock);
|
||||
audioOutDevEnabled = enabled;
|
||||
}
|
||||
|
||||
int Settings::getOutVolume() const
|
||||
{
|
||||
QMutexLocker locker{&bigLock};
|
||||
|
|
|
@ -179,9 +179,15 @@ public:
|
|||
QString getInDev() const;
|
||||
void setInDev(const QString& deviceSpecifier);
|
||||
|
||||
bool getAudioInDevEnabled() const;
|
||||
void setAudioInDevEnabled(bool enabled);
|
||||
|
||||
QString getOutDev() const;
|
||||
void setOutDev(const QString& deviceSpecifier);
|
||||
|
||||
bool getAudioOutDevEnabled() const;
|
||||
void setAudioOutDevEnabled(bool enabled);
|
||||
|
||||
qreal getAudioInGain() const;
|
||||
void setAudioInGain(qreal dB);
|
||||
|
||||
|
@ -433,8 +439,10 @@ private:
|
|||
|
||||
// Audio
|
||||
QString inDev;
|
||||
QString outDev;
|
||||
bool audioInDevEnabled;
|
||||
qreal audioInGainDecibel;
|
||||
QString outDev;
|
||||
bool audioOutDevEnabled;
|
||||
int outVolume;
|
||||
|
||||
// Video
|
||||
|
|
|
@ -345,36 +345,42 @@ void AVForm::getVideoDevices()
|
|||
void AVForm::getAudioInDevices()
|
||||
{
|
||||
QStringList deviceNames;
|
||||
deviceNames << tr("None") << Audio::inDeviceNames();
|
||||
deviceNames << tr("Disabled") << Audio::inDeviceNames();
|
||||
|
||||
bodyUI->inDevCombobox->blockSignals(true);
|
||||
bodyUI->inDevCombobox->clear();
|
||||
bodyUI->inDevCombobox->addItems(deviceNames);
|
||||
bodyUI->inDevCombobox->blockSignals(false);
|
||||
|
||||
int idx = deviceNames.indexOf(Settings::getInstance().getInDev());
|
||||
bodyUI->inDevCombobox->setCurrentIndex(idx > 0 ? idx : 0);
|
||||
int idx = Settings::getInstance().getAudioInDevEnabled()
|
||||
? deviceNames.indexOf(Settings::getInstance().getInDev())
|
||||
: 0;
|
||||
bodyUI->inDevCombobox->setCurrentIndex(idx < 0 ? 1 : idx);
|
||||
}
|
||||
|
||||
void AVForm::getAudioOutDevices()
|
||||
{
|
||||
QStringList deviceNames;
|
||||
deviceNames << tr("None") << Audio::outDeviceNames();
|
||||
deviceNames << tr("Disabled") << Audio::outDeviceNames();
|
||||
|
||||
bodyUI->outDevCombobox->blockSignals(true);
|
||||
bodyUI->outDevCombobox->clear();
|
||||
bodyUI->outDevCombobox->addItems(deviceNames);
|
||||
bodyUI->outDevCombobox->blockSignals(false);
|
||||
|
||||
int idx = deviceNames.indexOf(Settings::getInstance().getOutDev());
|
||||
bodyUI->outDevCombobox->setCurrentIndex(idx > 0 ? idx : 0);
|
||||
int idx = Settings::getInstance().getAudioOutDevEnabled()
|
||||
? deviceNames.indexOf(Settings::getInstance().getOutDev())
|
||||
: 0;
|
||||
bodyUI->outDevCombobox->setCurrentIndex(idx < 0 ? 1 : idx);
|
||||
}
|
||||
|
||||
void AVForm::onAudioInDevChanged(int deviceIndex)
|
||||
{
|
||||
QString deviceName = deviceIndex > 0
|
||||
? bodyUI->inDevCombobox->itemText(deviceIndex)
|
||||
: QStringLiteral("none");
|
||||
Settings::getInstance().setAudioInDevEnabled(deviceIndex != 0);
|
||||
|
||||
QString deviceName;
|
||||
if (deviceIndex > 0)
|
||||
deviceName = bodyUI->inDevCombobox->itemText(deviceIndex);
|
||||
|
||||
Settings::getInstance().setInDev(deviceName);
|
||||
|
||||
|
@ -386,9 +392,11 @@ void AVForm::onAudioInDevChanged(int deviceIndex)
|
|||
|
||||
void AVForm::onAudioOutDevChanged(int deviceIndex)
|
||||
{
|
||||
QString deviceName = deviceIndex > 0
|
||||
? bodyUI->outDevCombobox->itemText(deviceIndex)
|
||||
: QStringLiteral("none");
|
||||
Settings::getInstance().setAudioOutDevEnabled(deviceIndex != 0);
|
||||
|
||||
QString deviceName;
|
||||
if (deviceIndex > 0)
|
||||
deviceName = bodyUI->outDevCombobox->itemText(deviceIndex);
|
||||
|
||||
Settings::getInstance().setOutDev(deviceName);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user