| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | #include <QPainter>
 | 
					
						
							|  |  |  | #include <QColorDialog>
 | 
					
						
							|  |  |  | #include "gui/basicchannelsettingswidget.h"
 | 
					
						
							|  |  |  | #include "dsp/channelmarker.h"
 | 
					
						
							|  |  |  | #include "ui_basicchannelsettingswidget.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | BasicChannelSettingsWidget::BasicChannelSettingsWidget(ChannelMarker* marker, QWidget* parent) : | 
					
						
							|  |  |  | 	QWidget(parent), | 
					
						
							|  |  |  | 	ui(new Ui::BasicChannelSettingsWidget), | 
					
						
							| 
									
										
										
										
											2017-10-20 21:19:42 +02:00
										 |  |  | 	m_channelMarker(marker), | 
					
						
							|  |  |  | 	m_hasChanged(false) | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	ui->setupUi(this); | 
					
						
							|  |  |  | 	ui->title->setText(m_channelMarker->getTitle()); | 
					
						
							| 
									
										
										
										
											2017-08-23 23:43:11 +02:00
										 |  |  | 	ui->address->setText(m_channelMarker->getUDPAddress()); | 
					
						
							| 
									
										
										
										
											2017-08-24 02:26:47 +02:00
										 |  |  | 	ui->port->setText(QString("%1").arg(m_channelMarker->getUDPReceivePort())); | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 	paintColor(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | BasicChannelSettingsWidget::~BasicChannelSettingsWidget() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	delete ui; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void BasicChannelSettingsWidget::on_title_textChanged(const QString& text) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	m_channelMarker->setTitle(text); | 
					
						
							| 
									
										
										
										
											2017-10-20 21:19:42 +02:00
										 |  |  | 	m_hasChanged = true; | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void BasicChannelSettingsWidget::on_colorBtn_clicked() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	QColor c = m_channelMarker->getColor(); | 
					
						
							|  |  |  | 	c = QColorDialog::getColor(c, this, tr("Select Color for Channel")); | 
					
						
							|  |  |  | 	if(c.isValid()) { | 
					
						
							|  |  |  | 		m_channelMarker->setColor(c); | 
					
						
							|  |  |  | 		paintColor(); | 
					
						
							| 
									
										
										
										
											2017-10-20 21:19:42 +02:00
										 |  |  | 	    m_hasChanged = true; | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-23 23:43:11 +02:00
										 |  |  | void BasicChannelSettingsWidget::on_address_textEdited(const QString& arg1) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_channelMarker->setUDPAddress(arg1); | 
					
						
							| 
									
										
										
										
											2017-10-20 21:19:42 +02:00
										 |  |  |     m_hasChanged = true; | 
					
						
							| 
									
										
										
										
											2017-08-23 23:43:11 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void BasicChannelSettingsWidget::on_port_textEdited(const QString& arg1) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     bool ok; | 
					
						
							|  |  |  |     int udpPort = arg1.toInt(&ok); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if((!ok) || (udpPort < 1024) || (udpPort > 65535)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         udpPort = 9999; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-24 02:26:47 +02:00
										 |  |  |     m_channelMarker->setUDPReceivePort(udpPort); | 
					
						
							| 
									
										
										
										
											2017-10-20 21:19:42 +02:00
										 |  |  |     m_hasChanged = true; | 
					
						
							| 
									
										
										
										
											2017-08-23 23:43:11 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | void BasicChannelSettingsWidget::paintColor() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	QColor c(m_channelMarker->getColor()); | 
					
						
							|  |  |  | 	QPixmap pm(24, 24); | 
					
						
							|  |  |  | 	pm.fill(c); | 
					
						
							|  |  |  | 	ui->colorBtn->setIcon(pm); | 
					
						
							| 
									
										
										
										
											2017-08-23 23:43:11 +02:00
										 |  |  | 	ui->colorText->setText(tr("#%1%2%3") | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 		.arg(c.red(), 2, 16, QChar('0')) | 
					
						
							|  |  |  | 		.arg(c.green(), 2, 16, QChar('0')) | 
					
						
							|  |  |  | 		.arg(c.blue(), 2, 16, QChar('0'))); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-23 23:43:11 +02:00
										 |  |  | void BasicChannelSettingsWidget::setUDPDialogVisible(bool visible) | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-08-23 23:43:11 +02:00
										 |  |  |     if (visible) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->udpWidget->show(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->udpWidget->hide(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | } |