diff options
Diffstat (limited to 'examples/bluetooth/chat')
-rw-r--r-- | examples/bluetooth/chat/Button.qml | 93 | ||||
-rw-r--r-- | examples/bluetooth/chat/InputBox.qml | 130 | ||||
-rw-r--r-- | examples/bluetooth/chat/Search.qml | 107 | ||||
-rw-r--r-- | examples/bluetooth/chat/chat.pro | 20 | ||||
-rw-r--r-- | examples/bluetooth/chat/chat.qml | 248 | ||||
-rw-r--r-- | examples/bluetooth/chat/chat.qrc | 11 | ||||
-rw-r--r-- | examples/bluetooth/chat/doc/images/chat-view.png | bin | 10185 -> 0 bytes | |||
-rw-r--r-- | examples/bluetooth/chat/doc/src/chat.qdoc | 84 | ||||
-rw-r--r-- | examples/bluetooth/chat/images/clear.png | bin | 320 -> 0 bytes | |||
-rw-r--r-- | examples/bluetooth/chat/images/default.png | bin | 4738 -> 0 bytes | |||
-rw-r--r-- | examples/bluetooth/chat/images/lineedit-bg.png | bin | 217 -> 0 bytes | |||
-rw-r--r-- | examples/bluetooth/chat/qmlchat.cpp | 96 |
12 files changed, 0 insertions, 789 deletions
diff --git a/examples/bluetooth/chat/Button.qml b/examples/bluetooth/chat/Button.qml deleted file mode 100644 index 8c0096c9..00000000 --- a/examples/bluetooth/chat/Button.qml +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the QtBluetooth module. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.2 - -Rectangle { - // Identifier of the item - id: button - - // Attaches to the Text element's text content - property string label - - // Set appearance properties - radius: 3 - antialiasing: true - border.width: 1 - border.color: "#35322f" - color: "#14aaff" - height: buttonLabel.height * 1.5 - width: buttonLabel.width * 1.5 - - Text { - id: buttonLabel - anchors.centerIn: parent - text: label // Bind the text to the parent's text - color: "black" - font.pointSize: 20 - } - - // buttonClick() is callable and a signal handler, - // onButtonClick is automatically created - signal buttonClick() - - // Define the clickable area to be the whole rectangle - MouseArea { - id: buttonMouseArea - anchors.fill: parent // Stretch the area to the parent's dimension - onClicked: buttonClick() - } - - - // Scale the button when pressed - scale: buttonMouseArea.pressed ? 1.1 : 1.0 - // Animate the scale property change - Behavior on scale { NumberAnimation { duration: 55 } } -} diff --git a/examples/bluetooth/chat/InputBox.qml b/examples/bluetooth/chat/InputBox.qml deleted file mode 100644 index b37d9f57..00000000 --- a/examples/bluetooth/chat/InputBox.qml +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the QtBluetooth module. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.2 - -FocusScope { - id: focusScope - width: 250; height: 28 - - property string text: textInput.text - signal clear - - onClear: { - textInput.text="" - } - - BorderImage { - source: "images/lineedit-bg.png" - width: parent.width; height: parent.height - border { left: 4; top: 4; right: 4; bottom: 4 } - } - - Text { - id: typeSomething - anchors.fill: parent; anchors.leftMargin: 8 - verticalAlignment: Text.AlignVCenter - text: "Type something..." - color: "gray" - font.italic: true - font.pointSize: 14 - } - - MouseArea { - anchors.fill: parent - onClicked: { focusScope.focus = true; } - } - - TextInput { - id: textInput - anchors { left: parent.left; leftMargin: 8; right: clear.left; rightMargin: 8; verticalCenter: parent.verticalCenter } - focus: true - selectByMouse: true - font.pointSize: 14 - } - - Image { - id: clear - anchors { right: parent.right; rightMargin: 8; verticalCenter: parent.verticalCenter } - source: "images/clear.png" - opacity: 0 - - MouseArea { - // allow area to grow beyond image size - // easier to hit the area on high DPI devices - anchors.centerIn: parent - height:focusScope.height - width: focusScope.height - onClicked: { - //toogle focus to be able to jump out of input method composer - focusScope.focus = false; - textInput.text = ''; - focusScope.focus = true; - } - } - } - - states: State { - name: "hasText"; when: (textInput.text != '' || textInput.inputMethodComposing) - PropertyChanges { target: typeSomething; opacity: 0 } - PropertyChanges { target: clear; opacity: 1 } - } - - transitions: [ - Transition { - from: ""; to: "hasText" - NumberAnimation { exclude: typeSomething; properties: "opacity" } - }, - Transition { - from: "hasText"; to: "" - NumberAnimation { properties: "opacity" } - } - ] -} diff --git a/examples/bluetooth/chat/Search.qml b/examples/bluetooth/chat/Search.qml deleted file mode 100644 index 78a7f030..00000000 --- a/examples/bluetooth/chat/Search.qml +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the QtBluetooth module. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.2 - -Rectangle { - property bool animationRunning: true - - function appendText(newText) { - searchText.text += newText - } - function setText(newText) { - searchText.text = newText - } - - width: searchText.width + 40; - height: searchText.height + bluetoothImage.height + 40; - color: "#d7d6d5" - border.color: "black" - border.width: 1 - radius: 5 - - Behavior on height { - NumberAnimation { duration: 300 } - } - - Image { - id: bluetoothImage - source: "images/default.png" - anchors.top: parent.top - anchors.topMargin: 10 - anchors.horizontalCenter: parent.horizontalCenter - - RotationAnimation on rotation{ - id: ranimation - target: bluetoothImage - easing.type: Easing.InOutBack - property: "rotation" - from: 0 - to: 360 - duration: 2000 - loops: Animation.Infinite - alwaysRunToEnd: true - running: animationRunning - } - } - - Text { - id: searchText - - anchors.top: bluetoothImage.bottom - //anchors.bottom: parent.bottom - anchors.topMargin: 10 - anchors.horizontalCenter: parent.horizontalCenter - text: qsTr("Searching for chat service..."); - color: "black" - - } -} - diff --git a/examples/bluetooth/chat/chat.pro b/examples/bluetooth/chat/chat.pro deleted file mode 100644 index 36d815f9..00000000 --- a/examples/bluetooth/chat/chat.pro +++ /dev/null @@ -1,20 +0,0 @@ -QT = core bluetooth quick -android: QT += androidextras #see QTBUG-61392 -SOURCES += qmlchat.cpp - -TARGET = qml_chat -TEMPLATE = app - -RESOURCES += \ - chat.qrc - -OTHER_FILES += \ - chat.qml \ - InputBox.qml \ - Search.qml \ - Button.qml - -#DEFINES += QMLJSDEBUGGER - -target.path = $$[QT_INSTALL_EXAMPLES]/bluetooth/chat -INSTALLS += target diff --git a/examples/bluetooth/chat/chat.qml b/examples/bluetooth/chat/chat.qml deleted file mode 100644 index 5c2818b2..00000000 --- a/examples/bluetooth/chat/chat.qml +++ /dev/null @@ -1,248 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the QtBluetooth module. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.2 -import QtBluetooth 5.3 - -Item { - id: top - - Component.onCompleted: state = "begin" - - property string remoteDeviceName: "" - property bool serviceFound: false - - //! [BtDiscoveryModel-1] - BluetoothDiscoveryModel { - id: btModel - running: true - discoveryMode: BluetoothDiscoveryModel.FullServiceDiscovery - //! [BtDiscoveryModel-1] - onRunningChanged : { - if (!btModel.running && top.state == "begin" && !serviceFound) { - searchBox.animationRunning = false; - searchBox.appendText("\nNo service found. \n\nPlease start server\nand restart app.") - } - } - - onErrorChanged: { - if (error != BluetoothDiscoveryModel.NoError && !btModel.running) { - searchBox.animationRunning = false - searchBox.appendText("\n\nDiscovery failed.\nPlease ensure Bluetooth is available.") - } - } - - //! [BtDiscoveryModel-2] - onServiceDiscovered: { - if (serviceFound) - return - serviceFound = true - console.log("Found new service " + service.deviceAddress + " " + service.deviceName + " " + service.serviceName); - searchBox.appendText("\nConnecting to server...") - remoteDeviceName = service.deviceName - socket.setService(service) - } - //! [BtDiscoveryModel-2] - //! [BtDiscoveryModel-3] - uuidFilter: targetUuid //e8e10f95-1a70-4b27-9ccf-02010264e9c8 - } - //! [BtDiscoveryModel-3] - - //! [BluetoothSocket-1] - BluetoothSocket { - id: socket - connected: true - - onSocketStateChanged: { - switch (socketState) { - case BluetoothSocket.Unconnected: - case BluetoothSocket.NoServiceSet: - searchBox.animationRunning = false; - searchBox.setText("\nNo connection. \n\nPlease restart app."); - top.state = "begin"; - break; - case BluetoothSocket.Connected: - console.log("Connected to server "); - top.state = "chatActive"; // move to chat UI - break; - case BluetoothSocket.Connecting: - case BluetoothSocket.ServiceLookup: - case BluetoothSocket.Closing: - case BluetoothSocket.Listening: - case BluetoothSocket.Bound: - break; - } - } - //! [BluetoothSocket-1] - //! [BluetoothSocket-3] - onStringDataChanged: { - console.log("Received data: " ) - var data = remoteDeviceName + ": " + socket.stringData; - data = data.substring(0, data.indexOf('\n')) - chatContent.append({content: data}) - //! [BluetoothSocket-3] - console.log(data); - //! [BluetoothSocket-4] - } - //! [BluetoothSocket-4] - //! [BluetoothSocket-2] - //... - } - //! [BluetoothSocket-2] - - ListModel { - id: chatContent - ListElement { - content: "Connected to chat server" - } - } - - - Rectangle { - id: background - z: 0 - anchors.fill: parent - color: "#5d5b59" - } - - Search { - id: searchBox - anchors.centerIn: top - opacity: 1 - } - - Rectangle { - id: chatBox - opacity: 0 - anchors.centerIn: top - - color: "#5d5b59" - border.color: "black" - border.width: 1 - radius: 5 - anchors.fill: parent - - function sendMessage() - { - // toogle focus to force end of input method composer - var hasFocus = input.focus; - input.focus = false; - - var data = input.text - input.clear() - chatContent.append({content: "Me: " + data}) - //! [BluetoothSocket-5] - socket.stringData = data - //! [BluetoothSocket-5] - chatView.positionViewAtEnd() - - input.focus = hasFocus; - } - - Item { - anchors.fill: parent - anchors.margins: 10 - - InputBox { - id: input - Keys.onReturnPressed: chatBox.sendMessage() - height: sendButton.height - width: parent.width - sendButton.width - 15 - anchors.left: parent.left - } - - Button { - id: sendButton - anchors.right: parent.right - label: "Send" - onButtonClick: chatBox.sendMessage() - } - - - Rectangle { - height: parent.height - input.height - 15 - width: parent.width; - color: "#d7d6d5" - anchors.bottom: parent.bottom - border.color: "black" - border.width: 1 - radius: 5 - - ListView { - id: chatView - width: parent.width-5 - height: parent.height-5 - anchors.centerIn: parent - model: chatContent - clip: true - delegate: Component { - Text { - font.pointSize: 14 - text: modelData - } - } - } - } - } - } - - states: [ - State { - name: "begin" - PropertyChanges { target: searchBox; opacity: 1 } - PropertyChanges { target: chatBox; opacity: 0 } - }, - State { - name: "chatActive" - PropertyChanges { target: searchBox; opacity: 0 } - PropertyChanges { target: chatBox; opacity: 1 } - } - ] -} diff --git a/examples/bluetooth/chat/chat.qrc b/examples/bluetooth/chat/chat.qrc deleted file mode 100644 index f2219f5b..00000000 --- a/examples/bluetooth/chat/chat.qrc +++ /dev/null @@ -1,11 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>chat.qml</file> - <file>images/clear.png</file> - <file>images/lineedit-bg.png</file> - <file>InputBox.qml</file> - <file>images/default.png</file> - <file>Search.qml</file> - <file>Button.qml</file> - </qresource> -</RCC> diff --git a/examples/bluetooth/chat/doc/images/chat-view.png b/examples/bluetooth/chat/doc/images/chat-view.png Binary files differdeleted file mode 100644 index 81785fa2..00000000 --- a/examples/bluetooth/chat/doc/images/chat-view.png +++ /dev/null diff --git a/examples/bluetooth/chat/doc/src/chat.qdoc b/examples/bluetooth/chat/doc/src/chat.qdoc deleted file mode 100644 index 6fdf9b70..00000000 --- a/examples/bluetooth/chat/doc/src/chat.qdoc +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt local connectivty modules. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example chat - \title Bluetooth QML Chat Example - \brief An example demonstrating communication through Bluetooth QML API. - - \e {Bluetooth QML Chat} example shows how to use the \l{Qt Bluetooth} QML API to communicate - with another application on a remote device using Bluetooth. - - \image chat-view.png - - The Bluetooth QML Chat example implements a simple chat program between two parties. The - application acts as client and attempts to connect to a Bluetooth socket server. It uses - the \l BluetoothDiscoveryModel type to find the server and \l BluetoothSocket type to - facilitate the data exchange. - - \include examples-run.qdocinc - - The example only works in connection with the \l {btchat}{Bluetooth Chat Example}. - The Bluetooth Chat example launches the chat service and advertises it via the - Bluetooth SDP protocol. It is important that the device running the Bluetooth Chat - example actively advertises its SDP services. - This can be checked using the \l QBluetoothLocalDevice::hostMode property. - - \section1 Interacting with the Server - - The example application immediately starts the service discovery using the - \l BluetoothDiscoveryModel type: - - \snippet chat/chat.qml BtDiscoveryModel-1 - \snippet chat/chat.qml BtDiscoveryModel-3 - - The \l {BluetoothDiscoveryModel::uuidFilter}{uuidFilter} property is used to only search for - the chat server UUID and the \l {BluetoothDiscoveryModel::running}{running} - property activates the search. Once a service with a matching UUID is found the model emits the - \l {BluetoothDiscoveryModel::serviceDiscovered}{serviceDiscovered(BluetoothService)} signal. - - \snippet chat/chat.qml BtDiscoveryModel-2 - - The \l BluetoothService type encapsulates the details of the found chat server, such as the - \l {BluetoothService::serviceName}{name} and \l {BluetoothService::serviceDescription}{description} of the - service, as well as the \l{BluetoothService::deviceName}{name} and \l {BluetoothService::deviceAddress}{address} - of the Bluetooth device offering the chat server. It is passed to the \l BluetoothSocket - to establish the connection. - - Once the connection is established the socket's state is managed as follows: - \snippet chat/chat.qml BluetoothSocket-1 - \snippet chat/chat.qml BluetoothSocket-2 - - The payload is received via the \l {BluetoothSocket::stringData}{stringData} property: - - \snippet chat/chat.qml BluetoothSocket-3 - \snippet chat/chat.qml BluetoothSocket-4 - - And sent by setting the same property: - - \snippet chat/chat.qml BluetoothSocket-5 -*/ diff --git a/examples/bluetooth/chat/images/clear.png b/examples/bluetooth/chat/images/clear.png Binary files differdeleted file mode 100644 index c20a9cfb..00000000 --- a/examples/bluetooth/chat/images/clear.png +++ /dev/null diff --git a/examples/bluetooth/chat/images/default.png b/examples/bluetooth/chat/images/default.png Binary files differdeleted file mode 100644 index a1a74af5..00000000 --- a/examples/bluetooth/chat/images/default.png +++ /dev/null diff --git a/examples/bluetooth/chat/images/lineedit-bg.png b/examples/bluetooth/chat/images/lineedit-bg.png Binary files differdeleted file mode 100644 index e0d93cd1..00000000 --- a/examples/bluetooth/chat/images/lineedit-bg.png +++ /dev/null diff --git a/examples/bluetooth/chat/qmlchat.cpp b/examples/bluetooth/chat/qmlchat.cpp deleted file mode 100644 index 6c8d2fa7..00000000 --- a/examples/bluetooth/chat/qmlchat.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the QtBluetooth module. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtGui/QGuiApplication> -#include <QtQuick/QQuickView> -#include <QtQml/QQmlEngine> -#include <QtQml/QQmlContext> -#include <QDebug> -#include <QBluetoothLocalDevice> -#include <QtCore/QLoggingCategory> -#ifdef Q_OS_ANDROID -#include <QtAndroidExtras/QtAndroid> -#endif - -int main(int argc, char *argv[]) -{ - //QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true")); - QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QGuiApplication application(argc, argv); - - QList<QBluetoothHostInfo> infos = QBluetoothLocalDevice::allDevices(); - if (infos.isEmpty()) - qWarning() << "Missing Bluetooth local device. " - "Example will not work properly."; - - const QString mainQmlApp = QLatin1String("qrc:/chat.qml"); - QQuickView view; - -#ifdef Q_OS_ANDROID - //workaround for Android's SDP discovery bug (see QTBUG-61392) - QString uuid; - if (QtAndroid::androidSdkVersion() >= 23) - uuid = QStringLiteral("c8e96402-0102-cf9c-274b-701a950fe1e8"); - else - uuid = QStringLiteral("e8e10f95-1a70-4b27-9ccf-02010264e9c8"); -#else - const QString uuid(QStringLiteral("e8e10f95-1a70-4b27-9ccf-02010264e9c8")); -#endif - - view.engine()->rootContext()->setContextProperty(QStringLiteral("targetUuid"), uuid); - view.setSource(QUrl(mainQmlApp)); - view.setResizeMode(QQuickView::SizeRootObjectToView); - // Qt.quit() called in embedded .qml by default only emits - // quit() signal, so do this (optionally use Qt.exit()). - QObject::connect(view.engine(), SIGNAL(quit()), qApp, SLOT(quit())); - view.setGeometry(QRect(100, 100, 360, 480)); - view.show(); - return application.exec(); -} |