From 026a136f2cdc6d4a63e7c0b32bd1c65234171f25 Mon Sep 17 00:00:00 2001 From: Vladislav P Date: Fri, 18 Nov 2022 01:39:02 +0300 Subject: [PATCH] IQ tool: disable unused controls when recording/playback is in progress. Changing IO devices and loading/saving settings does not look like good thing to do while recording/playing an IQ file. Disable seek slider during recording as it has no function in this state. Disable file list and directory selector during recording/playback. --- src/applications/gqrx/mainwindow.cpp | 10 +++++++++ src/qtgui/iq_tool.cpp | 31 ++++++++++++++++++---------- src/qtgui/iq_tool.h | 7 +++++++ 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/applications/gqrx/mainwindow.cpp b/src/applications/gqrx/mainwindow.cpp index a9023d2b0..46d2ff3c6 100644 --- a/src/applications/gqrx/mainwindow.cpp +++ b/src/applications/gqrx/mainwindow.cpp @@ -1679,6 +1679,8 @@ void MainWindow::startIqRecording(const QString& recdir, const QString& format) } } + ui->actionIoConfig->setDisabled(true); + ui->actionLoadSettings->setDisabled(true); // start recorder; fails if recording already in progress if (!ok || rx->start_iq_recording(lastRec.toStdString())) { @@ -1713,6 +1715,8 @@ void MainWindow::stopIqRecording() ui->statusBar->showMessage(tr("Error stopping I/Q recoder")); else ui->statusBar->showMessage(tr("I/Q data recoding stopped"), 5000); + ui->actionIoConfig->setDisabled(false); + ui->actionLoadSettings->setDisabled(false); } void MainWindow::startIqPlayback(const QString& filename, float samprate, qint64 center_freq) @@ -1755,6 +1759,9 @@ void MainWindow::startIqPlayback(const QString& filename, float samprate, qint64 // FIXME: would be nice with good/bad status ui->statusBar->showMessage(tr("Playing %1").arg(filename)); + ui->actionIoConfig->setDisabled(true); + ui->actionLoadSettings->setDisabled(true); + ui->actionSaveSettings->setDisabled(true); on_actionDSP_triggered(true); } @@ -1768,6 +1775,9 @@ void MainWindow::stopIqPlayback() } ui->statusBar->showMessage(tr("I/Q playback stopped"), 5000); + ui->actionIoConfig->setDisabled(false); + ui->actionLoadSettings->setDisabled(false); + ui->actionSaveSettings->setDisabled(false); // restore original input device auto indev = m_settings->value("input/device", "").toString(); diff --git a/src/qtgui/iq_tool.cpp b/src/qtgui/iq_tool.cpp index 6a376d7fc..e8386ae6f 100644 --- a/src/qtgui/iq_tool.cpp +++ b/src/qtgui/iq_tool.cpp @@ -101,6 +101,20 @@ void CIqTool::on_listWidget_currentTextChanged(const QString ¤tText) } +/*! \brief Show/hide/enable/disable GUI controls */ + +void CIqTool::switchControlsState(enum IqToolState state) +{ + ui->recButton->setEnabled(state != STATE_PLAYING); + + ui->playButton->setEnabled(state != STATE_RECORDING); + ui->slider->setEnabled(state != STATE_RECORDING); + + ui->listWidget->setEnabled(state == STATE_IDLE); + ui->recDirEdit->setEnabled(state == STATE_IDLE); + ui->recDirButton->setEnabled(state == STATE_IDLE); +} + /*! \brief Start/stop playback */ void CIqTool::on_playButton_clicked(bool checked) { @@ -126,8 +140,7 @@ void CIqTool::on_playButton_clicked(bool checked) } else { - ui->listWidget->setEnabled(false); - ui->recButton->setEnabled(false); + switchControlsState(STATE_PLAYING); emit startPlayback(recdir->absoluteFilePath(current_file), (float)sample_rate, center_freq); } @@ -135,8 +148,7 @@ void CIqTool::on_playButton_clicked(bool checked) else { emit stopPlayback(); - ui->listWidget->setEnabled(true); - ui->recButton->setEnabled(true); + switchControlsState(STATE_IDLE); ui->slider->setValue(0); } } @@ -149,9 +161,7 @@ void CIqTool::on_playButton_clicked(bool checked) */ void CIqTool::cancelPlayback() { - ui->playButton->setChecked(false); - ui->listWidget->setEnabled(true); - ui->recButton->setEnabled(true); + switchControlsState(STATE_IDLE); is_playing = false; } @@ -172,7 +182,7 @@ void CIqTool::on_recButton_clicked(bool checked) if (checked) { - ui->playButton->setEnabled(false); + switchControlsState(STATE_RECORDING); emit startRecording(recdir->path(), ui->formatCombo->currentText()); refreshDir(); @@ -180,7 +190,7 @@ void CIqTool::on_recButton_clicked(bool checked) } else { - ui->playButton->setEnabled(true); + switchControlsState(STATE_IDLE); emit stopRecording(); } } @@ -223,8 +233,7 @@ void CIqTool::stopIqRecorder(void) */ void CIqTool::cancelRecording() { - ui->recButton->setChecked(false); - ui->playButton->setEnabled(true); + switchControlsState(STATE_IDLE); is_recording = false; } diff --git a/src/qtgui/iq_tool.h b/src/qtgui/iq_tool.h index dc56bd35a..abaa57523 100644 --- a/src/qtgui/iq_tool.h +++ b/src/qtgui/iq_tool.h @@ -84,9 +84,16 @@ private slots: void timeoutFunction(void); private: + enum IqToolState + { + STATE_IDLE = 0, + STATE_PLAYING, + STATE_RECORDING + }; void refreshDir(void); void refreshTimeWidgets(void); void parseFileName(const QString &filename); + void switchControlsState(enum IqToolState state); private: Ui::CIqTool *ui;