mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-04 23:14:47 -04:00
SoapySDR support: moved common gui elements to sdrgui
This commit is contained in:
@@ -8,9 +8,6 @@ set(soapysdrinput_SOURCES
|
||||
soapysdrinputplugin.cpp
|
||||
soapysdrinputsettings.cpp
|
||||
soapysdrinputthread.cpp
|
||||
itemsettinggui.cpp
|
||||
discreterangegui.cpp
|
||||
intervalrangegui.cpp
|
||||
)
|
||||
|
||||
set(soapysdrinput_HEADERS
|
||||
@@ -19,15 +16,10 @@ set(soapysdrinput_HEADERS
|
||||
soapysdrinputplugin.h
|
||||
soapysdrinputsettings.h
|
||||
soapysdrinputthread.h
|
||||
itemsettinggui.h
|
||||
discreterangegui.h
|
||||
intervalrangegui.h
|
||||
)
|
||||
|
||||
set(soapysdrinput_FORMS
|
||||
soapysdrinputgui.ui
|
||||
discreterangegui.ui
|
||||
intervalrangegui.ui
|
||||
)
|
||||
|
||||
if (BUILD_DEBIAN)
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2018 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 <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "ui_discreterangegui.h"
|
||||
#include "discreterangegui.h"
|
||||
|
||||
DiscreteRangeGUI::DiscreteRangeGUI(QWidget* parent) :
|
||||
ItemSettingGUI(parent),
|
||||
ui(new Ui::DiscreteRangeGUI)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
DiscreteRangeGUI::~DiscreteRangeGUI()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DiscreteRangeGUI::setLabel(const QString& text)
|
||||
{
|
||||
ui->rangeLabel->setText(text);
|
||||
}
|
||||
|
||||
void DiscreteRangeGUI::setUnits(const QString& units)
|
||||
{
|
||||
ui->rangeUnits->setText(units);
|
||||
}
|
||||
|
||||
void DiscreteRangeGUI::addItem(const QString& itemStr, double itemValue)
|
||||
{
|
||||
ui->rangeCombo->blockSignals(true);
|
||||
ui->rangeCombo->addItem(itemStr);
|
||||
itemValues.push_back(itemValue);
|
||||
ui->rangeCombo->blockSignals(false);
|
||||
}
|
||||
|
||||
double DiscreteRangeGUI::getCurrentValue()
|
||||
{
|
||||
return itemValues[ui->rangeCombo->currentIndex()];
|
||||
}
|
||||
|
||||
void DiscreteRangeGUI::setValue(double value)
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
for (const auto &it : itemValues)
|
||||
{
|
||||
if (it >= value)
|
||||
{
|
||||
ui->rangeCombo->blockSignals(true);
|
||||
ui->rangeCombo->setCurrentIndex(index);
|
||||
ui->rangeCombo->blockSignals(false);
|
||||
break;
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
void DiscreteRangeGUI::on_rangeCombo_currentIndexChanged(int index)
|
||||
{
|
||||
double newRange = itemValues[index];
|
||||
emit ItemSettingGUI::valueChanged(newRange);
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2018 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 <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_DISCRETERANGEGUI_H_
|
||||
#define PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_DISCRETERANGEGUI_H_
|
||||
|
||||
#include <QWidget>
|
||||
#include <QString>
|
||||
|
||||
#include "itemsettinggui.h"
|
||||
|
||||
namespace Ui {
|
||||
class DiscreteRangeGUI;
|
||||
}
|
||||
|
||||
class DiscreteRangeGUI : public ItemSettingGUI
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DiscreteRangeGUI(QWidget* parent = 0);
|
||||
virtual ~DiscreteRangeGUI();
|
||||
|
||||
void setLabel(const QString& text);
|
||||
void setUnits(const QString& units);
|
||||
void addItem(const QString& itemStr, double itemValue);
|
||||
virtual double getCurrentValue();
|
||||
virtual void setValue(double value);
|
||||
|
||||
private slots:
|
||||
void on_rangeCombo_currentIndexChanged(int index);
|
||||
|
||||
private:
|
||||
Ui::DiscreteRangeGUI* ui;
|
||||
std::vector<double> itemValues;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_DISCRETERANGEGUI_H_ */
|
||||
@@ -1,48 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DiscreteRangeGUI</class>
|
||||
<widget class="QWidget" name="DiscreteRangeGUI">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>203</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="horizontalLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>172</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="rangeLabel">
|
||||
<property name="text">
|
||||
<string>Label</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="rangeCombo"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="rangeUnits">
|
||||
<property name="text">
|
||||
<string>Unit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -1,100 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2018 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 <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "ui_intervalrangegui.h"
|
||||
#include "intervalrangegui.h"
|
||||
|
||||
IntervalRangeGUI::IntervalRangeGUI(QWidget* parent) :
|
||||
ItemSettingGUI(parent),
|
||||
ui(new Ui::IntervalRangeGUI),
|
||||
m_nbDigits(7)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->value->setColorMapper(ColorMapper(ColorMapper::GrayGreenYellow));
|
||||
}
|
||||
|
||||
IntervalRangeGUI::~IntervalRangeGUI()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void IntervalRangeGUI::setLabel(const QString& text)
|
||||
{
|
||||
ui->rangeLabel->setText(text);
|
||||
}
|
||||
|
||||
void IntervalRangeGUI::setUnits(const QString& units)
|
||||
{
|
||||
ui->rangeUnits->setText(units);
|
||||
}
|
||||
|
||||
void IntervalRangeGUI::addInterval(double minimum, double maximum)
|
||||
{
|
||||
ui->rangeInterval->blockSignals(true);
|
||||
ui->rangeInterval->addItem(QString("%1").arg(m_minima.size()));
|
||||
ui->rangeInterval->blockSignals(false);
|
||||
m_minima.push_back(minimum);
|
||||
m_maxima.push_back(maximum);
|
||||
}
|
||||
|
||||
void IntervalRangeGUI::reset()
|
||||
{
|
||||
if (m_minima.size() > 0)
|
||||
{
|
||||
double maxLog = 0.0;
|
||||
|
||||
for (const auto &it : m_maxima)
|
||||
{
|
||||
if (log10(it) > maxLog) {
|
||||
maxLog = log10(it);
|
||||
}
|
||||
}
|
||||
|
||||
m_nbDigits = maxLog;
|
||||
m_nbDigits++;
|
||||
ui->rangeInterval->blockSignals(true);
|
||||
ui->rangeInterval->setCurrentIndex(0);
|
||||
ui->rangeInterval->blockSignals(false);
|
||||
ui->value->setValueRange(m_nbDigits, m_minima[0], m_maxima[0]);
|
||||
}
|
||||
|
||||
if (m_minima.size() == 1) {
|
||||
ui->rangeInterval->setDisabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
double IntervalRangeGUI::getCurrentValue()
|
||||
{
|
||||
return ui->value->getValue();
|
||||
}
|
||||
|
||||
void IntervalRangeGUI::setValue(double value)
|
||||
{
|
||||
ui->value->setValue(value);
|
||||
}
|
||||
|
||||
void IntervalRangeGUI::on_value_changed(quint64 value)
|
||||
{
|
||||
emit ItemSettingGUI::valueChanged(value);
|
||||
}
|
||||
|
||||
void IntervalRangeGUI::on_rangeInterval_currentIndexChanged(int index)
|
||||
{
|
||||
ui->value->setValueRange(m_nbDigits, m_minima[index], m_maxima[index]);
|
||||
}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2018 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 <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_INTERVALRANGEGUI_H_
|
||||
#define PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_INTERVALRANGEGUI_H_
|
||||
|
||||
#include <QWidget>
|
||||
#include <QString>
|
||||
|
||||
#include "itemsettinggui.h"
|
||||
|
||||
namespace Ui {
|
||||
class IntervalRangeGUI;
|
||||
}
|
||||
|
||||
class IntervalRangeGUI : public ItemSettingGUI
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit IntervalRangeGUI(QWidget* parent = 0);
|
||||
virtual ~IntervalRangeGUI();
|
||||
|
||||
void setLabel(const QString& text);
|
||||
void setUnits(const QString& units);
|
||||
void addInterval(double minimum, double maximum);
|
||||
void reset();
|
||||
virtual double getCurrentValue();
|
||||
virtual void setValue(double value);
|
||||
|
||||
private slots:
|
||||
void on_value_changed(quint64 value);
|
||||
void on_rangeInterval_currentIndexChanged(int index);
|
||||
|
||||
private:
|
||||
Ui::IntervalRangeGUI* ui;
|
||||
std::vector<double> m_minima;
|
||||
std::vector<double> m_maxima;
|
||||
int m_nbDigits;
|
||||
};
|
||||
|
||||
#endif /* PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_INTERVALRANGEGUI_H_ */
|
||||
@@ -1,91 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>IntervalRangeGUI</class>
|
||||
<widget class="QWidget" name="IntervalRangeGUI">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>263</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="horizontalLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>262</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="rangeLabel">
|
||||
<property name="text">
|
||||
<string>Label</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="ValueDial" name="value" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Liberation Mono</family>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="rangeUnits">
|
||||
<property name="text">
|
||||
<string>Unit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="rangeInterval">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Range select</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ValueDial</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>gui/valuedial.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -1,11 +0,0 @@
|
||||
/*
|
||||
* itemsettinggui.cpp
|
||||
*
|
||||
* Created on: Nov 1, 2018
|
||||
* Author: f4exb
|
||||
*/
|
||||
|
||||
#include "itemsettinggui.h"
|
||||
|
||||
ItemSettingGUI::ItemSettingGUI(QWidget *parent) : QWidget(parent) {}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2018 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 <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This is an interface to an elementary GUI item used to get/set setting from the GUI
|
||||
|
||||
#ifndef PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_ITEMSETTINGGUI_H_
|
||||
#define PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_ITEMSETTINGGUI_H_
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class ItemSettingGUI : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ItemSettingGUI(QWidget *parent = 0);
|
||||
virtual ~ItemSettingGUI() {}
|
||||
virtual double getCurrentValue() = 0;
|
||||
virtual void setValue(double value) = 0;
|
||||
|
||||
signals:
|
||||
void valueChanged(double value);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_ITEMSETTINGGUI_H_ */
|
||||
@@ -22,10 +22,10 @@
|
||||
#include "device/deviceuiset.h"
|
||||
#include "util/simpleserializer.h"
|
||||
#include "gui/glspectrum.h"
|
||||
#include "soapygui/discreterangegui.h"
|
||||
#include "soapygui/intervalrangegui.h"
|
||||
|
||||
#include "ui_soapysdrinputgui.h"
|
||||
#include "discreterangegui.h"
|
||||
#include "intervalrangegui.h"
|
||||
#include "soapysdrinputgui.h"
|
||||
|
||||
SoapySDRInputGui::SoapySDRInputGui(DeviceUISet *deviceUISet, QWidget* parent) :
|
||||
|
||||
Reference in New Issue
Block a user