mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-22 08:04:49 -05:00
Multi audio device: dialogs cosmetic changes
This commit is contained in:
parent
c2d92ab888
commit
61aad30cbb
@ -14,9 +14,12 @@ AudioDialogX::AudioDialogX(AudioDeviceManager* audioDeviceManager, QWidget* pare
|
||||
|
||||
// out panel
|
||||
|
||||
AudioDeviceManager::OutputDeviceInfo outDeviceInfo;
|
||||
QAudioDeviceInfo defaultOutputDeviceInfo = QAudioDeviceInfo::defaultOutputDevice();
|
||||
treeItem = new QTreeWidgetItem(ui->audioOutTree);
|
||||
treeItem->setText(0, AudioDeviceManager::m_defaultDeviceName);
|
||||
treeItem->setText(1, AudioDeviceManager::m_defaultDeviceName);
|
||||
bool found = m_audioDeviceManager->getOutputDeviceInfo(AudioDeviceManager::m_defaultDeviceName, outDeviceInfo);
|
||||
treeItem->setText(0, found ? "__" : "_D");
|
||||
ui->audioOutTree->setCurrentItem(treeItem);
|
||||
|
||||
const QList<QAudioDeviceInfo>& outputDevices = m_audioDeviceManager->getOutputDevices();
|
||||
@ -24,18 +27,27 @@ AudioDialogX::AudioDialogX(AudioDeviceManager* audioDeviceManager, QWidget* pare
|
||||
for(QList<QAudioDeviceInfo>::const_iterator it = outputDevices.begin(); it != outputDevices.end(); ++it)
|
||||
{
|
||||
treeItem = new QTreeWidgetItem(ui->audioOutTree);
|
||||
treeItem->setText(0, it->deviceName());
|
||||
treeItem->setText(1, it->deviceName());
|
||||
bool systemDefault = it->deviceName() == defaultOutputDeviceInfo.deviceName();
|
||||
found = m_audioDeviceManager->getOutputDeviceInfo(it->deviceName(), outDeviceInfo);
|
||||
treeItem->setText(0, QString(systemDefault ? "S" : "_") + QString(found ? "_" : "D"));
|
||||
|
||||
if (it->deviceName() == defaultOutputDeviceInfo.deviceName()) {
|
||||
treeItem->setBackground(0, QBrush(qRgb(96,96,96)));
|
||||
if (systemDefault) {
|
||||
treeItem->setBackground(1, QBrush(qRgb(96,96,96)));
|
||||
}
|
||||
}
|
||||
|
||||
ui->audioOutTree->resizeColumnToContents(0);
|
||||
ui->audioOutTree->resizeColumnToContents(1);
|
||||
|
||||
// in panel
|
||||
|
||||
AudioDeviceManager::InputDeviceInfo inDeviceInfo;
|
||||
QAudioDeviceInfo defaultInputDeviceInfo = QAudioDeviceInfo::defaultInputDevice();
|
||||
treeItem = new QTreeWidgetItem(ui->audioInTree);
|
||||
treeItem->setText(0, AudioDeviceManager::m_defaultDeviceName);
|
||||
treeItem->setText(1, AudioDeviceManager::m_defaultDeviceName);
|
||||
found = m_audioDeviceManager->getInputDeviceInfo(AudioDeviceManager::m_defaultDeviceName, inDeviceInfo);
|
||||
treeItem->setText(0, found ? "__" : "_D");
|
||||
ui->audioInTree->setCurrentItem(treeItem);
|
||||
|
||||
const QList<QAudioDeviceInfo>& inputDevices = m_audioDeviceManager->getInputDevices();
|
||||
@ -43,13 +55,19 @@ AudioDialogX::AudioDialogX(AudioDeviceManager* audioDeviceManager, QWidget* pare
|
||||
for(QList<QAudioDeviceInfo>::const_iterator it = inputDevices.begin(); it != inputDevices.end(); ++it)
|
||||
{
|
||||
treeItem = new QTreeWidgetItem(ui->audioInTree);
|
||||
treeItem->setText(0, it->deviceName());
|
||||
treeItem->setText(1, it->deviceName());
|
||||
bool systemDefault = it->deviceName() == defaultInputDeviceInfo.deviceName();
|
||||
found = m_audioDeviceManager->getInputDeviceInfo(it->deviceName(), inDeviceInfo);
|
||||
treeItem->setText(0, QString(systemDefault ? "S" : "_") + QString(found ? "_" : "D"));
|
||||
|
||||
if (it->deviceName() == defaultInputDeviceInfo.deviceName()) {
|
||||
treeItem->setBackground(0, QBrush(qRgb(96,96,96)));
|
||||
if (systemDefault) {
|
||||
treeItem->setBackground(1, QBrush(qRgb(96,96,96)));
|
||||
}
|
||||
}
|
||||
|
||||
ui->audioInTree->resizeColumnToContents(0);
|
||||
ui->audioInTree->resizeColumnToContents(1);
|
||||
|
||||
m_outputUDPPort = 9998;
|
||||
m_outIndex = -1;
|
||||
m_inIndex = -1;
|
||||
@ -101,7 +119,7 @@ void AudioDialogX::on_audioInTree_currentItemChanged(
|
||||
QTreeWidgetItem* previousItem)
|
||||
{
|
||||
AudioDeviceManager::InputDeviceInfo inDeviceInfo;
|
||||
QString inDeviceName = currentItem->text(0);
|
||||
QString inDeviceName = currentItem->text(1);
|
||||
int newIndex = ui->audioInTree->indexOfTopLevelItem(currentItem);
|
||||
int oldIndex = ui->audioInTree->indexOfTopLevelItem(previousItem);
|
||||
//qDebug("AudioDialogX::on_audioInTree_currentItemChanged: %s", qPrintable(inDeviceName));
|
||||
@ -122,7 +140,7 @@ void AudioDialogX::on_audioOutTree_currentItemChanged(
|
||||
QTreeWidgetItem* previousItem)
|
||||
{
|
||||
AudioDeviceManager::OutputDeviceInfo outDeviceInfo;
|
||||
QString outDeviceName = currentItem->text(0);
|
||||
QString outDeviceName = currentItem->text(1);
|
||||
int newIndex = ui->audioOutTree->indexOfTopLevelItem(currentItem);
|
||||
int oldIndex = ui->audioOutTree->indexOfTopLevelItem(previousItem);
|
||||
|
||||
|
@ -32,9 +32,20 @@
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="audioOutTree">
|
||||
<property name="indentation">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string notr="true">Device</string>
|
||||
<string notr="true">SD</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Device</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
@ -299,6 +310,14 @@
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="audioInTree">
|
||||
<property name="indentation">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>SD</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Device</string>
|
||||
|
@ -27,22 +27,32 @@ AudioSelectDialog::AudioSelectDialog(AudioDeviceManager* audioDeviceManager, con
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QTreeWidgetItem *treeItem, *defaultItem, *selectedItem = 0;
|
||||
bool systemDefault;
|
||||
int sampleRate;
|
||||
|
||||
// panel
|
||||
|
||||
QAudioDeviceInfo defaultDeviceInfo = input ? QAudioDeviceInfo::defaultInputDevice() : QAudioDeviceInfo::defaultOutputDevice();
|
||||
defaultItem = new QTreeWidgetItem(ui->audioTree);
|
||||
defaultItem->setText(0, AudioDeviceManager::m_defaultDeviceName);
|
||||
defaultItem->setText(1, AudioDeviceManager::m_defaultDeviceName);
|
||||
bool deviceFound = getDeviceInfos(input, AudioDeviceManager::m_defaultDeviceName, systemDefault, sampleRate);
|
||||
defaultItem->setText(0, deviceFound ? "__" : "_D");
|
||||
defaultItem->setText(2, tr("%1").arg(sampleRate));
|
||||
defaultItem->setTextAlignment(2, Qt::AlignRight);
|
||||
|
||||
QList<QAudioDeviceInfo> devices = input ? m_audioDeviceManager->getInputDevices() : m_audioDeviceManager->getOutputDevices();
|
||||
|
||||
for(QList<QAudioDeviceInfo>::const_iterator it = devices.begin(); it != devices.end(); ++it)
|
||||
{
|
||||
treeItem = new QTreeWidgetItem(ui->audioTree);
|
||||
treeItem->setText(0, it->deviceName());
|
||||
treeItem->setText(1, it->deviceName());
|
||||
bool deviceFound = getDeviceInfos(input, it->deviceName(), systemDefault, sampleRate);
|
||||
treeItem->setText(0, QString(systemDefault ? "S" : "_") + QString(deviceFound ? "_" : "D"));
|
||||
treeItem->setText(2, tr("%1").arg(sampleRate));
|
||||
treeItem->setTextAlignment(2, Qt::AlignRight);
|
||||
|
||||
if (it->deviceName() == defaultDeviceInfo.deviceName()) {
|
||||
treeItem->setBackground(0, QBrush(qRgb(96,96,96)));
|
||||
if (systemDefault) {
|
||||
treeItem->setBackground(1, QBrush(qRgb(80,80,80)));
|
||||
}
|
||||
|
||||
if (deviceName == it->deviceName()) {
|
||||
@ -50,6 +60,10 @@ AudioSelectDialog::AudioSelectDialog(AudioDeviceManager* audioDeviceManager, con
|
||||
}
|
||||
}
|
||||
|
||||
ui->audioTree->resizeColumnToContents(0);
|
||||
ui->audioTree->resizeColumnToContents(1);
|
||||
ui->audioTree->resizeColumnToContents(2);
|
||||
|
||||
if (selectedItem) {
|
||||
ui->audioTree->setCurrentItem(selectedItem);
|
||||
} else {
|
||||
@ -90,5 +104,36 @@ void AudioSelectDialog::reject()
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
bool AudioSelectDialog::getDeviceInfos(bool input, const QString& deviceName, bool& systemDefault, int& sampleRate)
|
||||
{
|
||||
bool found;
|
||||
|
||||
if (input)
|
||||
{
|
||||
AudioDeviceManager::InputDeviceInfo inDeviceInfo;
|
||||
found = m_audioDeviceManager->getInputDeviceInfo(deviceName, inDeviceInfo);
|
||||
systemDefault = deviceName == QAudioDeviceInfo::defaultInputDevice().deviceName();
|
||||
|
||||
if (found) {
|
||||
sampleRate = inDeviceInfo.sampleRate;
|
||||
} else {
|
||||
sampleRate = AudioDeviceManager::m_defaultAudioSampleRate;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AudioDeviceManager::OutputDeviceInfo outDeviceInfo;
|
||||
found = m_audioDeviceManager->getOutputDeviceInfo(deviceName, outDeviceInfo);
|
||||
systemDefault = deviceName == QAudioDeviceInfo::defaultOutputDevice().deviceName();
|
||||
|
||||
if (found) {
|
||||
sampleRate = outDeviceInfo.sampleRate;
|
||||
} else {
|
||||
sampleRate = AudioDeviceManager::m_defaultAudioSampleRate;
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
|
@ -39,6 +39,7 @@ public:
|
||||
bool m_selected;
|
||||
|
||||
private:
|
||||
bool getDeviceInfos(bool input, const QString& deviceName, bool& systemDefault, int& sampleRate);
|
||||
Ui::AudioSelectDialog* ui;
|
||||
AudioDeviceManager* m_audioDeviceManager;
|
||||
bool m_input;
|
||||
|
@ -22,9 +22,25 @@
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="audioTree">
|
||||
<property name="indentation">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string notr="true">Device</string>
|
||||
<string notr="true">SD</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Device</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Rate</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
|
Loading…
Reference in New Issue
Block a user