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();
|
|
|
|
ui->udpAddress->setText(m_channelMarker->getUDPAddress());
|
2017-08-23 20:26:47 -04:00
|
|
|
ui->udpPortReceive->setText(QString("%1").arg(m_channelMarker->getUDPReceivePort()));
|
|
|
|
ui->udpPortSend->setText(QString("%1").arg(m_channelMarker->getUDPSendPort()));
|
2017-08-27 03:22:50 -04:00
|
|
|
ui->fScaleDisplayType->setCurrentIndex((int) m_channelMarker->getFrequencyScaleDisplayType());
|
2017-08-23 20:05:48 -04:00
|
|
|
paintColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
BasicChannelSettingsDialog::~BasicChannelSettingsDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
c = QColorDialog::getColor(c, this, tr("Select Color for Channel"));
|
|
|
|
if(c.isValid()) {
|
|
|
|
m_color = c;
|
|
|
|
paintColor();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_channelMarker->setUDPAddress(ui->udpAddress->text());
|
|
|
|
|
|
|
|
bool ok;
|
2017-08-23 20:26:47 -04:00
|
|
|
int udpPort = ui->udpPortReceive->text().toInt(&ok);
|
2017-08-23 20:05:48 -04:00
|
|
|
|
|
|
|
if((!ok) || (udpPort < 1024) || (udpPort > 65535))
|
|
|
|
{
|
|
|
|
udpPort = 9999;
|
|
|
|
}
|
|
|
|
|
2017-08-23 20:26:47 -04:00
|
|
|
m_channelMarker->setUDPReceivePort(udpPort);
|
|
|
|
|
|
|
|
udpPort = ui->udpPortSend->text().toInt(&ok);
|
|
|
|
|
|
|
|
if((!ok) || (udpPort < 1024) || (udpPort > 65535))
|
|
|
|
{
|
|
|
|
udpPort = 9999;
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
m_channelMarker->setUDPSendPort(udpPort); // activate signal on the last setting only
|
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();
|
|
|
|
}
|