Skip to content

Commit

Permalink
IQ tool: disable unused controls when recording/playback is in progress.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vladisslav2011 committed Nov 10, 2022
1 parent 23c6ad1 commit 036ea2b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
10 changes: 10 additions & 0 deletions src/applications/gqrx/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1552,6 +1552,8 @@ void MainWindow::startIqRecording(const QString& recdir)
toString("%1/gqrx_yyyyMMdd_hhmmss_%2_%3_fc.'raw'")
.arg(recdir).arg(freq).arg(sr/dec);

ui->actionIoConfig->setDisabled(true);
ui->actionLoadSettings->setDisabled(true);
// start recorder; fails if recording already in progress
if (rx->start_iq_recording(lastRec.toStdString()))
{
Expand Down Expand Up @@ -1582,6 +1584,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)
Expand Down Expand Up @@ -1624,6 +1628,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);
}
Expand All @@ -1637,6 +1644,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();
Expand Down
28 changes: 19 additions & 9 deletions src/qtgui/iq_tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,20 @@ void CIqTool::on_listWidget_currentTextChanged(const QString &currentText)

}

/*! \brief Show/hide/enable/disable GUI controls */

void CIqTool::switchControlsState(bool recording, bool playback)
{
ui->recButton->setEnabled(!playback);

ui->playButton->setEnabled(!recording);
ui->slider->setEnabled(!recording);

ui->listWidget->setEnabled(!(recording || playback));
ui->recDirEdit->setEnabled(!(recording || playback));
ui->recDirButton->setEnabled(!(recording || playback));
}

/*! \brief Start/stop playback */
void CIqTool::on_playButton_clicked(bool checked)
{
Expand All @@ -125,17 +139,15 @@ void CIqTool::on_playButton_clicked(bool checked)
}
else
{
ui->listWidget->setEnabled(false);
ui->recButton->setEnabled(false);
switchControlsState(false, true);
emit startPlayback(recdir->absoluteFilePath(current_file),
(float)sample_rate, center_freq);
}
}
else
{
emit stopPlayback();
ui->listWidget->setEnabled(true);
ui->recButton->setEnabled(true);
switchControlsState(false, false);
ui->slider->setValue(0);
}
}
Expand All @@ -148,9 +160,7 @@ void CIqTool::on_playButton_clicked(bool checked)
*/
void CIqTool::cancelPlayback()
{
ui->playButton->setChecked(false);
ui->listWidget->setEnabled(true);
ui->recButton->setEnabled(true);
switchControlsState(false, false);
is_playing = false;
}

Expand All @@ -172,15 +182,15 @@ void CIqTool::on_recButton_clicked(bool checked)

if (checked)
{
ui->playButton->setEnabled(false);
switchControlsState(true, false);
emit startRecording(recdir->path());

refreshDir();
ui->listWidget->setCurrentRow(ui->listWidget->count()-1);
}
else
{
ui->playButton->setEnabled(true);
switchControlsState(false, false);
emit stopRecording();
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/qtgui/iq_tool.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ private slots:
void refreshDir(void);
void refreshTimeWidgets(void);
void parseFileName(const QString &filename);
void switchControlsState(bool recording, bool playback);


private:
Ui::CIqTool *ui;
Expand Down

0 comments on commit 036ea2b

Please sign in to comment.