mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
QML UI: start BT discovery
So far all this does is list all the BT devices that it finds (and I worry if this will have negative battery implications on a mobile device), but this should allow us to connect to a standard BT dive computer (but that will of course require more code to pick the right device). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
9bea9fcdb7
commit
1ab6b50a34
2 changed files with 31 additions and 0 deletions
|
@ -89,6 +89,18 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false),
|
|||
m_credentialStatus(UNKNOWN),
|
||||
alreadySaving(false)
|
||||
{
|
||||
#if BT_SUPPORT
|
||||
if (localBtDevice.isValid()) {
|
||||
localBtDevice.powerOn();
|
||||
QString localDeviceName = "localDevice " + localBtDevice.name() + " is valid, starting discovery";
|
||||
appendTextToLog(localDeviceName.toUtf8().data());
|
||||
discoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
|
||||
connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, this, &QMLManager::btDeviceDiscovered);
|
||||
discoveryAgent->start();
|
||||
} else {
|
||||
appendTextToLog("localBtDevice isn't valid");
|
||||
}
|
||||
#endif
|
||||
m_instance = this;
|
||||
m_lastDevicePixelRatio = qApp->devicePixelRatio();
|
||||
connect(qobject_cast<QApplication *>(QApplication::instance()), &QApplication::applicationStateChanged, this, &QMLManager::applicationStateChanged);
|
||||
|
@ -191,6 +203,14 @@ void QMLManager::mergeLocalRepo()
|
|||
process_dives(true, false);
|
||||
}
|
||||
|
||||
#if BT_SUPPORT
|
||||
void QMLManager::btDeviceDiscovered(const QBluetoothDeviceInfo &device)
|
||||
{
|
||||
QString newDevice = "Found new device " + device.name() + " (" + device.address().toString() + ")";
|
||||
appendTextToLog(newDevice);
|
||||
}
|
||||
#endif
|
||||
|
||||
void QMLManager::finishSetup()
|
||||
{
|
||||
// Initialize cloud credentials.
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
#include <QNetworkAccessManager>
|
||||
#include <QScreen>
|
||||
#include <QElapsedTimer>
|
||||
#if BT_SUPPORT
|
||||
#include <QBluetoothLocalDevice>
|
||||
#include <QBluetoothDeviceDiscoveryAgent>
|
||||
#endif
|
||||
|
||||
#include "core/gpslocation.h"
|
||||
#include "qt-models/divelistmodel.h"
|
||||
|
@ -114,6 +118,9 @@ public:
|
|||
bool showPin() const;
|
||||
void setShowPin(bool enable);
|
||||
Q_INVOKABLE QStringList getDCListFromVendor(const QString& vendor);
|
||||
#if BT_SUPPORT
|
||||
void btDeviceDiscovered(const QBluetoothDeviceInfo &device);
|
||||
#endif
|
||||
|
||||
public slots:
|
||||
void applicationStateChanged(Qt::ApplicationState state);
|
||||
|
@ -196,6 +203,10 @@ private:
|
|||
bool checkDepth(DiveObjectHelper *myDive, struct dive *d, QString depth);
|
||||
bool currentGitLocalOnly;
|
||||
bool m_showPin;
|
||||
#if BT_SUPPORT
|
||||
QBluetoothLocalDevice localBtDevice;
|
||||
QBluetoothDeviceDiscoveryAgent *discoveryAgent;
|
||||
#endif
|
||||
|
||||
signals:
|
||||
void cloudUserNameChanged();
|
||||
|
|
Loading…
Reference in a new issue