summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Claudiu Olteanu <olteanu.claudiu@ymail.com>2015-07-18 21:01:40 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-20 05:39:43 -0700
commit8d2b6142c61934979a70b6b6d85a529575b8c297 (patch)
treed3d07f1f0379125bcdbb6e3a9af2a72a024594ae
parent5ccf3e81eb3a0254a1f85fcbd9bd4c6ea3addcb1 (diff)
downloadsubsurface-8d2b6142c61934979a70b6b6d85a529575b8c297.tar.gz
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 <olteanu.claudiu@ymail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/btdeviceselectiondialog.cpp32
1 files changed, 22 insertions, 10 deletions
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());