From 79f9fc30fe1235da4752068a2bcb4e32721bd2eb Mon Sep 17 00:00:00 2001 From: OpenSauce04 Date: Wed, 9 Oct 2024 14:36:05 +0100 Subject: [PATCH] lime_qt: Moved command line option checking to earlier in execution, improving response time --- src/lime_qt/main.cpp | 110 +++++++++++++++++++++++-------------------- 1 file changed, 58 insertions(+), 52 deletions(-) diff --git a/src/lime_qt/main.cpp b/src/lime_qt/main.cpp index 54689b489..b9feb33d9 100644 --- a/src/lime_qt/main.cpp +++ b/src/lime_qt/main.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -176,57 +177,9 @@ GMainWindow::GMainWindow(Core::System& system_) this->config = std::make_unique(); -#ifdef __unix__ - SetGamemodeEnabled(Settings::values.enable_gamemode.GetValue()); -#endif - - // register types to use in slots and signals - qRegisterMetaType("std::size_t"); - qRegisterMetaType("Service::AM::InstallStatus"); - - // Register CameraFactory - qt_cameras = std::make_shared(); - Camera::RegisterFactory("image", std::make_unique()); - Camera::RegisterFactory("qt", std::make_unique(qt_cameras)); - - LoadTranslation(); - - Pica::g_debug_context = Pica::DebugContext::Construct(); - setAcceptDrops(true); - ui->setupUi(this); - statusBar()->hide(); - - default_theme_paths = QIcon::themeSearchPaths(); - UpdateUITheme(); - - SetDiscordEnabled(UISettings::values.enable_discord_presence.GetValue()); - discord_rpc->Update(); - - play_time_manager = std::make_unique(); - - Network::Init(); - - movie.SetPlaybackCompletionCallback([this] { - QMetaObject::invokeMethod(this, "OnMoviePlaybackCompleted", Qt::BlockingQueuedConnection); - }); - - InitializeWidgets(); - InitializeDebugWidgets(); - InitializeRecentFileMenuActions(); - InitializeSaveStateMenuActions(); - InitializeHotkeys(); -#if ENABLE_QT_UPDATER - ShowUpdaterWidgets(); -#else - ui->action_Check_For_Updates->setVisible(false); - ui->action_Open_Maintenance_Tool->setVisible(false); -#endif - - SetDefaultUIGeometry(); - RestoreUIState(); - QStringList args = QApplication::arguments(); QString game_path; + std::optional fullscreen_override; for (int i = 1; i < args.size(); ++i) { // Preserves drag/drop functionality if (args.size() == 2 && !args[1].startsWith(QChar::fromLatin1('-'))) { @@ -245,13 +198,12 @@ GMainWindow::GMainWindow(Core::System& system_) } video_dumping_path = args[++i]; video_dumping_on_start = true; - ui->action_Dump_Video->setChecked(true); continue; } // Launch game in fullscreen mode if (args[i] == QStringLiteral("-f")) { - ui->action_Fullscreen->setChecked(true); + fullscreen_override = true; continue; } @@ -342,7 +294,7 @@ GMainWindow::GMainWindow(Core::System& system_) // Launch game in windowed mode if (args[i] == QStringLiteral("-w")) { - ui->action_Fullscreen->setChecked(false); + fullscreen_override = false; continue; } @@ -355,6 +307,60 @@ GMainWindow::GMainWindow(Core::System& system_) CheckForMigration(); +#ifdef __unix__ + SetGamemodeEnabled(Settings::values.enable_gamemode.GetValue()); +#endif + + // register types to use in slots and signals + qRegisterMetaType("std::size_t"); + qRegisterMetaType("Service::AM::InstallStatus"); + + // Register CameraFactory + qt_cameras = std::make_shared(); + Camera::RegisterFactory("image", std::make_unique()); + Camera::RegisterFactory("qt", std::make_unique(qt_cameras)); + + LoadTranslation(); + + Pica::g_debug_context = Pica::DebugContext::Construct(); + setAcceptDrops(true); + ui->setupUi(this); + statusBar()->hide(); + + default_theme_paths = QIcon::themeSearchPaths(); + UpdateUITheme(); + + SetDiscordEnabled(UISettings::values.enable_discord_presence.GetValue()); + discord_rpc->Update(); + + play_time_manager = std::make_unique(); + + Network::Init(); + + movie.SetPlaybackCompletionCallback([this] { + QMetaObject::invokeMethod(this, "OnMoviePlaybackCompleted", Qt::BlockingQueuedConnection); + }); + + InitializeWidgets(); + InitializeDebugWidgets(); + InitializeRecentFileMenuActions(); + InitializeSaveStateMenuActions(); + InitializeHotkeys(); +#if ENABLE_QT_UPDATER + ShowUpdaterWidgets(); +#else + ui->action_Check_For_Updates->setVisible(false); + ui->action_Open_Maintenance_Tool->setVisible(false); +#endif + + SetDefaultUIGeometry(); + RestoreUIState(); + + ui->action_Dump_Video->setChecked(video_dumping_on_start); + if (fullscreen_override) { + ui->action_Fullscreen->setChecked(*fullscreen_override); + } + ConnectAppEvents(); ConnectMenuEvents(); ConnectWidgetEvents();