diff --git a/src/qtgui/iq_tool.cpp b/src/qtgui/iq_tool.cpp index 22502e26eb..9b0e596bd6 100644 --- a/src/qtgui/iq_tool.cpp +++ b/src/qtgui/iq_tool.cpp @@ -99,6 +99,20 @@ void CIqTool::on_listWidget_currentTextChanged(const QString ¤tText) } +/*! \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) { @@ -125,8 +139,8 @@ 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); } @@ -134,8 +148,7 @@ void CIqTool::on_playButton_clicked(bool checked) else { emit stopPlayback(); - ui->listWidget->setEnabled(true); - ui->recButton->setEnabled(true); + switchControlsState(false, false); ui->slider->setValue(0); } } @@ -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; } @@ -172,7 +183,7 @@ void CIqTool::on_recButton_clicked(bool checked) if (checked) { - ui->playButton->setEnabled(false); + switchControlsState(true, false); emit startRecording(recdir->path()); refreshDir(); @@ -180,7 +191,7 @@ void CIqTool::on_recButton_clicked(bool checked) } else { - ui->playButton->setEnabled(true); + switchControlsState(false, false); emit stopRecording(); } } diff --git a/src/qtgui/iq_tool.h b/src/qtgui/iq_tool.h index 5ebe30a089..bf04b98c12 100644 --- a/src/qtgui/iq_tool.h +++ b/src/qtgui/iq_tool.h @@ -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;