Skip to content

Commit

Permalink
IQ Tool GUI improvements
Browse files Browse the repository at this point in the history
Fix jumpy scrollbar of IQ player

When file list grows long and the user tries to scroll the list to a new
postion, the list continues to return it's scroll to the last selected item.
That's really annoying.
Return the list to last seen position after refreshing it's contents.

IQ recorder: disable harmful buttons while recording is in progress.

Changing IO devices and loading/saving settings does not look like good thing
to do while recording an IQ file.

IQ tool: Always choose correct sampling rate

Reselect file before starting playback. Fixes incorrect sample rate
when playback is started, stopped, devices switched, dsp started,
stopped and then started playback of the same IQ file.

IQ tool: disable/enable controls properly

Disable directory selector, file list while playing/recording  IQ
file.
Disable slider while recording IQ file.
  • Loading branch information
vladisslav2011 committed Nov 5, 2022
1 parent f91f6a9 commit c452ac8
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 9 deletions.
12 changes: 12 additions & 0 deletions src/applications/gqrx/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
{
Expand Down Expand Up @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
Expand All @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/applications/gqrx/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
34 changes: 25 additions & 9 deletions src/qtgui/iq_tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <QString>
#include <QStringList>
#include <QTime>
#include <QScrollBar>

#include <math.h>

Expand Down Expand Up @@ -100,6 +101,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 +140,17 @@ 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);
}
}
else
{
emit stopPlayback();
ui->listWidget->setEnabled(true);
ui->recButton->setEnabled(true);
switchControlsState(false, false);
ui->slider->setValue(0);
}
}
Expand All @@ -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;
}

Expand All @@ -172,15 +185,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 Expand Up @@ -303,13 +316,16 @@ void CIqTool::refreshDir()
{
int selection = ui->listWidget->currentRow();

QScrollBar * sc = ui->listWidget->verticalScrollBar();
int lastScroll = sc->sliderPosition();
recdir->refresh();
QStringList files = recdir->entryList();

ui->listWidget->blockSignals(true);
ui->listWidget->clear();
ui->listWidget->insertItems(0, files);
ui->listWidget->setCurrentRow(selection);
sc->setSliderPosition(lastScroll);
ui->listWidget->blockSignals(false);

if (is_recording)
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 c452ac8

Please sign in to comment.