fix dark theme switching on initial welcome dialog (#16373)

This commit is contained in:
Antonino Di Guardo 2024-12-06 20:14:35 +01:00 committed by GitHub
parent 05d12f68ad
commit 24655fd975
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 13 additions and 23 deletions

View File

@ -161,19 +161,7 @@ bool gui_application::Init()
{
welcome_dialog* welcome = new welcome_dialog(m_gui_settings, false);
bool use_dark_theme = false;
connect(welcome, &QDialog::accepted, this, [&]()
{
use_dark_theme = welcome->does_user_want_dark_theme();
});
welcome->exec();
if (use_dark_theme)
{
m_gui_settings->SetValue(gui::m_currentStylesheet, "Darker Style by TheMitoSan");
}
}
// Check maxfiles

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

@ -150,11 +150,13 @@ namespace gui
static inline Qt::ColorScheme color_scheme()
{
// use the QGuiApplication's properties to report the default GUI color scheme
return QGuiApplication::styleHints()->colorScheme();
}
static inline bool dark_mode_active()
{
// "true" if the default GUI color scheme is dark. "false" otherwise
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,10 @@ 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();
if (ui->use_dark_theme->isChecked() && ui->use_dark_theme->isEnabled()) // if checked and also on initial welcome dialog
{
m_gui_settings->SetValue(gui::m_currentStylesheet, gui::DarkStylesheet);
}
});
}

View File

@ -17,12 +17,7 @@ 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
{
return m_user_wants_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;
};