From eb80b7ec34e282ba879147e70f410d13ff3a9ff3 Mon Sep 17 00:00:00 2001 From: Robbie Date: Thu, 13 Jul 2017 19:21:40 -0500 Subject: [PATCH] Small main_window refactoring. Fixed one of the guiconfig crashes too somehow. --- rpcs3/rpcs3_app.cpp | 2 ++ rpcs3/rpcs3qt/main_window.cpp | 39 +++++++++++++++++++---------------- rpcs3/rpcs3qt/main_window.h | 1 + 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/rpcs3/rpcs3_app.cpp b/rpcs3/rpcs3_app.cpp index 1e8b39beab..61729186db 100644 --- a/rpcs3/rpcs3_app.cpp +++ b/rpcs3/rpcs3_app.cpp @@ -68,6 +68,8 @@ void rpcs3_app::Init() // Create connects to propagate events throughout Gui. InitializeConnects(); + RPCS3MainWin->Init(); + setApplicationName("RPCS3"); RPCS3MainWin->show(); diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index 51f783199a..24220f4baa 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -47,6 +47,25 @@ inline std::string sstr(const QString& _in) { return _in.toUtf8().toStdString(); } main_window::main_window(QWidget *parent) : QMainWindow(parent), m_sys_menu_opened(false), ui(new Ui::main_window) +{ +} + +main_window::~main_window() +{ +} + +auto Pause = []() +{ + if (Emu.IsReady()) Emu.Run(); + else if (Emu.IsPaused()) Emu.Resume(); + else if (Emu.IsRunning()) Emu.Pause(); + else if (!Emu.GetPath().empty()) Emu.Load(); +}; + +/* An init method is used so that RPCS3App can create the necessary connects before calling init (specifically the stylesheet connect). + * Simplifies logic a bit. + */ +void main_window::Init() { ui->setupUi(this); @@ -87,26 +106,10 @@ main_window::main_window(QWidget *parent) : QMainWindow(parent), m_sys_menu_open setWindowTitle(QString::fromStdString("RPCS3 v" + rpcs3::version.to_string())); !appIcon.isNull() ? setWindowIcon(appIcon) : LOG_WARNING(GENERAL, "AppImage could not be loaded!"); - QTimer::singleShot(1, [=]() { - // Need to have this happen fast, but not now because connects aren't created yet. - // So, a tricky balance in terms of time but this works. - RequestGlobalStylesheetChange(guiSettings->GetCurrentStylesheetPath()); - ConfigureGuiFromSettings(true); - }); + RequestGlobalStylesheetChange(guiSettings->GetCurrentStylesheetPath()); + ConfigureGuiFromSettings(true); } -main_window::~main_window() -{ -} - -auto Pause = []() -{ - if (Emu.IsReady()) Emu.Run(); - else if (Emu.IsPaused()) Emu.Resume(); - else if (Emu.IsRunning()) Emu.Pause(); - else if (!Emu.GetPath().empty()) Emu.Load(); -}; - void main_window::CreateThumbnailToolbar() { #ifdef _WIN32 diff --git a/rpcs3/rpcs3qt/main_window.h b/rpcs3/rpcs3qt/main_window.h index 0715483ed6..059e5e32c7 100644 --- a/rpcs3/rpcs3qt/main_window.h +++ b/rpcs3/rpcs3qt/main_window.h @@ -55,6 +55,7 @@ class main_window : public QMainWindow public: explicit main_window(QWidget *parent = 0); + void Init(); ~main_window(); void CreateThumbnailToolbar(); QIcon GetAppIcon();