Merge pull request #139 from sophiekovalevsky/refactor-device-list

app: refactor enable connect to
This commit is contained in:
jankae 2022-07-17 15:15:35 +02:00 committed by GitHub
commit 32164dda87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -938,6 +938,7 @@ int AppWindow::UpdateDeviceList()
devices.insert(device->serial());
}
int available = 0;
bool found = false;
if(devices.size()) {
for(auto d : devices) {
if(!parser.value("device").isEmpty() && parser.value("device") != d) {
@ -953,13 +954,11 @@ int AppWindow::UpdateDeviceList()
connect(connectAction, &QAction::triggered, [this, d]() {
ConnectToDevice(d);
});
ui->menuConnect_to->setEnabled(true);
found = true;
available++;
}
} else {
// no devices available, disable connection option
ui->menuConnect_to->setEnabled(false);
}
ui->menuConnect_to->setEnabled(found);
qDebug() << "Updated device list, found" << available;
return available;
}