Skip to content

Commit 063c7c3

Browse files
IQ tool: disable unused controls when recording/playback is in progress.
Changing IO devices and loading/saving settings does not look like good thing to do while recording/playing an IQ file. Disable seek slider during recording as it has no function in this state. Disable file list and directory selector during recording/playback.
1 parent 53bd3c5 commit 063c7c3

File tree

3 files changed

+37
-11
lines changed

3 files changed

+37
-11
lines changed

src/applications/gqrx/mainwindow.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -1552,6 +1552,8 @@ void MainWindow::startIqRecording(const QString& recdir)
15521552
toString("%1/gqrx_yyyyMMdd_hhmmss_%2_%3_fc.'raw'")
15531553
.arg(recdir).arg(freq).arg(sr/dec);
15541554

1555+
ui->actionIoConfig->setDisabled(true);
1556+
ui->actionLoadSettings->setDisabled(true);
15551557
// start recorder; fails if recording already in progress
15561558
if (rx->start_iq_recording(lastRec.toStdString()))
15571559
{
@@ -1582,6 +1584,8 @@ void MainWindow::stopIqRecording()
15821584
ui->statusBar->showMessage(tr("Error stopping I/Q recoder"));
15831585
else
15841586
ui->statusBar->showMessage(tr("I/Q data recoding stopped"), 5000);
1587+
ui->actionIoConfig->setDisabled(false);
1588+
ui->actionLoadSettings->setDisabled(false);
15851589
}
15861590

15871591
void MainWindow::startIqPlayback(const QString& filename, float samprate, qint64 center_freq)
@@ -1624,6 +1628,9 @@ void MainWindow::startIqPlayback(const QString& filename, float samprate, qint64
16241628

16251629
// FIXME: would be nice with good/bad status
16261630
ui->statusBar->showMessage(tr("Playing %1").arg(filename));
1631+
ui->actionIoConfig->setDisabled(true);
1632+
ui->actionLoadSettings->setDisabled(true);
1633+
ui->actionSaveSettings->setDisabled(true);
16271634

16281635
on_actionDSP_triggered(true);
16291636
}
@@ -1637,6 +1644,9 @@ void MainWindow::stopIqPlayback()
16371644
}
16381645

16391646
ui->statusBar->showMessage(tr("I/Q playback stopped"), 5000);
1647+
ui->actionIoConfig->setDisabled(false);
1648+
ui->actionLoadSettings->setDisabled(false);
1649+
ui->actionSaveSettings->setDisabled(false);
16401650

16411651
// restore original input device
16421652
auto indev = m_settings->value("input/device", "").toString();

src/qtgui/iq_tool.cpp

+20-11
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,20 @@ void CIqTool::on_listWidget_currentTextChanged(const QString &currentText)
101101

102102
}
103103

104+
/*! \brief Show/hide/enable/disable GUI controls */
105+
106+
void CIqTool::switchControlsState(enum IqToolState state)
107+
{
108+
ui->recButton->setEnabled(state != STATE_PLAYING);
109+
110+
ui->playButton->setEnabled(state != STATE_RECORDING);
111+
ui->slider->setEnabled(state != STATE_RECORDING);
112+
113+
ui->listWidget->setEnabled(state == STATE_IDLE);
114+
ui->recDirEdit->setEnabled(state == STATE_IDLE);
115+
ui->recDirButton->setEnabled(state == STATE_IDLE);
116+
}
117+
104118
/*! \brief Start/stop playback */
105119
void CIqTool::on_playButton_clicked(bool checked)
106120
{
@@ -126,17 +140,15 @@ void CIqTool::on_playButton_clicked(bool checked)
126140
}
127141
else
128142
{
129-
ui->listWidget->setEnabled(false);
130-
ui->recButton->setEnabled(false);
143+
switchControlsState(STATE_PLAYING);
131144
emit startPlayback(recdir->absoluteFilePath(current_file),
132145
(float)sample_rate, center_freq);
133146
}
134147
}
135148
else
136149
{
137150
emit stopPlayback();
138-
ui->listWidget->setEnabled(true);
139-
ui->recButton->setEnabled(true);
151+
switchControlsState(STATE_IDLE);
140152
ui->slider->setValue(0);
141153
}
142154
}
@@ -149,9 +161,7 @@ void CIqTool::on_playButton_clicked(bool checked)
149161
*/
150162
void CIqTool::cancelPlayback()
151163
{
152-
ui->playButton->setChecked(false);
153-
ui->listWidget->setEnabled(true);
154-
ui->recButton->setEnabled(true);
164+
switchControlsState(STATE_IDLE);
155165
is_playing = false;
156166
}
157167

@@ -173,15 +183,15 @@ void CIqTool::on_recButton_clicked(bool checked)
173183

174184
if (checked)
175185
{
176-
ui->playButton->setEnabled(false);
186+
switchControlsState(STATE_RECORDING);
177187
emit startRecording(recdir->path());
178188

179189
refreshDir();
180190
ui->listWidget->setCurrentRow(ui->listWidget->count()-1);
181191
}
182192
else
183193
{
184-
ui->playButton->setEnabled(true);
194+
switchControlsState(STATE_IDLE);
185195
emit stopRecording();
186196
}
187197
}
@@ -196,8 +206,7 @@ void CIqTool::on_recButton_clicked(bool checked)
196206
*/
197207
void CIqTool::cancelRecording()
198208
{
199-
ui->recButton->setChecked(false);
200-
ui->playButton->setEnabled(true);
209+
switchControlsState(STATE_IDLE);
201210
is_recording = false;
202211
}
203212

src/qtgui/iq_tool.h

+7
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,16 @@ private slots:
8282
void timeoutFunction(void);
8383

8484
private:
85+
enum IqToolState
86+
{
87+
STATE_IDLE = 0,
88+
STATE_PLAYING,
89+
STATE_RECORDING
90+
};
8591
void refreshDir(void);
8692
void refreshTimeWidgets(void);
8793
void parseFileName(const QString &filename);
94+
void switchControlsState(enum IqToolState state);
8895

8996
private:
9097
Ui::CIqTool *ui;

0 commit comments

Comments
 (0)