From 6e1e387174d20fb62a804b6e27438bcc5ea59f28 Mon Sep 17 00:00:00 2001 From: Steven Ceuppens Date: Fri, 27 Sep 2013 14:27:27 +0200 Subject: Changes to integrate the websocket module as a full Qt Add-On module - Changed project files to use Qt structure - Moved existing sources into subdirectory, to make room for moduels - Created a "import/qmlwebsocket" module skeleton (works, but needs to be extended) - Modified examples to not use "include(.pri)", but use "QT += websocket" - Added qml example skeleton (works, but no useful functionality yet) Project can be build with: $ qmake $ make $ make install Module can be used in other projects with QT += websockets Change-Id: I2123026958b264670dbf8a978dee76edf5855806 Reviewed-by: Kurt Pattyn --- examples/echoclient/echoclient.pro | 4 +-- examples/echoserver/echoserver.pro | 4 +-- examples/examples.pro | 6 ++-- examples/qmlwebsocketclient/data.qrc | 5 +++ examples/qmlwebsocketclient/main.cpp | 32 +++++++++++++++++ .../qml/qmlwebsocketclient/main.qml | 42 ++++++++++++++++++++++ examples/qmlwebsocketclient/qmlwebsocketclient.pro | 11 ++++++ 7 files changed, 95 insertions(+), 9 deletions(-) create mode 100644 examples/qmlwebsocketclient/data.qrc create mode 100644 examples/qmlwebsocketclient/main.cpp create mode 100644 examples/qmlwebsocketclient/qml/qmlwebsocketclient/main.qml create mode 100644 examples/qmlwebsocketclient/qmlwebsocketclient.pro (limited to 'examples') diff --git a/examples/echoclient/echoclient.pro b/examples/echoclient/echoclient.pro index 565eea3..f6891ef 100644 --- a/examples/echoclient/echoclient.pro +++ b/examples/echoclient/echoclient.pro @@ -1,4 +1,4 @@ -QT += core +QT += core websockets QT -= gui TARGET = echoclient @@ -9,8 +9,6 @@ mac:QMAKE_CXXFLAGS += -Wall -Werror -Wextra TEMPLATE = app -include(../../src/qwebsockets.pri) - SOURCES += \ main.cpp \ echoclient.cpp diff --git a/examples/echoserver/echoserver.pro b/examples/echoserver/echoserver.pro index 913cb6e..d2edcae 100644 --- a/examples/echoserver/echoserver.pro +++ b/examples/echoserver/echoserver.pro @@ -1,4 +1,4 @@ -QT += core +QT += core websockets QT -= gui TARGET = echoserver @@ -9,8 +9,6 @@ mac:QMAKE_CXXFLAGS += -Wall -Werror -Wextra TEMPLATE = app -include(../../src/qwebsockets.pri) - SOURCES += \ main.cpp \ echoserver.cpp diff --git a/examples/examples.pro b/examples/examples.pro index b350436..653df67 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -1,5 +1,5 @@ -cache() TEMPLATE = subdirs -SUBDIRS = echoclient \ - echoserver +SUBDIRS = echoclient \ + echoserver \ + qmlwebsocketclient diff --git a/examples/qmlwebsocketclient/data.qrc b/examples/qmlwebsocketclient/data.qrc new file mode 100644 index 0000000..3ac4604 --- /dev/null +++ b/examples/qmlwebsocketclient/data.qrc @@ -0,0 +1,5 @@ + + + qml/qmlwebsocketclient/main.qml + + diff --git a/examples/qmlwebsocketclient/main.cpp b/examples/qmlwebsocketclient/main.cpp new file mode 100644 index 0000000..1df79e3 --- /dev/null +++ b/examples/qmlwebsocketclient/main.cpp @@ -0,0 +1,32 @@ +/* +QWebSockets implements the WebSocket protocol as defined in RFC 6455. +Copyright (C) 2013 Kurt Pattyn (pattyn.kurt@gmail.com) + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQuickView view; + view.setSource(QUrl(QStringLiteral("qrc:/qml/qmlwebsocketclient/main.qml"))); + view.show(); + + return app.exec(); +} diff --git a/examples/qmlwebsocketclient/qml/qmlwebsocketclient/main.qml b/examples/qmlwebsocketclient/qml/qmlwebsocketclient/main.qml new file mode 100644 index 0000000..7c227a4 --- /dev/null +++ b/examples/qmlwebsocketclient/qml/qmlwebsocketclient/main.qml @@ -0,0 +1,42 @@ +/* +QWebSockets implements the WebSocket protocol as defined in RFC 6455. +Copyright (C) 2013 Kurt Pattyn (pattyn.kurt@gmail.com) + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +import QtQuick 2.0 +import Qt.Playground.WebSockets 1.0 + +Rectangle { + width: 360 + height: 360 + + WebSocket { + + } + + Text { + text: qsTr("Hello World") + anchors.centerIn: parent + } + + MouseArea { + anchors.fill: parent + onClicked: { + Qt.quit(); + } + } +} diff --git a/examples/qmlwebsocketclient/qmlwebsocketclient.pro b/examples/qmlwebsocketclient/qmlwebsocketclient.pro new file mode 100644 index 0000000..e4a7d13 --- /dev/null +++ b/examples/qmlwebsocketclient/qmlwebsocketclient.pro @@ -0,0 +1,11 @@ +QT += qml quick + +TARGET = qmlwebsocketclient + +CONFIG -= app_bundle + +SOURCES += main.cpp + +RESOURCES += \ + data.qrc + -- cgit v1.2.1