SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Public Member Functions | Public Attributes | Private Slots | Private Member Functions | Private Attributes | List of all members
AudioSelectDialog Class Reference

#include <audioselectdialog.h>

Inherits QDialog.

+ Collaboration diagram for AudioSelectDialog:

Public Member Functions

 AudioSelectDialog (AudioDeviceManager *audioDeviceManager, const QString &deviceName, bool input=false, QWidget *parent=0)
 
 ~AudioSelectDialog ()
 

Public Attributes

QString m_audioDeviceName
 
bool m_selected
 

Private Slots

void accept ()
 
void reject ()
 

Private Member Functions

bool getDeviceInfos (bool input, const QString &deviceName, bool &systemDefault, int &sampleRate)
 

Private Attributes

Ui::AudioSelectDialog * ui
 
AudioDeviceManagerm_audioDeviceManager
 
bool m_input
 

Detailed Description

Definition at line 33 of file audioselectdialog.h.

Constructor & Destructor Documentation

◆ AudioSelectDialog()

AudioSelectDialog::AudioSelectDialog ( AudioDeviceManager audioDeviceManager,
const QString &  deviceName,
bool  input = false,
QWidget *  parent = 0 
)
explicit

Definition at line 22 of file audioselectdialog.cpp.

References arg(), getDeviceInfos(), AudioDeviceManager::getInputDevices(), AudioDeviceManager::getOutputDevices(), m_audioDeviceManager, AudioDeviceManager::m_defaultDeviceName, and ui.

22  :
23  QDialog(parent),
24  m_selected(false),
25  ui(new Ui::AudioSelectDialog),
26  m_audioDeviceManager(audioDeviceManager),
27  m_input(input)
28 {
29  ui->setupUi(this);
30  QTreeWidgetItem *treeItem, *defaultItem, *selectedItem = 0;
31  bool systemDefault;
32  int sampleRate;
33 
34  // panel
35 
36  QAudioDeviceInfo defaultDeviceInfo = input ? QAudioDeviceInfo::defaultInputDevice() : QAudioDeviceInfo::defaultOutputDevice();
37  defaultItem = new QTreeWidgetItem(ui->audioTree);
38  defaultItem->setText(1, AudioDeviceManager::m_defaultDeviceName);
39  bool deviceFound = getDeviceInfos(input, AudioDeviceManager::m_defaultDeviceName, systemDefault, sampleRate);
40  defaultItem->setText(0, deviceFound ? "__" : "_D");
41  defaultItem->setText(2, tr("%1").arg(sampleRate));
42  defaultItem->setTextAlignment(2, Qt::AlignRight);
43 
44  QList<QAudioDeviceInfo> devices = input ? m_audioDeviceManager->getInputDevices() : m_audioDeviceManager->getOutputDevices();
45 
46  for(QList<QAudioDeviceInfo>::const_iterator it = devices.begin(); it != devices.end(); ++it)
47  {
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);
54 
55  if (systemDefault) {
56  treeItem->setBackground(1, QBrush(qRgb(80,80,80)));
57  }
58 
59  if (deviceName == it->deviceName()) {
60  selectedItem = treeItem;
61  }
62  }
63 
64  ui->audioTree->resizeColumnToContents(0);
65  ui->audioTree->resizeColumnToContents(1);
66  ui->audioTree->resizeColumnToContents(2);
67 
68  if (selectedItem) {
69  ui->audioTree->setCurrentItem(selectedItem);
70  } else {
71  ui->audioTree->setCurrentItem(defaultItem);
72  }
73 }
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)
Definition: fixed.h:2401
const QList< QAudioDeviceInfo > & getOutputDevices() const
bool getDeviceInfos(bool input, const QString &deviceName, bool &systemDefault, int &sampleRate)
+ Here is the call graph for this function:

◆ ~AudioSelectDialog()

AudioSelectDialog::~AudioSelectDialog ( )

Definition at line 75 of file audioselectdialog.cpp.

References ui.

