diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2017-10-14 04:01:12 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-10-14 04:01:12 -0700 |
commit | 0039c61dce78ab148b05ceec3283a3bd29e1bb30 (patch) | |
tree | d8a429a53cb42e69a017ac4534fedfb075880a1f /mobile-widgets/qmlmanager.cpp | |
parent | aa7e78611ec87ce928f62a41311d47dec016ba97 (diff) | |
parent | ba4058667a21a278a394054fea70595358ac41f2 (diff) | |
download | subsurface-0039c61dce78ab148b05ceec3283a3bd29e1bb30.tar.gz |
Merge branch 'dynamic-bt' of https://github.com/janmulder/subsurface
Diffstat (limited to 'mobile-widgets/qmlmanager.cpp')
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index dc37fd4b0..5fbe61614 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -12,6 +12,7 @@ #include <QElapsedTimer> #include <QTimer> #include <QDateTime> +#include <QBluetoothLocalDevice> #include "qt-models/divelistmodel.h" #include "qt-models/gpslistmodel.h" @@ -77,6 +78,23 @@ extern "C" int gitProgressCB(const char *text) return 0; } +void QMLManager::btHostModeChange(QBluetoothLocalDevice::HostMode state) +{ + BTDiscovery *btDiscovery = BTDiscovery::instance(); + + qDebug() << "btHostModeChange to " << state; + if (state != QBluetoothLocalDevice::HostPoweredOff) { + connectionListModel.removeAllAddresses(); + btDiscovery->BTDiscoveryReDiscover(); + m_btEnabled = btDiscovery->btAvailable(); + } else { + connectionListModel.removeAllAddresses(); + set_non_bt_addresses(); + m_btEnabled = false; + } + emit btEnabledChanged(); +} + QMLManager::QMLManager() : m_locationServiceEnabled(false), m_verboseEnabled(false), reply(0), @@ -117,6 +135,8 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false), // to QML, but that doesn't seem to always work BTDiscovery *btDiscovery = BTDiscovery::instance(); m_btEnabled = btDiscovery->btAvailable(); + connect(&btDiscovery->localBtDevice, &QBluetoothLocalDevice::hostModeStateChanged, + this, &QMLManager::btHostModeChange); #else m_btEnabled = false; #endif @@ -1659,6 +1679,11 @@ bool QMLManager::btEnabled() const return m_btEnabled; } +void QMLManager::setBtEnabled(bool value) +{ + m_btEnabled = value; +} + #if defined (Q_OS_ANDROID) void writeToAppLogFile(QString logText) |