Browse Source

Add audio in/out device to settings

pull/559/head
Tux3 / Mlkj / !Lev.uXFMLA 11 years ago
parent
commit
434808cd67
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
  1. 30
      src/misc/settings.cpp
  2. 10
      src/misc/settings.h
  3. 43
      src/widget/form/settings/avform.cpp
  4. 4
      src/widget/form/settings/avform.h

30
src/misc/settings.cpp

@ -163,6 +163,11 @@ void Settings::load() @@ -163,6 +163,11 @@ void Settings::load()
autoAccept[key] = s.value(key).toString();
s.endGroup();
s.beginGroup("Audio");
inDev = s.value("inDev", "").toString();
outDev = s.value("outDev", "").toString();
s.endGroup();
// try to set a smiley pack if none is selected
if (!SmileyPack::isValid(smileyPack) && !SmileyPack::listSmileyPacks().isEmpty())
smileyPack = SmileyPack::listSmileyPacks()[0].second;
@ -281,6 +286,11 @@ void Settings::save(QString path) @@ -281,6 +286,11 @@ void Settings::save(QString path)
for (auto& id : autoAccept.keys())
s.setValue(id, autoAccept.value(id));
s.endGroup();
s.beginGroup("Audio");
s.setValue("inDev", inDev);
s.setValue("outDev", outDev);
s.endGroup();
}
QString Settings::getSettingsDirPath()
@ -711,3 +721,23 @@ void Settings::setTypingNotification(bool enabled) @@ -711,3 +721,23 @@ void Settings::setTypingNotification(bool enabled)
{
typingNotification = enabled;
}
QString Settings::getInDev() const
{
return inDev;
}
void Settings::setInDev(const QString& deviceSpecifier)
{
inDev = deviceSpecifier;
}
QString Settings::getOutDev() const
{
return outDev;
}
void Settings::setOutDev(const QString& deviceSpecifier)
{
outDev = deviceSpecifier;
}

10
src/misc/settings.h

@ -97,6 +97,12 @@ public: @@ -97,6 +97,12 @@ public:
QByteArray getAvatarHash(const QString& ownerId);
void saveAvatarHash(const QByteArray& hash, const QString& ownerId);
QString getInDev() const;
void setInDev(const QString& deviceSpecifier);
QString getOutDev() const;
void setOutDev(const QString& deviceSpecifier);
// Assume all widgets have unique names
// Don't use it to save every single thing you want to save, use it
// for some general purpose widgets, such as MainWindows or Splitters,
@ -240,6 +246,10 @@ private: @@ -240,6 +246,10 @@ private:
// Privacy
bool typingNotification;
// Audio
QString inDev;
QString outDev;
signals:
//void dataChanged();
void dhtServerListChanged();

43
src/widget/form/settings/avform.cpp

@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
#include "avform.h"
#include "ui_avsettings.h"
#include "src/misc/settings.h"
#if defined(__APPLE__) && defined(__MACH__)
#include <OpenAL/al.h>
@ -36,6 +37,10 @@ AVForm::AVForm() : @@ -36,6 +37,10 @@ AVForm::AVForm() :
connect(Camera::getInstance(), &Camera::propProbingFinished, this, &AVForm::onPropProbingFinished);
connect(Camera::getInstance(), &Camera::resolutionProbingFinished, this, &AVForm::onResProbingFinished);
auto qcomboboxIndexChanged = (void(QComboBox::*)(const QString&)) &QComboBox::currentIndexChanged;
connect(bodyUI->inDevCombobox, qcomboboxIndexChanged, this, &AVForm::onInDevChanged);
connect(bodyUI->outDevCombobox, qcomboboxIndexChanged, this, &AVForm::onOutDevChanged);
}
AVForm::~AVForm()
@ -117,20 +122,35 @@ void AVForm::hideEvent(QHideEvent *) @@ -117,20 +122,35 @@ void AVForm::hideEvent(QHideEvent *)
void AVForm::getAudioInDevices()
{
QString settingsInDev = Settings::getInstance().getInDev();
bool inDevFound = false;
bodyUI->inDevCombobox->clear();
const ALchar *pDeviceList = alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER);
if (pDeviceList)
{
while (*pDeviceList)
{
int len = strlen(pDeviceList);
bodyUI->inDevCombobox->addItem(QString::fromLocal8Bit(pDeviceList,len));
QString inDev = QString::fromLocal8Bit(pDeviceList,len);
bodyUI->inDevCombobox->addItem(inDev);
if (settingsInDev == inDev)
{
bodyUI->inDevCombobox->setCurrentIndex(bodyUI->inDevCombobox->count()-1);
inDevFound = true;
}
pDeviceList += len+1;
}
}
if (!inDevFound)
Settings::getInstance().setInDev(bodyUI->inDevCombobox->itemText(0));
}
void AVForm::getAudioOutDevices()
{
QString settingsOutDev = Settings::getInstance().getOutDev();
bool outDevFound = false;
bodyUI->outDevCombobox->clear();
const ALchar *pDeviceList;
if (alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT") != AL_FALSE)
pDeviceList = alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER);
@ -141,8 +161,27 @@ void AVForm::getAudioOutDevices() @@ -141,8 +161,27 @@ void AVForm::getAudioOutDevices()
while (*pDeviceList)
{
int len = strlen(pDeviceList);
bodyUI->outDevCombobox->addItem(QString::fromLocal8Bit(pDeviceList,len));
QString outDev = QString::fromLocal8Bit(pDeviceList,len);
bodyUI->outDevCombobox->addItem(outDev);
if (settingsOutDev == outDev)
{
bodyUI->outDevCombobox->setCurrentIndex(bodyUI->outDevCombobox->count()-1);
outDevFound = true;
}
pDeviceList += len+1;
}
}
if (!outDevFound)
Settings::getInstance().setOutDev(bodyUI->outDevCombobox->itemText(0));
}
void AVForm::onInDevChanged(const QString &deviceDescriptor)
{
Settings::getInstance().setInDev(deviceDescriptor);
}
void AVForm::onOutDevChanged(const QString& deviceDescriptor)
{
Settings::getInstance().setOutDev(deviceDescriptor);
}

4
src/widget/form/settings/avform.h

@ -49,6 +49,10 @@ private slots: @@ -49,6 +49,10 @@ private slots:
void on_HueSlider_sliderMoved(int position);
void on_videoModescomboBox_activated(int index);
// audio
void onInDevChanged(const QString& deviceDescriptor);
void onOutDevChanged(const QString& deviceDescriptor);
// camera
void onPropProbingFinished(Camera::Prop prop, double val);
void onResProbingFinished(QList<QSize> res);

Loading…
Cancel
Save