20 #include "ui_audioselectdialog.h" 26 m_audioDeviceManager(audioDeviceManager),
30 QTreeWidgetItem *treeItem, *defaultItem, *selectedItem = 0;
36 QAudioDeviceInfo defaultDeviceInfo = input ? QAudioDeviceInfo::defaultInputDevice() : QAudioDeviceInfo::defaultOutputDevice();
37 defaultItem =
new QTreeWidgetItem(
ui->audioTree);
40 defaultItem->setText(0, deviceFound ?
"__" :
"_D");
41 defaultItem->setText(2, tr(
"%1").
arg(sampleRate));
42 defaultItem->setTextAlignment(2, Qt::AlignRight);
46 for(QList<QAudioDeviceInfo>::const_iterator it = devices.begin(); it != devices.end(); ++it)
48 treeItem =
new QTreeWidgetItem(
ui->audioTree);
49 treeItem->setText(1, it->deviceName());
50 bool deviceFound =
getDeviceInfos(input, it->deviceName(), systemDefault, sampleRate);
51 treeItem->setText(0, QString(systemDefault ?
"S" :
"_") + QString(deviceFound ?
"_" :
"D"));
52 treeItem->setText(2, tr(
"%1").
arg(sampleRate));
53 treeItem->setTextAlignment(2, Qt::AlignRight);
56 treeItem->setBackground(1, QBrush(qRgb(80,80,80)));
59 if (deviceName == it->deviceName()) {
60 selectedItem = treeItem;
64 ui->audioTree->resizeColumnToContents(0);
65 ui->audioTree->resizeColumnToContents(1);
66 ui->audioTree->resizeColumnToContents(2);
69 ui->audioTree->setCurrentItem(selectedItem);
71 ui->audioTree->setCurrentItem(defaultItem);
82 int deviceIndex =
ui->audioTree->indexOfTopLevelItem(
ui->audioTree->currentItem()) - 1;
96 qDebug(
"AudioSelectDialog::accept: output: %d (%s)", deviceIndex, qPrintable(
m_audioDeviceName));
116 systemDefault = deviceName == QAudioDeviceInfo::defaultInputDevice().deviceName();
128 systemDefault = deviceName == QAudioDeviceInfo::defaultOutputDevice().deviceName();
static const QString m_defaultDeviceName
const QList< QAudioDeviceInfo > & getInputDevices() const
Ui::AudioSelectDialog * ui
AudioDeviceManager * m_audioDeviceManager
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
bool getInputDeviceName(int inputDeviceIndex, QString &deviceName) const
bool getInputDeviceInfo(const QString &deviceName, InputDeviceInfo &deviceInfo) const
bool getOutputDeviceInfo(const QString &deviceName, OutputDeviceInfo &deviceInfo) const
bool getOutputDeviceName(int outputDeviceIndex, QString &deviceName) const
AudioSelectDialog(AudioDeviceManager *audioDeviceManager, const QString &deviceName, bool input=false, QWidget *parent=0)
const QList< QAudioDeviceInfo > & getOutputDevices() const
QString m_audioDeviceName
static const unsigned int m_defaultAudioSampleRate
bool getDeviceInfos(bool input, const QString &deviceName, bool &systemDefault, int &sampleRate)