76 {
77  delete ui;
78 }
Ui::AudioSelectDialog * ui

Member Function Documentation

◆ accept

void AudioSelectDialog::accept ( )
privateslot

Definition at line 80 of file audioselectdialog.cpp.

References AudioDeviceManager::getInputDeviceName(), AudioDeviceManager::getOutputDeviceName(), m_audioDeviceManager, m_audioDeviceName, AudioDeviceManager::m_defaultDeviceName, m_input, m_selected, and ui.

81 {
82  int deviceIndex = ui->audioTree->indexOfTopLevelItem(ui->audioTree->currentItem()) - 1;
83 
84  if (m_input)
85  {
88  }
89  }
90  else
91  {
94  }
95 
96  qDebug("AudioSelectDialog::accept: output: %d (%s)", deviceIndex, qPrintable(m_audioDeviceName));
97  }
98 
99  m_selected = true;
100  QDialog::accept();
101 }
static const QString m_defaultDeviceName
Ui::AudioSelectDialog * ui
AudioDeviceManager * m_audioDeviceManager
bool getInputDeviceName(int inputDeviceIndex, QString &deviceName) const
bool getOutputDeviceName(int outputDeviceIndex, QString &deviceName) const
+ Here is the call graph for this function:

◆ getDeviceInfos()

bool AudioSelectDialog::getDeviceInfos ( bool  input,
const QString &  deviceName,
bool &  systemDefault,
int &  sampleRate 
)
private

Definition at line 108 of file audioselectdialog.cpp.

References AudioDeviceManager::getInputDeviceInfo(), AudioDeviceManager::getOutputDeviceInfo(), m_audioDeviceManager, AudioDeviceManager::m_defaultAudioSampleRate, AudioDeviceManager::InputDeviceInfo::sampleRate, and AudioDeviceManager::OutputDeviceInfo::sampleRate.

Referenced by AudioSelectDialog().

109 {
110  bool found;
111 
112  if (input)
113  {
115  found = m_audioDeviceManager->getInputDeviceInfo(deviceName, inDeviceInfo);
116  systemDefault = deviceName == QAudioDeviceInfo::defaultInputDevice().deviceName();
117 
118  if (found) {
119  sampleRate = inDeviceInfo.sampleRate;
120  } else {
122  }
123  }
124  else
125  {
127  found = m_audioDeviceManager->getOutputDeviceInfo(deviceName, outDeviceInfo);
128  systemDefault = deviceName == QAudioDeviceInfo::defaultOutputDevice().deviceName();
129 
130  if (found) {
131  sampleRate = outDeviceInfo.sampleRate;
132  } else {
134  }
135  }
136 
137  return found;
138 }
AudioDeviceManager * m_audioDeviceManager
bool getInputDeviceInfo(const QString &deviceName, InputDeviceInfo &deviceInfo) const
bool getOutputDeviceInfo(const QString &deviceName, OutputDeviceInfo &deviceInfo) const
static const unsigned int m_defaultAudioSampleRate
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reject

void AudioSelectDialog::reject ( )
privateslot

Definition at line 103 of file audioselectdialog.cpp.

104 {
105  QDialog::reject();
106 }

Member Data Documentation

◆ m_audioDeviceManager

AudioDeviceManager* AudioSelectDialog::m_audioDeviceManager
private

Definition at line 45 of file audioselectdialog.h.

Referenced by accept(), AudioSelectDialog(), and getDeviceInfos().

◆ m_audioDeviceName

QString AudioSelectDialog::m_audioDeviceName

◆ m_input

bool AudioSelectDialog::m_input
private

Definition at line 46 of file audioselectdialog.h.

Referenced by accept().

◆ m_selected

bool AudioSelectDialog::m_selected

◆ ui

Ui::AudioSelectDialog* AudioSelectDialog::ui
private

Definition at line 44 of file audioselectdialog.h.

Referenced by accept(), AudioSelectDialog(), and ~AudioSelectDialog().


The documentation for this class was generated from the following files: