| 500 | } |
| 501 | |
| 502 | void SetupWizardDialog::openAutomaticMappingMenu(u32 port, QLabel* update_label) |
| 503 | { |
| 504 | QMenu menu(this); |
| 505 | bool added = false; |
| 506 | |
| 507 | for (const QPair<QString, QString>& dev : m_device_list) |
| 508 | { |
| 509 | // we set it as data, because the device list could get invalidated while the menu is up |
| 510 | QAction* action = menu.addAction(QStringLiteral("%1 (%2)").arg(dev.first).arg(dev.second)); |
| 511 | action->setData(dev.first); |
| 512 | connect(action, &QAction::triggered, this, [this, port, update_label, action]() { |
| 513 | doDeviceAutomaticBinding(port, update_label, action->data().toString()); |
| 514 | }); |
| 515 | added = true; |
| 516 | } |
| 517 | |
| 518 | if (!added) |
| 519 | { |
| 520 | QAction* action = menu.addAction(tr("No devices available")); |
| 521 | action->setEnabled(false); |
| 522 | } |
| 523 | |
| 524 | menu.exec(QCursor::pos()); |
| 525 | } |
| 526 | |
| 527 | void SetupWizardDialog::doDeviceAutomaticBinding(u32 port, QLabel* update_label, const QString& device) |
| 528 | { |