diff --git a/plugins/samplesource/rtlsdr/rtlsdrgui.cpp b/plugins/samplesource/rtlsdr/rtlsdrgui.cpp index 91f1f0bca..217083d4e 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrgui.cpp +++ b/plugins/samplesource/rtlsdr/rtlsdrgui.cpp @@ -27,6 +27,7 @@ #include "gui/colormapper.h" #include "gui/glspectrum.h" #include "gui/crightclickenabler.h" +#include "gui/basicdevicesettingsdialog.h" #include "dsp/dspengine.h" #include "dsp/dspcommands.h" @@ -475,7 +476,7 @@ void RTLSDRGui::on_lowSampleRate_toggled(bool checked) void RTLSDRGui::openDeviceSettingsDialog(const QPoint& p) { - QMessageBox m(QMessageBox::Information, tr("Message"), tr("RTLSDRGui::openDeviceSettingsDialog")); - m.move(p); - m.exec(); + BasicDeviceSettingsDialog dialog(this); + dialog.move(p); + dialog.exec(); } diff --git a/sdrgui/CMakeLists.txt b/sdrgui/CMakeLists.txt index 7eaaaea6f..ff1b173dd 100644 --- a/sdrgui/CMakeLists.txt +++ b/sdrgui/CMakeLists.txt @@ -9,6 +9,7 @@ set(sdrgui_SOURCES gui/audiodialog.cpp gui/audioselectdialog.cpp gui/basicchannelsettingsdialog.cpp + gui/basicdevicesettingsdialog.cpp gui/buttonswitch.cpp gui/channelwindow.cpp gui/clickablelabel.cpp @@ -76,6 +77,7 @@ set(sdrgui_HEADERS gui/audiodialog.h gui/audioselectdialog.h gui/basicchannelsettingsdialog.h + gui/basicdevicesettingsdialog.h gui/buttonswitch.h gui/channelwindow.h gui/colormapper.h @@ -146,6 +148,7 @@ set(sdrgui_FORMS gui/aboutdialog.ui gui/addpresetdialog.ui gui/basicchannelsettingsdialog.ui + gui/basicdevicesettingsdialog.ui gui/commandoutputdialog.ui gui/cwkeyergui.ui gui/editcommanddialog.ui diff --git a/sdrgui/gui/basicchannelsettingsdialog.cpp b/sdrgui/gui/basicchannelsettingsdialog.cpp index 7e5fd13c7..2911b52f6 100644 --- a/sdrgui/gui/basicchannelsettingsdialog.cpp +++ b/sdrgui/gui/basicchannelsettingsdialog.cpp @@ -18,6 +18,8 @@ BasicChannelSettingsDialog::BasicChannelSettingsDialog(ChannelMarker* marker, QW setUseReverseAPI(false); setReverseAPIAddress("127.0.0.1"); setReverseAPIPort(8888); + setReverseAPIDeviceIndex(0); + setReverseAPIChannelIndex(0); paintColor(); } @@ -106,6 +108,30 @@ void BasicChannelSettingsDialog::on_reverseAPIPort_returnPressed() } } +void BasicChannelSettingsDialog::on_reverseAPIDeviceIndex_returnPressed() +{ + bool dataOk; + int reverseAPIDeviceIndex = ui->reverseAPIDeviceIndex->text().toInt(&dataOk); + + if ((!dataOk) || (reverseAPIDeviceIndex < 0)) { + return; + } else { + m_reverseAPIDeviceIndex = reverseAPIDeviceIndex; + } +} + +void BasicChannelSettingsDialog::on_reverseAPIChannelIndex_returnPressed() +{ + bool dataOk; + int reverseAPIChannelIndex = ui->reverseAPIChannelIndex->text().toInt(&dataOk); + + if ((!dataOk) || (reverseAPIChannelIndex < 0)) { + return; + } else { + m_reverseAPIChannelIndex = reverseAPIChannelIndex; + } +} + void BasicChannelSettingsDialog::accept() { m_channelMarker->blockSignals(true); diff --git a/sdrgui/gui/basicchannelsettingsdialog.h b/sdrgui/gui/basicchannelsettingsdialog.h index 7769d55d8..0b7fcb448 100644 --- a/sdrgui/gui/basicchannelsettingsdialog.h +++ b/sdrgui/gui/basicchannelsettingsdialog.h @@ -3,7 +3,7 @@ #include -#include "export.h" +#include "../../exports/export.h" namespace Ui { class BasicChannelSettingsDialog; @@ -35,6 +35,8 @@ private slots: void on_reverseAPI_toggled(bool checked); void on_reverseAPIAddress_returnPressed(); void on_reverseAPIPort_returnPressed(); + void on_reverseAPIDeviceIndex_returnPressed(); + void on_reverseAPIChannelIndex_returnPressed(); void accept(); private: diff --git a/sdrgui/gui/basicdevicesettingsdialog.cpp b/sdrgui/gui/basicdevicesettingsdialog.cpp new file mode 100644 index 000000000..6970e5b98 --- /dev/null +++ b/sdrgui/gui/basicdevicesettingsdialog.cpp @@ -0,0 +1,88 @@ +#include "basicdevicesettingsdialog.h" +#include "ui_basicdevicesettingsdialog.h" + +BasicDeviceSettingsDialog::BasicDeviceSettingsDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::BasicDeviceSettingsDialog), + m_hasChanged(false) +{ + ui->setupUi(this); + setUseReverseAPI(false); + setReverseAPIAddress("127.0.0.1"); + setReverseAPIPort(8888); + setReverseAPIDeviceIndex(0); +} + +BasicDeviceSettingsDialog::~BasicDeviceSettingsDialog() +{ + delete ui; +} + +void BasicDeviceSettingsDialog::setUseReverseAPI(bool useReverseAPI) +{ + m_useReverseAPI = useReverseAPI; + ui->reverseAPI->setChecked(m_useReverseAPI); +} + +void BasicDeviceSettingsDialog::setReverseAPIAddress(const QString& address) +{ + m_reverseAPIAddress = address; + ui->reverseAPIAddress->setText(m_reverseAPIAddress); +} + +void BasicDeviceSettingsDialog::setReverseAPIPort(uint16_t port) +{ + if (port < 1024) { + return; + } else { + m_reverseAPIPort = port; + } + + ui->reverseAPIPort->setText(tr("%1").arg(m_reverseAPIPort)); +} + +void BasicDeviceSettingsDialog::setReverseAPIDeviceIndex(uint16_t deviceIndex) +{ + m_reverseAPIDeviceIndex = deviceIndex > 99 ? 99 : deviceIndex; + ui->reverseAPIDeviceIndex->setText(tr("%1").arg(m_reverseAPIDeviceIndex)); +} + +void BasicDeviceSettingsDialog::on_reverseAPI_toggled(bool checked) +{ + m_useReverseAPI = checked; +} + +void BasicDeviceSettingsDialog::on_reverseAPIAddress_returnPressed() +{ + m_reverseAPIAddress = ui->reverseAPIAddress->text(); +} + +void BasicDeviceSettingsDialog::on_reverseAPIPort_returnPressed() +{ + bool dataOk; + int reverseAPIPort = ui->reverseAPIPort->text().toInt(&dataOk); + + if((!dataOk) || (reverseAPIPort < 1024) || (reverseAPIPort > 65535)) { + return; + } else { + m_reverseAPIPort = reverseAPIPort; + } +} + +void BasicDeviceSettingsDialog::on_reverseAPIDeviceIndex_returnPressed() +{ + bool dataOk; + int reverseAPIDeviceIndex = ui->reverseAPIDeviceIndex->text().toInt(&dataOk); + + if ((!dataOk) || (reverseAPIDeviceIndex < 0)) { + return; + } else { + m_reverseAPIDeviceIndex = reverseAPIDeviceIndex; + } +} + +void BasicDeviceSettingsDialog::accept() +{ + m_hasChanged = true; + QDialog::accept(); +} diff --git a/sdrgui/gui/basicdevicesettingsdialog.h b/sdrgui/gui/basicdevicesettingsdialog.h new file mode 100644 index 000000000..7b81a4e56 --- /dev/null +++ b/sdrgui/gui/basicdevicesettingsdialog.h @@ -0,0 +1,45 @@ +#ifndef BASICDEVICESETTINGSDIALOG_H +#define BASICDEVICESETTINGSDIALOG_H + +#include + +#include "../../exports/export.h" + +namespace Ui { + class BasicDeviceSettingsDialog; +} + +class SDRGUI_API BasicDeviceSettingsDialog : public QDialog +{ + Q_OBJECT + +public: + explicit BasicDeviceSettingsDialog(QWidget *parent = 0); + ~BasicDeviceSettingsDialog(); + 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; } + uint16_t getReverseAPIDeviceIndex() const { return m_reverseAPIDeviceIndex; } + void setUseReverseAPI(bool useReverseAPI); + void setReverseAPIAddress(const QString& address); + void setReverseAPIPort(uint16_t port); + void setReverseAPIDeviceIndex(uint16_t deviceIndex); + +private slots: + void on_reverseAPI_toggled(bool checked); + void on_reverseAPIAddress_returnPressed(); + void on_reverseAPIPort_returnPressed(); + void on_reverseAPIDeviceIndex_returnPressed(); + void accept(); + +private: + Ui::BasicDeviceSettingsDialog *ui; + bool m_useReverseAPI; + QString m_reverseAPIAddress; + uint16_t m_reverseAPIPort; + uint16_t m_reverseAPIDeviceIndex; + bool m_hasChanged; +}; + +#endif // BASICDEVICESETTINGSDIALOG_H diff --git a/sdrgui/gui/basicdevicesettingsdialog.ui b/sdrgui/gui/basicdevicesettingsdialog.ui new file mode 100644 index 000000000..a4c5736bd --- /dev/null +++ b/sdrgui/gui/basicdevicesettingsdialog.ui @@ -0,0 +1,183 @@ + + + BasicDeviceSettingsDialog + + + + 0 + 0 + 394 + 77 + + + + + Liberation Sans + 9 + + + + Basic device settings + + + + + + + + Sychronize with reverse API + + + reverse API + + + + + + + + 120 + 0 + + + + Reverse API address + + + 000.000.000.000 + + + 127.0.0.1 + + + + + + + : + + + + + + + + 45 + 0 + + + + + 45 + 16777215 + + + + Reverse API port + + + 00000 + + + 8888 + + + + + + + D + + + + + + + + 22 + 0 + + + + + 22 + 16777215 + + + + Reverse API destination device index + + + 00 + + + 0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + BasicDeviceSettingsDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + BasicDeviceSettingsDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +