| 452 | } |
| 453 | |
| 454 | int GuiMain(int argc, char* argv[]) |
| 455 | { |
| 456 | #ifdef WIN32 |
| 457 | util::WinCmdLineArgs winArgs; |
| 458 | std::tie(argc, argv) = winArgs.get(); |
| 459 | #endif |
| 460 | |
| 461 | std::unique_ptr<interfaces::Init> init = interfaces::MakeGuiInit(argc, argv); |
| 462 | |
| 463 | SetupEnvironment(); |
| 464 | util::ThreadSetInternalName("main"); |
| 465 | |
| 466 | // Subscribe to global signals from core |
| 467 | boost::signals2::scoped_connection handler_message_box = ::uiInterface.ThreadSafeMessageBox_connect(noui_ThreadSafeMessageBox); |
| 468 | boost::signals2::scoped_connection handler_question = ::uiInterface.ThreadSafeQuestion_connect(noui_ThreadSafeQuestion); |
| 469 | boost::signals2::scoped_connection handler_init_message = ::uiInterface.InitMessage_connect(noui_InitMessage); |
| 470 | |
| 471 | // Do not refer to data directory yet, this can be overridden by Intro::pickDataDirectory |
| 472 | |
| 473 | /// 1. Basic Qt initialization (not dependent on parameters or configuration) |
| 474 | Q_INIT_RESOURCE(bitcoin); |
| 475 | Q_INIT_RESOURCE(bitcoin_locale); |
| 476 | |
| 477 | // Generate high-dpi pixmaps |
| 478 | QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); |
| 479 | QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); |
| 480 | |
| 481 | #if defined(QT_QPA_PLATFORM_ANDROID) |
| 482 | QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar); |
| 483 | QApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); |
| 484 | QApplication::setAttribute(Qt::AA_DontUseNativeDialogs); |
| 485 | #endif |
| 486 | |
| 487 | BitcoinApplication app; |
| 488 | GUIUtil::LoadFont(QStringLiteral(":/fonts/monospace")); |
| 489 | |
| 490 | /// 2. Parse command-line options. We do this after qt in order to show an error if there are problems parsing these |
| 491 | // Command-line options take precedence: |
| 492 | SetupServerArgs(gArgs); |
| 493 | SetupUIArgs(gArgs); |
| 494 | std::string error; |
| 495 | if (!gArgs.ParseParameters(argc, argv, error)) { |
| 496 | InitError(strprintf(Untranslated("Error parsing command line arguments: %s\n"), error)); |
| 497 | // Create a message box, because the gui has neither been created nor has subscribed to core signals |
| 498 | QMessageBox::critical(nullptr, PACKAGE_NAME, |
| 499 | // message cannot be translated because translations have not been initialized |
| 500 | QString::fromStdString("Error parsing command line arguments: %1.").arg(QString::fromStdString(error))); |
| 501 | return EXIT_FAILURE; |
| 502 | } |
| 503 | |
| 504 | // Now that the QApplication is setup and we have parsed our parameters, we can set the platform style |
| 505 | app.setupPlatformStyle(); |
| 506 | |
| 507 | /// 3. Application identification |
| 508 | // must be set before OptionsModel is initialized or translations are loaded, |
| 509 | // as it is used to locate QSettings |
| 510 | QApplication::setOrganizationName(QAPP_ORG_NAME); |
| 511 | QApplication::setOrganizationDomain(QAPP_ORG_DOMAIN); |
no test coverage detected