diff --git a/plugins/channeltx/udpsink/udpsink.cpp b/plugins/channeltx/udpsink/udpsink.cpp index 632dbd460..28218aa57 100644 --- a/plugins/channeltx/udpsink/udpsink.cpp +++ b/plugins/channeltx/udpsink/udpsink.cpp @@ -20,6 +20,7 @@ #include "udpsink.h" MESSAGE_CLASS_DEFINITION(UDPSink::MsgUDPSinkConfigure, Message) +MESSAGE_CLASS_DEFINITION(UDPSink::MsgUDPSinkSpectrum, Message) UDPSink::UDPSink(MessageQueue* uiMessageQueue, UDPSinkGUI* udpSinkGUI, BasebandSampleSink* spectrum) : m_uiMessageQueue(uiMessageQueue), @@ -165,6 +166,13 @@ void UDPSink::configure(MessageQueue* messageQueue, messageQueue->push(cmd); } +void UDPSink::setSpectrum(MessageQueue* messageQueue, bool enabled) +{ + Message* cmd = MsgUDPSinkSpectrum::create(enabled); + messageQueue->push(cmd); +} + + void UDPSink::apply(bool force) { if ((m_config.m_inputFrequencyOffset != m_running.m_inputFrequencyOffset) || diff --git a/plugins/channeltx/udpsink/udpsink.h b/plugins/channeltx/udpsink/udpsink.h index ed7972aa6..50bc3057e 100644 --- a/plugins/channeltx/udpsink/udpsink.h +++ b/plugins/channeltx/udpsink/udpsink.h @@ -59,6 +59,7 @@ public: QString& udpAddress, int udpPort, bool channelMute); + void setSpectrum(MessageQueue* messageQueue, bool enabled); private: class MsgUDPSinkConfigure : public Message { @@ -118,6 +119,26 @@ private: { } }; + class MsgUDPSinkSpectrum : public Message { + MESSAGE_CLASS_DECLARATION + + public: + bool getEnabled() const { return m_enabled; } + + static MsgUDPSinkSpectrum* create(bool enabled) + { + return new MsgUDPSinkSpectrum(enabled); + } + + private: + bool m_enabled; + + MsgUDPSinkSpectrum(bool enabled) : + Message(), + m_enabled(enabled) + { } + }; + struct Config { int m_basebandSampleRate; Real m_outputSampleRate; diff --git a/plugins/channeltx/udpsink/udpsinkgui.cpp b/plugins/channeltx/udpsink/udpsinkgui.cpp index c39bfa292..3ae5283d8 100644 --- a/plugins/channeltx/udpsink/udpsinkgui.cpp +++ b/plugins/channeltx/udpsink/udpsinkgui.cpp @@ -18,9 +18,10 @@ #include "dsp/upchannelizer.h" #include "dsp/threadedbasebandsamplesource.h" #include "dsp/spectrumvis.h" -#include "plugin/pluginapi.h" -#include "util/simpleserializer.h" #include "dsp/dspengine.h" +#include "util/simpleserializer.h" +#include "gui/basicchannelsettingswidget.h" +#include "plugin/pluginapi.h" #include "mainwindow.h" #include "udpsinkgui.h" @@ -201,6 +202,7 @@ UDPSinkGUI::UDPSinkGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* m_pluginAPI(pluginAPI), m_deviceAPI(deviceAPI), m_channelMarker(this), + m_basicSettingsShown(false), m_doApplySettings(true) { ui->setupUi(this); @@ -374,3 +376,93 @@ void UDPSinkGUI::applySettings() } } +void UDPSinkGUI::on_deltaFrequency_changed(qint64 value) +{ + m_channelMarker.setCenterFrequency(value); +} + +void UDPSinkGUI::on_sampleFormat_currentIndexChanged(int index) +{ + if ((index == 1) || (index == 2)) { + ui->fmDeviation->setEnabled(true); + } else { + ui->fmDeviation->setEnabled(false); + } + + ui->applyBtn->setEnabled(true); +} + +void UDPSinkGUI::on_sampleRate_textEdited(const QString& arg1 __attribute__((unused))) +{ + ui->applyBtn->setEnabled(true); +} + +void UDPSinkGUI::on_rfBandwidth_textEdited(const QString& arg1 __attribute__((unused))) +{ + ui->applyBtn->setEnabled(true); +} + +void UDPSinkGUI::on_fmDeviation_textEdited(const QString& arg1 __attribute__((unused))) +{ + ui->applyBtn->setEnabled(true); +} + +void UDPSinkGUI::on_udpAddress_textEdited(const QString& arg1 __attribute__((unused))) +{ + ui->applyBtn->setEnabled(true); +} + +void UDPSinkGUI::on_udpPort_textEdited(const QString& arg1 __attribute__((unused))) +{ + ui->applyBtn->setEnabled(true); +} + +void UDPSinkGUI::on_volume_valueChanged(int value) +{ + ui->volume->setValue(value); + ui->volumeText->setText(QString("%1").arg(value)); + applySettings(); +} + +void UDPSinkGUI::on_channelMute_toggled(bool checked __attribute__((unused))) +{ + applySettings(); +} + +void UDPSinkGUI::on_applyBtn_clicked() +{ + applySettings(); +} + +void UDPSinkGUI::onWidgetRolled(QWidget* widget, bool rollDown) +{ + if ((widget == ui->spectrumBox) && (m_udpSink != 0)) + { + m_udpSink->setSpectrum(m_udpSink->getInputMessageQueue(), rollDown); + } +} + +void UDPSinkGUI::onMenuDoubleClicked() +{ + if (!m_basicSettingsShown) + { + m_basicSettingsShown = true; + BasicChannelSettingsWidget* bcsw = new BasicChannelSettingsWidget(&m_channelMarker, this); + bcsw->show(); + } +} + +void UDPSinkGUI::leaveEvent(QEvent*) +{ + blockApplySettings(true); + m_channelMarker.setHighlighted(false); + blockApplySettings(false); +} + +void UDPSinkGUI::enterEvent(QEvent*) +{ + blockApplySettings(true); + m_channelMarker.setHighlighted(true); + blockApplySettings(false); +} + diff --git a/plugins/channeltx/udpsink/udpsinkgui.h b/plugins/channeltx/udpsink/udpsinkgui.h index dda6c194a..596ca6ce7 100644 --- a/plugins/channeltx/udpsink/udpsinkgui.h +++ b/plugins/channeltx/udpsink/udpsinkgui.h @@ -56,6 +56,19 @@ public: private slots: void handleSourceMessages(); + void channelMarkerChanged(); + void on_deltaFrequency_changed(qint64 value); + void on_sampleFormat_currentIndexChanged(int index); + void on_sampleRate_textEdited(const QString& arg1); + void on_rfBandwidth_textEdited(const QString& arg1); + void on_udpAddress_textEdited(const QString& arg1); + void on_udpPort_textEdited(const QString& arg1); + void on_fmDeviation_textEdited(const QString& arg1); + void on_applyBtn_clicked(); + void onWidgetRolled(QWidget* widget, bool rollDown); + void onMenuDoubleClicked(); + void on_volume_valueChanged(int value); + void on_channelMute_toggled(bool checked); private: Ui::UDPSinkGUI* ui; @@ -75,6 +88,7 @@ private: int m_volume; QString m_udpAddress; int m_udpPort; + bool m_basicSettingsShown; bool m_doApplySettings; explicit UDPSinkGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* parent = NULL); @@ -82,6 +96,9 @@ private: void blockApplySettings(bool block); void applySettings(); + + void leaveEvent(QEvent*); + void enterEvent(QEvent*); }; #endif /* PLUGINS_CHANNELTX_UDPSINK_UDPSINKGUI_H_ */ diff --git a/plugins/channeltx/udpsink/udpsinkgui.ui b/plugins/channeltx/udpsink/udpsinkgui.ui index 2eea039c5..13a3a8fc1 100644 --- a/plugins/channeltx/udpsink/udpsinkgui.ui +++ b/plugins/channeltx/udpsink/udpsinkgui.ui @@ -6,7 +6,7 @@ 0 0 - 316 + 340 355 @@ -36,13 +36,13 @@ 2 2 - 312 + 330 142 - 312 + 330 0 @@ -342,6 +342,9 @@ FM deviation in Hz (for S16LE NFM format) + + 00000 + 2500 @@ -361,6 +364,9 @@ Signal bandwidth + + 0009999 + 32000 @@ -408,6 +414,9 @@ Samples rate + + 0009999 + 48000