Merge pull request #1564 from srcejon/fix_audio_input_gui

Audio Input: Make sure audio device name corresponds to GUI setting.
This commit is contained in:
Edouard Griffiths 2023-01-15 23:17:42 +01:00 committed by GitHub
commit 2b6b63e647
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 0 deletions

View File

@ -51,6 +51,8 @@ AudioInputGui::AudioInputGui(DeviceUISet *deviceUISet, QWidget* parent) :
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(openDeviceSettingsDialog(const QPoint &)));
connect(deviceUISet->m_deviceAPI, &DeviceAPI::stateChanged, this, &AudioInputGui::updateStatus);
updateStatus();
displaySettings();
makeUIConnections();
@ -233,6 +235,8 @@ void AudioInputGui::displaySettings()
} else {
ui->device->setCurrentIndex(0);
}
// Make sure on_device_currentIndexChanged is called. Index may be the same for a different device
on_device_currentIndexChanged(ui->device->currentIndex());
ui->decim->setCurrentIndex(m_settings.m_log2Decim);
ui->volume->setValue((int)(m_settings.m_volume*10.0f));
@ -312,6 +316,30 @@ void AudioInputGui::updateHardware()
}
}
void AudioInputGui::updateStatus()
{
int state = m_deviceUISet->m_deviceAPI->state();
switch (state)
{
case DeviceAPI::StNotStarted:
ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
break;
case DeviceAPI::StIdle:
ui->startStop->setStyleSheet("QToolButton { background-color : blue; }");
break;
case DeviceAPI::StRunning:
ui->startStop->setStyleSheet("QToolButton { background-color : green; }");
break;
case DeviceAPI::StError:
ui->startStop->setStyleSheet("QToolButton { background-color : red; }");
QMessageBox::information(this, tr("Message"), m_deviceUISet->m_deviceAPI->errorMessage());
break;
default:
break;
}
}
void AudioInputGui::openDeviceSettingsDialog(const QPoint& p)
{
if (m_contextMenuType == ContextMenuDeviceSettings)

View File

@ -80,6 +80,7 @@ private slots:
void on_startStop_toggled(bool checked);
void updateHardware();
void openDeviceSettingsDialog(const QPoint& p);
void updateStatus();
};
#endif // INCLUDE_AUDIOINPUTGUI_H