main: Use std::unique_ptr for ui

This commit is contained in:
Morph 2021-10-15 15:27:18 -04:00
parent ab441fb009
commit 86908d569e
2 changed files with 142 additions and 137 deletions

View file

@ -104,6 +104,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
#include "core/telemetry_session.h" #include "core/telemetry_session.h"
#include "input_common/main.h" #include "input_common/main.h"
#include "input_common/tas/tas_input.h" #include "input_common/tas/tas_input.h"
#include "ui_main.h"
#include "util/overlay_dialog.h" #include "util/overlay_dialog.h"
#include "video_core/gpu.h" #include "video_core/gpu.h"
#include "video_core/renderer_base.h" #include "video_core/renderer_base.h"
@ -199,7 +200,7 @@ GMainWindow::GMainWindow(Core::System& system_)
LoadTranslation(); LoadTranslation();
setAcceptDrops(true); setAcceptDrops(true);
ui.setupUi(this); ui->setupUi(this);
statusBar()->hide(); statusBar()->hide();
default_theme_paths = QIcon::themeSearchPaths(); default_theme_paths = QIcon::themeSearchPaths();
@ -274,16 +275,16 @@ GMainWindow::GMainWindow(Core::System& system_)
ShowTelemetryCallout(); ShowTelemetryCallout();
// make sure menubar has the arrow cursor instead of inheriting from this // make sure menubar has the arrow cursor instead of inheriting from this
ui.menubar->setCursor(QCursor()); ui->menubar->setCursor(QCursor());
statusBar()->setCursor(QCursor()); statusBar()->setCursor(QCursor());
mouse_hide_timer.setInterval(default_mouse_timeout); mouse_hide_timer.setInterval(default_mouse_timeout);
connect(&mouse_hide_timer, &QTimer::timeout, this, &GMainWindow::HideMouseCursor); connect(&mouse_hide_timer, &QTimer::timeout, this, &GMainWindow::HideMouseCursor);
connect(ui.menubar, &QMenuBar::hovered, this, &GMainWindow::ShowMouseCursor); connect(ui->menubar, &QMenuBar::hovered, this, &GMainWindow::ShowMouseCursor);
MigrateConfigFiles(); MigrateConfigFiles();
ui.action_Fullscreen->setChecked(false); ui->action_Fullscreen->setChecked(false);
QStringList args = QApplication::arguments(); QStringList args = QApplication::arguments();
@ -302,7 +303,7 @@ GMainWindow::GMainWindow(Core::System& system_)
// Launch game in fullscreen mode // Launch game in fullscreen mode
if (args[i] == QStringLiteral("-f")) { if (args[i] == QStringLiteral("-f")) {
ui.action_Fullscreen->setChecked(true); ui->action_Fullscreen->setChecked(true);
continue; continue;
} }
@ -568,9 +569,9 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url,
QtNXWebEngineView web_browser_view(this, system, input_subsystem.get()); QtNXWebEngineView web_browser_view(this, system, input_subsystem.get());
ui.action_Pause->setEnabled(false); ui->action_Pause->setEnabled(false);
ui.action_Restart->setEnabled(false); ui->action_Restart->setEnabled(false);
ui.action_Stop->setEnabled(false); ui->action_Stop->setEnabled(false);
{ {
QProgressDialog loading_progress(this); QProgressDialog loading_progress(this);
@ -634,7 +635,7 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url,
web_browser_view.SetFinished(true); web_browser_view.SetFinished(true);
} }
}); });
ui.menubar->addAction(exit_action); ui->menubar->addAction(exit_action);
while (!web_browser_view.IsFinished()) { while (!web_browser_view.IsFinished()) {
QCoreApplication::processEvents(); QCoreApplication::processEvents();
@ -676,11 +677,11 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url,
render_window->show(); render_window->show();
} }
ui.action_Pause->setEnabled(true); ui->action_Pause->setEnabled(true);
ui.action_Restart->setEnabled(true); ui->action_Restart->setEnabled(true);
ui.action_Stop->setEnabled(true); ui->action_Stop->setEnabled(true);
ui.menubar->removeAction(exit_action); ui->menubar->removeAction(exit_action);
QCoreApplication::processEvents(); QCoreApplication::processEvents();
@ -696,21 +697,21 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url,
void GMainWindow::InitializeWidgets() { void GMainWindow::InitializeWidgets() {
#ifdef YUZU_ENABLE_COMPATIBILITY_REPORTING #ifdef YUZU_ENABLE_COMPATIBILITY_REPORTING
ui.action_Report_Compatibility->setVisible(true); ui->action_Report_Compatibility->setVisible(true);
#endif #endif
render_window = new GRenderWindow(this, emu_thread.get(), input_subsystem, system); render_window = new GRenderWindow(this, emu_thread.get(), input_subsystem, system);
render_window->hide(); render_window->hide();
game_list = new GameList(vfs, provider.get(), system, this); game_list = new GameList(vfs, provider.get(), system, this);
ui.horizontalLayout->addWidget(game_list); ui->horizontalLayout->addWidget(game_list);
game_list_placeholder = new GameListPlaceholder(this); game_list_placeholder = new GameListPlaceholder(this);
ui.horizontalLayout->addWidget(game_list_placeholder); ui->horizontalLayout->addWidget(game_list_placeholder);
game_list_placeholder->setVisible(false); game_list_placeholder->setVisible(false);
loading_screen = new LoadingScreen(this); loading_screen = new LoadingScreen(this);
loading_screen->hide(); loading_screen->hide();
ui.horizontalLayout->addWidget(loading_screen); ui->horizontalLayout->addWidget(loading_screen);
connect(loading_screen, &LoadingScreen::Hidden, [&] { connect(loading_screen, &LoadingScreen::Hidden, [&] {
loading_screen->Clear(); loading_screen->Clear();
if (emulation_running) { if (emulation_running) {
@ -835,7 +836,7 @@ void GMainWindow::InitializeWidgets() {
} }
void GMainWindow::InitializeDebugWidgets() { void GMainWindow::InitializeDebugWidgets() {
QMenu* debug_menu = ui.menu_View_Debugging; QMenu* debug_menu = ui->menu_View_Debugging;
#if MICROPROFILE_ENABLED #if MICROPROFILE_ENABLED
microProfileDialog = new MicroProfileDialog(this); microProfileDialog = new MicroProfileDialog(this);
@ -864,16 +865,16 @@ void GMainWindow::InitializeRecentFileMenuActions() {
actions_recent_files[i]->setVisible(false); actions_recent_files[i]->setVisible(false);
connect(actions_recent_files[i], &QAction::triggered, this, &GMainWindow::OnMenuRecentFile); connect(actions_recent_files[i], &QAction::triggered, this, &GMainWindow::OnMenuRecentFile);
ui.menu_recent_files->addAction(actions_recent_files[i]); ui->menu_recent_files->addAction(actions_recent_files[i]);
} }
ui.menu_recent_files->addSeparator(); ui->menu_recent_files->addSeparator();
QAction* action_clear_recent_files = new QAction(this); QAction* action_clear_recent_files = new QAction(this);
action_clear_recent_files->setText(tr("&Clear Recent Files")); action_clear_recent_files->setText(tr("&Clear Recent Files"));
connect(action_clear_recent_files, &QAction::triggered, this, [this] { connect(action_clear_recent_files, &QAction::triggered, this, [this] {
UISettings::values.recent_files.clear(); UISettings::values.recent_files.clear();
UpdateRecentFiles(); UpdateRecentFiles();
}); });
ui.menu_recent_files->addAction(action_clear_recent_files); ui->menu_recent_files->addAction(action_clear_recent_files);
UpdateRecentFiles(); UpdateRecentFiles();
} }
@ -892,43 +893,43 @@ void GMainWindow::InitializeHotkeys() {
const QString fullscreen = QStringLiteral("Fullscreen"); const QString fullscreen = QStringLiteral("Fullscreen");
const QString capture_screenshot = QStringLiteral("Capture Screenshot"); const QString capture_screenshot = QStringLiteral("Capture Screenshot");
ui.action_Load_File->setShortcut(hotkey_registry.GetKeySequence(main_window, load_file)); ui->action_Load_File->setShortcut(hotkey_registry.GetKeySequence(main_window, load_file));
ui.action_Load_File->setShortcutContext( ui->action_Load_File->setShortcutContext(
hotkey_registry.GetShortcutContext(main_window, load_file)); hotkey_registry.GetShortcutContext(main_window, load_file));
ui.action_Load_Amiibo->setShortcut(hotkey_registry.GetKeySequence(main_window, load_amiibo)); ui->action_Load_Amiibo->setShortcut(hotkey_registry.GetKeySequence(main_window, load_amiibo));
ui.action_Load_Amiibo->setShortcutContext( ui->action_Load_Amiibo->setShortcutContext(
hotkey_registry.GetShortcutContext(main_window, load_amiibo)); hotkey_registry.GetShortcutContext(main_window, load_amiibo));
ui.action_Exit->setShortcut(hotkey_registry.GetKeySequence(main_window, exit_yuzu)); ui->action_Exit->setShortcut(hotkey_registry.GetKeySequence(main_window, exit_yuzu));
ui.action_Exit->setShortcutContext(hotkey_registry.GetShortcutContext(main_window, exit_yuzu)); ui->action_Exit->setShortcutContext(hotkey_registry.GetShortcutContext(main_window, exit_yuzu));
ui.action_Restart->setShortcut(hotkey_registry.GetKeySequence(main_window, restart_emulation)); ui->action_Restart->setShortcut(hotkey_registry.GetKeySequence(main_window, restart_emulation));
ui.action_Restart->setShortcutContext( ui->action_Restart->setShortcutContext(
hotkey_registry.GetShortcutContext(main_window, restart_emulation)); hotkey_registry.GetShortcutContext(main_window, restart_emulation));
ui.action_Stop->setShortcut(hotkey_registry.GetKeySequence(main_window, stop_emulation)); ui->action_Stop->setShortcut(hotkey_registry.GetKeySequence(main_window, stop_emulation));
ui.action_Stop->setShortcutContext( ui->action_Stop->setShortcutContext(
hotkey_registry.GetShortcutContext(main_window, stop_emulation)); hotkey_registry.GetShortcutContext(main_window, stop_emulation));
ui.action_Show_Filter_Bar->setShortcut( ui->action_Show_Filter_Bar->setShortcut(
hotkey_registry.GetKeySequence(main_window, toggle_filter_bar)); hotkey_registry.GetKeySequence(main_window, toggle_filter_bar));
ui.action_Show_Filter_Bar->setShortcutContext( ui->action_Show_Filter_Bar->setShortcutContext(
hotkey_registry.GetShortcutContext(main_window, toggle_filter_bar)); hotkey_registry.GetShortcutContext(main_window, toggle_filter_bar));
ui.action_Show_Status_Bar->setShortcut( ui->action_Show_Status_Bar->setShortcut(
hotkey_registry.GetKeySequence(main_window, toggle_status_bar)); hotkey_registry.GetKeySequence(main_window, toggle_status_bar));
ui.action_Show_Status_Bar->setShortcutContext( ui->action_Show_Status_Bar->setShortcutContext(
hotkey_registry.GetShortcutContext(main_window, toggle_status_bar)); hotkey_registry.GetShortcutContext(main_window, toggle_status_bar));
ui.action_Capture_Screenshot->setShortcut( ui->action_Capture_Screenshot->setShortcut(
hotkey_registry.GetKeySequence(main_window, capture_screenshot)); hotkey_registry.GetKeySequence(main_window, capture_screenshot));
ui.action_Capture_Screenshot->setShortcutContext( ui->action_Capture_Screenshot->setShortcutContext(
hotkey_registry.GetShortcutContext(main_window, capture_screenshot)); hotkey_registry.GetShortcutContext(main_window, capture_screenshot));
ui.action_Fullscreen->setShortcut( ui->action_Fullscreen->setShortcut(
hotkey_registry.GetHotkey(main_window, fullscreen, this)->key()); hotkey_registry.GetHotkey(main_window, fullscreen, this)->key());
ui.action_Fullscreen->setShortcutContext( ui->action_Fullscreen->setShortcutContext(
hotkey_registry.GetShortcutContext(main_window, fullscreen)); hotkey_registry.GetShortcutContext(main_window, fullscreen));
connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Load File"), this), connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Load File"), this),
@ -952,13 +953,13 @@ void GMainWindow::InitializeHotkeys() {
BootGame(game_path); BootGame(game_path);
}); });
connect(hotkey_registry.GetHotkey(main_window, fullscreen, render_window), connect(hotkey_registry.GetHotkey(main_window, fullscreen, render_window),
&QShortcut::activated, ui.action_Fullscreen, &QAction::trigger); &QShortcut::activated, ui->action_Fullscreen, &QAction::trigger);
connect(hotkey_registry.GetHotkey(main_window, fullscreen, render_window), connect(hotkey_registry.GetHotkey(main_window, fullscreen, render_window),
&QShortcut::activatedAmbiguously, ui.action_Fullscreen, &QAction::trigger); &QShortcut::activatedAmbiguously, ui->action_Fullscreen, &QAction::trigger);
connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Exit Fullscreen"), this), connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Exit Fullscreen"), this),
&QShortcut::activated, this, [&] { &QShortcut::activated, this, [&] {
if (emulation_running) { if (emulation_running) {
ui.action_Fullscreen->setChecked(false); ui->action_Fullscreen->setChecked(false);
ToggleFullscreen(); ToggleFullscreen();
} }
}); });
@ -987,7 +988,7 @@ void GMainWindow::InitializeHotkeys() {
}); });
connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Load Amiibo"), this), connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Load Amiibo"), this),
&QShortcut::activated, this, [&] { &QShortcut::activated, this, [&] {
if (ui.action_Load_Amiibo->isEnabled()) { if (ui->action_Load_Amiibo->isEnabled()) {
OnLoadAmiibo(); OnLoadAmiibo();
} }
}); });
@ -1068,20 +1069,20 @@ void GMainWindow::RestoreUIState() {
game_list->LoadInterfaceLayout(); game_list->LoadInterfaceLayout();
ui.action_Single_Window_Mode->setChecked(UISettings::values.single_window_mode.GetValue()); ui->action_Single_Window_Mode->setChecked(UISettings::values.single_window_mode.GetValue());
ToggleWindowMode(); ToggleWindowMode();
ui.action_Fullscreen->setChecked(UISettings::values.fullscreen.GetValue()); ui->action_Fullscreen->setChecked(UISettings::values.fullscreen.GetValue());
ui.action_Display_Dock_Widget_Headers->setChecked( ui->action_Display_Dock_Widget_Headers->setChecked(
UISettings::values.display_titlebar.GetValue()); UISettings::values.display_titlebar.GetValue());
OnDisplayTitleBars(ui.action_Display_Dock_Widget_Headers->isChecked()); OnDisplayTitleBars(ui->action_Display_Dock_Widget_Headers->isChecked());
ui.action_Show_Filter_Bar->setChecked(UISettings::values.show_filter_bar.GetValue()); ui->action_Show_Filter_Bar->setChecked(UISettings::values.show_filter_bar.GetValue());
game_list->SetFilterVisible(ui.action_Show_Filter_Bar->isChecked()); game_list->SetFilterVisible(ui->action_Show_Filter_Bar->isChecked());
ui.action_Show_Status_Bar->setChecked(UISettings::values.show_status_bar.GetValue()); ui->action_Show_Status_Bar->setChecked(UISettings::values.show_status_bar.GetValue());
statusBar()->setVisible(ui.action_Show_Status_Bar->isChecked()); statusBar()->setVisible(ui->action_Show_Status_Bar->isChecked());
Debugger::ToggleConsole(); Debugger::ToggleConsole();
} }
@ -1093,11 +1094,11 @@ void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) {
state != Qt::ApplicationActive) { state != Qt::ApplicationActive) {
LOG_DEBUG(Frontend, "ApplicationState unusual flag: {} ", state); LOG_DEBUG(Frontend, "ApplicationState unusual flag: {} ", state);
} }
if (ui.action_Pause->isEnabled() && if (ui->action_Pause->isEnabled() &&
(state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) { (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) {
auto_paused = true; auto_paused = true;
OnPauseGame(); OnPauseGame();
} else if (ui.action_Start->isEnabled() && auto_paused && state == Qt::ApplicationActive) { } else if (ui->action_Start->isEnabled() && auto_paused && state == Qt::ApplicationActive) {
auto_paused = false; auto_paused = false;
OnStartGame(); OnStartGame();
} }
@ -1142,59 +1143,60 @@ void GMainWindow::ConnectWidgetEvents() {
void GMainWindow::ConnectMenuEvents() { void GMainWindow::ConnectMenuEvents() {
// File // File
connect(ui.action_Load_File, &QAction::triggered, this, &GMainWindow::OnMenuLoadFile); connect(ui->action_Load_File, &QAction::triggered, this, &GMainWindow::OnMenuLoadFile);
connect(ui.action_Load_Folder, &QAction::triggered, this, &GMainWindow::OnMenuLoadFolder); connect(ui->action_Load_Folder, &QAction::triggered, this, &GMainWindow::OnMenuLoadFolder);
connect(ui.action_Install_File_NAND, &QAction::triggered, this, connect(ui->action_Install_File_NAND, &QAction::triggered, this,
&GMainWindow::OnMenuInstallToNAND); &GMainWindow::OnMenuInstallToNAND);
connect(ui.action_Exit, &QAction::triggered, this, &QMainWindow::close); connect(ui->action_Exit, &QAction::triggered, this, &QMainWindow::close);
connect(ui.action_Load_Amiibo, &QAction::triggered, this, &GMainWindow::OnLoadAmiibo); connect(ui->action_Load_Amiibo, &QAction::triggered, this, &GMainWindow::OnLoadAmiibo);
// Emulation // Emulation
connect(ui.action_Start, &QAction::triggered, this, &GMainWindow::OnStartGame); connect(ui->action_Start, &QAction::triggered, this, &GMainWindow::OnStartGame);
connect(ui.action_Pause, &QAction::triggered, this, &GMainWindow::OnPauseGame); connect(ui->action_Pause, &QAction::triggered, this, &GMainWindow::OnPauseGame);
connect(ui.action_Stop, &QAction::triggered, this, &GMainWindow::OnStopGame); connect(ui->action_Stop, &QAction::triggered, this, &GMainWindow::OnStopGame);
connect(ui.action_Report_Compatibility, &QAction::triggered, this, connect(ui->action_Report_Compatibility, &QAction::triggered, this,
&GMainWindow::OnMenuReportCompatibility); &GMainWindow::OnMenuReportCompatibility);
connect(ui.action_Open_Mods_Page, &QAction::triggered, this, &GMainWindow::OnOpenModsPage); connect(ui->action_Open_Mods_Page, &QAction::triggered, this, &GMainWindow::OnOpenModsPage);
connect(ui.action_Open_Quickstart_Guide, &QAction::triggered, this, connect(ui->action_Open_Quickstart_Guide, &QAction::triggered, this,
&GMainWindow::OnOpenQuickstartGuide); &GMainWindow::OnOpenQuickstartGuide);
connect(ui.action_Open_FAQ, &QAction::triggered, this, &GMainWindow::OnOpenFAQ); connect(ui->action_Open_FAQ, &QAction::triggered, this, &GMainWindow::OnOpenFAQ);
connect(ui.action_Restart, &QAction::triggered, this, [this] { BootGame(QString(game_path)); }); connect(ui->action_Restart, &QAction::triggered, this,
connect(ui.action_Configure, &QAction::triggered, this, &GMainWindow::OnConfigure); [this] { BootGame(QString(game_path)); });
connect(ui.action_Configure_Tas, &QAction::triggered, this, &GMainWindow::OnConfigureTas); connect(ui->action_Configure, &QAction::triggered, this, &GMainWindow::OnConfigure);
connect(ui.action_Configure_Current_Game, &QAction::triggered, this, connect(ui->action_Configure_Tas, &QAction::triggered, this, &GMainWindow::OnConfigureTas);
connect(ui->action_Configure_Current_Game, &QAction::triggered, this,
&GMainWindow::OnConfigurePerGame); &GMainWindow::OnConfigurePerGame);
// View // View
connect(ui.action_Single_Window_Mode, &QAction::triggered, this, connect(ui->action_Single_Window_Mode, &QAction::triggered, this,
&GMainWindow::ToggleWindowMode); &GMainWindow::ToggleWindowMode);
connect(ui.action_Display_Dock_Widget_Headers, &QAction::triggered, this, connect(ui->action_Display_Dock_Widget_Headers, &QAction::triggered, this,
&GMainWindow::OnDisplayTitleBars); &GMainWindow::OnDisplayTitleBars);
connect(ui.action_Show_Filter_Bar, &QAction::triggered, this, &GMainWindow::OnToggleFilterBar); connect(ui->action_Show_Filter_Bar, &QAction::triggered, this, &GMainWindow::OnToggleFilterBar);
connect(ui.action_Show_Status_Bar, &QAction::triggered, statusBar(), &QStatusBar::setVisible); connect(ui->action_Show_Status_Bar, &QAction::triggered, statusBar(), &QStatusBar::setVisible);
connect(ui.action_Reset_Window_Size_720, &QAction::triggered, this, connect(ui->action_Reset_Window_Size_720, &QAction::triggered, this,
&GMainWindow::ResetWindowSize720); &GMainWindow::ResetWindowSize720);
connect(ui.action_Reset_Window_Size_900, &QAction::triggered, this, connect(ui->action_Reset_Window_Size_900, &QAction::triggered, this,
&GMainWindow::ResetWindowSize900); &GMainWindow::ResetWindowSize900);
connect(ui.action_Reset_Window_Size_1080, &QAction::triggered, this, connect(ui->action_Reset_Window_Size_1080, &QAction::triggered, this,
&GMainWindow::ResetWindowSize1080); &GMainWindow::ResetWindowSize1080);
ui.menu_Reset_Window_Size->addAction(ui.action_Reset_Window_Size_720); ui->menu_Reset_Window_Size->addAction(ui->action_Reset_Window_Size_720);
ui.menu_Reset_Window_Size->addAction(ui.action_Reset_Window_Size_900); ui->menu_Reset_Window_Size->addAction(ui->action_Reset_Window_Size_900);
ui.menu_Reset_Window_Size->addAction(ui.action_Reset_Window_Size_1080); ui->menu_Reset_Window_Size->addAction(ui->action_Reset_Window_Size_1080);
// Fullscreen // Fullscreen
connect(ui.action_Fullscreen, &QAction::triggered, this, &GMainWindow::ToggleFullscreen); connect(ui->action_Fullscreen, &QAction::triggered, this, &GMainWindow::ToggleFullscreen);
// Movie // Movie
connect(ui.action_Capture_Screenshot, &QAction::triggered, this, connect(ui->action_Capture_Screenshot, &QAction::triggered, this,
&GMainWindow::OnCaptureScreenshot); &GMainWindow::OnCaptureScreenshot);
// Help // Help
connect(ui.action_Open_yuzu_Folder, &QAction::triggered, this, &GMainWindow::OnOpenYuzuFolder); connect(ui->action_Open_yuzu_Folder, &QAction::triggered, this, &GMainWindow::OnOpenYuzuFolder);
connect(ui.action_Rederive, &QAction::triggered, this, connect(ui->action_Rederive, &QAction::triggered, this,
std::bind(&GMainWindow::OnReinitializeKeys, this, ReinitializeKeyBehavior::Warning)); std::bind(&GMainWindow::OnReinitializeKeys, this, ReinitializeKeyBehavior::Warning));
connect(ui.action_About, &QAction::triggered, this, &GMainWindow::OnAbout); connect(ui->action_About, &QAction::triggered, this, &GMainWindow::OnAbout);
} }
void GMainWindow::OnDisplayTitleBars(bool show) { void GMainWindow::OnDisplayTitleBars(bool show) {
@ -1405,7 +1407,7 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t
// Update the GUI // Update the GUI
UpdateStatusButtons(); UpdateStatusButtons();
if (ui.action_Single_Window_Mode->isChecked()) { if (ui->action_Single_Window_Mode->isChecked()) {
game_list->hide(); game_list->hide();
game_list_placeholder->hide(); game_list_placeholder->hide();
} }
@ -1451,7 +1453,7 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t
loading_screen->show(); loading_screen->show();
emulation_running = true; emulation_running = true;
if (ui.action_Fullscreen->isChecked()) { if (ui->action_Fullscreen->isChecked()) {
ShowFullscreen(); ShowFullscreen();
} }
OnStartGame(); OnStartGame();
@ -1462,7 +1464,7 @@ void GMainWindow::ShutdownGame() {
return; return;
} }
if (ui.action_Fullscreen->isChecked()) { if (ui->action_Fullscreen->isChecked()) {
HideFullscreen(); HideFullscreen();
} }
@ -1483,15 +1485,15 @@ void GMainWindow::ShutdownGame() {
disconnect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame); disconnect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame);
// Update the GUI // Update the GUI
ui.action_Start->setEnabled(false); ui->action_Start->setEnabled(false);
ui.action_Start->setText(tr("Start")); ui->action_Start->setText(tr("Start"));
ui.action_Pause->setEnabled(false); ui->action_Pause->setEnabled(false);
ui.action_Stop->setEnabled(false); ui->action_Stop->setEnabled(false);
ui.action_Restart->setEnabled(false); ui->action_Restart->setEnabled(false);
ui.action_Configure_Current_Game->setEnabled(false); ui->action_Configure_Current_Game->setEnabled(false);
ui.action_Report_Compatibility->setEnabled(false); ui->action_Report_Compatibility->setEnabled(false);
ui.action_Load_Amiibo->setEnabled(false); ui->action_Load_Amiibo->setEnabled(false);
ui.action_Capture_Screenshot->setEnabled(false); ui->action_Capture_Screenshot->setEnabled(false);
render_window->hide(); render_window->hide();
loading_screen->hide(); loading_screen->hide();
loading_screen->Clear(); loading_screen->Clear();
@ -1553,7 +1555,7 @@ void GMainWindow::UpdateRecentFiles() {
} }
// Enable the recent files menu if the list isn't empty // Enable the recent files menu if the list isn't empty
ui.menu_recent_files->setEnabled(num_recent_files != 0); ui->menu_recent_files->setEnabled(num_recent_files != 0);
} }
void GMainWindow::OnGameListLoadFile(QString game_path, u64 program_id) { void GMainWindow::OnGameListLoadFile(QString game_path, u64 program_id) {
@ -2079,7 +2081,7 @@ void GMainWindow::OnGameListAddDirectory() {
} }
void GMainWindow::OnGameListShowList(bool show) { void GMainWindow::OnGameListShowList(bool show) {
if (emulation_running && ui.action_Single_Window_Mode->isChecked()) if (emulation_running && ui->action_Single_Window_Mode->isChecked())
return; return;
game_list->setVisible(show); game_list->setVisible(show);
game_list_placeholder->setVisible(!show); game_list_placeholder->setVisible(!show);
@ -2181,7 +2183,7 @@ void GMainWindow::OnMenuInstallToNAND() {
QStringList failed_files{}; // Files that failed to install due to errors QStringList failed_files{}; // Files that failed to install due to errors
bool detected_base_install{}; // Whether a base game was attempted to be installed bool detected_base_install{}; // Whether a base game was attempted to be installed
ui.action_Install_File_NAND->setEnabled(false); ui->action_Install_File_NAND->setEnabled(false);
install_progress = new QProgressDialog(QString{}, tr("Cancel"), 0, total_size, this); install_progress = new QProgressDialog(QString{}, tr("Cancel"), 0, total_size, this);
install_progress->setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint & install_progress->setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint &
@ -2257,7 +2259,7 @@ void GMainWindow::OnMenuInstallToNAND() {
Common::FS::RemoveDirRecursively(Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) / Common::FS::RemoveDirRecursively(Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) /
"game_list"); "game_list");
game_list->PopulateAsync(UISettings::values.game_dirs); game_list->PopulateAsync(UISettings::values.game_dirs);
ui.action_Install_File_NAND->setEnabled(true); ui->action_Install_File_NAND->setEnabled(true);
} }
InstallResult GMainWindow::InstallNSPXCI(const QString& filename) { InstallResult GMainWindow::InstallNSPXCI(const QString& filename) {
@ -2423,27 +2425,27 @@ void GMainWindow::OnStartGame() {
connect(emu_thread.get(), &EmuThread::ErrorThrown, this, &GMainWindow::OnCoreError); connect(emu_thread.get(), &EmuThread::ErrorThrown, this, &GMainWindow::OnCoreError);
ui.action_Start->setEnabled(false); ui->action_Start->setEnabled(false);
ui.action_Start->setText(tr("&Continue")); ui->action_Start->setText(tr("&Continue"));
ui.action_Pause->setEnabled(true); ui->action_Pause->setEnabled(true);
ui.action_Stop->setEnabled(true); ui->action_Stop->setEnabled(true);
ui.action_Restart->setEnabled(true); ui->action_Restart->setEnabled(true);
ui.action_Configure_Current_Game->setEnabled(true); ui->action_Configure_Current_Game->setEnabled(true);
ui.action_Report_Compatibility->setEnabled(true); ui->action_Report_Compatibility->setEnabled(true);
discord_rpc->Update(); discord_rpc->Update();
ui.action_Load_Amiibo->setEnabled(true); ui->action_Load_Amiibo->setEnabled(true);
ui.action_Capture_Screenshot->setEnabled(true); ui->action_Capture_Screenshot->setEnabled(true);
} }
void GMainWindow::OnPauseGame() { void GMainWindow::OnPauseGame() {
emu_thread->SetRunning(false); emu_thread->SetRunning(false);
ui.action_Start->setEnabled(true); ui->action_Start->setEnabled(true);
ui.action_Pause->setEnabled(false); ui->action_Pause->setEnabled(false);
ui.action_Stop->setEnabled(true); ui->action_Stop->setEnabled(true);
ui.action_Capture_Screenshot->setEnabled(false); ui->action_Capture_Screenshot->setEnabled(false);
AllowOSSleep(); AllowOSSleep();
} }
@ -2519,7 +2521,7 @@ void GMainWindow::ToggleFullscreen() {
if (!emulation_running) { if (!emulation_running) {
return; return;
} }
if (ui.action_Fullscreen->isChecked()) { if (ui->action_Fullscreen->isChecked()) {
ShowFullscreen(); ShowFullscreen();
} else { } else {
HideFullscreen(); HideFullscreen();
@ -2527,10 +2529,10 @@ void GMainWindow::ToggleFullscreen() {
} }
void GMainWindow::ShowFullscreen() { void GMainWindow::ShowFullscreen() {
if (ui.action_Single_Window_Mode->isChecked()) { if (ui->action_Single_Window_Mode->isChecked()) {
UISettings::values.geometry = saveGeometry(); UISettings::values.geometry = saveGeometry();
ui.menubar->hide(); ui->menubar->hide();
statusBar()->hide(); statusBar()->hide();
if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) { if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) {
@ -2564,7 +2566,7 @@ void GMainWindow::ShowFullscreen() {
} }
void GMainWindow::HideFullscreen() { void GMainWindow::HideFullscreen() {
if (ui.action_Single_Window_Mode->isChecked()) { if (ui->action_Single_Window_Mode->isChecked()) {
if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) { if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) {
showNormal(); showNormal();
restoreGeometry(UISettings::values.geometry); restoreGeometry(UISettings::values.geometry);
@ -2576,8 +2578,8 @@ void GMainWindow::HideFullscreen() {
show(); show();
} }
statusBar()->setVisible(ui.action_Show_Status_Bar->isChecked()); statusBar()->setVisible(ui->action_Show_Status_Bar->isChecked());
ui.menubar->show(); ui->menubar->show();
} else { } else {
if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) { if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) {
render_window->showNormal(); render_window->showNormal();
@ -2593,10 +2595,10 @@ void GMainWindow::HideFullscreen() {
} }
void GMainWindow::ToggleWindowMode() { void GMainWindow::ToggleWindowMode() {
if (ui.action_Single_Window_Mode->isChecked()) { if (ui->action_Single_Window_Mode->isChecked()) {
// Render in the main window... // Render in the main window...
render_window->BackupGeometry(); render_window->BackupGeometry();
ui.horizontalLayout->addWidget(render_window); ui->horizontalLayout->addWidget(render_window);
render_window->setFocusPolicy(Qt::StrongFocus); render_window->setFocusPolicy(Qt::StrongFocus);
if (emulation_running) { if (emulation_running) {
render_window->setVisible(true); render_window->setVisible(true);
@ -2606,7 +2608,7 @@ void GMainWindow::ToggleWindowMode() {
} else { } else {
// Render in a separate window... // Render in a separate window...
ui.horizontalLayout->removeWidget(render_window); ui->horizontalLayout->removeWidget(render_window);
render_window->setParent(nullptr); render_window->setParent(nullptr);
render_window->setFocusPolicy(Qt::NoFocus); render_window->setFocusPolicy(Qt::NoFocus);
if (emulation_running) { if (emulation_running) {
@ -2621,10 +2623,10 @@ void GMainWindow::ResetWindowSize(u32 width, u32 height) {
const auto aspect_ratio = Layout::EmulationAspectRatio( const auto aspect_ratio = Layout::EmulationAspectRatio(
static_cast<Layout::AspectRatio>(Settings::values.aspect_ratio.GetValue()), static_cast<Layout::AspectRatio>(Settings::values.aspect_ratio.GetValue()),
static_cast<float>(height) / width); static_cast<float>(height) / width);
if (!ui.action_Single_Window_Mode->isChecked()) { if (!ui->action_Single_Window_Mode->isChecked()) {
render_window->resize(height / aspect_ratio, height); render_window->resize(height / aspect_ratio, height);
} else { } else {
const bool show_status_bar = ui.action_Show_Status_Bar->isChecked(); const bool show_status_bar = ui->action_Show_Status_Bar->isChecked();
const auto status_bar_height = show_status_bar ? statusBar()->height() : 0; const auto status_bar_height = show_status_bar ? statusBar()->height() : 0;
resize(height / aspect_ratio, height + menuBar()->height() + status_bar_height); resize(height / aspect_ratio, height + menuBar()->height() + status_bar_height);
} }
@ -2835,8 +2837,8 @@ void GMainWindow::OnAbout() {
} }
void GMainWindow::OnToggleFilterBar() { void GMainWindow::OnToggleFilterBar() {
game_list->SetFilterVisible(ui.action_Show_Filter_Bar->isChecked()); game_list->SetFilterVisible(ui->action_Show_Filter_Bar->isChecked());
if (ui.action_Show_Filter_Bar->isChecked()) { if (ui->action_Show_Filter_Bar->isChecked()) {
game_list->SetFilterFocus(); game_list->SetFilterFocus();
} else { } else {
game_list->ClearFilter(); game_list->ClearFilter();
@ -3013,7 +3015,7 @@ void GMainWindow::UpdateStatusButtons() {
} }
void GMainWindow::UpdateUISettings() { void GMainWindow::UpdateUISettings() {
if (!ui.action_Fullscreen->isChecked()) { if (!ui->action_Fullscreen->isChecked()) {
UISettings::values.geometry = saveGeometry(); UISettings::values.geometry = saveGeometry();
UISettings::values.renderwindow_geometry = render_window->saveGeometry(); UISettings::values.renderwindow_geometry = render_window->saveGeometry();
} }
@ -3022,11 +3024,11 @@ void GMainWindow::UpdateUISettings() {
UISettings::values.microprofile_geometry = microProfileDialog->saveGeometry(); UISettings::values.microprofile_geometry = microProfileDialog->saveGeometry();
UISettings::values.microprofile_visible = microProfileDialog->isVisible(); UISettings::values.microprofile_visible = microProfileDialog->isVisible();
#endif #endif
UISettings::values.single_window_mode = ui.action_Single_Window_Mode->isChecked(); UISettings::values.single_window_mode = ui->action_Single_Window_Mode->isChecked();
UISettings::values.fullscreen = ui.action_Fullscreen->isChecked(); UISettings::values.fullscreen = ui->action_Fullscreen->isChecked();
UISettings::values.display_titlebar = ui.action_Display_Dock_Widget_Headers->isChecked(); UISettings::values.display_titlebar = ui->action_Display_Dock_Widget_Headers->isChecked();
UISettings::values.show_filter_bar = ui.action_Show_Filter_Bar->isChecked(); UISettings::values.show_filter_bar = ui->action_Show_Filter_Bar->isChecked();
UISettings::values.show_status_bar = ui.action_Show_Status_Bar->isChecked(); UISettings::values.show_status_bar = ui->action_Show_Status_Bar->isChecked();
UISettings::values.first_start = false; UISettings::values.first_start = false;
} }
@ -3356,7 +3358,7 @@ void GMainWindow::RequestGameExit() {
} }
void GMainWindow::filterBarSetChecked(bool state) { void GMainWindow::filterBarSetChecked(bool state) {
ui.action_Show_Filter_Bar->setChecked(state); ui->action_Show_Filter_Bar->setChecked(state);
emit(OnToggleFilterBar()); emit(OnToggleFilterBar());
} }
@ -3424,11 +3426,11 @@ void GMainWindow::OnLanguageChanged(const QString& locale) {
UISettings::values.language = locale; UISettings::values.language = locale;
LoadTranslation(); LoadTranslation();
ui.retranslateUi(this); ui->retranslateUi(this);
UpdateWindowTitle(); UpdateWindowTitle();
if (emulation_running) if (emulation_running)
ui.action_Start->setText(tr("&Continue")); ui->action_Start->setText(tr("&Continue"));
} }
void GMainWindow::SetDiscordEnabled([[maybe_unused]] bool state) { void GMainWindow::SetDiscordEnabled([[maybe_unused]] bool state) {

View file

@ -15,7 +15,6 @@
#include "common/common_types.h" #include "common/common_types.h"
#include "core/core.h" #include "core/core.h"
#include "core/hle/service/acc/profile_manager.h" #include "core/hle/service/acc/profile_manager.h"
#include "ui_main.h"
#include "yuzu/compatibility_list.h" #include "yuzu/compatibility_list.h"
#include "yuzu/hotkeys.h" #include "yuzu/hotkeys.h"
@ -73,6 +72,10 @@ enum class SwkbdReplyType : u32;
enum class WebExitReason : u32; enum class WebExitReason : u32;
} // namespace Service::AM::Applets } // namespace Service::AM::Applets
namespace Ui {
class MainWindow;
}
enum class EmulatedDirectoryTarget { enum class EmulatedDirectoryTarget {
NAND, NAND,
SDMC, SDMC,
@ -306,7 +309,7 @@ private:
void OpenPerGameConfiguration(u64 title_id, const std::string& file_name); void OpenPerGameConfiguration(u64 title_id, const std::string& file_name);
QString GetTasStateDescription() const; QString GetTasStateDescription() const;
Ui::MainWindow ui; std::unique_ptr<Ui::MainWindow> ui;
std::unique_ptr<DiscordRPC::DiscordInterface> discord_rpc; std::unique_ptr<DiscordRPC::DiscordInterface> discord_rpc;
std::shared_ptr<InputCommon::InputSubsystem> input_subsystem; std::shared_ptr<InputCommon::InputSubsystem> input_subsystem;