mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
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>
This commit is contained in:
parent
5f60a688c6
commit
baa45472a2
1 changed files with 13 additions and 10 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue