diff --git a/plugins/channelrx/demodam/amdemodgui.cpp b/plugins/channelrx/demodam/amdemodgui.cpp index 06c879983..649d5c306 100644 --- a/plugins/channelrx/demodam/amdemodgui.cpp +++ b/plugins/channelrx/demodam/amdemodgui.cpp @@ -104,7 +104,7 @@ void AMDemodGUI::channelMarkerChanged() m_settings.m_udpPort = m_channelMarker.getUDPSendPort(), m_settings.m_rgbColor = m_channelMarker.getColor().rgb(); displayUDPAddress(); - m_settings.m_channelMarkerBytes = m_channelMarker.serialize(); + //m_settings.m_channelMarkerBytes = m_channelMarker.serialize(); applySettings(); } @@ -202,6 +202,7 @@ AMDemodGUI::AMDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget m_channelMarker.setUDPSendPort(9999); m_channelMarker.setVisible(true); setTitleColor(m_channelMarker.getColor()); + m_settings.setChannelMarker(&m_channelMarker); connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(channelMarkerChanged())); @@ -281,7 +282,7 @@ void AMDemodGUI::updateChannelMarker() { m_channelMarker.blockSignals(true); - m_channelMarker.deserialize(m_settings.m_channelMarkerBytes); + //m_channelMarker.deserialize(m_settings.m_channelMarkerBytes); this->setWindowTitle(m_channelMarker.getTitle()); m_channelMarker.blockSignals(false); diff --git a/plugins/channelrx/demodam/amdemodsettings.cpp b/plugins/channelrx/demodam/amdemodsettings.cpp index 3778e8723..e9a14c14f 100644 --- a/plugins/channelrx/demodam/amdemodsettings.cpp +++ b/plugins/channelrx/demodam/amdemodsettings.cpp @@ -16,9 +16,11 @@ #include "dsp/dspengine.h" #include "util/simpleserializer.h" +#include "settings/serializable.h" #include "amdemodsettings.h" -AMDemodSettings::AMDemodSettings() +AMDemodSettings::AMDemodSettings() : + m_channelMarker(0) { resetToDefaults(); } @@ -45,7 +47,11 @@ QByteArray AMDemodSettings::serialize() const s.writeS32(2, m_rfBandwidth/100); s.writeS32(4, m_volume*10); s.writeS32(5, m_squelch); - s.writeBlob(6, m_channelMarkerBytes); + + if (m_channelMarker) { + s.writeBlob(6, m_channelMarker->serialize()); + } + s.writeU32(7, m_rgbColor); s.writeBool(8, m_bandpassEnable); return s.final(); @@ -74,7 +80,12 @@ bool AMDemodSettings::deserialize(const QByteArray& data) m_volume = tmp * 0.1; d.readS32(5, &tmp, -40); m_squelch = tmp; - d.readBlob(6, &m_channelMarkerBytes); + d.readBlob(6, &bytetmp); + + if (m_channelMarker) { + m_channelMarker->deserialize(bytetmp); + } + d.readU32(7, &m_rgbColor); d.readBool(8, &m_bandpassEnable, false); return true; diff --git a/plugins/channelrx/demodam/amdemodsettings.h b/plugins/channelrx/demodam/amdemodsettings.h index 5652636b7..abbb12556 100644 --- a/plugins/channelrx/demodam/amdemodsettings.h +++ b/plugins/channelrx/demodam/amdemodsettings.h @@ -19,6 +19,8 @@ #include +class Serializable; + struct AMDemodSettings { int m_inputSampleRate; @@ -33,10 +35,11 @@ struct AMDemodSettings QString m_udpAddress; quint16 m_udpPort; quint32 m_rgbColor; - QByteArray m_channelMarkerBytes; + Serializable *m_channelMarker; AMDemodSettings(); void resetToDefaults(); + void setChannelMarker(Serializable *channelMarker) { m_channelMarker = channelMarker; } QByteArray serialize() const; bool deserialize(const QByteArray& data); }; diff --git a/sdrbase/dsp/channelmarker.h b/sdrbase/dsp/channelmarker.h index f64365b5e..8685ac887 100644 --- a/sdrbase/dsp/channelmarker.h +++ b/sdrbase/dsp/channelmarker.h @@ -5,9 +5,10 @@ #include #include +#include "settings/serializable.h" #include "util/export.h" -class SDRANGEL_API ChannelMarker : public QObject { +class SDRANGEL_API ChannelMarker : public QObject, public Serializable { Q_OBJECT public: @@ -76,8 +77,8 @@ public: const QString& getDisplayAddressSend() const { return m_displayAddressSend; } const QString& getDisplayAddressReceive() const { return m_displayAddressReceive; } - QByteArray serialize() const; - bool deserialize(const QByteArray& data); + virtual QByteArray serialize() const; + virtual bool deserialize(const QByteArray& data); protected: static QRgb m_colorTable[]; diff --git a/sdrbase/settings/serializable.h b/sdrbase/settings/serializable.h new file mode 100644 index 000000000..b5a088e74 --- /dev/null +++ b/sdrbase/settings/serializable.h @@ -0,0 +1,28 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2017 Edouard Griffiths, F4EXB. // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef SDRBASE_SETTINGS_SERIALIZABLE_H_ +#define SDRBASE_SETTINGS_SERIALIZABLE_H_ + +class Serializable +{ +public: + virtual ~Serializable() {} + virtual QByteArray serialize() const = 0; + virtual bool deserialize(const QByteArray& data) = 0; +}; + +#endif /* SDRBASE_SETTINGS_SERIALIZABLE_H_ */