diff options
author | Alex Blasche <alexander.blasche@qt.io> | 2017-10-17 09:42:01 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@qt.io> | 2017-10-17 09:42:13 +0200 |
commit | fc2a206322f6190226ebc1f04062f2c9170f0bac (patch) | |
tree | 7df8ca41816c24ccfa6e0c6add4612689a933bdd /examples | |
parent | ca5490859338f28e30104668a353275d23df1ec6 (diff) | |
parent | 125cdccc346903d6e70ed26289cdaed85e26ec3f (diff) |
Merge remote-tracking branch 'gerrit/dev' into btle
Change-Id: Ia1cbaac9774ce2bc1b6972c02bad34fa593d40ff
Diffstat (limited to 'examples')
36 files changed, 201 insertions, 126 deletions
diff --git a/examples/bluetooth/btchat/btchat.pro b/examples/bluetooth/btchat/btchat.pro index 08fdd4a7..6ecae4c7 100644 --- a/examples/bluetooth/btchat/btchat.pro +++ b/examples/bluetooth/btchat/btchat.pro @@ -2,6 +2,7 @@ TEMPLATE = app TARGET = btchat QT = core bluetooth widgets +android: QT += androidextras SOURCES = \ main.cpp \ diff --git a/examples/bluetooth/btchat/chat.cpp b/examples/bluetooth/btchat/chat.cpp index 51a2d4ed..929a42e4 100644 --- a/examples/bluetooth/btchat/chat.cpp +++ b/examples/bluetooth/btchat/chat.cpp @@ -49,11 +49,18 @@ #include <qbluetoothdeviceinfo.h> #include <qbluetoothlocaldevice.h> +#ifdef Q_OS_ANDROID +#include <QtAndroidExtras/QtAndroid> +#endif + #include <QTimer> #include <QDebug> static const QLatin1String serviceUuid("e8e10f95-1a70-4b27-9ccf-02010264e9c8"); +#ifdef Q_OS_ANDROID +static const QLatin1String reverseUuid("c8e96402-0102-cf9c-274b-701a950fe1e8"); +#endif Chat::Chat(QWidget *parent) : QDialog(parent), currentAdapterIndex(0), ui(new Ui_Chat) @@ -170,7 +177,14 @@ void Chat::connectClicked() localAdapters.at(currentAdapterIndex).address(); RemoteSelector remoteSelector(adapter); +#ifdef Q_OS_ANDROID + if (QtAndroid::androidSdkVersion() >= 23) + remoteSelector.startDiscovery(QBluetoothUuid(reverseUuid)); + else + remoteSelector.startDiscovery(QBluetoothUuid(serviceUuid)); +#else remoteSelector.startDiscovery(QBluetoothUuid(serviceUuid)); +#endif if (remoteSelector.exec() == QDialog::Accepted) { QBluetoothServiceInfo service = remoteSelector.service(); diff --git a/examples/bluetooth/btchat/doc/src/btchat.qdoc b/examples/bluetooth/btchat/doc/src/btchat.qdoc index 213db715..42a82bc6 100644 --- a/examples/bluetooth/btchat/doc/src/btchat.qdoc +++ b/examples/bluetooth/btchat/doc/src/btchat.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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. ** @@ -11,8 +11,8 @@ ** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 @@ -20,7 +20,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/examples/bluetooth/btchat/main.cpp b/examples/bluetooth/btchat/main.cpp index bb862798..50e682e7 100644 --- a/examples/bluetooth/btchat/main.cpp +++ b/examples/bluetooth/btchat/main.cpp @@ -51,7 +51,11 @@ int main(int argc, char *argv[]) Chat d; QObject::connect(&d, SIGNAL(accepted()), &app, SLOT(quit())); +#ifdef Q_OS_ANDROID + d.showMaximized(); +#else d.show(); +#endif app.exec(); diff --git a/examples/bluetooth/btfiletransfer/doc/src/btfiletransfer.qdoc b/examples/bluetooth/btfiletransfer/doc/src/btfiletransfer.qdoc index 5f07e088..adcafc11 100644 --- a/examples/bluetooth/btfiletransfer/doc/src/btfiletransfer.qdoc +++ b/examples/bluetooth/btfiletransfer/doc/src/btfiletransfer.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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. ** @@ -11,8 +11,8 @@ ** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 @@ -20,7 +20,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/examples/bluetooth/btfiletransfer/progress.h b/examples/bluetooth/btfiletransfer/progress.h index b71009b7..8a30ff94 100644 --- a/examples/bluetooth/btfiletransfer/progress.h +++ b/examples/bluetooth/btfiletransfer/progress.h @@ -42,7 +42,6 @@ #define PROGRESS_H #include <QDialog> -#include <qbluetoothglobal.h> #include <QTime> QT_FORWARD_DECLARE_CLASS(QBluetoothTransferReply) diff --git a/examples/bluetooth/btscanner/device.h b/examples/bluetooth/btscanner/device.h index 9e5c59f6..f5b3a715 100644 --- a/examples/bluetooth/btscanner/device.h +++ b/examples/bluetooth/btscanner/device.h @@ -43,7 +43,6 @@ #include "ui_device.h" -#include <qbluetoothglobal.h> #include <qbluetoothlocaldevice.h> #include <QDialog> diff --git a/examples/bluetooth/btscanner/doc/src/btscanner.qdoc b/examples/bluetooth/btscanner/doc/src/btscanner.qdoc index 600cfe39..c4e45650 100644 --- a/examples/bluetooth/btscanner/doc/src/btscanner.qdoc +++ b/examples/bluetooth/btscanner/doc/src/btscanner.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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. ** @@ -11,8 +11,8 @@ ** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 @@ -20,7 +20,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/examples/bluetooth/btscanner/service.h b/examples/bluetooth/btscanner/service.h index 5b47d11a..871d975b 100644 --- a/examples/bluetooth/btscanner/service.h +++ b/examples/bluetooth/btscanner/service.h @@ -43,7 +43,6 @@ #include "ui_service.h" -#include <qbluetoothglobal.h> #include <QDialog> QT_FORWARD_DECLARE_CLASS(QBluetoothAddress) diff --git a/examples/bluetooth/chat/Search.qml b/examples/bluetooth/chat/Search.qml index f1f8f6ac..ea542462 100644 --- a/examples/bluetooth/chat/Search.qml +++ b/examples/bluetooth/chat/Search.qml @@ -46,6 +46,9 @@ Rectangle { function appendText(newText) { searchText.text += newText } + function setText(newText) { + searchText.text = newText + } width: searchText.width + 40; height: searchText.height + bluetoothImage.height + 40; diff --git a/examples/bluetooth/chat/chat.pro b/examples/bluetooth/chat/chat.pro index 7bc5c8bd..36d815f9 100644 --- a/examples/bluetooth/chat/chat.pro +++ b/examples/bluetooth/chat/chat.pro @@ -1,4 +1,5 @@ QT = core bluetooth quick +android: QT += androidextras #see QTBUG-61392 SOURCES += qmlchat.cpp TARGET = qml_chat diff --git a/examples/bluetooth/chat/chat.qml b/examples/bluetooth/chat/chat.qml index ecac39fc..eee29789 100644 --- a/examples/bluetooth/chat/chat.qml +++ b/examples/bluetooth/chat/chat.qml @@ -53,7 +53,7 @@ Item { BluetoothDiscoveryModel { id: btModel running: true - discoveryMode: BluetoothDiscoveryModel.MinimalServiceDiscovery + discoveryMode: BluetoothDiscoveryModel.FullServiceDiscovery //! [BtDiscoveryModel-1] onRunningChanged : { if (!btModel.running && top.state == "begin" && !serviceFound) { @@ -81,7 +81,7 @@ Item { } //! [BtDiscoveryModel-2] //! [BtDiscoveryModel-3] - uuidFilter: "e8e10f95-1a70-4b27-9ccf-02010264e9c8" + uuidFilter: targetUuid //e8e10f95-1a70-4b27-9ccf-02010264e9c8 } //! [BtDiscoveryModel-3] @@ -91,8 +91,24 @@ Item { connected: true onSocketStateChanged: { - console.log("Connected to server") - top.state = "chatActive" + 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] @@ -107,6 +123,7 @@ Item { } //! [BluetoothSocket-4] //! [BluetoothSocket-2] + //... } //! [BluetoothSocket-2] diff --git a/examples/bluetooth/chat/doc/src/chat.qdoc b/examples/bluetooth/chat/doc/src/chat.qdoc index 4b5e8778..6fdf9b70 100644 --- a/examples/bluetooth/chat/doc/src/chat.qdoc +++ b/examples/bluetooth/chat/doc/src/chat.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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. ** @@ -11,8 +11,8 @@ ** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 @@ -20,7 +20,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -69,7 +69,7 @@ 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 chat information is: + 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 diff --git a/examples/bluetooth/chat/qmlchat.cpp b/examples/bluetooth/chat/qmlchat.cpp index 8cd90bda..c6ff6341 100644 --- a/examples/bluetooth/chat/qmlchat.cpp +++ b/examples/bluetooth/chat/qmlchat.cpp @@ -44,9 +44,14 @@ #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 application(argc, argv); QList<QBluetoothHostInfo> infos = QBluetoothLocalDevice::allDevices(); @@ -56,6 +61,19 @@ int main(int argc, char *argv[]) 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 diff --git a/examples/bluetooth/heartrate-game/devicehandler.cpp b/examples/bluetooth/heartrate-game/devicehandler.cpp index dfc514b5..b9fe69c6 100644 --- a/examples/bluetooth/heartrate-game/devicehandler.cpp +++ b/examples/bluetooth/heartrate-game/devicehandler.cpp @@ -42,6 +42,7 @@ #include "devicehandler.h" #include "deviceinfo.h" #include <QtEndian> +#include <QRandomGenerator> DeviceHandler::DeviceHandler(QObject *parent) : BluetoothBaseClass(parent), @@ -248,11 +249,11 @@ void DeviceHandler::updateDemoHR() { int randomValue = 0; if (m_currentValue < 30) { // Initial value - randomValue = 55 + qrand()%30; + randomValue = 55 + QRandomGenerator::bounded(30); } else if (!m_measuring) { // Value when relax - randomValue = qBound(55, m_currentValue - 2 + qrand()%5, 75); + randomValue = qBound(55, m_currentValue - 2 + QRandomGenerator::bounded(5), 75); } else { // Measuring - randomValue = m_currentValue + qrand()%10 - 2; + randomValue = m_currentValue + QRandomGenerator::bounded(10) - 2; } addMeasurement(randomValue); diff --git a/examples/bluetooth/heartrate-game/doc/src/heartrate-game.qdoc b/examples/bluetooth/heartrate-game/doc/src/heartrate-game.qdoc index 2b2b75d0..f0d4c365 100644 --- a/examples/bluetooth/heartrate-game/doc/src/heartrate-game.qdoc +++ b/examples/bluetooth/heartrate-game/doc/src/heartrate-game.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 @@ -20,7 +20,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/examples/bluetooth/heartrate-server/doc/src/heartrate-server.qdoc b/examples/bluetooth/heartrate-server/doc/src/heartrate-server.qdoc index 34f1b633..7e0c29e8 100644 --- a/examples/bluetooth/heartrate-server/doc/src/heartrate-server.qdoc +++ b/examples/bluetooth/heartrate-server/doc/src/heartrate-server.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 @@ -20,7 +20,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/examples/bluetooth/lowenergyscanner/device.cpp b/examples/bluetooth/lowenergyscanner/device.cpp index 28a051f5..765a0d1c 100644 --- a/examples/bluetooth/lowenergyscanner/device.cpp +++ b/examples/bluetooth/lowenergyscanner/device.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "device.h" + #include <qbluetoothaddress.h> #include <qbluetoothdevicediscoveryagent.h> #include <qbluetoothlocaldevice.h> @@ -55,11 +56,11 @@ Device::Device(): //! [les-devicediscovery-1] discoveryAgent = new QBluetoothDeviceDiscoveryAgent(); discoveryAgent->setLowEnergyDiscoveryTimeout(5000); - connect(discoveryAgent, SIGNAL(deviceDiscovered(const QBluetoothDeviceInfo&)), - this, SLOT(addDevice(const QBluetoothDeviceInfo&))); - connect(discoveryAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)), - this, SLOT(deviceScanError(QBluetoothDeviceDiscoveryAgent::Error))); - connect(discoveryAgent, SIGNAL(finished()), this, SLOT(deviceScanFinished())); + connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, + this, &Device::addDevice); + connect(discoveryAgent, QOverload<QBluetoothDeviceDiscoveryAgent::Error>::of(&QBluetoothDeviceDiscoveryAgent::error), + this, &Device::deviceScanError); + connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::finished, this, &Device::deviceScanFinished); //! [les-devicediscovery-1] setUpdate("Search"); @@ -169,16 +170,16 @@ void Device::scanServices(const QString &address) if (!controller) { // Connecting signals and slots for connecting to LE services. controller = new QLowEnergyController(currentDevice.getDevice()); - connect(controller, SIGNAL(connected()), - this, SLOT(deviceConnected())); - connect(controller, SIGNAL(error(QLowEnergyController::Error)), - this, SLOT(errorReceived(QLowEnergyController::Error))); - connect(controller, SIGNAL(disconnected()), - this, SLOT(deviceDisconnected())); - connect(controller, SIGNAL(serviceDiscovered(QBluetoothUuid)), - this, SLOT(addLowEnergyService(QBluetoothUuid))); - connect(controller, SIGNAL(discoveryFinished()), - this, SLOT(serviceScanDone())); + connect(controller, &QLowEnergyController::connected, + this, &Device::deviceConnected); + connect(controller, QOverload<QLowEnergyController::Error>::of(&QLowEnergyController::error), + this, &Device::errorReceived); + connect(controller, &QLowEnergyController::disconnected, + this, &Device::deviceDisconnected); + connect(controller, &QLowEnergyController::serviceDiscovered, + this, &Device::addLowEnergyService); + connect(controller, &QLowEnergyController::discoveryFinished, + this, &Device::serviceScanDone); } if (isRandomAddress()) @@ -235,8 +236,8 @@ void Device::connectToService(const QString &uuid) if (service->state() == QLowEnergyService::DiscoveryRequired) { //! [les-service-3] - connect(service, SIGNAL(stateChanged(QLowEnergyService::ServiceState)), - this, SLOT(serviceDetailsDiscovered(QLowEnergyService::ServiceState))); + connect(service, &QLowEnergyService::stateChanged, + this, &Device::serviceDetailsDiscovered); service->discoverDetails(); setUpdate("Back\n(Discovering details...)"); //! [les-service-3] @@ -250,7 +251,7 @@ void Device::connectToService(const QString &uuid) m_characteristics.append(cInfo); } - QTimer::singleShot(0, this, SIGNAL(characteristicsUpdated())); + QTimer::singleShot(0, this, &Device::characteristicsUpdated); } void Device::deviceConnected() diff --git a/examples/bluetooth/lowenergyscanner/device.h b/examples/bluetooth/lowenergyscanner/device.h index 331d4458..1dc10300 100644 --- a/examples/bluetooth/lowenergyscanner/device.h +++ b/examples/bluetooth/lowenergyscanner/device.h @@ -41,7 +41,6 @@ #ifndef DEVICE_H #define DEVICE_H -#include <qbluetoothglobal.h> #include <qbluetoothlocaldevice.h> #include <QObject> #include <QVariant> diff --git a/examples/bluetooth/lowenergyscanner/doc/src/lowenergyscanner.qdoc b/examples/bluetooth/lowenergyscanner/doc/src/lowenergyscanner.qdoc index b4ad9fa2..bb2372a0 100644 --- a/examples/bluetooth/lowenergyscanner/doc/src/lowenergyscanner.qdoc +++ b/examples/bluetooth/lowenergyscanner/doc/src/lowenergyscanner.qdoc @@ -1,8 +1,8 @@ /**************************************************************************** ** ** Copyright (C) 2013 BlackBerry Limited all rights reserved -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -12,8 +12,8 @@ ** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 @@ -21,7 +21,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/examples/bluetooth/picturetransfer/doc/src/picturetransfer.qdoc b/examples/bluetooth/picturetransfer/doc/src/picturetransfer.qdoc index f597819d..a2acafb9 100644 --- a/examples/bluetooth/picturetransfer/doc/src/picturetransfer.qdoc +++ b/examples/bluetooth/picturetransfer/doc/src/picturetransfer.qdoc @@ -1,7 +1,7 @@ a/**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the QtBluetooth module. ** @@ -11,8 +11,8 @@ a/**************************************************************************** ** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 @@ -20,7 +20,7 @@ a/**************************************************************************** ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/examples/bluetooth/pingpong/assets/Dialog.qml b/examples/bluetooth/pingpong/assets/Dialog.qml index 2a332715..53be3eaa 100644 --- a/examples/bluetooth/pingpong/assets/Dialog.qml +++ b/examples/bluetooth/pingpong/assets/Dialog.qml @@ -42,7 +42,7 @@ import QtQuick 2.0 Rectangle { width: parent.width/2 - height: 100 + height: message.implicitHeight*2 z: 50 border.width: 2 border.color: "#363636" diff --git a/examples/bluetooth/pingpong/assets/Menu.qml b/examples/bluetooth/pingpong/assets/Menu.qml index b7516262..09eabb36 100644 --- a/examples/bluetooth/pingpong/assets/Menu.qml +++ b/examples/bluetooth/pingpong/assets/Menu.qml @@ -47,17 +47,18 @@ Rectangle { Rectangle { width: parent.width - height: 70 + height: headerText.implicitHeight *1.2 border.width: 1 border.color: "#363636" radius: 5 Text { + id: headerText horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter anchors.fill: parent text: "Welcome to PingPong Game \n Please select an option" - font.pixelSize: 20 + font.pointSize: 20 elide: Text.ElideMiddle color: "#363636" } @@ -67,10 +68,11 @@ Rectangle { id: startServer anchors.centerIn: parent width: parent.width/2 - height: parent.height/5 + height: startServerText.implicitHeight*5 color: "#363636" Text { + id: startServerText horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter anchors.fill: parent @@ -95,10 +97,11 @@ Rectangle { anchors.top: startServer.bottom anchors.topMargin: 10 width: parent.width/2 - height: parent.height/5 + height: startClientText.implicitHeight*5 color: "#363636" Text { + id: startClientText horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter anchors.fill: parent diff --git a/examples/bluetooth/pingpong/doc/src/pingpong.qdoc b/examples/bluetooth/pingpong/doc/src/pingpong.qdoc index 1fabdf5c..259b6b97 100644 --- a/examples/bluetooth/pingpong/doc/src/pingpong.qdoc +++ b/examples/bluetooth/pingpong/doc/src/pingpong.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 @@ -20,7 +20,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/examples/bluetooth/pingpong/main.cpp b/examples/bluetooth/pingpong/main.cpp index d2a84440..b6430248 100644 --- a/examples/bluetooth/pingpong/main.cpp +++ b/examples/bluetooth/pingpong/main.cpp @@ -41,10 +41,13 @@ #include <QQmlContext> #include <QGuiApplication> #include <QQmlApplicationEngine> +#include <QLoggingCategory> #include "pingpong.h" + int main(int argc, char *argv[]) { + //QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true")); QGuiApplication app(argc, argv); PingPong pingPong; QQmlApplicationEngine engine; diff --git a/examples/bluetooth/pingpong/pingpong.cpp b/examples/bluetooth/pingpong/pingpong.cpp index ab6ba8c7..d893f64c 100644 --- a/examples/bluetooth/pingpong/pingpong.cpp +++ b/examples/bluetooth/pingpong/pingpong.cpp @@ -40,13 +40,16 @@ #include "pingpong.h" #include <QDebug> +#ifdef Q_OS_ANDROID +#include <QtAndroid> +#endif PingPong::PingPong(): m_serverInfo(0), socket(0), discoveryAgent(0), interval(5), m_resultLeft(0), m_resultRight(0), m_showDialog(false), m_role(0), m_proportionX(0), m_proportionY(0), m_serviceFound(false) { m_timer = new QTimer(this); - connect(m_timer, SIGNAL(timeout()), this, SLOT(update())); + connect(m_timer, &QTimer::timeout, this, &PingPong::update); } PingPong::~PingPong() @@ -230,9 +233,10 @@ void PingPong::startServer() setMessage(QStringLiteral("Starting the server")); //! [Starting the server] m_serverInfo = new QBluetoothServer(QBluetoothServiceInfo::RfcommProtocol, this); - connect(m_serverInfo, SIGNAL(newConnection()), this, SLOT(clientConnected())); - connect(m_serverInfo, SIGNAL(error(QBluetoothServer::Error)), - this, SLOT(serverError(QBluetoothServer::Error))); + connect(m_serverInfo, &QBluetoothServer::newConnection, + this, &PingPong::clientConnected); + connect(m_serverInfo, QOverload<QBluetoothServer::Error>::of(&QBluetoothServer::error), + this, &PingPong::serverError); const QBluetoothUuid uuid(serviceUuid); m_serverInfo->listen(uuid, QStringLiteral("PingPong server")); @@ -248,13 +252,22 @@ void PingPong::startClient() //! [Searching for the service] discoveryAgent = new QBluetoothServiceDiscoveryAgent(QBluetoothAddress()); - connect(discoveryAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)), - this, SLOT(addService(QBluetoothServiceInfo))); - connect(discoveryAgent, SIGNAL(finished()), this, SLOT(done())); - connect(discoveryAgent, SIGNAL(error(QBluetoothServiceDiscoveryAgent::Error)), - this, SLOT(serviceScanError(QBluetoothServiceDiscoveryAgent::Error))); + connect(discoveryAgent, &QBluetoothServiceDiscoveryAgent::serviceDiscovered, + this, &PingPong::addService); + connect(discoveryAgent, &QBluetoothServiceDiscoveryAgent::finished, + this, &PingPong::done); + connect(discoveryAgent, QOverload<QBluetoothServiceDiscoveryAgent::Error>::of(&QBluetoothServiceDiscoveryAgent::error), + this, &PingPong::serviceScanError); +#ifdef Q_OS_ANDROID //see QTBUG-61392 + if (QtAndroid::androidSdkVersion() >= 23) + discoveryAgent->setUuidFilter(QBluetoothUuid(androidUuid)); + else + discoveryAgent->setUuidFilter(QBluetoothUuid(serviceUuid)); +#else discoveryAgent->setUuidFilter(QBluetoothUuid(serviceUuid)); +#endif discoveryAgent->start(QBluetoothServiceDiscoveryAgent::FullDiscovery); + //! [Searching for the service] setMessage(QStringLiteral("Starting server discovery. You are the right player")); // m_role is set to 2 if it is a client @@ -273,10 +286,13 @@ void PingPong::clientConnected() if (!socket) return; socket->setParent(this); - connect(socket, SIGNAL(readyRead()), this, SLOT(readSocket())); - connect(socket, SIGNAL(disconnected()), this, SLOT(clientDisconnected())); - connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), - this, SLOT(socketError(QBluetoothSocket::SocketError))); + connect(socket, &QBluetoothSocket::readyRead, + this, &PingPong::readSocket); + connect(socket, &QBluetoothSocket::disconnected, + this, &PingPong::clientDisconnected); + connect(socket, QOverload<QBluetoothSocket::SocketError>::of(&QBluetoothSocket::error), + this, &PingPong::socketError); + //! [Initiating server socket] setMessage(QStringLiteral("Client connected.")); @@ -323,9 +339,9 @@ void PingPong::addService(const QBluetoothServiceInfo &service) socket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol); socket->connectToService(service); - connect(socket, SIGNAL(readyRead()), this, SLOT(readSocket())); - connect(socket, SIGNAL(connected()), this, SLOT(serverConnected())); - connect(socket, SIGNAL(disconnected()), this, SLOT(serverDisconnected())); + connect(socket, &QBluetoothSocket::readyRead, this, &PingPong::readSocket); + connect(socket, &QBluetoothSocket::connected, this, &PingPong::serverConnected); + connect(socket, &QBluetoothSocket::disconnected, this, &PingPong::serverDisconnected); //! [Connecting the socket] m_serviceFound = true; } diff --git a/examples/bluetooth/pingpong/pingpong.h b/examples/bluetooth/pingpong/pingpong.h index 650cd597..21c9ef1c 100644 --- a/examples/bluetooth/pingpong/pingpong.h +++ b/examples/bluetooth/pingpong/pingpong.h @@ -48,7 +48,8 @@ #include <qbluetoothlocaldevice.h> #include <qbluetoothservicediscoveryagent.h> -static const QString serviceUuid(QStringLiteral("e8e10f95-1a70-4b27-9ccf-02010264e9c9")); +static QString serviceUuid(QStringLiteral("e8e10f95-1a70-4b27-9ccf-02010264e9c9")); +static QString androidUuid(QStringLiteral("c9e96402-0102-cf9c-274b-701a950fe1e8")); class PingPong: public QObject { diff --git a/examples/bluetooth/pingpong/pingpong.pro b/examples/bluetooth/pingpong/pingpong.pro index 07675f27..aa79212e 100644 --- a/examples/bluetooth/pingpong/pingpong.pro +++ b/examples/bluetooth/pingpong/pingpong.pro @@ -2,6 +2,7 @@ TEMPLATE = app TARGET = pingpong QT += quick bluetooth +android: QT += androidextras # Input SOURCES += main.cpp \ diff --git a/examples/bluetooth/scanner/doc/src/scanner.qdoc b/examples/bluetooth/scanner/doc/src/scanner.qdoc index da5e55da..78720c00 100644 --- a/examples/bluetooth/scanner/doc/src/scanner.qdoc +++ b/examples/bluetooth/scanner/doc/src/scanner.qdoc @@ -1,8 +1,8 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Copyright (C) 2013 Aaron McCarthy <mccarthy.aaron@gmail.com> -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt local connectivty modules. ** @@ -12,8 +12,8 @@ ** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 @@ -21,7 +21,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/examples/nfc/annotatedurl/annotatedurl.h b/examples/nfc/annotatedurl/annotatedurl.h index 08e5b38e..853bdd7f 100644 --- a/examples/nfc/annotatedurl/annotatedurl.h +++ b/examples/nfc/annotatedurl/annotatedurl.h @@ -41,7 +41,6 @@ #ifndef ANNOTATEDURL_H #define ANNOTATEDURL_H -#include <qnfcglobal.h> #include <QNdefMessage> #include <QtCore/QObject> diff --git a/examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc b/examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc index a6ed6b34..0ea57a7c 100644 --- a/examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc +++ b/examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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. ** @@ -11,8 +11,8 @@ ** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 @@ -20,7 +20,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/examples/nfc/corkboard/doc/src/corkboard.qdoc b/examples/nfc/corkboard/doc/src/corkboard.qdoc index 46179107..29ad8eac 100644 --- a/examples/nfc/corkboard/doc/src/corkboard.qdoc +++ b/examples/nfc/corkboard/doc/src/corkboard.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the QtNfc module. ** @@ -11,8 +11,8 @@ ** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 @@ -20,7 +20,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc b/examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc index 51801609..ed7d2bba 100644 --- a/examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc +++ b/examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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. ** @@ -11,8 +11,8 @@ ** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 @@ -20,7 +20,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/examples/nfc/ndefeditor/mainwindow.h b/examples/nfc/ndefeditor/mainwindow.h index 374b2ee3..69eeee30 100644 --- a/examples/nfc/ndefeditor/mainwindow.h +++ b/examples/nfc/ndefeditor/mainwindow.h @@ -43,8 +43,6 @@ #include <QMainWindow> -#include <qnfcglobal.h> - #include <qnearfieldtarget.h> QT_BEGIN_NAMESPACE diff --git a/examples/nfc/ndefeditor/mimeimagerecordeditor.h b/examples/nfc/ndefeditor/mimeimagerecordeditor.h index 996cabc3..ef6506f3 100644 --- a/examples/nfc/ndefeditor/mimeimagerecordeditor.h +++ b/examples/nfc/ndefeditor/mimeimagerecordeditor.h @@ -42,8 +42,6 @@ #ifndef MIMEIMAGERECORDEDITOR_H #define MIMEIMAGERECORDEDITOR_H -#include <qnfcglobal.h> - #include <QWidget> #include <qndefrecord.h> diff --git a/examples/nfc/poster/doc/src/poster.qdoc b/examples/nfc/poster/doc/src/poster.qdoc index 26320f56..b94bcca8 100644 --- a/examples/nfc/poster/doc/src/poster.qdoc +++ b/examples/nfc/poster/doc/src/poster.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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. ** @@ -11,8 +11,8 @@ ** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 @@ -20,7 +20,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ |