summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre de la Rocha <andre.rocha@qt.io>2019-06-06 13:55:29 +0200
committerAndre de la Rocha <andre.rocha@qt.io>2019-06-06 13:55:29 +0200
commitbbd5a988592e31b5f8ec0a111e7fea30c222f0ec (patch)
treee0d88cc8f106f46a24489a7b8fee19f627898146
parent6ee559eefc3fee286eb92a5f5d8b8fe004d0dc42 (diff)
Update Bluetooth examples for high-DPI displays and nullptr
This change sets the Qt::AA_EnableHighDpiScaling application attribute. It also uses nullptr to initialize pointers and adds a trivial optimization to the low energy scanner example. Change-Id: Ia923573ad78108a2a6a72be4c0948ea97a7ec094 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--examples/bluetooth/btchat/main.cpp1
-rw-r--r--examples/bluetooth/btfiletransfer/main.cpp1
-rw-r--r--examples/bluetooth/btfiletransfer/pindisplay.h2
-rw-r--r--examples/bluetooth/btfiletransfer/progress.h2
-rw-r--r--examples/bluetooth/btfiletransfer/remoteselector.h2
-rw-r--r--examples/bluetooth/btscanner/device.h2
-rw-r--r--examples/bluetooth/btscanner/main.cpp1
-rw-r--r--examples/bluetooth/btscanner/service.h2
-rw-r--r--examples/bluetooth/chat/qmlchat.cpp1
-rw-r--r--examples/bluetooth/heartrate-game/main.cpp1
-rw-r--r--examples/bluetooth/lowenergyscanner/device.cpp12
-rw-r--r--examples/bluetooth/lowenergyscanner/main.cpp1
-rw-r--r--examples/bluetooth/picturetransfer/filetransfer.h2
-rw-r--r--examples/bluetooth/picturetransfer/main.cpp1
-rw-r--r--examples/bluetooth/pingpong/main.cpp1
-rw-r--r--examples/bluetooth/scanner/qmlscanner.cpp1
16 files changed, 21 insertions, 12 deletions
diff --git a/examples/bluetooth/btchat/main.cpp b/examples/bluetooth/btchat/main.cpp
index 5c7bbf75..e728efd2 100644
--- a/examples/bluetooth/btchat/main.cpp
+++ b/examples/bluetooth/btchat/main.cpp
@@ -56,6 +56,7 @@
int main(int argc, char *argv[])
{
//QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
+ QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
Chat d;
diff --git a/examples/bluetooth/btfiletransfer/main.cpp b/examples/bluetooth/btfiletransfer/main.cpp
index 2c2b6df5..1871e207 100644
--- a/examples/bluetooth/btfiletransfer/main.cpp
+++ b/examples/bluetooth/btfiletransfer/main.cpp
@@ -54,6 +54,7 @@
int main(int argc, char *argv[])
{
+ QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
RemoteSelector d;
diff --git a/examples/bluetooth/btfiletransfer/pindisplay.h b/examples/bluetooth/btfiletransfer/pindisplay.h
index b7ad8866..7acc517e 100644
--- a/examples/bluetooth/btfiletransfer/pindisplay.h
+++ b/examples/bluetooth/btfiletransfer/pindisplay.h
@@ -64,7 +64,7 @@ class pinDisplay : public QDialog
Q_OBJECT
public:
- explicit pinDisplay(QString title, QString pin, QWidget *parent = 0);
+ explicit pinDisplay(QString title, QString pin, QWidget *parent = nullptr);
~pinDisplay();
void setOkCancel();
diff --git a/examples/bluetooth/btfiletransfer/progress.h b/examples/bluetooth/btfiletransfer/progress.h
index ec73e14b..afd72153 100644
--- a/examples/bluetooth/btfiletransfer/progress.h
+++ b/examples/bluetooth/btfiletransfer/progress.h
@@ -69,7 +69,7 @@ class Progress : public QDialog
Q_OBJECT
public:
- explicit Progress(QWidget *parent = 0);
+ explicit Progress(QWidget *parent = nullptr);
~Progress();
void setStatus(QString title, QString filename);
diff --git a/examples/bluetooth/btfiletransfer/remoteselector.h b/examples/bluetooth/btfiletransfer/remoteselector.h
index b0850c41..670eb252 100644
--- a/examples/bluetooth/btfiletransfer/remoteselector.h
+++ b/examples/bluetooth/btfiletransfer/remoteselector.h
@@ -78,7 +78,7 @@ class RemoteSelector : public QDialog
Q_OBJECT
public:
- explicit RemoteSelector(QWidget *parent = 0);
+ explicit RemoteSelector(QWidget *parent = nullptr);
~RemoteSelector();
void startDiscovery(const QBluetoothUuid &uuid);
diff --git a/examples/bluetooth/btscanner/device.h b/examples/bluetooth/btscanner/device.h
index 7111e1ec..35dc7965 100644
--- a/examples/bluetooth/btscanner/device.h
+++ b/examples/bluetooth/btscanner/device.h
@@ -67,7 +67,7 @@ class DeviceDiscoveryDialog : public QDialog
Q_OBJECT
public:
- DeviceDiscoveryDialog(QWidget *parent = 0);
+ DeviceDiscoveryDialog(QWidget *parent = nullptr);
~DeviceDiscoveryDialog();
public slots:
diff --git a/examples/bluetooth/btscanner/main.cpp b/examples/bluetooth/btscanner/main.cpp
index ca762802..a84dcda9 100644
--- a/examples/bluetooth/btscanner/main.cpp
+++ b/examples/bluetooth/btscanner/main.cpp
@@ -54,6 +54,7 @@
int main(int argc, char *argv[])
{
+ QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
DeviceDiscoveryDialog d;
diff --git a/examples/bluetooth/btscanner/service.h b/examples/bluetooth/btscanner/service.h
index 94748dad..93d1e12b 100644
--- a/examples/bluetooth/btscanner/service.h
+++ b/examples/bluetooth/btscanner/service.h
@@ -66,7 +66,7 @@ class ServiceDiscoveryDialog : public QDialog
Q_OBJECT
public:
- ServiceDiscoveryDialog(const QString &name, const QBluetoothAddress &address, QWidget *parent = 0);
+ ServiceDiscoveryDialog(const QString &name, const QBluetoothAddress &address, QWidget *parent = nullptr);
~ServiceDiscoveryDialog();
public slots:
diff --git a/examples/bluetooth/chat/qmlchat.cpp b/examples/bluetooth/chat/qmlchat.cpp
index e7ce3f3a..6c8d2fa7 100644
--- a/examples/bluetooth/chat/qmlchat.cpp
+++ b/examples/bluetooth/chat/qmlchat.cpp
@@ -62,6 +62,7 @@
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();
diff --git a/examples/bluetooth/heartrate-game/main.cpp b/examples/bluetooth/heartrate-game/main.cpp
index 099f82a7..05557c05 100644
--- a/examples/bluetooth/heartrate-game/main.cpp
+++ b/examples/bluetooth/heartrate-game/main.cpp
@@ -60,6 +60,7 @@
int main(int argc, char *argv[])
{
QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
+ QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
ConnectionHandler connectionHandler;
diff --git a/examples/bluetooth/lowenergyscanner/device.cpp b/examples/bluetooth/lowenergyscanner/device.cpp
index 82179db1..d860457e 100644
--- a/examples/bluetooth/lowenergyscanner/device.cpp
+++ b/examples/bluetooth/lowenergyscanner/device.cpp
@@ -152,12 +152,12 @@ void Device::scanServices(const QString &address)
// We need the current device for service discovery.
for (auto d: qAsConst(devices)) {
- auto device = qobject_cast<DeviceInfo *>(d);
- if (!device)
- continue;
-
- if (device->getAddress() == address )
- currentDevice.setDevice(device->getDevice());
+ if (auto device = qobject_cast<DeviceInfo *>(d)) {
+ if (device->getAddress() == address ) {
+ currentDevice.setDevice(device->getDevice());
+ break;
+ }
+ }
}
if (!currentDevice.getDevice().isValid()) {
diff --git a/examples/bluetooth/lowenergyscanner/main.cpp b/examples/bluetooth/lowenergyscanner/main.cpp
index 351ab13a..f223b028 100644
--- a/examples/bluetooth/lowenergyscanner/main.cpp
+++ b/examples/bluetooth/lowenergyscanner/main.cpp
@@ -59,6 +59,7 @@
int main(int argc, char *argv[])
{
//QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
+ QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
Device d;
diff --git a/examples/bluetooth/picturetransfer/filetransfer.h b/examples/bluetooth/picturetransfer/filetransfer.h
index 5e2e08f9..4dee32fe 100644
--- a/examples/bluetooth/picturetransfer/filetransfer.h
+++ b/examples/bluetooth/picturetransfer/filetransfer.h
@@ -59,7 +59,7 @@ class FileTransfer : public QObject
Q_OBJECT
Q_PROPERTY(float progress READ getProgress NOTIFY progressChanged)
public:
- explicit FileTransfer(QObject *parent = 0);
+ explicit FileTransfer(QObject *parent = nullptr);
float getProgress() { return m_progress;}
signals:
diff --git a/examples/bluetooth/picturetransfer/main.cpp b/examples/bluetooth/picturetransfer/main.cpp
index b4a1e670..4622e87e 100644
--- a/examples/bluetooth/picturetransfer/main.cpp
+++ b/examples/bluetooth/picturetransfer/main.cpp
@@ -58,6 +58,7 @@
int main(int argc, char *argv[])
{
+ QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication application(argc, argv);
//! [Transfer-2]
QQuickView view;
diff --git a/examples/bluetooth/pingpong/main.cpp b/examples/bluetooth/pingpong/main.cpp
index fc1029de..7c34b135 100644
--- a/examples/bluetooth/pingpong/main.cpp
+++ b/examples/bluetooth/pingpong/main.cpp
@@ -58,6 +58,7 @@
int main(int argc, char *argv[])
{
//QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
+ QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
PingPong pingPong;
QQmlApplicationEngine engine;
diff --git a/examples/bluetooth/scanner/qmlscanner.cpp b/examples/bluetooth/scanner/qmlscanner.cpp
index 4ead2364..2dbc0c27 100644
--- a/examples/bluetooth/scanner/qmlscanner.cpp
+++ b/examples/bluetooth/scanner/qmlscanner.cpp
@@ -56,6 +56,7 @@
int main(int argc, char *argv[])
{
//QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
+ QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication application(argc, argv);
const QString mainQmlApp(QStringLiteral("qrc:/scanner.qml"));
QQuickView view;