Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IQ tool: disable unused controls when recording/playback is in progress. #1171

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/applications/gqrx/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1629,6 +1629,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 @@ -1659,6 +1661,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 @@ -1701,6 +1705,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);
vladisslav2011 marked this conversation as resolved.
Show resolved Hide resolved

on_actionDSP_triggered(true);
}
Expand All @@ -1714,6 +1721,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
31 changes: 20 additions & 11 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(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)
{
Expand All @@ -125,17 +139,15 @@ 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);
}
}
else
{
emit stopPlayback();
ui->listWidget->setEnabled(true);
ui->recButton->setEnabled(true);
switchControlsState(STATE_IDLE);
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(STATE_IDLE);
is_playing = false;
}

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

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

refreshDir();
ui->listWidget->setCurrentRow(ui->listWidget->count()-1);
}
else
{
ui->playButton->setEnabled(true);
switchControlsState(STATE_IDLE);
emit stopRecording();
}
}
Expand All @@ -195,8 +205,7 @@ void CIqTool::on_recButton_clicked(bool checked)
*/
void CIqTool::cancelRecording()
{
ui->recButton->setChecked(false);
ui->playButton->setEnabled(true);
switchControlsState(STATE_IDLE);
is_recording = false;
}

Expand Down
7 changes: 7 additions & 0 deletions src/qtgui/iq_tool.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,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;
Expand Down