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 = ""; + QBluetoothDeviceInfo::CoreConfigurations flags = device->coreConfigurations(); + bool isBle = flags == QBluetoothDeviceInfo::LowEnergyCoreConfiguration; - flags = device->coreConfigurations(); - if (flags == QBluetoothDeviceInfo::LowEnergyCoreConfiguration) - prefix = "LE:"; - if (device->address().isNull()) - return prefix + device->deviceUuid().toString(); - else - return prefix + device->address().toString(); + return btDeviceAddress(device, isBle); } void BTDiscovery::btDeviceDiscovered(const QBluetoothDeviceInfo &device) diff --git a/desktop-widgets/btdeviceselectiondialog.cpp b/desktop-widgets/btdeviceselectiondialog.cpp index de3e383c5..fc7b2e86f 100644 --- a/desktop-widgets/btdeviceselectiondialog.cpp +++ b/desktop-widgets/btdeviceselectiondialog.cpp @@ -449,13 +449,25 @@ void BtDeviceSelectionDialog::deviceDiscoveryError(QBluetoothDeviceDiscoveryAgen } extern QString markBLEAddress(const QBluetoothDeviceInfo *device); +extern QString btDeviceAddress(const QBluetoothDeviceInfo *device, bool isBle); QString BtDeviceSelectionDialog::getSelectedDeviceAddress() { - if (selectedRemoteDeviceInfo) - return markBLEAddress(selectedRemoteDeviceInfo.data()); + if (!selectedRemoteDeviceInfo) + return QString(); - return QString(); + int btMode = ui->btMode->currentIndex(); + QBluetoothDeviceInfo *device = selectedRemoteDeviceInfo.data(); + + switch (btMode) { + case 0: // Auto + default: + return markBLEAddress(device); + case 1: // Force LE + return btDeviceAddress(device, true); + case 2: // Force classical + return btDeviceAddress(device, false); + } } QString BtDeviceSelectionDialog::getSelectedDeviceName() diff --git a/desktop-widgets/btdeviceselectiondialog.ui b/desktop-widgets/btdeviceselectiondialog.ui index 4aa83cf1c..be63b4160 100644 --- a/desktop-widgets/btdeviceselectiondialog.ui +++ b/desktop-widgets/btdeviceselectiondialog.ui @@ -14,25 +14,6 @@ Remote Bluetooth device selection - - - - - 0 - 0 - - - - - 75 - true - - - - Discovered devices - - - @@ -57,49 +38,15 @@ - - - - - - - 0 - 0 - - - - - - - - - - - 0 - 0 - - - - Scan - - - - - - - - 0 - 0 - - - - Clear - - - - - - + + + + + + + true + + @@ -207,16 +154,99 @@ - - - - + + + + + 0 + 0 + - - true + + + 75 + true + + + + Discovered devices + + + + + + + 0 + 0 + + + + + + + + + + Bluetooth mode + + + + + + + + Auto + + + + + Force LE + + + + + Force classical + + + + + + + + + + + + + 0 + 0 + + + + Scan + + + + + + + + 0 + 0 + + + + Clear + + + + + + +