summaryrefslogtreecommitdiffstats
path: root/qt-ui/btdeviceselectiondialog.cpp
diff options
context:
space:
mode:
authorGravatar Claudiu Olteanu <olteanu.claudiu@ymail.com>2015-07-19 21:50:06 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-20 05:52:10 -0700
commitaaf61c52d81b5a8ebf479f3107c4a7529ea4187a (patch)
tree80060730d7c74e0992d5986698378cc20dbd53b3 /qt-ui/btdeviceselectiondialog.cpp
parent8c373f419d95a8359491c50ac149bf84e6aa4201 (diff)
downloadsubsurface-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.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();