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 --- desktop-widgets/btdeviceselectiondialog.cpp | 18 ++- desktop-widgets/btdeviceselectiondialog.ui | 166 ++++++++++++++++------------ 2 files changed, 113 insertions(+), 71 deletions(-) (limited to 'desktop-widgets') 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 + + + + + + + -- cgit v1.2.3-70-g09d2