Qt: move GetBootConfirmation to gui_settings

This commit is contained in:
Megamouse 2020-04-22 20:23:45 +02:00
parent b4b8c1e4b2
commit 1805cb44e6
5 changed files with 44 additions and 43 deletions

View file

@ -817,36 +817,6 @@ void game_list_frame::itemSelectionChangedSlot()
Q_EMIT NotifyGameSelection(game); 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) void game_list_frame::ShowContextMenu(const QPoint &pos)
{ {
QPoint global_pos; QPoint global_pos;
@ -1071,7 +1041,7 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
}); });
connect(create_ppu_cache, &QAction::triggered, [gameinfo, this] connect(create_ppu_cache, &QAction::triggered, [gameinfo, this]
{ {
if (GetBootConfirmation()) if (m_gui_settings->GetBootConfirmation(this))
{ {
CreatePPUCache(gameinfo); CreatePPUCache(gameinfo);
} }
@ -1431,7 +1401,7 @@ void game_list_frame::BatchCreatePPUCaches()
return; return;
} }
if (!GetBootConfirmation()) if (!m_gui_settings->GetBootConfirmation(this))
{ {
return; return;
} }

View file

@ -69,8 +69,6 @@ public:
void SetShowHidden(bool show); void SetShowHidden(bool show);
bool GetBootConfirmation(const gui_save& gui_save_entry = gui_save());
public Q_SLOTS: public Q_SLOTS:
void BatchCreatePPUCaches(); void BatchCreatePPUCaches();
void BatchRemovePPUCaches(); void BatchRemovePPUCaches();

View file

@ -3,6 +3,8 @@
#include "qt_utils.h" #include "qt_utils.h"
#include "localized.h" #include "localized.h"
#include "Emu/System.h"
#include <QCheckBox> #include <QCheckBox>
#include <QCoreApplication> #include <QCoreApplication>
#include <QMessageBox> #include <QMessageBox>
@ -217,6 +219,36 @@ void gui_settings::ShowInfoBox(const QString& title, const QString& text, const
ShowBox(false, title, text, entry, nullptr, parent, false); 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) void gui_settings::SetGamelistColVisibility(int col, bool val)
{ {
SetValue(GetGuiSaveForColumn(col), val); SetValue(GetGuiSaveForColumn(col), val);

View file

@ -239,6 +239,7 @@ public:
void ShowConfirmationBox(const QString& title, const QString& text, const gui_save& entry, int* result, QWidget* parent); 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); 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(); logs::level GetLogLevel();
bool GetGamelistColVisibility(int col); bool GetGamelistColVisibility(int col);

View file

@ -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) 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; return;
} }
@ -419,7 +419,7 @@ void main_window::BootRsxCapture(std::string path)
path = sstr(file_path); path = sstr(file_path);
} }
if (!m_game_list_frame->GetBootConfirmation()) if (!m_gui_settings->GetBootConfirmation(this))
{ {
return; return;
} }
@ -476,7 +476,7 @@ void main_window::HandlePackageInstallation(QStringList file_paths)
return; return;
} }
if (!m_game_list_frame->GetBootConfirmation()) if (!m_gui_settings->GetBootConfirmation(this))
{ {
return; return;
} }
@ -603,7 +603,7 @@ void main_window::HandlePupInstallation(QString file_path)
return; return;
} }
if (!m_game_list_frame->GetBootConfirmation()) if (!m_gui_settings->GetBootConfirmation(this))
{ {
return; return;
} }
@ -765,7 +765,7 @@ void main_window::DecryptSPRXLibraries()
return; return;
} }
if (!m_game_list_frame->GetBootConfirmation()) if (!m_gui_settings->GetBootConfirmation(this))
{ {
return; return;
} }
@ -2049,7 +2049,7 @@ void main_window::RemoveFirmwareCache()
void main_window::CreateFirmwareCache() void main_window::CreateFirmwareCache()
{ {
if (!m_game_list_frame->GetBootConfirmation()) if (!m_gui_settings->GetBootConfirmation(this))
{ {
return; return;
} }
@ -2093,7 +2093,7 @@ void main_window::mouseDoubleClickEvent(QMouseEvent *event)
*/ */
void main_window::closeEvent(QCloseEvent* closeEvent) 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(); closeEvent->ignore();
return; return;
@ -2280,7 +2280,7 @@ void main_window::dropEvent(QDropEvent* event)
} }
case drop_type::drop_dir: // import valid games to gamelist (games.yaml) 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; return;
} }
@ -2293,7 +2293,7 @@ void main_window::dropEvent(QDropEvent* event)
} }
case drop_type::drop_game: // import valid games to gamelist (games.yaml) 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; return;
} }