mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
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>
This commit is contained in:
parent
5ccf3e81eb
commit
8d2b6142c6
1 changed files with 22 additions and 10 deletions
|
@ -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());
|
||||
|
|
Loading…
Reference in a new issue