From 1805cb44e60221b52db2558bf26305977d65d2f7 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Wed, 22 Apr 2020 20:23:45 +0200 Subject: [PATCH] Qt: move GetBootConfirmation to gui_settings --- rpcs3/rpcs3qt/game_list_frame.cpp | 34 ++----------------------------- rpcs3/rpcs3qt/game_list_frame.h | 2 -- rpcs3/rpcs3qt/gui_settings.cpp | 32 +++++++++++++++++++++++++++++ rpcs3/rpcs3qt/gui_settings.h | 1 + rpcs3/rpcs3qt/main_window.cpp | 18 ++++++++-------- 5 files changed, 44 insertions(+), 43 deletions(-) diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index 09b64afd43..fbd09c13e6 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -817,36 +817,6 @@ void game_list_frame::itemSelectionChangedSlot() Q_EMIT NotifyGameSelection(game); } -bool game_list_frame::GetBootConfirmation(const gui_save& gui_save_entry) -{ - if (m_gui_settings && !Emu.IsStopped()) - { - QString title = tr("Close Running Game?"); - QString message = tr("Performing this action will close the current game.\nDo you really want to continue?\n\nAny unsaved progress will be lost!\n"); - - if (gui_save_entry == gui::ib_confirm_boot) - { - message = tr("Booting another game will close the current game.\nDo you really want to boot another game?\n\nAny unsaved progress will be lost!\n"); - } - else if (gui_save_entry == gui::ib_confirm_exit) - { - title = tr("Exit RPCS3?"); - message = tr("A game is currently running. Do you really want to close RPCS3?\n\nAny unsaved progress will be lost!\n"); - } - - int result = QMessageBox::Yes; - - m_gui_settings->ShowConfirmationBox(title, message, gui_save_entry, &result, this); - - if (result != QMessageBox::Yes) - { - return false; - } - } - - return true; -} - void game_list_frame::ShowContextMenu(const QPoint &pos) { QPoint global_pos; @@ -1071,7 +1041,7 @@ void game_list_frame::ShowContextMenu(const QPoint &pos) }); connect(create_ppu_cache, &QAction::triggered, [gameinfo, this] { - if (GetBootConfirmation()) + if (m_gui_settings->GetBootConfirmation(this)) { CreatePPUCache(gameinfo); } @@ -1431,7 +1401,7 @@ void game_list_frame::BatchCreatePPUCaches() return; } - if (!GetBootConfirmation()) + if (!m_gui_settings->GetBootConfirmation(this)) { return; } diff --git a/rpcs3/rpcs3qt/game_list_frame.h b/rpcs3/rpcs3qt/game_list_frame.h index 2c1f6a61d9..3c9c6803f0 100644 --- a/rpcs3/rpcs3qt/game_list_frame.h +++ b/rpcs3/rpcs3qt/game_list_frame.h @@ -69,8 +69,6 @@ public: void SetShowHidden(bool show); - bool GetBootConfirmation(const gui_save& gui_save_entry = gui_save()); - public Q_SLOTS: void BatchCreatePPUCaches(); void BatchRemovePPUCaches(); diff --git a/rpcs3/rpcs3qt/gui_settings.cpp b/rpcs3/rpcs3qt/gui_settings.cpp index ad23fee091..f75c69a3e8 100644 --- a/rpcs3/rpcs3qt/gui_settings.cpp +++ b/rpcs3/rpcs3qt/gui_settings.cpp @@ -3,6 +3,8 @@ #include "qt_utils.h" #include "localized.h" +#include "Emu/System.h" + #include #include #include @@ -217,6 +219,36 @@ void gui_settings::ShowInfoBox(const QString& title, const QString& text, const ShowBox(false, title, text, entry, nullptr, parent, false); } +bool gui_settings::GetBootConfirmation(QWidget* parent, const gui_save& gui_save_entry) +{ + if (!Emu.IsStopped()) + { + QString title = tr("Close Running Game?"); + QString message = tr("Performing this action will close the current game.\nDo you really want to continue?\n\nAny unsaved progress will be lost!\n"); + + if (gui_save_entry == gui::ib_confirm_boot) + { + message = tr("Booting another game will close the current game.\nDo you really want to boot another game?\n\nAny unsaved progress will be lost!\n"); + } + else if (gui_save_entry == gui::ib_confirm_exit) + { + title = tr("Exit RPCS3?"); + message = tr("A game is currently running. Do you really want to close RPCS3?\n\nAny unsaved progress will be lost!\n"); + } + + int result = QMessageBox::Yes; + + ShowConfirmationBox(title, message, gui_save_entry, &result, parent); + + if (result != QMessageBox::Yes) + { + return false; + } + } + + return true; +} + void gui_settings::SetGamelistColVisibility(int col, bool val) { SetValue(GetGuiSaveForColumn(col), val); diff --git a/rpcs3/rpcs3qt/gui_settings.h b/rpcs3/rpcs3qt/gui_settings.h index a4803d0112..ae6aa802a7 100644 --- a/rpcs3/rpcs3qt/gui_settings.h +++ b/rpcs3/rpcs3qt/gui_settings.h @@ -239,6 +239,7 @@ public: void ShowConfirmationBox(const QString& title, const QString& text, const gui_save& entry, int* result, QWidget* parent); void ShowInfoBox(const QString& title, const QString& text, const gui_save& entry, QWidget* parent); + bool GetBootConfirmation(QWidget* parent, const gui_save& gui_save_entry = gui_save()); logs::level GetLogLevel(); bool GetGamelistColVisibility(int col); diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index ad9e9ae008..dd56082c63 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -300,7 +300,7 @@ void main_window::show_boot_error(game_boot_result status) void main_window::Boot(const std::string& path, const std::string& title_id, bool direct, bool add_only, bool force_global_config) { - if (!m_game_list_frame->GetBootConfirmation(gui::ib_confirm_boot)) + if (!m_gui_settings->GetBootConfirmation(this, gui::ib_confirm_boot)) { return; } @@ -419,7 +419,7 @@ void main_window::BootRsxCapture(std::string path) path = sstr(file_path); } - if (!m_game_list_frame->GetBootConfirmation()) + if (!m_gui_settings->GetBootConfirmation(this)) { return; } @@ -476,7 +476,7 @@ void main_window::HandlePackageInstallation(QStringList file_paths) return; } - if (!m_game_list_frame->GetBootConfirmation()) + if (!m_gui_settings->GetBootConfirmation(this)) { return; } @@ -603,7 +603,7 @@ void main_window::HandlePupInstallation(QString file_path) return; } - if (!m_game_list_frame->GetBootConfirmation()) + if (!m_gui_settings->GetBootConfirmation(this)) { return; } @@ -765,7 +765,7 @@ void main_window::DecryptSPRXLibraries() return; } - if (!m_game_list_frame->GetBootConfirmation()) + if (!m_gui_settings->GetBootConfirmation(this)) { return; } @@ -2049,7 +2049,7 @@ void main_window::RemoveFirmwareCache() void main_window::CreateFirmwareCache() { - if (!m_game_list_frame->GetBootConfirmation()) + if (!m_gui_settings->GetBootConfirmation(this)) { return; } @@ -2093,7 +2093,7 @@ void main_window::mouseDoubleClickEvent(QMouseEvent *event) */ void main_window::closeEvent(QCloseEvent* closeEvent) { - if (!m_game_list_frame->GetBootConfirmation(gui::ib_confirm_exit)) + if (!m_gui_settings->GetBootConfirmation(this, gui::ib_confirm_exit)) { closeEvent->ignore(); return; @@ -2280,7 +2280,7 @@ void main_window::dropEvent(QDropEvent* event) } case drop_type::drop_dir: // import valid games to gamelist (games.yaml) { - if (!m_game_list_frame->GetBootConfirmation()) + if (!m_gui_settings->GetBootConfirmation(this)) { return; } @@ -2293,7 +2293,7 @@ void main_window::dropEvent(QDropEvent* event) } case drop_type::drop_game: // import valid games to gamelist (games.yaml) { - if (!m_game_list_frame->GetBootConfirmation()) + if (!m_gui_settings->GetBootConfirmation(this)) { return; }