2018-03-23 22:36:49 -04:00
|
|
|
#include "audiodialog.h"
|
2018-03-23 13:08:38 -04:00
|
|
|
|
|
|
|
#include <audio/audiodevicemanager.h>
|
2014-05-18 11:52:39 -04:00
|
|
|
#include <QTreeWidgetItem>
|
2016-05-04 11:07:26 -04:00
|
|
|
#include "ui_audiodialog.h"
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2018-03-25 07:36:09 -04:00
|
|
|
AudioDialogX::AudioDialogX(AudioDeviceManager* audioDeviceManager, QWidget* parent) :
|
2014-05-18 11:52:39 -04:00
|
|
|
QDialog(parent),
|
2016-05-04 11:07:26 -04:00
|
|
|
ui(new Ui::AudioDialog),
|
2018-03-23 22:36:49 -04:00
|
|
|
m_audioDeviceManager(audioDeviceManager)
|
2014-05-18 11:52:39 -04:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2017-01-06 06:43:18 -05:00
|
|
|
QTreeWidgetItem* treeItem;
|
|
|
|
int i;
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2017-01-06 06:43:18 -05:00
|
|
|
// out panel
|
|
|
|
|
2018-03-25 07:36:09 -04:00
|
|
|
QAudioDeviceInfo defaultOutputDeviceInfo = QAudioDeviceInfo::defaultOutputDevice();
|
2017-01-06 06:43:18 -05:00
|
|
|
treeItem = new QTreeWidgetItem(ui->audioOutTree);
|
2018-03-25 07:36:09 -04:00
|
|
|
treeItem->setText(0, tr("System default output device"));
|
2017-01-06 06:43:18 -05:00
|
|
|
|
2018-03-23 22:36:49 -04:00
|
|
|
const QList<QAudioDeviceInfo>& outputDevices = m_audioDeviceManager->getOutputDevices();
|
2017-01-06 06:43:18 -05:00
|
|
|
i = 0;
|
|
|
|
|
|
|
|
for(QList<QAudioDeviceInfo>::const_iterator it = outputDevices.begin(); it != outputDevices.end(); ++it)
|
|
|
|
{
|
2018-03-25 07:36:09 -04:00
|
|
|
bool isDefaultDevice = it->deviceName() == defaultOutputDeviceInfo.deviceName();
|
2017-01-06 06:43:18 -05:00
|
|
|
treeItem = new QTreeWidgetItem(ui->audioOutTree);
|
2018-03-25 07:36:09 -04:00
|
|
|
treeItem->setText(0, it->deviceName() + (isDefaultDevice ? "(*)" : ""));
|
2017-01-06 06:43:18 -05:00
|
|
|
|
2018-03-24 18:50:28 -04:00
|
|
|
if (i == 0)
|
2017-01-06 06:43:18 -05:00
|
|
|
{
|
|
|
|
ui->audioOutTree->setCurrentItem(treeItem);
|
|
|
|
}
|
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// in panel
|
|
|
|
|
2018-03-25 07:36:09 -04:00
|
|
|
QAudioDeviceInfo defaultInputDeviceInfo = QAudioDeviceInfo::defaultInputDevice();
|
2017-01-06 06:43:18 -05:00
|
|
|
treeItem = new QTreeWidgetItem(ui->audioInTree);
|
2018-03-25 07:36:09 -04:00
|
|
|
treeItem->setText(0, tr("System default input device"));
|
2017-01-06 06:43:18 -05:00
|
|
|
|
2018-03-23 22:36:49 -04:00
|
|
|
const QList<QAudioDeviceInfo>& inputDevices = m_audioDeviceManager->getInputDevices();
|
2017-01-06 06:43:18 -05:00
|
|
|
i = 0;
|
|
|
|
|
|
|
|
for(QList<QAudioDeviceInfo>::const_iterator it = inputDevices.begin(); it != inputDevices.end(); ++it)
|
|
|
|
{
|
2018-03-25 07:36:09 -04:00
|
|
|
bool isDefaultDevice = it->deviceName() == defaultInputDeviceInfo.deviceName();
|
2017-01-06 06:43:18 -05:00
|
|
|
treeItem = new QTreeWidgetItem(ui->audioInTree);
|
2018-03-25 07:36:09 -04:00
|
|
|
treeItem->setText(0, it->deviceName() + (isDefaultDevice ? "(*)" : ""));
|
2017-01-06 06:43:18 -05:00
|
|
|
|
2018-03-24 19:57:14 -04:00
|
|
|
if (i == 0)
|
2017-01-06 06:43:18 -05:00
|
|
|
{
|
|
|
|
ui->audioInTree->setCurrentItem(treeItem);
|
|
|
|
}
|
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
2017-01-05 21:02:57 -05:00
|
|
|
|
2017-09-29 22:05:32 -04:00
|
|
|
if(ui->audioOutTree->currentItem() == 0) {
|
2017-01-05 21:02:57 -05:00
|
|
|
ui->audioOutTree->setCurrentItem(ui->audioOutTree->topLevelItem(0));
|
2017-09-29 22:05:32 -04:00
|
|
|
}
|
2017-01-05 21:02:57 -05:00
|
|
|
|
2017-09-29 22:05:32 -04:00
|
|
|
if(ui->audioInTree->currentItem() == 0) {
|
2017-01-05 21:02:57 -05:00
|
|
|
ui->audioInTree->setCurrentItem(ui->audioInTree->topLevelItem(0));
|
2017-09-29 22:05:32 -04:00
|
|
|
}
|
2014-05-18 11:52:39 -04:00
|
|
|
|
|
|
|
ui->tabWidget->setCurrentIndex(0);
|
2017-01-06 06:43:18 -05:00
|
|
|
|
|
|
|
ui->inputVolume->setValue((int) (m_inputVolume * 100.0f));
|
|
|
|
ui->inputVolumeText->setText(QString("%1").arg(m_inputVolume, 0, 'f', 2));
|
2014-05-18 11:52:39 -04:00
|
|
|
}
|
|
|
|
|
2018-03-25 07:36:09 -04:00
|
|
|
AudioDialogX::~AudioDialogX()
|
2014-05-18 11:52:39 -04:00
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2018-03-25 07:36:09 -04:00
|
|
|
void AudioDialogX::accept()
|
2014-05-18 11:52:39 -04:00
|
|
|
{
|
|
|
|
QDialog::accept();
|
|
|
|
}
|
2017-01-05 21:13:53 -05:00
|
|
|
|
2018-03-25 07:36:09 -04:00
|
|
|
void AudioDialogX::on_inputVolume_valueChanged(int value)
|
2017-01-05 21:13:53 -05:00
|
|
|
{
|
2017-01-06 06:43:18 -05:00
|
|
|
m_inputVolume = (float) value / 100.0f;
|
|
|
|
ui->inputVolumeText->setText(QString("%1").arg(m_inputVolume, 0, 'f', 2));
|
2017-01-05 21:13:53 -05:00
|
|
|
}
|