Skip to content

Commit

Permalink
IQ tool: disable/enable controls properly
Browse files Browse the repository at this point in the history
Disable directory selector, file list while playing/recording  IQ
file.
Disable slider while recording IQ file.
  • Loading branch information
vladisslav2011 committed Dec 3, 2021
1 parent 1e63a78 commit a8da052
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
29 changes: 20 additions & 9 deletions src/qtgui/iq_tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,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,16 @@ void CIqTool::on_playButton_clicked(bool checked)
else
{
on_listWidget_currentTextChanged(current_file);
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 +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(false, false);
is_playing = false;
}

Expand All @@ -172,15 +183,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 a8da052

Please sign in to comment.