diff --git a/src/applications/gqrx/mainwindow.cpp b/src/applications/gqrx/mainwindow.cpp index d54307497..f014cccf5 100644 --- a/src/applications/gqrx/mainwindow.cpp +++ b/src/applications/gqrx/mainwindow.cpp @@ -1581,6 +1581,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())) { @@ -1611,6 +1613,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) @@ -1622,6 +1626,8 @@ void MainWindow::startIqPlayback(const QString& filename, float samprate, qint64 } storeSession(); + backupFreq = ui->freqCtrl->getFrequency(); + backupOffset = (qint64) rx->get_filter_offset(); auto sri = (int)samprate; auto cf = center_freq; @@ -1653,6 +1659,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); } @@ -1666,6 +1675,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/applications/gqrx/mainwindow.h b/src/applications/gqrx/mainwindow.h index 56404e918..f4efba904 100644 --- a/src/applications/gqrx/mainwindow.h +++ b/src/applications/gqrx/mainwindow.h @@ -80,6 +80,8 @@ public slots: qint64 d_hw_freq; qint64 d_hw_freq_start{}; qint64 d_hw_freq_stop{}; + qint64 backupFreq; /* for IQ player */ + qint64 backupOffset; /* for IQ player */ bool d_ignore_limits; diff --git a/src/qtgui/iq_tool.cpp b/src/qtgui/iq_tool.cpp index 8375db8e9..e4d102ba1 100644 --- a/src/qtgui/iq_tool.cpp +++ b/src/qtgui/iq_tool.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -100,6 +101,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 +140,9 @@ void CIqTool::on_playButton_clicked(bool checked) } else { - ui->listWidget->setEnabled(false); - ui->recButton->setEnabled(false); + on_listWidget_currentTextChanged(current_file); + switchControlsState(false, true); + emit startPlayback(recdir->absoluteFilePath(current_file), (float)sample_rate, center_freq); } @@ -134,8 +150,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 +163,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 +185,7 @@ void CIqTool::on_recButton_clicked(bool checked) if (checked) { - ui->playButton->setEnabled(false); + switchControlsState(true, false); emit startRecording(recdir->path()); refreshDir(); @@ -180,7 +193,7 @@ void CIqTool::on_recButton_clicked(bool checked) } else { - ui->playButton->setEnabled(true); + switchControlsState(false, false); emit stopRecording(); } } @@ -303,6 +316,8 @@ void CIqTool::refreshDir() { int selection = ui->listWidget->currentRow(); + QScrollBar * sc = ui->listWidget->verticalScrollBar(); + int lastScroll = sc->sliderPosition(); recdir->refresh(); QStringList files = recdir->entryList(); @@ -310,6 +325,7 @@ void CIqTool::refreshDir() ui->listWidget->clear(); ui->listWidget->insertItems(0, files); ui->listWidget->setCurrentRow(selection); + sc->setSliderPosition(lastScroll); ui->listWidget->blockSignals(false); if (is_recording) diff --git a/src/qtgui/iq_tool.h b/src/qtgui/iq_tool.h index cb8da0f5b..e47e6ca56 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;