fix dark theme switching on initial welcome dialog

This commit is contained in:
digant 2024-12-04 21:43:08 +01:00
parent d84fe592c8
commit 3e1423481c
6 changed files with 18 additions and 12 deletions

View file

@ -163,16 +163,17 @@ bool gui_application::Init()
bool use_dark_theme = false;
connect(welcome, &QDialog::accepted, this, [&]()
connect(welcome, &QDialog::finished, this, [&]()
{
use_dark_theme = welcome->does_user_want_dark_theme();
use_dark_theme = welcome->use_dark_theme();
});
// welcome dialog is auto-flagged (in its constructor) as WA_DeleteOnClose, so its pointer is no more usable after welcome->exec()
welcome->exec();
if (use_dark_theme)
{
m_gui_settings->SetValue(gui::m_currentStylesheet, "Darker Style by TheMitoSan");
m_gui_settings->SetValue(gui::m_currentStylesheet, gui::DarkStylesheet);
}
}

View file

@ -87,10 +87,11 @@ namespace gui
return q_string_pair(path, title.simplified()); // simplified() forces single line text
}
const QString Settings = "CurrentSettings";
const QString Settings = "CurrentSettings";
const QString DefaultStylesheet = "default";
const QString NoStylesheet = "none";
const QString NativeStylesheet = "native";
const QString NoStylesheet = "none";
const QString NativeStylesheet = "native";
const QString DarkStylesheet = "Darker Style by TheMitoSan";
const QString main_window = "main_window";
const QString game_list = "GameList";

View file

@ -3275,6 +3275,8 @@ void main_window::CreateConnects()
connect(ui->welcomeAct, &QAction::triggered, this, [this]()
{
welcome_dialog* welcome = new welcome_dialog(m_gui_settings, true, this);
// welcome dialog is auto-flagged (in its constructor) as WA_DeleteOnClose, so its pointer is no more usable after welcome->open()
welcome->open();
});

View file

@ -155,6 +155,7 @@ namespace gui
static inline bool dark_mode_active()
{
// use the QGuiApplication's properties to report the default color scheme
return color_scheme() == Qt::ColorScheme::Dark;
}

View file

@ -22,10 +22,11 @@ welcome_dialog::welcome_dialog(std::shared_ptr<gui_settings> gui_settings, bool
setWindowFlag(Qt::WindowCloseButtonHint, is_manual_show);
ui->okay->setEnabled(is_manual_show);
ui->i_have_read->setChecked(is_manual_show);
ui->i_have_read->setEnabled(!is_manual_show);
ui->i_have_read->setChecked(is_manual_show);
ui->do_not_show->setEnabled(!is_manual_show);
ui->do_not_show->setChecked(!m_gui_settings->GetValue(gui::ib_show_welcome).toBool());
ui->use_dark_theme->setEnabled(!is_manual_show);
ui->use_dark_theme->setChecked(gui::utils::dark_mode_active());
ui->icon_label->load(QStringLiteral(":/rpcs3.svg"));
ui->label_3->setText(tr(
@ -76,7 +77,7 @@ welcome_dialog::welcome_dialog(std::shared_ptr<gui_settings> gui_settings, bool
layout()->setSizeConstraint(QLayout::SetFixedSize);
connect(this, &QDialog::finished, this, [this]()
connect(this, &QDialog::accepted, this, [this]()
{
if (ui->create_desktop_shortcut->isChecked())
{
@ -88,7 +89,7 @@ welcome_dialog::welcome_dialog(std::shared_ptr<gui_settings> gui_settings, bool
gui::utils::create_shortcut("RPCS3", "", "", "RPCS3", ":/rpcs3.svg", fs::get_temp_dir(), gui::utils::shortcut_location::applications);
}
m_user_wants_dark_theme = ui->use_dark_theme->isChecked();
m_use_dark_theme = ui->use_dark_theme->isChecked();
});
}

View file

@ -17,12 +17,12 @@ public:
explicit welcome_dialog(std::shared_ptr<gui_settings> gui_settings, bool is_manual_show, QWidget* parent = nullptr);
~welcome_dialog();
bool does_user_want_dark_theme() const
bool use_dark_theme() const
{
return m_user_wants_dark_theme;
return m_use_dark_theme;
}
private:
std::unique_ptr<Ui::welcome_dialog> ui;
std::shared_ptr<gui_settings> m_gui_settings;
bool m_user_wants_dark_theme = false;
bool m_use_dark_theme = false;
};