diff options
author | Claudiu Olteanu <olteanu.claudiu@ymail.com> | 2015-08-18 22:38:14 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-08-20 22:45:51 -0700 |
commit | baa45472a2cc17981376f0bfb16c857165239f23 (patch) | |
tree | 37caa5fa47f3860c53952b3b7b1434ac19ea8179 | |
parent | 5f60a688c6bf49d83f5a3575065ed6ce3c6fa0a0 (diff) | |
download | subsurface-baa45472a2cc17981376f0bfb16c857165239f23.tar.gz |
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 <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-ui/btdeviceselectiondialog.cpp | 23 |
1 files 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<QBluetoothDeviceInfo>(); + 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) |