mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
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:
parent
8c373f419d
commit
aaf61c52d8
1 changed files with 19 additions and 12 deletions
|
@ -26,23 +26,30 @@ 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)));
|
||||
} else {
|
||||
// If there is only one local Bluetooth adapter hide the combobox and the label
|
||||
ui->selectDeviceLable->hide();
|
||||
ui->localSelectedDevice->hide();
|
||||
}
|
||||
|
||||
// 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)));
|
||||
|
||||
// Update the UI information about the local device
|
||||
updateLocalDeviceInformation();
|
||||
|
||||
|
|
Loading…
Reference in a new issue