1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -05:00

SoapySDR support: interface for all generic GUI elements

This commit is contained in:
f4exb 2018-11-01 10:06:27 +01:00
parent d5ce833668
commit f79e6bc3ab
9 changed files with 108 additions and 18 deletions

View File

@ -8,6 +8,7 @@ set(soapysdrinput_SOURCES
soapysdrinputplugin.cpp
soapysdrinputsettings.cpp
soapysdrinputthread.cpp
itemsettinggui.cpp
discreterangegui.cpp
intervalrangegui.cpp
)
@ -18,6 +19,7 @@ set(soapysdrinput_HEADERS
soapysdrinputplugin.h
soapysdrinputsettings.h
soapysdrinputthread.h
itemsettinggui.h
discreterangegui.h
intervalrangegui.h
)

View File

@ -18,7 +18,7 @@
#include "discreterangegui.h"
DiscreteRangeGUI::DiscreteRangeGUI(QWidget* parent) :
QWidget(parent),
ItemSettingGUI(parent),
ui(new Ui::DiscreteRangeGUI)
{
ui->setupUi(this);
@ -52,8 +52,26 @@ 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 rangeChanged(newRange);
emit ItemSettingGUI::valueChanged(newRange);
}

View File

@ -20,24 +20,24 @@
#include <QWidget>
#include <QString>
#include "itemsettinggui.h"
namespace Ui {
class DiscreteRangeGUI;
}
class DiscreteRangeGUI : public QWidget
class DiscreteRangeGUI : public ItemSettingGUI
{
Q_OBJECT
public:
explicit DiscreteRangeGUI(QWidget* parent = 0);
~DiscreteRangeGUI();
virtual ~DiscreteRangeGUI();
void setLabel(const QString& text);
void setUnits(const QString& units);
void addItem(const QString& itemStr, double itemValue);
double getCurrentValue();
signals:
void rangeChanged(double value);
virtual double getCurrentValue();
virtual void setValue(double value);
private slots:
void on_rangeCombo_currentIndexChanged(int index);

View File

@ -20,7 +20,7 @@
#include "intervalrangegui.h"
IntervalRangeGUI::IntervalRangeGUI(QWidget* parent) :
QWidget(parent),
ItemSettingGUI(parent),
ui(new Ui::IntervalRangeGUI),
m_nbDigits(7)
{
@ -83,9 +83,14 @@ double IntervalRangeGUI::getCurrentValue()
return ui->value->getValue();
}
void IntervalRangeGUI::setValue(double value)
{
ui->value->setValue(value);
}
void IntervalRangeGUI::on_value_changed(quint64 value)
{
emit valueChanged(value);
emit ItemSettingGUI::valueChanged(value);
}
void IntervalRangeGUI::on_rangeInterval_currentIndexChanged(int index)

View File

@ -21,25 +21,25 @@
#include <QWidget>
#include <QString>
#include "itemsettinggui.h"
namespace Ui {
class IntervalRangeGUI;
}
class IntervalRangeGUI : public QWidget
class IntervalRangeGUI : public ItemSettingGUI
{
Q_OBJECT
public:
explicit IntervalRangeGUI(QWidget* parent = 0);
~IntervalRangeGUI();
virtual ~IntervalRangeGUI();
void setLabel(const QString& text);
void setUnits(const QString& units);
void addInterval(double minimum, double maximum);
void reset();
double getCurrentValue();
signals:
void valueChanged(double value);
virtual double getCurrentValue();
virtual void setValue(double value);
private slots:
void on_value_changed(quint64 value);

View File

@ -0,0 +1,11 @@
/*
* itemsettinggui.cpp
*
* Created on: Nov 1, 2018
* Author: f4exb
*/
#include "itemsettinggui.h"
ItemSettingGUI::ItemSettingGUI(QWidget *parent) : QWidget(parent) {}

View File

@ -0,0 +1,39 @@
///////////////////////////////////////////////////////////////////////////////////
// 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_ */

View File

@ -34,7 +34,8 @@ SoapySDRInputGui::SoapySDRInputGui(DeviceUISet *deviceUISet, QWidget* parent) :
m_sampleSource(0),
m_sampleRate(0),
m_deviceCenterFrequency(0),
m_lastEngineState(DSPDeviceSourceEngine::StNotStarted)
m_lastEngineState(DSPDeviceSourceEngine::StNotStarted),
m_sampleRateGUI(0)
{
m_sampleSource = (SoapySDRInput*) m_deviceUISet->m_deviceSourceAPI->getSampleSource();
ui->setupUi(this);
@ -85,6 +86,8 @@ void SoapySDRInputGui::createRangesControl(const SoapySDR::RangeList& rangeList,
rangeGUI->addItem(QString("%1").arg(QString::number(it.minimum()/1000.0, 'f', 0)), it.minimum());
}
m_sampleRateGUI = rangeGUI;
connect(m_sampleRateGUI, SIGNAL(valueChanged(double)), this, SLOT(sampleRateChanged(double)));
// QHBoxLayout *layout = new QHBoxLayout();
// QLabel *rangeLabel = new QLabel();
// rangeLabel->setText(text);
@ -121,6 +124,9 @@ void SoapySDRInputGui::createRangesControl(const SoapySDR::RangeList& rangeList,
}
rangeGUI->reset();
m_sampleRateGUI = rangeGUI;
connect(m_sampleRateGUI, SIGNAL(valueChanged(double)), this, SLOT(sampleRateChanged(double)));
}
}
@ -164,4 +170,7 @@ bool SoapySDRInputGui::handleMessage(const Message& message __attribute__((unuse
return false;
}
void SoapySDRInputGui::sampleRateChanged(double sampleRate)
{
qDebug("SoapySDRInputGui::sampleRateChanged: %lf", sampleRate);
}

View File

@ -28,6 +28,7 @@
#include "soapysdrinput.h"
class DeviceUISet;
class ItemSettingGUI;
namespace Ui {
class SoapySDRInputGui;
@ -66,6 +67,11 @@ private:
quint64 m_deviceCenterFrequency; //!< Center frequency in device
int m_lastEngineState;
MessageQueue m_inputMessageQueue;
ItemSettingGUI *m_sampleRateGUI;
private slots:
void sampleRateChanged(double sampleRate);
};