diff --git a/sdrbase/CMakeLists.txt b/sdrbase/CMakeLists.txt index 378de595a..fe3192cf9 100644 --- a/sdrbase/CMakeLists.txt +++ b/sdrbase/CMakeLists.txt @@ -116,6 +116,7 @@ set(sdrbase_SOURCES device/deviceapi.cpp device/deviceenumerator.cpp + device/deviceuserarg.cpp settings/preferences.cpp settings/preset.cpp @@ -241,6 +242,7 @@ set(sdrbase_HEADERS device/deviceapi.h device/deviceenumerator.h + device/deviceuserarg.h plugin/plugininstancegui.h plugin/plugininterface.h diff --git a/sdrbase/device/deviceuserarg.cpp b/sdrbase/device/deviceuserarg.cpp new file mode 100644 index 000000000..735f8cadd --- /dev/null +++ b/sdrbase/device/deviceuserarg.cpp @@ -0,0 +1,83 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2019 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 // +// (at your option) any later version. // +// // +// 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 . // +/////////////////////////////////////////////////////////////////////////////////// + +#include + +#include "util/simpleserializer.h" +#include "deviceuserarg.h" + +QByteArray DeviceUserArg::serialize() const +{ + SimpleSerializer s(1); + QByteArray data; + QDataStream *stream = new QDataStream(&data, QIODevice::WriteOnly); + *stream << m_argByDevice; + s.writeBlob(1, data); + return s.final(); +} + +bool DeviceUserArg::deserialize(const QByteArray& data) +{ + SimpleDeserializer d(data); + + if (!d.isValid()) { + return false; + } + + if(d.getVersion() == 1) + { + QByteArray data; + + d.readBlob(1, &data); + QDataStream readStream(&data, QIODevice::ReadOnly); + readStream >> m_argByDevice; + + return true; + } + else + { + return false; + } +} + +void DeviceUserArg::splitDeviceKey(const QString& key, QString& driver, int& sequence) +{ + QStringList elms = key.split('-'); + + if (elms.size() > 0) { + driver = elms[0]; + } + + if (elms.size() > 1) + { + bool ok; + QString seqStr = elms[1]; + int seq = seqStr.toInt(&ok); + + if (ok) { + sequence = seq; + } + } +} + +void DeviceUserArg::composeDeviceKey(const QString& driver, int sequence, QString& key) +{ + QStringList strList; + strList.append(driver); + strList.append(QString::number(sequence)); + key = strList.join('-'); +} diff --git a/sdrbase/device/deviceuserarg.h b/sdrbase/device/deviceuserarg.h new file mode 100644 index 000000000..2ae9c2591 --- /dev/null +++ b/sdrbase/device/deviceuserarg.h @@ -0,0 +1,42 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2019 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 // +// (at your option) any later version. // +// // +// 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_DEVICE_DEVICEUSERARG_H_ +#define SDRBASE_DEVICE_DEVICEUSERARG_H_ + +#include +#include +#include + +#include "export.h" + +struct DEVICES_API DeviceUserArg +{ +public: + typedef QMap UserArgs; + + QByteArray serialize() const; + bool deserialize(const QByteArray& data); + + static void splitDeviceKey(const QString& key, QString& id, int& sequence); + static void composeDeviceKey(const QString& id, int sequence, QString& key); + + QMap m_argByDevice; //!< "id-index" to arg map +}; + + +#endif // SDRBASE_DEVICE_DEVICEUSERARGS_H_ \ No newline at end of file diff --git a/sdrgui/CMakeLists.txt b/sdrgui/CMakeLists.txt index 3be7206bb..2d5c239b3 100644 --- a/sdrgui/CMakeLists.txt +++ b/sdrgui/CMakeLists.txt @@ -23,6 +23,7 @@ set(sdrgui_SOURCES gui/crightclickenabler.cpp gui/cwkeyergui.cpp gui/devicestreamselectiondialog.cpp + gui/deviceuserargdialog.cpp gui/editcommanddialog.cpp gui/externalclockbutton.cpp gui/externalclockdialog.cpp @@ -91,6 +92,7 @@ set(sdrgui_HEADERS gui/crightclickenabler.h gui/cwkeyergui.h gui/devicestreamselectiondialog.h + gui/deviceuserargdialog.h gui/editcommanddialog.h gui/externalclockbutton.h gui/externalclockdialog.h @@ -149,6 +151,7 @@ set(sdrgui_FORMS gui/commandoutputdialog.ui gui/cwkeyergui.ui gui/devicestreamselectiondialog.ui + gui/deviceuserargdialog.ui gui/editcommanddialog.ui gui/externalclockdialog.ui gui/glscopegui.ui diff --git a/sdrgui/gui/deviceuserargdialog.cpp b/sdrgui/gui/deviceuserargdialog.cpp new file mode 100644 index 000000000..7e534f22c --- /dev/null +++ b/sdrgui/gui/deviceuserargdialog.cpp @@ -0,0 +1,72 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2019 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 // +// (at your option) any later version. // +// // +// 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 . // +/////////////////////////////////////////////////////////////////////////////////// + +#include "ui_deviceuserargdialog.h" +#include "deviceuserargdialog.h" + +DeviceUserArgDialog::DeviceUserArgDialog(DeviceEnumerator* deviceEnumerator, QWidget* parent) : + QDialog(parent), + ui(new Ui::DeviceUserArgDialog), + m_deviceEnumerator(deviceEnumerator) +{ + ui->setupUi(this); +} + +DeviceUserArgDialog::~DeviceUserArgDialog() +{ + delete ui; +} + +void DeviceUserArgDialog::accept() +{ + QDialog::accept(); +} + +void DeviceUserArgDialog::reject() +{ + QDialog::reject(); +} + +void DeviceUserArgDialog::on_keySelect_currentIndexChanged(int index) +{ + +} + +void DeviceUserArgDialog::on_deleteKey_clicked(bool checked) +{ + +} + +void DeviceUserArgDialog::on_keyEdit_returnPressed() +{ + +} + +void DeviceUserArgDialog::on_addKey_clicked(bool checked) +{ + +} + +void DeviceUserArgDialog::on_refreshKeys_clicked(bool checked) +{ + +} + +void DeviceUserArgDialog::on_valueEdit_returnPressed() +{ + +} \ No newline at end of file diff --git a/sdrgui/gui/deviceuserargdialog.h b/sdrgui/gui/deviceuserargdialog.h new file mode 100644 index 000000000..3c9f4ad69 --- /dev/null +++ b/sdrgui/gui/deviceuserargdialog.h @@ -0,0 +1,54 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2019 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 // +// (at your option) any later version. // +// // +// 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 SDRGUI_GUI_DEVICEUSERARGDIALOG_H +#define SDRGUI_GUI_DEVICEUSERARGDIALOG_H + +#include + +#include "export.h" + +class QTreeWidgetItem; +class DeviceEnumerator; + +namespace Ui { + class DeviceUserArgDialog; +} + +class SDRGUI_API DeviceUserArgDialog : public QDialog { + Q_OBJECT + +public: + explicit DeviceUserArgDialog(DeviceEnumerator* deviceEnumerator, QWidget* parent = 0); + ~DeviceUserArgDialog(); + +private: + Ui::DeviceUserArgDialog* ui; + DeviceEnumerator* m_deviceEnumerator; + +private slots: + void accept(); + void reject(); + void on_keySelect_currentIndexChanged(int index); + void on_deleteKey_clicked(bool checked); + void on_keyEdit_returnPressed(); + void on_addKey_clicked(bool checked); + void on_refreshKeys_clicked(bool checked); + void on_valueEdit_returnPressed(); +}; + +#endif // SDRGUI_GUI_DEVICEUSERARGDIALOG_H \ No newline at end of file diff --git a/sdrgui/gui/deviceuserargdialog.ui b/sdrgui/gui/deviceuserargdialog.ui new file mode 100644 index 000000000..d84ed8b1c --- /dev/null +++ b/sdrgui/gui/deviceuserargdialog.ui @@ -0,0 +1,334 @@ + + + DeviceUserArgDialog + + + + 0 + 0 + 477 + 461 + + + + + Liberation Sans + 9 + + + + Device user arguments + + + + + 10 + 430 + 461 + 23 + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + 10 + 10 + 461 + 411 + + + + + Liberation Sans + 9 + + + + Override kwargs + + + 0 + + + + Kwargs + + + + + 10 + 10 + 441 + 231 + + + + + SD + + + + + Driver + + + + + Seq + + + + + + + 10 + 250 + 441 + 24 + + + + + + + + 0 + 22 + + + + ... + + + + + + + + + 10 + 280 + 441 + 25 + + + + + + + + 35 + 22 + + + + Key + + + + + + + + 120 + 0 + + + + + 120 + 16777215 + + + + Channel copy mode + + + + + + + + 24 + 16777215 + + + + Delete key + + + + + + + :/bin.png:/bin.png + + + + + + + + 80 + 0 + + + + + 100 + 16777215 + + + + New key + + + + + + + + 24 + 16777215 + + + + Add the key + + + + + + + :/plusw.png:/plusw.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 24 + 16777215 + + + + + + + + :/recycle.png:/recycle.png + + + + + + + + + 10 + 310 + 441 + 25 + + + + + + + + 35 + 22 + + + + Edit value + + + Value + + + + + + + Value + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + buttonBox + accepted() + SoapySDRDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + SoapySDRDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +