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 --- mobile-widgets/qmlmanager.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'mobile-widgets/qmlmanager.h') diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h index 1da147c9f..45851dfdf 100644 --- a/mobile-widgets/qmlmanager.h +++ b/mobile-widgets/qmlmanager.h @@ -45,6 +45,7 @@ class QMLManager : public QObject { Q_PROPERTY(QString progressMessage READ progressMessage WRITE setProgressMessage NOTIFY progressMessageChanged) Q_PROPERTY(bool libdcLog READ libdcLog WRITE setLibdcLog NOTIFY libdcLogChanged) Q_PROPERTY(bool developer READ developer WRITE setDeveloper NOTIFY developerChanged) + Q_PROPERTY(bool btEnabled READ btEnabled WRITE setBtEnabled NOTIFY btEnabledChanged) public: QMLManager(); @@ -124,6 +125,9 @@ public: bool developer() const; void setDeveloper(bool value); + bool btEnabled() const; + void setBtEnabled(bool value); + typedef void (QMLManager::*execute_function_type)(); DiveListSortModel *dlSortModel; @@ -134,7 +138,7 @@ public: bool showPin() const; void setShowPin(bool enable); Q_INVOKABLE void setStatusbarColor(QColor color); - Q_INVOKABLE bool btEnabled() const; + void btHostModeChange(QBluetoothLocalDevice::HostMode state); #if defined(Q_OS_ANDROID) void writeToAppLogFile(QString logText); @@ -258,6 +262,7 @@ signals: void progressMessageChanged(); void libdcLogChanged(); void developerChanged(); + void btEnabledChanged(); }; #endif -- cgit v1.2.3-70-g09d2