| 2414 | QMessageBox::StandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); |
| 2415 | |
| 2416 | void RDDialog::show(QMenu *menu, QPoint pos) |
| 2417 | { |
| 2418 | // menus aren't always visible immediately, so we need to listen for aboutToHide to exit the event |
| 2419 | // loop. As a safety precaution because I don't trust the damn signals, if we loop for over a |
| 2420 | // second then we'll quit as soon as the menu is not visible |
| 2421 | volatile bool menuHiding = false; |
| 2422 | auto connection = |
| 2423 | QObject::connect(menu, &QMenu::aboutToHide, [&menuHiding]() { menuHiding = true; }); |
| 2424 | |
| 2425 | menu->setWindowModality(Qt::ApplicationModal); |
| 2426 | menu->popup(pos); |
| 2427 | |
| 2428 | QElapsedTimer elapsed; |
| 2429 | elapsed.start(); |
| 2430 | |
| 2431 | QEventLoop loop; |
| 2432 | for(;;) |
| 2433 | { |
| 2434 | // stop processing once aboutToHide has been signalled |
| 2435 | if(menuHiding) |
| 2436 | break; |
| 2437 | |
| 2438 | // stop processing if 1s has passed and the menu isn't visible anymore. |
| 2439 | if(elapsed.hasExpired(1000) && !menu->isVisible()) |
| 2440 | break; |
| 2441 | |
| 2442 | loop.processEvents(QEventLoop::WaitForMoreEvents); |
| 2443 | QCoreApplication::sendPostedEvents(); |
| 2444 | } |
| 2445 | |
| 2446 | QObject::disconnect(connection); |
| 2447 | } |
| 2448 | |
| 2449 | int RDDialog::show(QDialog *dialog) |
| 2450 | { |
no test coverage detected