yuzu-emu
/
yuzu-mainline
Archived
1
0
Fork 0

Merge pull request #7185 from Morph1984/make_unique_ui

yuzu: Use make_unique instead of operator new for constructing ui
This commit is contained in:
Mai M 2021-10-15 16:58:45 -04:00 committed by GitHub
commit 5b7b7276d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 157 additions and 151 deletions

View File

@ -8,7 +8,8 @@
#include "ui_aboutdialog.h"
#include "yuzu/about_dialog.h"
AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AboutDialog) {
AboutDialog::AboutDialog(QWidget* parent)
: QDialog(parent), ui{std::make_unique<Ui::AboutDialog>()} {
const auto branch_name = std::string(Common::g_scm_branch);
const auto description = std::string(Common::g_scm_desc);
const auto build_id = std::string(Common::g_build_id);

View File

@ -14,7 +14,7 @@
#include "yuzu/configuration/configure_cpu.h"
ConfigureCpu::ConfigureCpu(const Core::System& system_, QWidget* parent)
: QWidget(parent), ui(new Ui::ConfigureCpu), system{system_} {
: QWidget(parent), ui{std::make_unique<Ui::ConfigureCpu>()}, system{system_} {
ui->setupUi(this);
SetupPerGameUI();

View File

@ -12,7 +12,7 @@
#include "yuzu/configuration/configure_cpu_debug.h"
ConfigureCpuDebug::ConfigureCpuDebug(const Core::System& system_, QWidget* parent)
: QWidget(parent), ui(new Ui::ConfigureCpuDebug), system{system_} {
: QWidget(parent), ui{std::make_unique<Ui::ConfigureCpuDebug>()}, system{system_} {
ui->setupUi(this);
SetConfiguration();

View File

@ -15,7 +15,7 @@
#include "yuzu/uisettings.h"
ConfigureDebug::ConfigureDebug(const Core::System& system_, QWidget* parent)
: QWidget(parent), ui(new Ui::ConfigureDebug), system{system_} {
: QWidget(parent), ui{std::make_unique<Ui::ConfigureDebug>()}, system{system_} {
ui->setupUi(this);
SetConfiguration();

View File

@ -9,8 +9,8 @@
#include "yuzu/configuration/configure_debug_tab.h"
ConfigureDebugTab::ConfigureDebugTab(const Core::System& system_, QWidget* parent)
: QWidget(parent),
ui(new Ui::ConfigureDebugTab), debug_tab{std::make_unique<ConfigureDebug>(system_, this)},
: QWidget(parent), ui{std::make_unique<Ui::ConfigureDebugTab>()},
debug_tab{std::make_unique<ConfigureDebug>(system_, this)},
cpu_debug_tab{std::make_unique<ConfigureCpuDebug>(system_, this)} {
ui->setupUi(this);

View File

@ -36,7 +36,7 @@
ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry,
InputCommon::InputSubsystem* input_subsystem,
Core::System& system_)
: QDialog(parent), ui(new Ui::ConfigureDialog),
: QDialog(parent), ui{std::make_unique<Ui::ConfigureDialog>()},
registry(registry), system{system_}, audio_tab{std::make_unique<ConfigureAudio>(system_,
this)},
cpu_tab{std::make_unique<ConfigureCpu>(system_, this)},

View File

@ -16,7 +16,7 @@
#include "yuzu/uisettings.h"
ConfigureGeneral::ConfigureGeneral(const Core::System& system_, QWidget* parent)
: QWidget(parent), ui(new Ui::ConfigureGeneral), system{system_} {
: QWidget(parent), ui{std::make_unique<Ui::ConfigureGeneral>()}, system{system_} {
ui->setupUi(this);
SetupPerGameUI();

View File

@ -20,7 +20,7 @@
#include "yuzu/configuration/configure_graphics.h"
ConfigureGraphics::ConfigureGraphics(const Core::System& system_, QWidget* parent)
: QWidget(parent), ui(new Ui::ConfigureGraphics), system{system_} {
: QWidget(parent), ui{std::make_unique<Ui::ConfigureGraphics>()}, system{system_} {
vulkan_device = Settings::values.vulkan_device.GetValue();
RetrieveVulkanDevices();

View File

@ -9,7 +9,7 @@
#include "yuzu/configuration/configure_graphics_advanced.h"
ConfigureGraphicsAdvanced::ConfigureGraphicsAdvanced(const Core::System& system_, QWidget* parent)
: QWidget(parent), ui(new Ui::ConfigureGraphicsAdvanced), system{system_} {
: QWidget(parent), ui{std::make_unique<Ui::ConfigureGraphicsAdvanced>()}, system{system_} {
ui->setupUi(this);

View File

@ -27,7 +27,7 @@
#include "yuzu/util/util.h"
ConfigurePerGameAddons::ConfigurePerGameAddons(Core::System& system_, QWidget* parent)
: QWidget(parent), ui(new Ui::ConfigurePerGameAddons), system{system_} {
: QWidget(parent), ui{std::make_unique<Ui::ConfigurePerGameAddons>()}, system{system_} {
ui->setupUi(this);
layout = new QVBoxLayout;

View File

@ -77,7 +77,7 @@ QString GetProfileUsernameFromUser(QWidget* parent, const QString& description_t
} // Anonymous namespace
ConfigureProfileManager::ConfigureProfileManager(const Core::System& system_, QWidget* parent)
: QWidget(parent), ui(new Ui::ConfigureProfileManager),
: QWidget(parent), ui{std::make_unique<Ui::ConfigureProfileManager>()},
profile_manager(std::make_unique<Service::Account::ProfileManager>()), system{system_} {
ui->setupUi(this);

View File

@ -18,7 +18,7 @@
#include "yuzu/configuration/configure_system.h"
ConfigureSystem::ConfigureSystem(Core::System& system_, QWidget* parent)
: QWidget(parent), ui(new Ui::ConfigureSystem), system{system_} {
: QWidget(parent), ui{std::make_unique<Ui::ConfigureSystem>()}, system{system_} {
ui->setupUi(this);
connect(ui->button_regenerate_console_id, &QPushButton::clicked, this,
&ConfigureSystem::RefreshConsoleID);

View File

@ -55,7 +55,7 @@ QString GetTranslatedRowTextName(size_t index) {
} // Anonymous namespace
ConfigureUi::ConfigureUi(Core::System& system_, QWidget* parent)
: QWidget(parent), ui(new Ui::ConfigureUi), system{system_} {
: QWidget(parent), ui{std::make_unique<Ui::ConfigureUi>()}, system{system_} {
ui->setupUi(this);
InitializeLanguageComboBox();

View File

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

View File

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