00001 #include <QtGui> 00002 00003 #include "receiverdialog.h" 00004 00005 ReceiverDialog::ReceiverDialog(QWidget *parent) 00006 : QDialog(parent) 00007 { 00008 setupUi(this); 00009 00010 receiver = new Receiver; 00011 00012 connect(receiver, SIGNAL( connectionBound() ), SLOT(connectionBound() ) ); 00013 connect(receiver, SIGNAL( connectionClose() ), SLOT(connectionClose() ) ); 00014 connect(receiver, SIGNAL( textReceived(QString) ), SLOT( received(QString) ) ); 00015 00016 Url->setText("udp://localhost:1234"); 00017 Url->setReadOnly(false); 00018 ReceivedText->setReadOnly(true); 00019 00020 } 00021 00022 void ReceiverDialog::on_ButtonListen_clicked() 00023 { 00024 if ( receiver->isListening() ) 00025 { 00026 receiver->disconnect(); 00027 } 00028 else 00029 { 00030 QUrl url = Url->text(); 00031 if (url.isValid() ) 00032 receiver->bindUrl(url); 00033 } 00034 } 00035 00036 00037 void ReceiverDialog::connectionBound() 00038 { 00039 ButtonListen->setText("Stop Listening"); 00040 Url->setReadOnly(true); 00041 } 00042 00043 void ReceiverDialog::connectionClose() 00044 { 00045 ButtonListen->setText("Listen"); 00046 Url->setReadOnly(false); 00047 00048 } 00049 00050 void ReceiverDialog::received(QString line) 00051 { 00052 ReceivedText->setText(line); 00053 } 00054