aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-ui/btdeviceselectiondialog.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/qt-ui/btdeviceselectiondialog.cpp b/qt-ui/btdeviceselectiondialog.cpp
index f84d9cd4b..1d6b8128d 100644
--- a/qt-ui/btdeviceselectiondialog.cpp
+++ b/qt-ui/btdeviceselectiondialog.cpp
@@ -26,22 +26,29 @@ BtDeviceSelectionDialog::BtDeviceSelectionDialog(QWidget *parent) :
// Populate the list with local bluetooth devices
QList<QBluetoothHostInfo> localAvailableDevices = localDevice->allDevices();
- int defaultDeviceIndex = -1;
int availableDevicesSize = localAvailableDevices.size();
- for (int it = 0; it < availableDevicesSize; it++) {
- QBluetoothHostInfo localAvailableDevice = localAvailableDevices.at(it);
- ui->localSelectedDevice->addItem(localAvailableDevice.name(),
- QVariant::fromValue(localAvailableDevice.address()));
+ if (availableDevicesSize > 1) {
+ int defaultDeviceIndex = -1;
- if (localDevice->address() == localAvailableDevice.address())
- defaultDeviceIndex = it;
- }
+ for (int it = 0; it < availableDevicesSize; it++) {
+ QBluetoothHostInfo localAvailableDevice = localAvailableDevices.at(it);
+ ui->localSelectedDevice->addItem(localAvailableDevice.name(),
+ QVariant::fromValue(localAvailableDevice.address()));
+
+ if (localDevice->address() == localAvailableDevice.address())
+ defaultDeviceIndex = it;
+ }
- // Positionate the current index to the default device and register to index changes events
- ui->localSelectedDevice->setCurrentIndex(defaultDeviceIndex);
- connect(ui->localSelectedDevice, SIGNAL(currentIndexChanged(int)),
- this, SLOT(localDeviceChanged(int)));
+ // Positionate the current index to the default device and register to index changes events
+ ui->localSelectedDevice->setCurrentIndex(defaultDeviceIndex);
+ connect(ui->localSelectedDevice, SIGNAL(currentIndexChanged(int)),
+ this, SLOT(localDeviceChanged(int)));
+ } else {
+ // If there is only one local Bluetooth adapter hide the combobox and the label
+ ui->selectDeviceLable->hide();
+ ui->localSelectedDevice->hide();
+ }
// Update the UI information about the local device
updateLocalDeviceInformation();