diff --git a/plugins/channelrx/filesink/filesink.cpp b/plugins/channelrx/filesink/filesink.cpp index 9c24d8a6f..b684f85cd 100644 --- a/plugins/channelrx/filesink/filesink.cpp +++ b/plugins/channelrx/filesink/filesink.cpp @@ -43,6 +43,7 @@ #include "filesink.h" MESSAGE_CLASS_DEFINITION(FileSink::MsgConfigureFileSink, Message) +MESSAGE_CLASS_DEFINITION(FileSink::MsgReportStartStop, Message) const char* const FileSink::m_channelIdURI = "sdrangel.channel.filesink"; const char* const FileSink::m_channelId = "FileSink"; @@ -116,6 +117,12 @@ void FileSink::start() FileSinkBaseband::MsgConfigureFileSinkBaseband *msg = FileSinkBaseband::MsgConfigureFileSinkBaseband::create(m_settings, true); m_basebandSink->getInputMessageQueue()->push(msg); + + if (getMessageQueueToGUI()) + { + MsgReportStartStop *msg = MsgReportStartStop::create(true); + getMessageQueueToGUI()->push(msg); + } } void FileSink::stop() @@ -124,6 +131,12 @@ void FileSink::stop() m_basebandSink->stopWork(); m_thread.exit(); m_thread.wait(); + + if (getMessageQueueToGUI()) + { + MsgReportStartStop *msg = MsgReportStartStop::create(false); + getMessageQueueToGUI()->push(msg); + } } bool FileSink::handleMessage(const Message& cmd) diff --git a/plugins/channelrx/filesink/filesink.h b/plugins/channelrx/filesink/filesink.h index cfe95b15b..8a7a30e8a 100644 --- a/plugins/channelrx/filesink/filesink.h +++ b/plugins/channelrx/filesink/filesink.h @@ -62,6 +62,25 @@ public: { } }; + class MsgReportStartStop : public Message { + MESSAGE_CLASS_DECLARATION + + public: + bool getStartStop() const { return m_startStop; } + + static MsgReportStartStop* create(bool startStop) { + return new MsgReportStartStop(startStop); + } + + protected: + bool m_startStop; + + MsgReportStartStop(bool startStop) : + Message(), + m_startStop(startStop) + { } + }; + FileSink(DeviceAPI *deviceAPI); virtual ~FileSink(); virtual void destroy() { delete this; } diff --git a/plugins/channelrx/filesink/filesinkgui.cpp b/plugins/channelrx/filesink/filesinkgui.cpp index fadc1ee82..07e1dca50 100644 --- a/plugins/channelrx/filesink/filesinkgui.cpp +++ b/plugins/channelrx/filesink/filesinkgui.cpp @@ -100,6 +100,18 @@ bool FileSinkGUI::handleMessage(const Message& message) blockApplySettings(false); return true; } + else if (FileSink::MsgReportStartStop::match(message)) + { + const FileSink::MsgReportStartStop& cfg = (FileSink::MsgReportStartStop&) message; + m_running = cfg.getStartStop(); + ui->record->setEnabled(m_running && !m_settings.m_squelchRecordingEnable); + + if (!m_running) { + ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); + } + + return true; + } else if (FileSinkMessages::MsgConfigureSpectrum::match(message)) { const FileSinkMessages::MsgConfigureSpectrum& cfg = (FileSinkMessages::MsgConfigureSpectrum&) message; @@ -126,12 +138,10 @@ bool FileSinkGUI::handleMessage(const Message& message) if (report.getOpen()) { ui->record->setStyleSheet("QToolButton { background-color : red; }"); - ui->squelchedRecording->setEnabled(false); } else { ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); - ui->squelchedRecording->setEnabled(true); } return true; @@ -160,6 +170,7 @@ FileSinkGUI::FileSinkGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban m_pluginAPI(pluginAPI), m_deviceUISet(deviceUISet), m_channelMarker(this), + m_running(false), m_fixedShiftIndex(0), m_basebandSampleRate(0), m_fixedPosition(false), @@ -180,6 +191,7 @@ FileSinkGUI::FileSinkGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban ui->deltaFrequency->setValueRange(false, 8, -99999999, 99999999); ui->position->setEnabled(m_fixedPosition); ui->glSpectrumGUI->setBuddies(m_spectrumVis, ui->glSpectrum); + ui->record->setEnabled(false); m_channelMarker.blockSignals(true); m_channelMarker.setColor(m_settings.m_rgbColor); @@ -248,8 +260,7 @@ void FileSinkGUI::displaySettings() ui->preRecordTimeText->setText(tr("%1").arg(m_settings.m_preRecordTime)); ui->postSquelchTime->setValue(m_settings.m_squelchPostRecordTime); ui->postSquelchTimeText->setText(tr("%1").arg(m_settings.m_squelchPostRecordTime)); - ui->squelchedRecording->setChecked(m_settings.m_squelchRecordingEnable); - ui->record->setEnabled(!m_settings.m_squelchRecordingEnable); + ui->record->setEnabled(m_running && !m_settings.m_squelchRecordingEnable); if (!m_settings.m_spectrumSquelchMode) { ui->squelchLevel->setStyleSheet("QDial { background:rgb(79,79,79); }"); @@ -440,8 +451,6 @@ void FileSinkGUI::on_spectrumSquelch_toggled(bool checked) ui->record->setEnabled(true); } - ui->squelchedRecording->setEnabled(checked); - applySettings(); } @@ -468,15 +477,13 @@ void FileSinkGUI::on_postSquelchTime_valueChanged(int value) void FileSinkGUI::on_squelchedRecording_toggled(bool checked) { - ui->record->setEnabled(!checked); + ui->record->setEnabled(m_running && !checked); m_settings.m_squelchRecordingEnable = checked; applySettings(); } void FileSinkGUI::on_record_toggled(bool checked) { - ui->squelchedRecording->setEnabled(!checked); - if (checked) { ui->record->setStyleSheet("QToolButton { background-color : red; }"); } else { diff --git a/plugins/channelrx/filesink/filesinkgui.h b/plugins/channelrx/filesink/filesinkgui.h index e248eb4d4..dad76fc6e 100644 --- a/plugins/channelrx/filesink/filesinkgui.h +++ b/plugins/channelrx/filesink/filesinkgui.h @@ -59,6 +59,7 @@ private: DeviceUISet* m_deviceUISet; ChannelMarker m_channelMarker; FileSinkSettings m_settings; + bool m_running; int m_fixedShiftIndex; int m_basebandSampleRate; double m_shiftFrequencyFactor; //!< Channel frequency shift factor