From 7d4eddbeaca5eb925304d0858d23fad7b3e2efda Mon Sep 17 00:00:00 2001 From: f4exb Date: Wed, 23 Aug 2017 23:43:11 +0200 Subject: [PATCH] New basic channel marker settings with UDP address and port --- sdrbase/dsp/channelmarker.cpp | 16 +- sdrbase/dsp/channelmarker.h | 9 + sdrbase/gui/basicchannelsettingswidget.cpp | 58 +++--- sdrbase/gui/basicchannelsettingswidget.h | 6 +- sdrbase/gui/basicchannelsettingswidget.ui | 196 ++++++++++++--------- 5 files changed, 170 insertions(+), 115 deletions(-) diff --git a/sdrbase/dsp/channelmarker.cpp b/sdrbase/dsp/channelmarker.cpp index ae18b3c57..c2d15b5b5 100644 --- a/sdrbase/dsp/channelmarker.cpp +++ b/sdrbase/dsp/channelmarker.cpp @@ -35,7 +35,9 @@ ChannelMarker::ChannelMarker(QObject* parent) : m_visible(false), m_highlighted(false), m_color(m_colorTable[m_nextColor]), - m_movable(true) + m_movable(true), + m_udpAddress("127.0.0.1"), + m_udpPort(9999) { ++m_nextColor; if(m_colorTable[m_nextColor] == 0) @@ -95,3 +97,15 @@ void ChannelMarker::setColor(const QColor& color) m_color = color; emit changed(); } + +void ChannelMarker::setUDPAddress(const QString& udpAddress) +{ + m_udpAddress = udpAddress; + emit changed(); +} + +void ChannelMarker::setUDPPort(quint16 port) +{ + m_udpPort = port; + emit changed(); +} diff --git a/sdrbase/dsp/channelmarker.h b/sdrbase/dsp/channelmarker.h index f20fa2522..9a7035d36 100644 --- a/sdrbase/dsp/channelmarker.h +++ b/sdrbase/dsp/channelmarker.h @@ -50,6 +50,13 @@ public: void setMovable(bool movable) { m_movable = movable; } bool getMovable() const { return m_movable; } + void setUDPAddress(const QString& udpAddress); + const QString& getUDPAddress() const { return m_udpAddress; } + + void setUDPPort(quint16 port); + quint16 getUDPPort() const { return m_udpPort; } + + protected: static QRgb m_colorTable[]; static int m_nextColor; @@ -64,6 +71,8 @@ protected: bool m_highlighted; QColor m_color; bool m_movable; + QString m_udpAddress; + quint16 m_udpPort; signals: void changed(); diff --git a/sdrbase/gui/basicchannelsettingswidget.cpp b/sdrbase/gui/basicchannelsettingswidget.cpp index 77f607e8f..ae4e30f86 100644 --- a/sdrbase/gui/basicchannelsettingswidget.cpp +++ b/sdrbase/gui/basicchannelsettingswidget.cpp @@ -11,10 +11,9 @@ BasicChannelSettingsWidget::BasicChannelSettingsWidget(ChannelMarker* marker, QW { ui->setupUi(this); ui->title->setText(m_channelMarker->getTitle()); + ui->address->setText(m_channelMarker->getUDPAddress()); + ui->port->setText(QString("%1").arg(m_channelMarker->getUDPPort())); paintColor(); - ui->red->setValue(m_channelMarker->getColor().red()); - ui->green->setValue(m_channelMarker->getColor().green()); - ui->blue->setValue(m_channelMarker->getColor().blue()); } BasicChannelSettingsWidget::~BasicChannelSettingsWidget() @@ -34,44 +33,47 @@ void BasicChannelSettingsWidget::on_colorBtn_clicked() if(c.isValid()) { m_channelMarker->setColor(c); paintColor(); - ui->red->setValue(m_channelMarker->getColor().red()); - ui->green->setValue(m_channelMarker->getColor().green()); - ui->blue->setValue(m_channelMarker->getColor().blue()); } } +void BasicChannelSettingsWidget::on_address_textEdited(const QString& arg1) +{ + m_channelMarker->setUDPAddress(arg1); +} + +void BasicChannelSettingsWidget::on_port_textEdited(const QString& arg1) +{ + bool ok; + int udpPort = arg1.toInt(&ok); + + if((!ok) || (udpPort < 1024) || (udpPort > 65535)) + { + udpPort = 9999; + } + + m_channelMarker->setUDPPort(udpPort); +} + void BasicChannelSettingsWidget::paintColor() { QColor c(m_channelMarker->getColor()); QPixmap pm(24, 24); pm.fill(c); ui->colorBtn->setIcon(pm); - ui->color->setText(tr("#%1%2%3") + ui->colorText->setText(tr("#%1%2%3") .arg(c.red(), 2, 16, QChar('0')) .arg(c.green(), 2, 16, QChar('0')) .arg(c.blue(), 2, 16, QChar('0'))); } -void BasicChannelSettingsWidget::on_red_valueChanged(int value) +void BasicChannelSettingsWidget::setUDPDialogVisible(bool visible) { - QColor c(m_channelMarker->getColor()); - c.setRed(value); - m_channelMarker->setColor(c); - paintColor(); -} - -void BasicChannelSettingsWidget::on_green_valueChanged(int value) -{ - QColor c(m_channelMarker->getColor()); - c.setGreen(value); - m_channelMarker->setColor(c); - paintColor(); -} - -void BasicChannelSettingsWidget::on_blue_valueChanged(int value) -{ - QColor c(m_channelMarker->getColor()); - c.setBlue(value); - m_channelMarker->setColor(c); - paintColor(); + if (visible) + { + ui->udpWidget->show(); + } + else + { + ui->udpWidget->hide(); + } } diff --git a/sdrbase/gui/basicchannelsettingswidget.h b/sdrbase/gui/basicchannelsettingswidget.h index 2f96b6db6..2392152fc 100644 --- a/sdrbase/gui/basicchannelsettingswidget.h +++ b/sdrbase/gui/basicchannelsettingswidget.h @@ -16,13 +16,13 @@ class SDRANGEL_API BasicChannelSettingsWidget : public QWidget { public: explicit BasicChannelSettingsWidget(ChannelMarker* marker, QWidget* parent = NULL); ~BasicChannelSettingsWidget(); + void setUDPDialogVisible(bool visible); private slots: void on_title_textChanged(const QString& text); void on_colorBtn_clicked(); - void on_red_valueChanged(int value); - void on_green_valueChanged(int value); - void on_blue_valueChanged(int value); + void on_address_textEdited(const QString& arg1); + void on_port_textEdited(const QString& arg1); private: Ui::BasicChannelSettingsWidget* ui; diff --git a/sdrbase/gui/basicchannelsettingswidget.ui b/sdrbase/gui/basicchannelsettingswidget.ui index cb8b25500..7cb233a03 100644 --- a/sdrbase/gui/basicchannelsettingswidget.ui +++ b/sdrbase/gui/basicchannelsettingswidget.ui @@ -6,8 +6,8 @@ 0 0 - 149 - 156 + 363 + 83 @@ -17,9 +17,12 @@ - Title & Color + Channel basics - + + + 3 + 2 @@ -32,91 +35,118 @@ 2 - - 3 - - - - - - 0 - 0 - - - - Title - - + + + + + + + 0 + 0 + + + + Title + + + + + + + Channel marker title + + + + - - + + + + + + + 0 + 0 + + + + Color + + + + + + + Channel marker color + + + + + + + + + + #ff0000 + + + + - - - - - 0 - 0 - - - - Color - - - - - - - - - - - - - - #ff0000 - - - - - - - 255 - - - Qt::Horizontal - - - - - - - 255 - - - Qt::Horizontal - - - - - - - 255 - - - Qt::Horizontal - + + + + + + + Addr + + + + + + + UDP address + + + 000.000.000.000 + + + 127.0.0.1 + + + + + + + Port + + + + + + + + 60 + 16777215 + + + + UDP port + + + 00000 + + + 9999 + + + + - - title - colorBtn - red - green - blue -