1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -05:00

Audio Input: Make sure audio device name corresponds to GUI setting. Set start/stop button background colour according to device status.

This commit is contained in:
Jon Beniston 2023-01-15 10:24:58 +00:00
parent 0a257f393e
commit d548ff0eb9
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