mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-11 01:08:39 +12:00
Qt: spawn Confirmation Dialog on exit
This commit is contained in:
parent
37c621ebbf
commit
5f9b441dd7
11 changed files with 123 additions and 25 deletions
|
@ -121,6 +121,9 @@
|
||||||
"configs": "Only useful to developers.\nIf unsure, don't use this option.",
|
"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.",
|
"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_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.",
|
"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.",
|
"discordState": "Tell your friends what you are doing.",
|
||||||
"custom_colors": "Prioritize custom user interface colors over properties set in stylesheet."
|
"custom_colors": "Prioritize custom user interface colors over properties set in stylesheet."
|
||||||
|
|
|
@ -202,7 +202,6 @@ void rpcs3_app::InitializeCallbacks()
|
||||||
h = guiSettings->GetValue(gui::gs_height).toInt();
|
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);
|
auto frame_geometry = gui::utils::create_centered_window_geometry(RPCS3MainWin->geometry(), w, h);
|
||||||
|
|
||||||
gs_frame* frame;
|
gs_frame* frame;
|
||||||
|
@ -211,23 +210,23 @@ void rpcs3_app::InitializeCallbacks()
|
||||||
{
|
{
|
||||||
case video_renderer::null:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case video_renderer::opengl:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case video_renderer::vulkan:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
case video_renderer::dx12:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
#include <qoffscreensurface.h>
|
#include <qoffscreensurface.h>
|
||||||
#include <QWindow>
|
#include <QWindow>
|
||||||
|
|
||||||
gl_gs_frame::gl_gs_frame(const QRect& geometry, QIcon appIcon, bool disableMouse)
|
gl_gs_frame::gl_gs_frame(const QRect& geometry, const QIcon& appIcon, const std::shared_ptr<gui_settings>& gui_settings)
|
||||||
: gs_frame("OpenGL", geometry, appIcon, disableMouse)
|
: gs_frame("OpenGL", geometry, appIcon, gui_settings)
|
||||||
{
|
{
|
||||||
setSurfaceType(QSurface::OpenGLSurface);
|
setSurfaceType(QSurface::OpenGLSurface);
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ private:
|
||||||
GLContext *m_primary_context = nullptr;
|
GLContext *m_primary_context = nullptr;
|
||||||
|
|
||||||
public:
|
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>& gui_settings);
|
||||||
|
|
||||||
draw_context_t make_context() override;
|
draw_context_t make_context() override;
|
||||||
void set_current(draw_context_t context) override;
|
void set_current(draw_context_t context) override;
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QLibraryInfo>
|
#include <QLibraryInfo>
|
||||||
|
#include <QMessageBox>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "rpcs3_version.h"
|
#include "rpcs3_version.h"
|
||||||
|
@ -26,9 +27,11 @@
|
||||||
|
|
||||||
constexpr auto qstr = QString::fromStdString;
|
constexpr auto qstr = QString::fromStdString;
|
||||||
|
|
||||||
gs_frame::gs_frame(const QString& title, const QRect& geometry, QIcon appIcon, bool disableMouse)
|
gs_frame::gs_frame(const QString& title, const QRect& geometry, const QIcon& appIcon, const std::shared_ptr<gui_settings>& gui_settings)
|
||||||
: QWindow(), m_windowTitle(title), m_disable_mouse(disableMouse)
|
: 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
|
// Workaround for a Qt bug affecting 5.11.1 binaries
|
||||||
m_use_5_11_1_workaround = QLibraryInfo::version() == QVersionNumber(5, 11, 1);
|
m_use_5_11_1_workaround = QLibraryInfo::version() == QVersionNumber(5, 11, 1);
|
||||||
|
|
||||||
|
@ -327,6 +330,22 @@ 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();
|
close();
|
||||||
}
|
}
|
||||||
return QWindow::event(ev);
|
return QWindow::event(ev);
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "Emu/RSX/GSRender.h"
|
#include "Emu/RSX/GSRender.h"
|
||||||
|
|
||||||
|
#include "gui_settings.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QWindow>
|
#include <QWindow>
|
||||||
|
|
||||||
|
@ -31,6 +33,8 @@ private:
|
||||||
void UpdateProgress(int progress, bool disable = false);
|
void UpdateProgress(int progress, bool disable = false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
std::shared_ptr<gui_settings> m_gui_settings;
|
||||||
|
|
||||||
u64 m_frames = 0;
|
u64 m_frames = 0;
|
||||||
QString m_windowTitle;
|
QString m_windowTitle;
|
||||||
bool m_show_fps;
|
bool m_show_fps;
|
||||||
|
@ -44,7 +48,7 @@ private:
|
||||||
bool m_use_5_11_1_workaround = false; // QT ABI bug workaround
|
bool m_use_5_11_1_workaround = false; // QT ABI bug workaround
|
||||||
|
|
||||||
public:
|
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>& gui_settings);
|
||||||
~gs_frame();
|
~gs_frame();
|
||||||
|
|
||||||
draw_context_t make_context() override;
|
draw_context_t make_context() override;
|
||||||
|
|
|
@ -241,21 +241,49 @@ void gui_settings::SetCategoryVisibility(int cat, const bool& val)
|
||||||
SetValue(value, 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);
|
const QFlags<QMessageBox::StandardButton> buttons = confirm ? QMessageBox::Yes | QMessageBox::No : QMessageBox::Ok;
|
||||||
mb->setCheckBox(new QCheckBox(tr("Don't show again")));
|
const QMessageBox::Icon icon = confirm ? QMessageBox::Question : QMessageBox::Information;
|
||||||
|
|
||||||
|
QMessageBox* mb = new QMessageBox(icon, title, text, buttons, parent);
|
||||||
mb->deleteLater();
|
mb->deleteLater();
|
||||||
mb->exec();
|
|
||||||
if (mb->checkBox()->isChecked())
|
if (!entry.name.isEmpty())
|
||||||
|
{
|
||||||
|
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);
|
SetValue(entry, false);
|
||||||
LOG_NOTICE(GENERAL, "Info Box for Entry %s is now disabled", sstr(entry.name));
|
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)
|
void gui_settings::SetGamelistColVisibility(int col, bool val)
|
||||||
|
|
|
@ -139,6 +139,7 @@ namespace gui
|
||||||
const gui_save ib_pkg_success = gui_save(main_window, "infoBoxEnabledInstallPKG", true);
|
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_pup_success = gui_save(main_window, "infoBoxEnabledInstallPUP", true);
|
||||||
const gui_save ib_show_welcome = gui_save(main_window, "infoBoxEnabledWelcome", 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_pkg = gui_save(main_window, "lastExplorePathPKG", "");
|
||||||
const gui_save fd_install_pup = gui_save(main_window, "lastExplorePathPUP", "");
|
const gui_save fd_install_pup = gui_save(main_window, "lastExplorePathPUP", "");
|
||||||
|
@ -250,7 +251,8 @@ public:
|
||||||
QVariant List2Var(const q_pair_list& list);
|
QVariant List2Var(const q_pair_list& list);
|
||||||
q_pair_list Var2List(const QVariant &var);
|
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();
|
logs::level GetLogLevel();
|
||||||
bool GetGamelistColVisibility(int col);
|
bool GetGamelistColVisibility(int col);
|
||||||
|
@ -285,6 +287,7 @@ public Q_SLOTS:
|
||||||
private:
|
private:
|
||||||
QString ComputeSettingsDir();
|
QString ComputeSettingsDir();
|
||||||
void BackupSettingsToTarget(const QString& friendly_name);
|
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;
|
QSettings m_settings;
|
||||||
QDir m_settingsDir;
|
QDir m_settingsDir;
|
||||||
|
|
|
@ -493,7 +493,7 @@ void main_window::InstallPkg(const QString& dropPath, bool is_bulk)
|
||||||
{
|
{
|
||||||
m_gameListFrame->Refresh(true);
|
m_gameListFrame->Refresh(true);
|
||||||
LOG_SUCCESS(GENERAL, "Successfully installed %s.", fileName);
|
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)
|
if (progress > 0)
|
||||||
{
|
{
|
||||||
LOG_SUCCESS(GENERAL, "Successfully installed PS3 firmware version %s.", version_string);
|
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.SetForceBoot(true);
|
||||||
Emu.BootGame(g_cfg.vfs.get_dev_flash() + "sys/external/", true);
|
Emu.BootGame(g_cfg.vfs.get_dev_flash() + "sys/external/", true);
|
||||||
|
|
|
@ -1011,6 +1011,12 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
|
||||||
// Checkboxes: gui options
|
// Checkboxes: gui options
|
||||||
SubscribeTooltip(ui->cb_show_welcome, json_gui["show_welcome"].toString());
|
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->useRichPresence, json_gui["useRichPresence"].toString());
|
||||||
|
|
||||||
SubscribeTooltip(ui->discordState, json_gui["discordState"].toString());
|
SubscribeTooltip(ui->discordState, json_gui["discordState"].toString());
|
||||||
|
@ -1067,6 +1073,9 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
|
||||||
AddColoredIcons();
|
AddColoredIcons();
|
||||||
|
|
||||||
ui->cb_show_welcome->setChecked(xgui_settings->GetValue(gui::ib_show_welcome).toBool());
|
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();
|
bool enableUIColors = xgui_settings->GetValue(gui::m_enableUIColors).toBool();
|
||||||
ui->cb_custom_colors->setChecked(enableUIColors);
|
ui->cb_custom_colors->setChecked(enableUIColors);
|
||||||
|
@ -1125,6 +1134,18 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
|
||||||
{
|
{
|
||||||
xgui_settings->SetValue(gui::ib_show_welcome, val);
|
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)
|
connect(ui->cb_custom_colors, &QCheckBox::clicked, [=](bool val)
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>752</width>
|
<width>752</width>
|
||||||
<height>576</height>
|
<height>584</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -1918,6 +1918,27 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="cb_show_exit_game">
|
||||||
|
<property name="text">
|
||||||
|
<string>Show Exit Game Dialog</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="cb_show_pkg_install">
|
||||||
|
<property name="text">
|
||||||
|
<string>Show PGK Installation Dialog</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="cb_show_pup_install">
|
||||||
|
<property name="text">
|
||||||
|
<string>Show PUP Installation Dialog</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer_17">
|
<spacer name="verticalSpacer_17">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue