| 99 | #ifdef MAPPER_USE_QTSINGLEAPPLICATION |
| 100 | |
| 101 | void resetActivationWindow(QtSingleApplication& app) |
| 102 | { |
| 103 | const auto* const old_window = app.activationWindow(); |
| 104 | app.setActivationWindow(nullptr); |
| 105 | |
| 106 | if (!QCoreApplication::closingDown()) |
| 107 | { |
| 108 | const auto top_level_widgets = QApplication::topLevelWidgets(); |
| 109 | for (auto* widget : top_level_widgets) |
| 110 | { |
| 111 | auto* const new_window = qobject_cast<MainWindow*>(widget); |
| 112 | if (new_window && new_window != old_window) |
| 113 | { |
| 114 | app.setActivationWindow(new_window); |
| 115 | QObject::connect(new_window, &QObject::destroyed, &app, [&app]() { resetActivationWindow(app); }); |
| 116 | QObject::connect(&app, &QtSingleApplication::messageReceived, new_window, &MainWindow::openPathLater); |
| 117 | break; |
| 118 | } |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | #endif |
| 124 |
no test coverage detected