1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-23 08:28:36 -05:00
sdrangel/sdrgui/gui/samplingdevicecontrol.cpp

104 lines
3.5 KiB
C++
Raw Normal View History

///////////////////////////////////////////////////////////////////////////////////
2017-11-01 22:30:54 -04:00
// Copyright (C) 2015-2017 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/>. //
///////////////////////////////////////////////////////////////////////////////////
2017-11-01 22:30:54 -04:00
#include "samplingdevicecontrol.h"
#include "samplingdevicedialog.h"
#include "plugin/pluginmanager.h"
2017-11-01 22:30:54 -04:00
#include "device/deviceenumerator.h"
#include "ui_samplingdevicecontrol.h"
2017-11-01 22:30:54 -04:00
SamplingDeviceControl::SamplingDeviceControl(int tabIndex, bool rxElseTx, QWidget* parent) :
QWidget(parent),
ui(new Ui::SamplingDeviceControl),
m_pluginManager(0),
2017-11-01 22:30:54 -04:00
m_deviceTabIndex(tabIndex),
m_rxElseTx(rxElseTx),
m_selectedDeviceIndex(-1)
{
ui->setupUi(this);
ui->deviceSelectedText->setText("None");
}
SamplingDeviceControl::~SamplingDeviceControl()
{
delete ui;
}
2017-11-01 22:30:54 -04:00
void SamplingDeviceControl::on_deviceChange_clicked()
{
2017-11-01 22:30:54 -04:00
SamplingDeviceDialog dialog(m_rxElseTx, m_deviceTabIndex, this);
dialog.exec();
if (dialog.getSelectedDeviceIndex() >= 0)
{
m_selectedDeviceIndex = dialog.getSelectedDeviceIndex();
setSelectedDeviceIndex(m_selectedDeviceIndex);
emit changed();
}
}
2017-11-01 22:30:54 -04:00
void SamplingDeviceControl::on_deviceReload_clicked()
{
2017-11-01 22:30:54 -04:00
if (m_selectedDeviceIndex >= 0) {
emit changed();
}
}
void SamplingDeviceControl::setSelectedDeviceIndex(int index)
{
if (m_rxElseTx)
{
PluginInterface::SamplingDevice samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(index);
DeviceEnumerator::instance()->changeRxSelection(m_deviceTabIndex, index);
2017-11-01 22:30:54 -04:00
ui->deviceSelectedText->setText(samplingDevice.displayedName);
}
else
{
PluginInterface::SamplingDevice samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(index);
DeviceEnumerator::instance()->changeTxSelection(m_deviceTabIndex, index);
2017-11-01 22:30:54 -04:00
ui->deviceSelectedText->setText(samplingDevice.displayedName);
}
m_selectedDeviceIndex = index;
}
void SamplingDeviceControl::removeSelectedDeviceIndex()
{
if (m_rxElseTx)
{
DeviceEnumerator::instance()->removeRxSelection(m_deviceTabIndex);
ui->deviceSelectedText->setText("None");
}
else
{
DeviceEnumerator::instance()->removeTxSelection(m_deviceTabIndex);
ui->deviceSelectedText->setText("None");
}
m_selectedDeviceIndex = -1;
}
QComboBox *SamplingDeviceControl::getChannelSelector()
{
return ui->channelSelect;
}
QPushButton *SamplingDeviceControl::getAddChannelButton()
{
return ui->addChannel;
}