diff --git a/plugins/samplesource/audioinput/audioinputgui.cpp b/plugins/samplesource/audioinput/audioinputgui.cpp index d2a47ebad..4f227f195 100644 --- a/plugins/samplesource/audioinput/audioinputgui.cpp +++ b/plugins/samplesource/audioinput/audioinputgui.cpp @@ -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) diff --git a/plugins/samplesource/audioinput/audioinputgui.h b/plugins/samplesource/audioinput/audioinputgui.h index 9de6904c3..cb9351fc0 100644 --- a/plugins/samplesource/audioinput/audioinputgui.h +++ b/plugins/samplesource/audioinput/audioinputgui.h @@ -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