1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-17 13:51:47 -05:00

Device user arguments (1)

This commit is contained in:
f4exb 2019-06-12 08:39:25 +02:00
parent 19bc6b1b93
commit 1c8f0c8c14
7 changed files with 590 additions and 0 deletions

View File

@ -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

View File

@ -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 <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QDataStream>
#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('-');
}

View File

@ -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 <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef SDRBASE_DEVICE_DEVICEUSERARG_H_
#define SDRBASE_DEVICE_DEVICEUSERARG_H_
#include <QMap>
#include <QString>
#include <QByteArray>
#include "export.h"
struct DEVICES_API DeviceUserArg
{
public:
typedef QMap<QString, QString> 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<QString, UserArgs> m_argByDevice; //!< "id-index" to arg map
};
#endif // SDRBASE_DEVICE_DEVICEUSERARGS_H_

View File

@ -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

View File

@ -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 <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#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()
{
}

View File

@ -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 <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef SDRGUI_GUI_DEVICEUSERARGDIALOG_H
#define SDRGUI_GUI_DEVICEUSERARGDIALOG_H
#include <QDialog>
#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

View File

@ -0,0 +1,334 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DeviceUserArgDialog</class>
<widget class="QDialog" name="DeviceUserArgDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>477</width>
<height>461</height>
</rect>
</property>
<property name="font">
<font>
<family>Liberation Sans</family>
<pointsize>9</pointsize>
</font>
</property>
<property name="windowTitle">
<string>Device user arguments</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>10</x>
<y>430</y>
<width>461</width>
<height>23</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QTabWidget" name="tabWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>461</width>
<height>411</height>
</rect>
</property>
<property name="font">
<font>
<family>Liberation Sans</family>
<pointsize>9</pointsize>
</font>
</property>
<property name="toolTip">
<string>Override kwargs</string>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tabKwargs">
<attribute name="title">
<string>Kwargs</string>
</attribute>
<widget class="QTreeWidget" name="deviceTree">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>441</width>
<height>231</height>
</rect>
</property>
<column>
<property name="text">
<string>SD</string>
</property>
</column>
<column>
<property name="text">
<string>Driver</string>
</property>
</column>
<column>
<property name="text">
<string>Seq</string>
</property>
</column>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>250</y>
<width>441</width>
<height>24</height>
</rect>
</property>
<layout class="QHBoxLayout" name="deviceLabelLayout">
<item>
<widget class="QLabel" name="deviceLabel">
<property name="minimumSize">
<size>
<width>0</width>
<height>22</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget_2">
<property name="geometry">
<rect>
<x>10</x>
<y>280</y>
<width>441</width>
<height>25</height>
</rect>
</property>
<layout class="QHBoxLayout" name="keysLayout">
<item>
<widget class="QLabel" name="keyLabel">
<property name="minimumSize">
<size>
<width>35</width>
<height>22</height>
</size>
</property>
<property name="text">
<string>Key</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="keySelect">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Channel copy mode</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="deleteKey">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Delete key</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resources/res.qrc">
<normaloff>:/bin.png</normaloff>:/bin.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="keyEdit">
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>New key</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="addKey">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Add the key</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resources/res.qrc">
<normaloff>:/plusw.png</normaloff>:/plusw.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="refreshKeys">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resources/res.qrc">
<normaloff>:/recycle.png</normaloff>:/recycle.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget_5">
<property name="geometry">
<rect>
<x>10</x>
<y>310</y>
<width>441</width>
<height>25</height>
</rect>
</property>
<layout class="QHBoxLayout" name="valuesLayout">
<item>
<widget class="QLabel" name="valueLabel">
<property name="minimumSize">
<size>
<width>35</width>
<height>22</height>
</size>
</property>
<property name="toolTip">
<string>Edit value</string>
</property>
<property name="text">
<string>Value</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="valueEdit">
<property name="toolTip">
<string>Value</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>
</widget>
</widget>
</widget>
</widget>
<resources>
<include location="../resources/res.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>SoapySDRDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>SoapySDRDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>