diff options
author | Claudiu Olteanu <olteanu.claudiu@ymail.com> | 2015-07-19 21:50:06 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-07-20 05:52:10 -0700 |
commit | aaf61c52d81b5a8ebf479f3107c4a7529ea4187a (patch) | |
tree | 80060730d7c74e0992d5986698378cc20dbd53b3 /qt-ui/btdeviceselectiondialog.cpp | |
parent | 8c373f419d95a8359491c50ac149bf84e6aa4201 (diff) | |
download | subsurface-aaf61c52d81b5a8ebf479f3107c4a7529ea4187a.tar.gz |
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>
Diffstat (limited to 'qt-ui/btdeviceselectiondialog.cpp')
-rw-r--r-- | qt-ui/btdeviceselectiondialog.cpp | 31 |
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(); |