From e9cbf5c404c89ad67b31002e99552a4bec9a3103 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Thu, 19 Dec 2024 12:52:26 +0100 Subject: [PATCH] Qt: fix settings_dialog opening on wrong tab The dialog now uses open instead of exec, so we have to override open. --- rpcs3/rpcs3qt/settings_dialog.cpp | 15 +++++---------- rpcs3/rpcs3qt/settings_dialog.h | 4 ++-- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/rpcs3/rpcs3qt/settings_dialog.cpp b/rpcs3/rpcs3qt/settings_dialog.cpp index ace07fdba5..6d17c7e9a5 100644 --- a/rpcs3/rpcs3qt/settings_dialog.cpp +++ b/rpcs3/rpcs3qt/settings_dialog.cpp @@ -94,7 +94,7 @@ void remove_item(QComboBox* box, int data_value, int def_value) extern const std::map g_prx_list; -settings_dialog::settings_dialog(std::shared_ptr gui_settings, std::shared_ptr emu_settings, const int& tab_index, QWidget* parent, const GameInfo* game, bool create_cfg_from_global_cfg) +settings_dialog::settings_dialog(std::shared_ptr gui_settings, std::shared_ptr emu_settings, int tab_index, QWidget* parent, const GameInfo* game, bool create_cfg_from_global_cfg) : QDialog(parent) , m_tab_index(tab_index) , ui(new Ui::settings_dialog) @@ -2607,14 +2607,11 @@ void settings_dialog::ApplyStylesheet(bool reset) } } -int settings_dialog::exec() +void settings_dialog::open() { - // singleShot Hack to fix following bug: - // If we use setCurrentIndex now we will miraculously see a resize of the dialog as soon as we - // switch to the cpu tab after conjuring the settings_dialog with another tab opened first. - // Weirdly enough this won't happen if we change the tab order so that anything else is at index 0. - ui->tab_widget_settings->setCurrentIndex(0); - QTimer::singleShot(0, [this]{ ui->tab_widget_settings->setCurrentIndex(m_tab_index); }); + QDialog::open(); + + ui->tab_widget_settings->setCurrentIndex(m_tab_index); // Open a dialog if your config file contained invalid entries QTimer::singleShot(10, [this] @@ -2640,8 +2637,6 @@ int settings_dialog::exec() } } }); - - return QDialog::exec(); } void settings_dialog::SubscribeDescription(QLabel* description) diff --git a/rpcs3/rpcs3qt/settings_dialog.h b/rpcs3/rpcs3qt/settings_dialog.h index 203fd1c8f9..0513227e80 100644 --- a/rpcs3/rpcs3qt/settings_dialog.h +++ b/rpcs3/rpcs3qt/settings_dialog.h @@ -21,9 +21,9 @@ class settings_dialog : public QDialog Q_OBJECT public: - explicit settings_dialog(std::shared_ptr gui_settings, std::shared_ptr emu_settings, const int& tab_index = 0, QWidget* parent = nullptr, const GameInfo* game = nullptr, bool create_cfg_from_global_cfg = true); + explicit settings_dialog(std::shared_ptr gui_settings, std::shared_ptr emu_settings, int tab_index = 0, QWidget* parent = nullptr, const GameInfo* game = nullptr, bool create_cfg_from_global_cfg = true); ~settings_dialog(); - int exec() override; + void open() override; Q_SIGNALS: void GuiStylesheetRequest(); void GuiRepaintRequest();