2017-08-23 20:05:48 -04:00
|
|
|
#include <QColorDialog>
|
|
|
|
|
|
|
|
#include "dsp/channelmarker.h"
|
|
|
|
|
|
|
|
#include "basicchannelsettingsdialog.h"
|
|
|
|
#include "ui_basicchannelsettingsdialog.h"
|
|
|
|
|
|
|
|
BasicChannelSettingsDialog::BasicChannelSettingsDialog(ChannelMarker* marker, QWidget *parent) :
|
|
|
|
QDialog(parent),
|
|
|
|
ui(new Ui::BasicChannelSettingsDialog),
|
2017-10-21 04:34:00 -04:00
|
|
|
m_channelMarker(marker),
|
|
|
|
m_hasChanged(false)
|
2017-08-23 20:05:48 -04:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
ui->title->setText(m_channelMarker->getTitle());
|
|
|
|
m_color = m_channelMarker->getColor();
|
2017-08-27 03:22:50 -04:00
|
|
|
ui->fScaleDisplayType->setCurrentIndex((int) m_channelMarker->getFrequencyScaleDisplayType());
|
2018-12-13 17:52:09 -05:00
|
|
|
setUseReverseAPI(false);
|
|
|
|
setReverseAPIAddress("127.0.0.1");
|
|
|
|
setReverseAPIPort(8888);
|
2018-12-16 19:25:54 -05:00
|
|
|
setReverseAPIDeviceIndex(0);
|
|
|
|
setReverseAPIChannelIndex(0);
|
2017-08-23 20:05:48 -04:00
|
|
|
paintColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
BasicChannelSettingsDialog::~BasicChannelSettingsDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2018-12-13 17:52:09 -05:00
|
|
|
void BasicChannelSettingsDialog::setUseReverseAPI(bool useReverseAPI)
|
|
|
|
{
|
|
|
|
m_useReverseAPI = useReverseAPI;
|
|
|
|
ui->reverseAPI->setChecked(m_useReverseAPI);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BasicChannelSettingsDialog::setReverseAPIAddress(const QString& address)
|
|
|
|
{
|
|
|
|
m_reverseAPIAddress = address;
|
|
|
|
ui->reverseAPIAddress->setText(m_reverseAPIAddress);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BasicChannelSettingsDialog::setReverseAPIPort(uint16_t port)
|
|
|
|
{
|
|
|
|
if (port < 1024) {
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
m_reverseAPIPort = port;
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->reverseAPIPort->setText(tr("%1").arg(m_reverseAPIPort));
|
|
|
|
}
|
|
|
|
|
2018-12-14 02:51:01 -05:00
|
|
|
void BasicChannelSettingsDialog::setReverseAPIDeviceIndex(uint16_t deviceIndex)
|
|
|
|
{
|
|
|
|
m_reverseAPIDeviceIndex = deviceIndex > 99 ? 99 : deviceIndex;
|
|
|
|
ui->reverseAPIDeviceIndex->setText(tr("%1").arg(m_reverseAPIDeviceIndex));
|
|
|
|
}
|
|
|
|
|
|
|
|
void BasicChannelSettingsDialog::setReverseAPIChannelIndex(uint16_t channelIndex)
|
|
|
|
{
|
|
|
|
m_reverseAPIChannelIndex = channelIndex > 99 ? 99 : channelIndex;
|
2019-04-20 13:11:58 -04:00
|
|
|
ui->reverseAPIChannelIndex->setText(tr("%1").arg(m_reverseAPIChannelIndex));
|
2018-12-14 02:51:01 -05:00
|
|
|
}
|
|
|
|
|
2017-08-23 20:05:48 -04:00
|
|
|
void BasicChannelSettingsDialog::paintColor()
|
|
|
|
{
|
|
|
|
QPixmap pm(24, 24);
|
|
|
|
pm.fill(m_color);
|
|
|
|
ui->colorBtn->setIcon(pm);
|
|
|
|
ui->colorText->setText(tr("#%1%2%3")
|
|
|
|
.arg(m_color.red(), 2, 16, QChar('0'))
|
|
|
|
.arg(m_color.green(), 2, 16, QChar('0'))
|
|
|
|
.arg(m_color.blue(), 2, 16, QChar('0')));
|
|
|
|
}
|
|
|
|
|
|
|
|
void BasicChannelSettingsDialog::on_colorBtn_clicked()
|
|
|
|
{
|
|
|
|
QColor c = m_color;
|
2018-05-10 17:45:43 -04:00
|
|
|
c = QColorDialog::getColor(c, this, tr("Select Color for Channel"), QColorDialog::DontUseNativeDialog);
|
2018-12-13 17:52:09 -05:00
|
|
|
|
|
|
|
if (c.isValid())
|
|
|
|
{
|
2017-08-23 20:05:48 -04:00
|
|
|
m_color = c;
|
|
|
|
paintColor();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-13 17:52:09 -05:00
|
|
|
void BasicChannelSettingsDialog::on_reverseAPI_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_useReverseAPI = checked;
|
|
|
|
}
|
|
|
|
|
2018-12-27 03:31:55 -05:00
|
|
|
void BasicChannelSettingsDialog::on_reverseAPIAddress_editingFinished()
|
2018-12-13 17:52:09 -05:00
|
|
|
{
|
|
|
|
m_reverseAPIAddress = ui->reverseAPIAddress->text();
|
|
|
|
}
|
|
|
|
|
2018-12-27 03:31:55 -05:00
|
|
|
void BasicChannelSettingsDialog::on_reverseAPIPort_editingFinished()
|
2018-12-13 17:52:09 -05:00
|
|
|
{
|
|
|
|
bool dataOk;
|
|
|
|
int reverseAPIPort = ui->reverseAPIPort->text().toInt(&dataOk);
|
|
|
|
|
|
|
|
if((!dataOk) || (reverseAPIPort < 1024) || (reverseAPIPort > 65535)) {
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
m_reverseAPIPort = reverseAPIPort;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-27 03:31:55 -05:00
|
|
|
void BasicChannelSettingsDialog::on_reverseAPIDeviceIndex_editingFinished()
|
2018-12-16 19:25:54 -05:00
|
|
|
{
|
|
|
|
bool dataOk;
|
|
|
|
int reverseAPIDeviceIndex = ui->reverseAPIDeviceIndex->text().toInt(&dataOk);
|
|
|
|
|
|
|
|
if ((!dataOk) || (reverseAPIDeviceIndex < 0)) {
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
m_reverseAPIDeviceIndex = reverseAPIDeviceIndex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-27 03:31:55 -05:00
|
|
|
void BasicChannelSettingsDialog::on_reverseAPIChannelIndex_editingFinished()
|
2018-12-16 19:25:54 -05:00
|
|
|
{
|
|
|
|
bool dataOk;
|
|
|
|
int reverseAPIChannelIndex = ui->reverseAPIChannelIndex->text().toInt(&dataOk);
|
|
|
|
|
|
|
|
if ((!dataOk) || (reverseAPIChannelIndex < 0)) {
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
m_reverseAPIChannelIndex = reverseAPIChannelIndex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-23 20:05:48 -04:00
|
|
|
void BasicChannelSettingsDialog::accept()
|
|
|
|
{
|
2017-11-13 18:06:42 -05:00
|
|
|
m_channelMarker->blockSignals(true);
|
2017-08-23 20:05:48 -04:00
|
|
|
m_channelMarker->setTitle(ui->title->text());
|
|
|
|
|
|
|
|
if(m_color.isValid()) {
|
|
|
|
m_channelMarker->setColor(m_color);
|
|
|
|
}
|
|
|
|
|
2017-08-26 00:38:28 -04:00
|
|
|
m_channelMarker->setFrequencyScaleDisplayType((ChannelMarker::frequencyScaleDisplay_t) ui->fScaleDisplayType->currentIndex());
|
2017-11-13 18:06:42 -05:00
|
|
|
m_channelMarker->blockSignals(false);
|
2017-08-26 00:38:28 -04:00
|
|
|
|
2017-10-21 04:34:00 -04:00
|
|
|
m_hasChanged = true;
|
2017-08-23 20:05:48 -04:00
|
|
|
QDialog::accept();
|
|
|
|
}
|