1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-04 16:01:14 -05:00
sdrangel/sdrgui/gui/audiodialog.cpp

87 lines
2.2 KiB
C++
Raw Normal View History

#include "audiodialog.h"
#include <audio/audiodevicemanager.h>
#include <QTreeWidgetItem>
#include "ui_audiodialog.h"
AudioDialog::AudioDialog(AudioDeviceManager* audioDeviceManager, QWidget* parent) :
QDialog(parent),
ui(new Ui::AudioDialog),
m_audioDeviceManager(audioDeviceManager)
{
ui->setupUi(this);
QTreeWidgetItem* treeItem;
int i;
// out panel
treeItem = new QTreeWidgetItem(ui->audioOutTree);
treeItem->setText(0, tr("Default (use first suitable device)"));
const QList<QAudioDeviceInfo>& outputDevices = m_audioDeviceManager->getOutputDevices();
i = 0;
for(QList<QAudioDeviceInfo>::const_iterator it = outputDevices.begin(); it != outputDevices.end(); ++it)
{
treeItem = new QTreeWidgetItem(ui->audioOutTree);
treeItem->setText(0, qPrintable(it->deviceName()));
if (i == 0)
{
ui->audioOutTree->setCurrentItem(treeItem);
}
i++;
}
// in panel
treeItem = new QTreeWidgetItem(ui->audioInTree);
treeItem->setText(0, tr("Default (use first suitable device)"));
const QList<QAudioDeviceInfo>& inputDevices = m_audioDeviceManager->getInputDevices();
i = 0;
for(QList<QAudioDeviceInfo>::const_iterator it = inputDevices.begin(); it != inputDevices.end(); ++it)
{
treeItem = new QTreeWidgetItem(ui->audioInTree);
treeItem->setText(0, qPrintable(it->deviceName()));
if (i == 0)
{
ui->audioInTree->setCurrentItem(treeItem);
}
i++;
}
2017-09-29 22:05:32 -04:00
if(ui->audioOutTree->currentItem() == 0) {
ui->audioOutTree->setCurrentItem(ui->audioOutTree->topLevelItem(0));
2017-09-29 22:05:32 -04:00
}
2017-09-29 22:05:32 -04:00
if(ui->audioInTree->currentItem() == 0) {
ui->audioInTree->setCurrentItem(ui->audioInTree->topLevelItem(0));
2017-09-29 22:05:32 -04:00
}
ui->tabWidget->setCurrentIndex(0);
ui->inputVolume->setValue((int) (m_inputVolume * 100.0f));
ui->inputVolumeText->setText(QString("%1").arg(m_inputVolume, 0, 'f', 2));
}
AudioDialog::~AudioDialog()
{
delete ui;
}
void AudioDialog::accept()
{
QDialog::accept();
}
void AudioDialog::on_inputVolume_valueChanged(int value)
{
m_inputVolume = (float) value / 100.0f;
ui->inputVolumeText->setText(QString("%1").arg(m_inputVolume, 0, 'f', 2));
}