| 306 | } |
| 307 | |
| 308 | int MOApplication::run(MOMultiProcess& multiProcess) |
| 309 | { |
| 310 | // checking command line |
| 311 | TimeThis tt("MOApplication::run()"); |
| 312 | |
| 313 | // show splash |
| 314 | tt.start("MOApplication::doOneRun() splash"); |
| 315 | |
| 316 | MOSplash splash(*m_settings, m_instance->directory(), m_instance->gamePlugin()); |
| 317 | |
| 318 | tt.start("MOApplication::doOneRun() finishing"); |
| 319 | |
| 320 | // start an api check |
| 321 | QString apiKey; |
| 322 | if (GlobalSettings::nexusApiKey(apiKey)) { |
| 323 | m_nexus->getAccessManager()->apiCheck(apiKey); |
| 324 | } |
| 325 | |
| 326 | // tutorials |
| 327 | log::debug("initializing tutorials"); |
| 328 | TutorialManager::init(qApp->applicationDirPath() + "/" + |
| 329 | QString::fromStdWString(AppConfig::tutorialsPath()) + "/", |
| 330 | m_core.get()); |
| 331 | |
| 332 | // styling |
| 333 | if (!setStyleFile(m_settings->interface().styleName().value_or(""))) { |
| 334 | // disable invalid stylesheet |
| 335 | m_settings->interface().setStyleName(""); |
| 336 | } |
| 337 | |
| 338 | int res = 1; |
| 339 | |
| 340 | { |
| 341 | tt.start("MOApplication::doOneRun() MainWindow setup"); |
| 342 | MainWindow mainWindow(*m_settings, *m_core, *m_plugins); |
| 343 | |
| 344 | // the nexus interface can show dialogs, make sure they're parented to the |
| 345 | // main window |
| 346 | m_nexus->getAccessManager()->setTopLevelWidget(&mainWindow); |
| 347 | |
| 348 | connect( |
| 349 | &mainWindow, &MainWindow::styleChanged, this, |
| 350 | [this](auto&& file) { |
| 351 | setStyleFile(file); |
| 352 | }, |
| 353 | Qt::QueuedConnection); |
| 354 | |
| 355 | log::debug("displaying main window"); |
| 356 | mainWindow.show(); |
| 357 | mainWindow.activateWindow(); |
| 358 | splash.close(); |
| 359 | |
| 360 | tt.stop(); |
| 361 | |
| 362 | res = exec(); |
| 363 | mainWindow.close(); |
| 364 | |
| 365 | // main window is about to be destroyed |
no test coverage detected