diff options
Diffstat (limited to 'examples/network/remotecontrol/remotectrlimpl.cpp')
-rw-r--r-- | examples/network/remotecontrol/remotectrlimpl.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/examples/network/remotecontrol/remotectrlimpl.cpp b/examples/network/remotecontrol/remotectrlimpl.cpp new file mode 100644 index 000000000..03af938f8 --- /dev/null +++ b/examples/network/remotecontrol/remotectrlimpl.cpp @@ -0,0 +1,50 @@ +#include "remotectrlimpl.h" + +#include <qpushbutton.h> +#include <qlineedit.h> +#include <qsocket.h> +#include <qfiledialog.h> +#include <qcolordialog.h> +#include <qimage.h> + +RemoteCtrlImpl::RemoteCtrlImpl( TQSocket *s ) +{ + socket = s; + connect( sImage, SIGNAL(clicked()), SLOT(sendImage()) ); + connect( sText, SIGNAL(clicked()), SLOT(sendText()) ); + connect( sPalette, SIGNAL(clicked()), SLOT(sendPalette()) ); +} + +void RemoteCtrlImpl::sendPacket( const TQVariant &v ) +{ + TQByteArray ba; + TQDataStream varDs( ba, IO_WriteOnly ); + varDs << v; + + TQDataStream ds( socket ); + ds << (Q_UINT32) ba.size(); + socket->writeBlock( ba.data(), ba.size() ); +} + +void RemoteCtrlImpl::sendImage() +{ + TQString imageName = TQFileDialog::getOpenFileName( TQString::null, + "Images (*.png *.xpm *.jpg)", this ); + TQImage image( imageName ); + if ( !image.isNull() ) { + sendPacket( image ); + } +} + +void RemoteCtrlImpl::sendText() +{ + sendPacket( textToSend->text() ); +} + +void RemoteCtrlImpl::sendPalette() +{ + TQColor col = TQColorDialog::getColor( white, this ); + if ( col.isValid() ) { + sendPacket( TQPalette(col,col) ); + } +} |