From d7cf15e076eb5ff6ccf968e5abde6f43d8c3a4b3 Mon Sep 17 00:00:00 2001 From: Rafael Kitover Date: Wed, 20 Feb 2019 19:44:42 -0800 Subject: [PATCH] implement factory reset option #368 Add a "Factory Reset" item to the Options menu, which calls `DeleteAll()` on the config object, which actually deletes the config file. After this the application is relaunched asynchronously without parameters and the current instance is closed. Signed-off-by: Rafael Kitover --- src/wx/cmdevents.cpp | 16 ++++++++++++++++ src/wx/xrc/MainMenu.xrc | 3 +++ 2 files changed, 19 insertions(+) diff --git a/src/wx/cmdevents.cpp b/src/wx/cmdevents.cpp index f617213d..416962a1 100644 --- a/src/wx/cmdevents.cpp +++ b/src/wx/cmdevents.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #ifndef NO_FFMPEG extern "C" { @@ -2381,6 +2382,21 @@ EVT_HANDLER(Customize, "Customize UI...") update_opts(); } +EVT_HANDLER(FactoryReset, "Factory Reset...") +{ + wxMessageDialog dlg(NULL, wxString(wxT( +"YOUR CONFIGURATION WILL BE DELETED!\n\n")) + wxString(wxT( +"Are you sure?")), + wxT("FACTORY RESET"), wxYES_NO | wxNO_DEFAULT | wxCENTRE); + + if (dlg.ShowModal() == wxID_YES) { + wxGetApp().cfg->DeleteAll(); + + wxExecute(wxStandardPaths::Get().GetExecutablePath(), wxEXEC_ASYNC); + Close(true); + } +} + EVT_HANDLER(BugReport, "Report bugs...") { wxLaunchDefaultBrowser(wxT("https://github.com/visualboyadvance-m/visualboyadvance-m/issues")); diff --git a/src/wx/xrc/MainMenu.xrc b/src/wx/xrc/MainMenu.xrc index 736e9c86..7d4f9444 100644 --- a/src/wx/xrc/MainMenu.xrc +++ b/src/wx/xrc/MainMenu.xrc @@ -466,6 +466,9 @@ + + +