summaryrefslogtreecommitdiffstats
path: root/mobile-widgets
diff options
context:
space:
mode:
Diffstat (limited to 'mobile-widgets')
-rw-r--r--mobile-widgets/qml/DownloadFromDiveComputer.qml4
-rw-r--r--mobile-widgets/qmlmanager.cpp25
-rw-r--r--mobile-widgets/qmlmanager.h7
3 files changed, 33 insertions, 3 deletions
diff --git a/mobile-widgets/qml/DownloadFromDiveComputer.qml b/mobile-widgets/qml/DownloadFromDiveComputer.qml
index 9ff0494c0..b7857f871 100644
--- a/mobile-widgets/qml/DownloadFromDiveComputer.qml
+++ b/mobile-widgets/qml/DownloadFromDiveComputer.qml
@@ -17,8 +17,8 @@ Kirigami.Page {
property alias dcImportModel: importModel
property bool divesDownloaded: false
- property bool btEnabled: manager.btEnabled()
- property string btMessage: manager.btEnabled() ? "" : qsTr("Bluetooth is not enabled")
+ property bool btEnabled: manager.btEnabled
+ property string btMessage: manager.btEnabled ? "" : qsTr("Bluetooth is not enabled")
DCDownloadThread {
id: downloadThread
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)
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