sdrangel/sdrgui/gui/samplingdevicecontrol.cpp

85 wiersze
2.9 KiB
C++

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