diff --git a/rpcs3/Json/tooltips.json b/rpcs3/Json/tooltips.json index 9001db5569..6d731233ed 100644 --- a/rpcs3/Json/tooltips.json +++ b/rpcs3/Json/tooltips.json @@ -121,6 +121,9 @@ "configs": "Only useful to developers.\nIf unsure, don't use this option.", "stylesheets": "Changes the overall look of RPCS3.\nChoose a stylesheet and click Apply to change between styles.", "show_welcome": "Shows the initial welcome screen upon starting RPCS3.", + "show_exit_game": "Shows a confirmation dialog when the game window is being closed.", + "show_pkg_install": "Shows a dialog when packages were installed successfully.", + "show_pup_install": "Shows a dialog when firmware was installed successfully.", "useRichPresence": "Enables use of Discord Rich Presence to show what game you are playing on Discord.\nRequires a restart of RPCS3 to completely close the connection.", "discordState": "Tell your friends what you are doing.", "custom_colors": "Prioritize custom user interface colors over properties set in stylesheet." diff --git a/rpcs3/rpcs3_app.cpp b/rpcs3/rpcs3_app.cpp index 1691493433..9216eab671 100644 --- a/rpcs3/rpcs3_app.cpp +++ b/rpcs3/rpcs3_app.cpp @@ -202,7 +202,6 @@ void rpcs3_app::InitializeCallbacks() h = guiSettings->GetValue(gui::gs_height).toInt(); } - bool disableMouse = guiSettings->GetValue(gui::gs_disableMouse).toBool(); auto frame_geometry = gui::utils::create_centered_window_geometry(RPCS3MainWin->geometry(), w, h); gs_frame* frame; @@ -211,23 +210,23 @@ void rpcs3_app::InitializeCallbacks() { case video_renderer::null: { - frame = new gs_frame("Null", frame_geometry, RPCS3MainWin->GetAppIcon(), disableMouse); + frame = new gs_frame("Null", frame_geometry, RPCS3MainWin->GetAppIcon(), guiSettings); break; } case video_renderer::opengl: { - frame = new gl_gs_frame(frame_geometry, RPCS3MainWin->GetAppIcon(), disableMouse); + frame = new gl_gs_frame(frame_geometry, RPCS3MainWin->GetAppIcon(), guiSettings); break; } case video_renderer::vulkan: { - frame = new gs_frame("Vulkan", frame_geometry, RPCS3MainWin->GetAppIcon(), disableMouse); + frame = new gs_frame("Vulkan", frame_geometry, RPCS3MainWin->GetAppIcon(), guiSettings); break; } #ifdef _MSC_VER case video_renderer::dx12: { - frame = new gs_frame("DirectX 12", frame_geometry, RPCS3MainWin->GetAppIcon(), disableMouse); + frame = new gs_frame("DirectX 12", frame_geometry, RPCS3MainWin->GetAppIcon(), guiSettings); break; } #endif diff --git a/rpcs3/rpcs3qt/gl_gs_frame.cpp b/rpcs3/rpcs3qt/gl_gs_frame.cpp index a43e6d2dee..53f5c19c7b 100644 --- a/rpcs3/rpcs3qt/gl_gs_frame.cpp +++ b/rpcs3/rpcs3qt/gl_gs_frame.cpp @@ -6,8 +6,8 @@ #include #include -gl_gs_frame::gl_gs_frame(const QRect& geometry, QIcon appIcon, bool disableMouse) - : gs_frame("OpenGL", geometry, appIcon, disableMouse) +gl_gs_frame::gl_gs_frame(const QRect& geometry, const QIcon& appIcon, const std::shared_ptr& gui_settings) + : gs_frame("OpenGL", geometry, appIcon, gui_settings) { setSurfaceType(QSurface::OpenGLSurface); diff --git a/rpcs3/rpcs3qt/gl_gs_frame.h b/rpcs3/rpcs3qt/gl_gs_frame.h index 2f44be37e8..b02174032d 100644 --- a/rpcs3/rpcs3qt/gl_gs_frame.h +++ b/rpcs3/rpcs3qt/gl_gs_frame.h @@ -17,7 +17,7 @@ private: GLContext *m_primary_context = nullptr; public: - gl_gs_frame(const QRect& geometry, QIcon appIcon, bool disableMouse); + gl_gs_frame(const QRect& geometry, const QIcon& appIcon, const std::shared_ptr& gui_settings); draw_context_t make_context() override; void set_current(draw_context_t context) override; diff --git a/rpcs3/rpcs3qt/gs_frame.cpp b/rpcs3/rpcs3qt/gs_frame.cpp index 69ff6a774c..38f9aee2be 100644 --- a/rpcs3/rpcs3qt/gs_frame.cpp +++ b/rpcs3/rpcs3qt/gs_frame.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "rpcs3_version.h" @@ -26,9 +27,11 @@ constexpr auto qstr = QString::fromStdString; -gs_frame::gs_frame(const QString& title, const QRect& geometry, QIcon appIcon, bool disableMouse) - : QWindow(), m_windowTitle(title), m_disable_mouse(disableMouse) +gs_frame::gs_frame(const QString& title, const QRect& geometry, const QIcon& appIcon, const std::shared_ptr& gui_settings) + : QWindow(), m_windowTitle(title), m_gui_settings(gui_settings) { + m_disable_mouse = gui_settings->GetValue(gui::gs_disableMouse).toBool(); + // Workaround for a Qt bug affecting 5.11.1 binaries m_use_5_11_1_workaround = QLibraryInfo::version() == QVersionNumber(5, 11, 1); @@ -325,8 +328,24 @@ void gs_frame::HandleCursor(QWindow::Visibility visibility) bool gs_frame::event(QEvent* ev) { - if (ev->type()==QEvent::Close) + if (ev->type() == QEvent::Close) { + if (m_gui_settings->GetValue(gui::ib_confirm_exit).toBool()) + { + int result; + + Emu.CallAfter([this, &result]() + { + m_gui_settings->ShowConfirmationBox(tr("Exit Game?"), + tr("Do you really want to exit the game?\n\nAny unsaved progress will be lost!\n"), + gui::ib_confirm_exit, &result, nullptr); + }); + + if (result != QMessageBox::Yes) + { + return true; + } + } close(); } return QWindow::event(ev); diff --git a/rpcs3/rpcs3qt/gs_frame.h b/rpcs3/rpcs3qt/gs_frame.h index a7426d56e2..1cfa430a39 100644 --- a/rpcs3/rpcs3qt/gs_frame.h +++ b/rpcs3/rpcs3qt/gs_frame.h @@ -3,6 +3,8 @@ #include "stdafx.h" #include "Emu/RSX/GSRender.h" +#include "gui_settings.h" + #include #include @@ -31,6 +33,8 @@ private: void UpdateProgress(int progress, bool disable = false); #endif + std::shared_ptr m_gui_settings; + u64 m_frames = 0; QString m_windowTitle; bool m_show_fps; @@ -44,7 +48,7 @@ private: bool m_use_5_11_1_workaround = false; // QT ABI bug workaround public: - gs_frame(const QString& title, const QRect& geometry, QIcon appIcon, bool disableMouse); + gs_frame(const QString& title, const QRect& geometry, const QIcon& appIcon, const std::shared_ptr& gui_settings); ~gs_frame(); draw_context_t make_context() override; diff --git a/rpcs3/rpcs3qt/gui_settings.cpp b/rpcs3/rpcs3qt/gui_settings.cpp index 315dc4f708..f5167f08f2 100644 --- a/rpcs3/rpcs3qt/gui_settings.cpp +++ b/rpcs3/rpcs3qt/gui_settings.cpp @@ -241,21 +241,49 @@ void gui_settings::SetCategoryVisibility(int cat, const bool& val) SetValue(value, val); } -void gui_settings::ShowInfoBox(const gui_save& entry, const QString& title, const QString& text, QWidget* parent) +void gui_settings::ShowBox(bool confirm, const QString& title, const QString& text, const gui_save& entry, int* result = nullptr, QWidget* parent = nullptr) { - if (GetValue(entry).toBool()) + const std::string dialog_type = confirm ? "Confirmation" : "Info"; + + if (entry.name.isEmpty() || GetValue(entry).toBool()) { - QMessageBox* mb = new QMessageBox(QMessageBox::Information, title, text, QMessageBox::Ok, parent); - mb->setCheckBox(new QCheckBox(tr("Don't show again"))); + const QFlags buttons = confirm ? QMessageBox::Yes | QMessageBox::No : QMessageBox::Ok; + const QMessageBox::Icon icon = confirm ? QMessageBox::Question : QMessageBox::Information; + + QMessageBox* mb = new QMessageBox(icon, title, text, buttons, parent); mb->deleteLater(); - mb->exec(); - if (mb->checkBox()->isChecked()) + + if (!entry.name.isEmpty()) { - SetValue(entry, false); - LOG_NOTICE(GENERAL, "Info Box for Entry %s is now disabled", sstr(entry.name)); + mb->setCheckBox(new QCheckBox(tr("Don't show again"))); } + + connect(mb, &QMessageBox::finished, [&](int res) + { + if (result) + { + *result = res; + } + if (!entry.name.isEmpty() && mb->checkBox()->isChecked()) + { + SetValue(entry, false); + LOG_NOTICE(GENERAL, "%s Dialog for Entry %s is now disabled", dialog_type, sstr(entry.name)); + } + }); + + mb->exec(); } - else LOG_NOTICE(GENERAL, "Info Box for Entry %s was ignored", sstr(entry.name)); + else LOG_NOTICE(GENERAL, "%s Dialog for Entry %s was ignored", dialog_type, sstr(entry.name)); +} + +void gui_settings::ShowConfirmationBox(const QString& title, const QString& text, const gui_save& entry, int* result = nullptr, QWidget* parent = nullptr) +{ + ShowBox(true, title, text, entry, result, parent); +} + +void gui_settings::ShowInfoBox(const QString& title, const QString& text, const gui_save& entry, QWidget* parent = nullptr) +{ + ShowBox(false, title, text, entry, nullptr, parent); } void gui_settings::SetGamelistColVisibility(int col, bool val) diff --git a/rpcs3/rpcs3qt/gui_settings.h b/rpcs3/rpcs3qt/gui_settings.h index 50f20efe50..3d4f107f3d 100644 --- a/rpcs3/rpcs3qt/gui_settings.h +++ b/rpcs3/rpcs3qt/gui_settings.h @@ -139,6 +139,7 @@ namespace gui const gui_save ib_pkg_success = gui_save(main_window, "infoBoxEnabledInstallPKG", true); const gui_save ib_pup_success = gui_save(main_window, "infoBoxEnabledInstallPUP", true); const gui_save ib_show_welcome = gui_save(main_window, "infoBoxEnabledWelcome", true); + const gui_save ib_confirm_exit = gui_save(main_window, "confirmationBoxExitGame", true); const gui_save fd_install_pkg = gui_save(main_window, "lastExplorePathPKG", ""); const gui_save fd_install_pup = gui_save(main_window, "lastExplorePathPUP", ""); @@ -250,7 +251,8 @@ public: QVariant List2Var(const q_pair_list& list); q_pair_list Var2List(const QVariant &var); - void ShowInfoBox(const gui_save& entry, const QString& title, const QString& text, QWidget* parent = 0); + 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); logs::level GetLogLevel(); bool GetGamelistColVisibility(int col); @@ -285,6 +287,7 @@ public Q_SLOTS: private: QString ComputeSettingsDir(); void BackupSettingsToTarget(const QString& friendly_name); + void ShowBox(bool confirm, const QString& title, const QString& text, const gui_save& entry, int* result, QWidget* parent); QSettings m_settings; QDir m_settingsDir; diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index 3ad7e1b47c..4126a519ea 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -493,7 +493,7 @@ void main_window::InstallPkg(const QString& dropPath, bool is_bulk) { m_gameListFrame->Refresh(true); LOG_SUCCESS(GENERAL, "Successfully installed %s.", fileName); - guiSettings->ShowInfoBox(gui::ib_pkg_success, tr("Success!"), tr("Successfully installed software from package!"), this); + guiSettings->ShowInfoBox(tr("Success!"), tr("Successfully installed software from package!"), gui::ib_pkg_success, this); } } @@ -633,7 +633,7 @@ void main_window::InstallPup(const QString& dropPath) if (progress > 0) { LOG_SUCCESS(GENERAL, "Successfully installed PS3 firmware version %s.", version_string); - guiSettings->ShowInfoBox(gui::ib_pup_success, tr("Success!"), tr("Successfully installed PS3 firmware and LLE Modules!"), this); + guiSettings->ShowInfoBox(tr("Success!"), tr("Successfully installed PS3 firmware and LLE Modules!"), gui::ib_pup_success, this); Emu.SetForceBoot(true); Emu.BootGame(g_cfg.vfs.get_dev_flash() + "sys/external/", true); diff --git a/rpcs3/rpcs3qt/settings_dialog.cpp b/rpcs3/rpcs3qt/settings_dialog.cpp index 20f5f8af4e..93e369d12e 100644 --- a/rpcs3/rpcs3qt/settings_dialog.cpp +++ b/rpcs3/rpcs3qt/settings_dialog.cpp @@ -1011,6 +1011,12 @@ settings_dialog::settings_dialog(std::shared_ptr guiSettings, std: // Checkboxes: gui options SubscribeTooltip(ui->cb_show_welcome, json_gui["show_welcome"].toString()); + SubscribeTooltip(ui->cb_show_exit_game, json_gui["show_exit_game"].toString()); + + SubscribeTooltip(ui->cb_show_pkg_install, json_gui["show_pkg_install"].toString()); + + SubscribeTooltip(ui->cb_show_pup_install, json_gui["show_pup_install"].toString()); + SubscribeTooltip(ui->useRichPresence, json_gui["useRichPresence"].toString()); SubscribeTooltip(ui->discordState, json_gui["discordState"].toString()); @@ -1067,6 +1073,9 @@ settings_dialog::settings_dialog(std::shared_ptr guiSettings, std: AddColoredIcons(); ui->cb_show_welcome->setChecked(xgui_settings->GetValue(gui::ib_show_welcome).toBool()); + ui->cb_show_exit_game->setChecked(xgui_settings->GetValue(gui::ib_confirm_exit).toBool()); + ui->cb_show_pkg_install->setChecked(xgui_settings->GetValue(gui::ib_pkg_success).toBool()); + ui->cb_show_pup_install->setChecked(xgui_settings->GetValue(gui::ib_pup_success).toBool()); bool enableUIColors = xgui_settings->GetValue(gui::m_enableUIColors).toBool(); ui->cb_custom_colors->setChecked(enableUIColors); @@ -1125,6 +1134,18 @@ settings_dialog::settings_dialog(std::shared_ptr guiSettings, std: { xgui_settings->SetValue(gui::ib_show_welcome, val); }); + connect(ui->cb_show_exit_game, &QCheckBox::clicked, [=](bool val) + { + xgui_settings->SetValue(gui::ib_confirm_exit, val); + }); + connect(ui->cb_show_pkg_install, &QCheckBox::clicked, [=](bool val) + { + xgui_settings->SetValue(gui::ib_pkg_success, val); + }); + connect(ui->cb_show_pup_install, &QCheckBox::clicked, [=](bool val) + { + xgui_settings->SetValue(gui::ib_pup_success, val); + }); connect(ui->cb_custom_colors, &QCheckBox::clicked, [=](bool val) { diff --git a/rpcs3/rpcs3qt/settings_dialog.ui b/rpcs3/rpcs3qt/settings_dialog.ui index 59e33d82d8..9f7c4d1376 100644 --- a/rpcs3/rpcs3qt/settings_dialog.ui +++ b/rpcs3/rpcs3qt/settings_dialog.ui @@ -7,7 +7,7 @@ 0 0 752 - 576 + 584 @@ -1918,6 +1918,27 @@ + + + + Show Exit Game Dialog + + + + + + + Show PGK Installation Dialog + + + + + + + Show PUP Installation Dialog + + +