From baa45472a2cc17981376f0bfb16c857165239f23 Mon Sep 17 00:00:00 2001 From: Claudiu Olteanu Date: Tue, 18 Aug 2015 22:38:14 +0300 Subject: Add implementation for BTH device item selection on Windows platforms When a Bluetooth device is selected from the discovered list display information about its address and enable the save button. On Windows we don't need to check if the devices are paired because the pairing process is done automatically on the connection step. If the devices are not paired Windows will ask for user's permission to continue the process. Signed-off-by: Claudiu Olteanu Signed-off-by: Dirk Hohndel --- qt-ui/btdeviceselectiondialog.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/qt-ui/btdeviceselectiondialog.cpp b/qt-ui/btdeviceselectiondialog.cpp index c78b01b94..6595912da 100644 --- a/qt-ui/btdeviceselectiondialog.cpp +++ b/qt-ui/btdeviceselectiondialog.cpp @@ -225,22 +225,25 @@ void BtDeviceSelectionDialog::addRemoteDevice(const QBluetoothDeviceInfo &remote void BtDeviceSelectionDialog::itemClicked(QListWidgetItem *item) { -#if defined(Q_OS_WIN) - // TODO enable the save button and log the information about the selected item -#else + // By default we assume that the devices are paired QBluetoothDeviceInfo remoteDeviceInfo = item->data(Qt::UserRole).value(); + QString statusMessage = QString("The device %1 can be used for connection. You can press the Save button.") + .arg(remoteDeviceInfo.address().toString()); + bool enableSaveButton = true; + +#if !defined(Q_OS_WIN) + // On other platforms than Windows we can obtain the pairing status so if the devices are not paired we disable the button QBluetoothLocalDevice::Pairing pairingStatus = localDevice->pairingStatus(remoteDeviceInfo.address()); if (pairingStatus == QBluetoothLocalDevice::Unpaired) { - ui->dialogStatus->setText(QString("The device %1 must be paired in order to be used. Please use the context menu for pairing options.") - .arg(remoteDeviceInfo.address().toString())); - ui->save->setEnabled(false); - } else { - ui->dialogStatus->setText(QString("The device %1 can be used for connection. You can press the Save button.") - .arg(remoteDeviceInfo.address().toString())); - ui->save->setEnabled(true); + statusMessage = QString("The device %1 must be paired in order to be used. Please use the context menu for pairing options.") + .arg(remoteDeviceInfo.address().toString()); + enableSaveButton = false; } #endif + // Update the status message and the save button + ui->dialogStatus->setText(statusMessage); + ui->save->setEnabled(enableSaveButton); } void BtDeviceSelectionDialog::localDeviceChanged(int index) -- cgit v1.2.3-70-g09d2