From 8d2b6142c61934979a70b6b6d85a529575b8c297 Mon Sep 17 00:00:00 2001 From: Claudiu Olteanu Date: Sat, 18 Jul 2015 21:01:40 +0300 Subject: Don't close the BT selection Widget if the local BT adapter is invalid Don't close the Bluetooth selection widget if the default local Bluetooth adapter is invalid. Maybe there is a problem with the default Bluetooth device and the user has another one (a BT dongle) which can be used. If the selected device is invalid then update the UI information, disable the available buttons and announce the user about the problem. Also move the device changed logging message before we call the update information method. In this way the logging message with the problem will not be overwritten. Signed-off-by: Claudiu Olteanu Signed-off-by: Dirk Hohndel --- qt-ui/btdeviceselectiondialog.cpp | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/btdeviceselectiondialog.cpp b/qt-ui/btdeviceselectiondialog.cpp index e52580e78..f84d9cd4b 100644 --- a/qt-ui/btdeviceselectiondialog.cpp +++ b/qt-ui/btdeviceselectiondialog.cpp @@ -11,14 +11,6 @@ BtDeviceSelectionDialog::BtDeviceSelectionDialog(QWidget *parent) : localDevice(new QBluetoothLocalDevice), ui(new Ui::BtDeviceSelectionDialog) { - // Check if Bluetooth is available on this device - if (!localDevice->isValid()) { - QMessageBox::warning(this, tr("Warning"), - "This should never happen, please contact the Subsurface developers " - "and tell them that the Bluetooth download mode doesn't work."); - return; - } - ui->setupUi(this); // Quit button callbacks @@ -183,14 +175,14 @@ void BtDeviceSelectionDialog::localDeviceChanged(int index) // Create a new local device using the selected address localDevice = new QBluetoothLocalDevice(localDeviceSelectedAddress); + ui->dialogStatus->setText(QString("The local device was changed.")); + // Clear the discovered devices list on_clear_clicked(); // Update the UI information about the local device updateLocalDeviceInformation(); - ui->dialogStatus->setText(QString("The local device was changed.")); - // Initialize the device discovery agent if (localDevice->isValid()) initializeDeviceDiscoveryAgent(); @@ -315,6 +307,26 @@ QString BtDeviceSelectionDialog::getSelectedDeviceName() void BtDeviceSelectionDialog::updateLocalDeviceInformation() { + // Check if the selected Bluetooth device can be accessed + if (!localDevice->isValid()) { + QString na = QString("Not available"); + + // Update the UI information + ui->deviceAddress->setText(na); + ui->deviceName->setText(na); + + // Announce the user that there is a problem with the selected local Bluetooth adapter + ui->dialogStatus->setText(QString("The local Bluetooth adapter cannot be accessed.")); + + // Disable the buttons + ui->save->setEnabled(false); + ui->scan->setEnabled(false); + ui->clear->setEnabled(false); + ui->changeDeviceState->setEnabled(false); + + return; + } + // Set UI information about the local device ui->deviceAddress->setText(localDevice->address().toString()); ui->deviceName->setText(localDevice->name()); -- cgit v1.2.3-70-g09d2