Reverse API: BasicChannelSettingsDialog changes. Applied to AM demod GUI

pull/267/head^2^2
f4exb 2018-12-13 23:52:09 +01:00
rodzic f9062881fc
commit e7f123390f
7 zmienionych plików z 162 dodań i 3 usunięć

Wyświetl plik

@ -206,12 +206,18 @@ void AMDemodGUI::onWidgetRolled(QWidget* widget, bool rollDown)
void AMDemodGUI::onMenuDialogCalled(const QPoint &p)
{
BasicChannelSettingsDialog dialog(&m_channelMarker, this);
dialog.setUseReverseAPI(m_settings.m_useReverseAPI);
dialog.setReverseAPIAddress(m_settings.m_reverseAPIAddress);
dialog.setReverseAPIPort(m_settings.m_reverseAPIPort);
dialog.move(p);
dialog.exec();
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
m_settings.m_rgbColor = m_channelMarker.getColor().rgb();
m_settings.m_title = m_channelMarker.getTitle();
m_settings.m_useReverseAPI = dialog.useReverseAPI();
m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress();
m_settings.m_reverseAPIPort = dialog.getReverseAPIPort();
setWindowTitle(m_settings.m_title);
setTitleColor(m_settings.m_rgbColor);

Wyświetl plik

@ -9,7 +9,7 @@
const PluginDescriptor AMDemodPlugin::m_pluginDescriptor = {
QString("AM Demodulator"),
QString("4.1.0"),
QString("4.3.2"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,

Wyświetl plik

@ -40,6 +40,9 @@ void AMDemodSettings::resetToDefaults()
m_audioDeviceName = AudioDeviceManager::m_defaultDeviceName;
m_pll = false;
m_syncAMOperation = SyncAMDSB;
m_useReverseAPI = false;
m_reverseAPIAddress = "127.0.0.1";
m_reverseAPIPort = 8888;
}
QByteArray AMDemodSettings::serialize() const
@ -60,6 +63,9 @@ QByteArray AMDemodSettings::serialize() const
s.writeString(11, m_audioDeviceName);
s.writeBool(12, m_pll);
s.writeS32(13, (int) m_syncAMOperation);
s.writeBool(14, m_useReverseAPI);
s.writeString(15, m_reverseAPIAddress);
s.writeU32(16, m_reverseAPIPort);
return s.final();
}
@ -78,6 +84,7 @@ bool AMDemodSettings::deserialize(const QByteArray& data)
{
QByteArray bytetmp;
qint32 tmp;
uint32_t utmp;
QString strtmp;
d.readS32(1, &m_inputFrequencyOffset, 0);
@ -100,6 +107,15 @@ bool AMDemodSettings::deserialize(const QByteArray& data)
d.readBool(12, &m_pll, false);
d.readS32(13, &tmp, 0);
m_syncAMOperation = tmp < 0 ? SyncAMDSB : tmp > 2 ? SyncAMDSB : (SyncAMOperation) tmp;
d.readBool(14, &m_useReverseAPI, false);
d.readString(15, &m_reverseAPIAddress, "127.0.0.1");
d.readU32(16, &utmp, 0);
if ((utmp > 1023) && (utmp < 65535)) {
m_reverseAPIPort = utmp;
} else {
m_reverseAPIPort = 8888;
}
return true;
}

Wyświetl plik

@ -42,6 +42,9 @@ struct AMDemodSettings
QString m_audioDeviceName;
bool m_pll;
SyncAMOperation m_syncAMOperation;
bool m_useReverseAPI;
QString m_reverseAPIAddress;
uint16_t m_reverseAPIPort;
AMDemodSettings();
void resetToDefaults();

Wyświetl plik

@ -15,6 +15,9 @@ BasicChannelSettingsDialog::BasicChannelSettingsDialog(ChannelMarker* marker, QW
ui->title->setText(m_channelMarker->getTitle());
m_color = m_channelMarker->getColor();
ui->fScaleDisplayType->setCurrentIndex((int) m_channelMarker->getFrequencyScaleDisplayType());
setUseReverseAPI(false);
setReverseAPIAddress("127.0.0.1");
setReverseAPIPort(8888);
paintColor();
}
@ -23,6 +26,29 @@ BasicChannelSettingsDialog::~BasicChannelSettingsDialog()
delete ui;
}
void BasicChannelSettingsDialog::setUseReverseAPI(bool useReverseAPI)
{
m_useReverseAPI = useReverseAPI;
ui->reverseAPI->setChecked(m_useReverseAPI);
}
void BasicChannelSettingsDialog::setReverseAPIAddress(const QString& address)
{
m_reverseAPIAddress = address;
ui->reverseAPIAddress->setText(m_reverseAPIAddress);
}
void BasicChannelSettingsDialog::setReverseAPIPort(uint16_t port)
{
if (port < 1024) {
return;
} else {
m_reverseAPIPort = port;
}
ui->reverseAPIPort->setText(tr("%1").arg(m_reverseAPIPort));
}
void BasicChannelSettingsDialog::paintColor()
{
QPixmap pm(24, 24);
@ -38,12 +64,36 @@ void BasicChannelSettingsDialog::on_colorBtn_clicked()
{
QColor c = m_color;
c = QColorDialog::getColor(c, this, tr("Select Color for Channel"), QColorDialog::DontUseNativeDialog);
if(c.isValid()) {
if (c.isValid())
{
m_color = c;
paintColor();
}
}
void BasicChannelSettingsDialog::on_reverseAPI_toggled(bool checked)
{
m_useReverseAPI = checked;
}
void BasicChannelSettingsDialog::on_reverseAPIAddress_returnPressed()
{
m_reverseAPIAddress = ui->reverseAPIAddress->text();
}
void BasicChannelSettingsDialog::on_reverseAPIPort_returnPressed()
{
bool dataOk;
int reverseAPIPort = ui->reverseAPIPort->text().toInt(&dataOk);
if((!dataOk) || (reverseAPIPort < 1024) || (reverseAPIPort > 65535)) {
return;
} else {
m_reverseAPIPort = reverseAPIPort;
}
}
void BasicChannelSettingsDialog::accept()
{
m_channelMarker->blockSignals(true);

Wyświetl plik

@ -19,15 +19,27 @@ public:
explicit BasicChannelSettingsDialog(ChannelMarker* marker, QWidget *parent = 0);
~BasicChannelSettingsDialog();
bool hasChanged() const { return m_hasChanged; }
bool useReverseAPI() const { return m_useReverseAPI; }
const QString& getReverseAPIAddress() const { return m_reverseAPIAddress; }
uint16_t getReverseAPIPort() const { return m_reverseAPIPort; }
void setUseReverseAPI(bool useReverseAPI);
void setReverseAPIAddress(const QString& address);
void setReverseAPIPort(uint16_t port);
private slots:
void on_colorBtn_clicked();
void on_reverseAPI_toggled(bool checked);
void on_reverseAPIAddress_returnPressed();
void on_reverseAPIPort_returnPressed();
void accept();
private:
Ui::BasicChannelSettingsDialog *ui;
ChannelMarker* m_channelMarker;
QColor m_color;
bool m_useReverseAPI;
QString m_reverseAPIAddress;
uint16_t m_reverseAPIPort;
bool m_hasChanged;
void paintColor();

Wyświetl plik

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>400</width>
<height>131</height>
<height>135</height>
</rect>
</property>
<property name="font">
@ -112,6 +112,78 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="reverseAPILayout">
<item>
<widget class="QCheckBox" name="reverseAPI">
<property name="toolTip">
<string>Sychronize with reverse API </string>
</property>
<property name="text">
<string>reverse API</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="reverseAPIAddress">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Reverse API address</string>
</property>
<property name="inputMask">
<string>000.000.000.000</string>
</property>
<property name="text">
<string>127.0.0.1</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="reverseAPISeparator">
<property name="text">
<string>:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="reverseAPIPort">
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Reverse API port</string>
</property>
<property name="inputMask">
<string>00000</string>
</property>
<property name="text">
<string>8888</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">