From ba4058667a21a278a394054fea70595358ac41f2 Mon Sep 17 00:00:00 2001 From: Jan Mulder Date: Thu, 12 Oct 2017 09:43:40 +0200 Subject: mobile: enable switching BT on/off during session. This commit implements possible switching BT on and off during a session, so not needing a restart of the app when the user forgot to switch it on when starting the app. For this, the following needed to be done: 1) create a handler that reacts on local BT device status changes. 2) repopulate the connection list in the download screen when a BT status change is detected. Notice the subtile change of the Q_INVOKABLE btEnabled() function to a Q_PROPERTY. This gives a nice dynamic behaviour when switching BT on/off with the app open. Fixes: #556 Signed-off-by: Jan Mulder --- core/btdiscovery.cpp | 7 ++++++- core/btdiscovery.h | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/btdiscovery.cpp b/core/btdiscovery.cpp index f9c6e8522..281e3b314 100644 --- a/core/btdiscovery.cpp +++ b/core/btdiscovery.cpp @@ -60,6 +60,12 @@ BTDiscovery::BTDiscovery(QObject *parent) } m_instance = this; #if defined(BT_SUPPORT) + BTDiscoveryReDiscover(); +#endif +} + +void BTDiscovery::BTDiscoveryReDiscover() +{ #if !defined(Q_OS_IOS) if (localBtDevice.isValid() && localBtDevice.hostMode() == QBluetoothLocalDevice::HostConnectable) { @@ -100,7 +106,6 @@ BTDiscovery::BTDiscovery(QObject *parent) m_btValid = false; } #endif -#endif } BTDiscovery::~BTDiscovery() diff --git a/core/btdiscovery.h b/core/btdiscovery.h index 61d03f49b..7a9e9c655 100644 --- a/core/btdiscovery.h +++ b/core/btdiscovery.h @@ -46,6 +46,8 @@ public: void getBluetoothDevices(); #endif QList getBtDcs(); + QBluetoothLocalDevice localBtDevice; + void BTDiscoveryReDiscover(); private: static BTDiscovery *m_instance; @@ -59,7 +61,6 @@ private: #endif QList btPairedDevices; - QBluetoothLocalDevice localBtDevice; QBluetoothDeviceDiscoveryAgent *discoveryAgent; signals: -- cgit v1.2.3-70-g09d2