2017-08-24 00:05:48 +00: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 08:34:00 +00:00
|
|
|
m_channelMarker(marker),
|
|
|
|
m_hasChanged(false)
|
2017-08-24 00:05:48 +00:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
ui->title->setText(m_channelMarker->getTitle());
|
|
|
|
m_color = m_channelMarker->getColor();
|
2017-08-27 07:22:50 +00:00
|
|
|
ui->fScaleDisplayType->setCurrentIndex((int) m_channelMarker->getFrequencyScaleDisplayType());
|
2018-12-13 22:52:09 +00:00
|
|
|
setUseReverseAPI(false);
|
|
|
|
setReverseAPIAddress("127.0.0.1");
|
|
|
|
setReverseAPIPort(8888);
|
2017-08-24 00:05:48 +00:00
|
|
|
paintColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
BasicChannelSettingsDialog::~BasicChannelSettingsDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2018-12-13 22:52:09 +00: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));
|
|
|
|
}
|
|
|
|
|
2017-08-24 00:05:48 +00: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 21:45:43 +00:00
|
|
|
c = QColorDialog::getColor(c, this, tr("Select Color for Channel"), QColorDialog::DontUseNativeDialog);
|
2018-12-13 22:52:09 +00:00
|
|
|
|
|
|
|
if (c.isValid())
|
|
|
|
{
|
2017-08-24 00:05:48 +00:00
|
|
|
m_color = c;
|
|
|
|
paintColor();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-13 22:52:09 +00:00
|
|
|
void BasicChannelSettingsDialog::on_reverseAPI_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_useReverseAPI = checked;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BasicChannelSettingsDialog::on_reverseAPIAddress_returnPressed()
|
|
|
|
{
|
|
|
|
m_reverseAPIAddress = ui->reverseAPIAddress->text();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BasicChannelSettingsDialog::on_reverseAPIPort_returnPressed()
|
|
|
|
{
|
|
|
|
bool dataOk;
|
|
|
|
int reverseAPIPort = ui->reverseAPIPort->text().toInt(&dataOk);
|
|
|
|
|
|
|
|
if((!dataOk) || (reverseAPIPort < 1024) || (reverseAPIPort > 65535)) {
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
m_reverseAPIPort = reverseAPIPort;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-24 00:05:48 +00:00
|
|
|
void BasicChannelSettingsDialog::accept()
|
|
|
|
{
|
2017-11-13 23:06:42 +00:00
|
|
|
m_channelMarker->blockSignals(true);
|
2017-08-24 00:05:48 +00:00
|
|
|
m_channelMarker->setTitle(ui->title->text());
|
|
|
|
|
|
|
|
if(m_color.isValid()) {
|
|
|
|
m_channelMarker->setColor(m_color);
|
|
|
|
}
|
|
|
|
|
2017-08-26 04:38:28 +00:00
|
|
|
m_channelMarker->setFrequencyScaleDisplayType((ChannelMarker::frequencyScaleDisplay_t) ui->fScaleDisplayType->currentIndex());
|
2017-11-13 23:06:42 +00:00
|
|
|
m_channelMarker->blockSignals(false);
|
2017-08-26 04:38:28 +00:00
|
|
|
|
2017-10-21 08:34:00 +00:00
|
|
|
m_hasChanged = true;
|
2017-08-24 00:05:48 +00:00
|
|
|
QDialog::accept();
|
|
|
|
}
|