summaryrefslogtreecommitdiffstats
path: root/examples/network/remotecontrol/remotectrlimpl.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-07-10 15:24:15 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-07-10 15:24:15 -0500
commitbd0f3345a938b35ce6a12f6150373b0955b8dd12 (patch)
tree7a520322212d48ebcb9fbe1087e7fca28b76185c /examples/network/remotecontrol/remotectrlimpl.cpp
downloadqt3-bd0f3345a938b35ce6a12f6150373b0955b8dd12.tar.gz
qt3-bd0f3345a938b35ce6a12f6150373b0955b8dd12.zip
Add Qt3 development HEAD version
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 0000000..bac7806
--- /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( QSocket *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 QVariant &v )
+{
+ QByteArray ba;
+ QDataStream varDs( ba, IO_WriteOnly );
+ varDs << v;
+
+ QDataStream ds( socket );
+ ds << (Q_UINT32) ba.size();
+ socket->writeBlock( ba.data(), ba.size() );
+}
+
+void RemoteCtrlImpl::sendImage()
+{
+ QString imageName = QFileDialog::getOpenFileName( QString::null,
+ "Images (*.png *.xpm *.jpg)", this );
+ QImage image( imageName );
+ if ( !image.isNull() ) {
+ sendPacket( image );
+ }
+}
+
+void RemoteCtrlImpl::sendText()
+{
+ sendPacket( textToSend->text() );
+}
+
+void RemoteCtrlImpl::sendPalette()
+{
+ QColor col = QColorDialog::getColor( white, this );
+ if ( col.isValid() ) {
+ sendPacket( QPalette(col,col) );
+ }
+}