BLE scanner search bar fix

During device scan, search bar was gone after device is added
and device scan was not yet done.

Change-Id: I39bd7fc1c3f8c22a93921313d818ba1cd00363a0
Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
This commit is contained in:
Nedim Hadzic 2014-03-08 14:19:55 +01:00 committed by The Qt Project
parent 649f3519a1
commit 10126f30e5
3 changed files with 17 additions and 4 deletions

View File

@ -44,9 +44,9 @@ Rectangle {
id: back
width: 300
height: 600
property string message: device.update
onMessageChanged: {
if (device.update != "Scanning for devices..." && device.update != "Search")
property bool deviceState: device.state
onDeviceStateChanged: {
if (!device.state)
info.visible = false;
}

View File

@ -51,7 +51,7 @@
#include <QList>
Device::Device():
connected(false), info(0)
connected(false), info(0), m_deviceScanState(false)
{
discoveryAgent = new QBluetoothDeviceDiscoveryAgent();
connect(discoveryAgent, SIGNAL(deviceDiscovered(const QBluetoothDeviceInfo&)),
@ -89,6 +89,8 @@ void Device::startDeviceDiscovery()
devices.clear();
setUpdate("Scanning for devices ...");
discoveryAgent->start();
m_deviceScanState = true;
Q_EMIT stateChanged();
}
void Device::addDevice(const QBluetoothDeviceInfo &info)
@ -103,6 +105,8 @@ void Device::addDevice(const QBluetoothDeviceInfo &info)
void Device::scanFinished()
{
Q_EMIT devicesDone();
m_deviceScanState = false;
Q_EMIT stateChanged();
if (devices.isEmpty())
setUpdate("No Low Energy devices found...");
else
@ -233,3 +237,8 @@ void Device::serviceScanError(QBluetoothServiceDiscoveryAgent::Error error)
else
setUpdate("An unknown error has occurred.");
}
bool Device::state()
{
return m_deviceScanState;
}

View File

@ -66,6 +66,7 @@ class Device: public QObject
Q_PROPERTY(QVariant servicesList READ getServices NOTIFY servicesDone)
Q_PROPERTY(QVariant characteristicList READ getCharacteristics NOTIFY characteristicsDone)
Q_PROPERTY(QString update READ getUpdate NOTIFY updateChanged)
Q_PROPERTY(bool state READ state NOTIFY stateChanged)
public:
Device();
~Device();
@ -73,6 +74,7 @@ public:
QVariant getServices();
QVariant getCharacteristics();
QString getUpdate();
bool state();
public slots:
void addDevice(const QBluetoothDeviceInfo&);
@ -94,6 +96,7 @@ Q_SIGNALS:
void servicesDone();
void characteristicsDone();
void updateChanged();
void stateChanged();
private:
void setUpdate(QString message);
@ -106,6 +109,7 @@ private:
QString m_message;
bool connected;
QLowEnergyController *info;
bool m_deviceScanState;
};
#endif // DEVICE_H