summaryrefslogtreecommitdiffstats
path: root/examples/network/remotecontrol/remotectrlimpl.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2011-11-08 12:31:36 -0600
committerTimothy Pearson <[email protected]>2011-11-08 12:31:36 -0600
commitd796c9dd933ab96ec83b9a634feedd5d32e1ba3f (patch)
tree6e3dcca4f77e20ec8966c666aac7c35bd4704053 /examples/network/remotecontrol/remotectrlimpl.cpp
downloadtqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.tar.gz
tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.zip
Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731
Diffstat (limited to 'examples/network/remotecontrol/remotectrlimpl.cpp')
-rw-r--r--examples/network/remotecontrol/remotectrlimpl.cpp50
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) );
+ }
+}