* @brief Shows a file-open dialog and loads the selected project; the selection * handler defers via a queued invoke so the macOS NSSavePanel KVO callback can * unwind before re-entering the model. */
| 2332 | * unwind before re-entering the model. |
| 2333 | */ |
| 2334 | void DataModel::ProjectModel::openJsonFile() |
| 2335 | { |
| 2336 | auto* dialog = new QFileDialog(qApp->activeWindow(), |
| 2337 | tr("Select Project File"), |
| 2338 | jsonProjectsPath(), |
| 2339 | tr("Project Files (*.json *.ssproj)")); |
| 2340 | |
| 2341 | dialog->setFileMode(QFileDialog::ExistingFile); |
| 2342 | dialog->setAttribute(Qt::WA_DeleteOnClose); |
| 2343 | |
| 2344 | connect(dialog, &QFileDialog::fileSelected, this, [this](const QString& path) { |
| 2345 | if (path.isEmpty()) |
| 2346 | return; |
| 2347 | |
| 2348 | QMetaObject::invokeMethod(this, [this, path]() { openJsonFile(path); }, Qt::QueuedConnection); |
| 2349 | }); |
| 2350 | |
| 2351 | dialog->open(); |
| 2352 | } |
| 2353 | |
| 2354 | /** |
| 2355 | * @brief Loads a project from the given .ssproj/.json path. |
no test coverage detected