Hide the local BT combobox if there is only one device

If there is only one local Bluetooth adapter, then hide the
selection combobox and the label.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Claudiu Olteanu 2015-07-19 21:50:06 +03:00 committed by Dirk Hohndel
parent 8c373f419d
commit aaf61c52d8

View file

@ -26,9 +26,11 @@ BtDeviceSelectionDialog::BtDeviceSelectionDialog(QWidget *parent) :
// Populate the list with local bluetooth devices // Populate the list with local bluetooth devices
QList<QBluetoothHostInfo> localAvailableDevices = localDevice->allDevices(); QList<QBluetoothHostInfo> localAvailableDevices = localDevice->allDevices();
int defaultDeviceIndex = -1;
int availableDevicesSize = localAvailableDevices.size(); int availableDevicesSize = localAvailableDevices.size();
if (availableDevicesSize > 1) {
int defaultDeviceIndex = -1;
for (int it = 0; it < availableDevicesSize; it++) { for (int it = 0; it < availableDevicesSize; it++) {
QBluetoothHostInfo localAvailableDevice = localAvailableDevices.at(it); QBluetoothHostInfo localAvailableDevice = localAvailableDevices.at(it);
ui->localSelectedDevice->addItem(localAvailableDevice.name(), ui->localSelectedDevice->addItem(localAvailableDevice.name(),
@ -42,6 +44,11 @@ BtDeviceSelectionDialog::BtDeviceSelectionDialog(QWidget *parent) :
ui->localSelectedDevice->setCurrentIndex(defaultDeviceIndex); ui->localSelectedDevice->setCurrentIndex(defaultDeviceIndex);
connect(ui->localSelectedDevice, SIGNAL(currentIndexChanged(int)), connect(ui->localSelectedDevice, SIGNAL(currentIndexChanged(int)),
this, SLOT(localDeviceChanged(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 // Update the UI information about the local device
updateLocalDeviceInformation(); updateLocalDeviceInformation();