From aca4a3a4fa0be1c900985968b75c53aa50f40167 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 13 Nov 2017 22:46:42 +0100 Subject: Introduce mode field in Bluetooth device selection dialog Some BT devices support both, classical and LE, modes. Users could choose either by prepending or removing "LE:" in the device address field. After commit d23bd46a1be2dfb25293639abcf06b5b4d4b94df, the device field is always disabled in Bluetooth mode. Therefore, add a mode combo box to the Bluetooth device selection dialog. In the default mode (auto), the old code path (based on the Qt device flags) is used. The two other modes (force LE, force classical) allow the user to force the preferred behavior. This feature is meant as a stop-gap measure until a more refined transport choice is implemented. Therefore, the value of the new combo box is not saved in the settings, to avoid cluttering of the preferences with soon to be obsolete entries. Signed-off-by: Berthold Stoeger --- core/btdiscovery.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'core') diff --git a/core/btdiscovery.cpp b/core/btdiscovery.cpp index b764098ef..f51a62b23 100644 --- a/core/btdiscovery.cpp +++ b/core/btdiscovery.cpp @@ -132,18 +132,20 @@ extern void addBtUuid(QBluetoothUuid uuid); extern QHash productList; extern QStringList vendorList; +QString btDeviceAddress(const QBluetoothDeviceInfo *device, bool isBle) +{ + QString address = device->address().isNull() ? + device->deviceUuid().toString() : device->address().toString(); + const char *prefix = isBle ? "LE:" : ""; + return prefix + address; +} + QString markBLEAddress(const QBluetoothDeviceInfo *device) { - QBluetoothDeviceInfo::CoreConfigurations flags; - QString prefix = ""; - - flags = device->coreConfigurations(); - if (flags == QBluetoothDeviceInfo::LowEnergyCoreConfiguration) - prefix = "LE:"; - if (device->address().isNull()) - return prefix + device->deviceUuid().toString(); - else - return prefix + device->address().toString(); + QBluetoothDeviceInfo::CoreConfigurations flags = device->coreConfigurations(); + bool isBle = flags == QBluetoothDeviceInfo::LowEnergyCoreConfiguration; + + return btDeviceAddress(device, isBle); } void BTDiscovery::btDeviceDiscovered(const QBluetoothDeviceInfo &device) -- cgit v1.2.3-70-g09d2