diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/BalloonTip.cpp b/Source/Core/DolphinQt/Config/ToolTipControls/BalloonTip.cpp index ccec65c374..435b60e462 100644 --- a/Source/Core/DolphinQt/Config/ToolTipControls/BalloonTip.cpp +++ b/Source/Core/DolphinQt/Config/ToolTipControls/BalloonTip.cpp @@ -133,7 +133,7 @@ void BalloonTip::UpdateBoundsAndRedraw(const QPoint& pos, ShowArrow show_arrow) const QRect screen_rect = screen->geometry(); QSize sh = sizeHint(); - // The look should resemble the default tooltip style set in Settings::SetCurrentUserStyle() + // The look should resemble the default tooltip style set in Settings::ApplyStyle() const int border = 1; const int arrow_height = 18; const int arrow_width = 18; diff --git a/Source/Core/DolphinQt/Main.cpp b/Source/Core/DolphinQt/Main.cpp index 39aa5c6f1f..30922f1c63 100644 --- a/Source/Core/DolphinQt/Main.cpp +++ b/Source/Core/DolphinQt/Main.cpp @@ -247,7 +247,7 @@ int main(int argc, char* argv[]) Settings::Instance().InitDefaultPalette(); Settings::Instance().UpdateSystemDark(); - Settings::Instance().SetCurrentUserStyle(Settings::Instance().GetCurrentUserStyle()); + Settings::Instance().ApplyStyle(); MainWindow win{std::move(boot), static_cast(options.get("movie"))}; win.Show(); diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index 3e9596f72e..7df52cdebf 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -240,9 +240,7 @@ MainWindow::MainWindow(std::unique_ptr boot_parameters, #if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) connect(QGuiApplication::styleHints(), &QStyleHints::colorSchemeChanged, this, - [](Qt::ColorScheme colorScheme) { - Settings::Instance().SetCurrentUserStyle(Settings::Instance().GetCurrentUserStyle()); - }); + [](Qt::ColorScheme colorScheme) { Settings::Instance().ApplyStyle(); }); #endif connect(m_cheats_manager, &CheatsManager::OpenGeneralSettings, this, @@ -1739,7 +1737,7 @@ bool MainWindow::nativeEvent(const QByteArray& eventType, void* message, qintptr settings.UpdateSystemDark(); if (settings.IsSystemDark() != was_dark_before) { - settings.SetCurrentUserStyle(settings.GetCurrentUserStyle()); + settings.ApplyStyle(); // force the colors in the Skylander window to update if (m_skylander_window) diff --git a/Source/Core/DolphinQt/Settings.cpp b/Source/Core/DolphinQt/Settings.cpp index ebcf90ee8e..21ab0d62ef 100644 --- a/Source/Core/DolphinQt/Settings.cpp +++ b/Source/Core/DolphinQt/Settings.cpp @@ -123,7 +123,7 @@ void Settings::SetThemeName(const QString& theme_name) emit ThemeChanged(); } -QString Settings::GetCurrentUserStyle() const +QString Settings::GetUserStyleName() const { if (GetQSettings().contains(QStringLiteral("userstyle/name"))) return GetQSettings().value(QStringLiteral("userstyle/name")).toString(); @@ -132,6 +132,11 @@ QString Settings::GetCurrentUserStyle() const return QFileInfo(GetQSettings().value(QStringLiteral("userstyle/path")).toString()).fileName(); } +void Settings::SetUserStyleName(const QString& stylesheet_name) +{ + GetQSettings().setValue(QStringLiteral("userstyle/name"), stylesheet_name); +} + void Settings::InitDefaultPalette() { s_default_palette = std::make_unique(qApp->palette()); @@ -169,8 +174,9 @@ bool Settings::IsThemeDark() } // Calling this before the main window has been created breaks the style of some widgets. -void Settings::SetCurrentUserStyle(const QString& stylesheet_name) +void Settings::ApplyStyle() { + const QString stylesheet_name = GetUserStyleName(); QString stylesheet_contents; // If we haven't found one, we continue with an empty (default) style @@ -243,8 +249,6 @@ void Settings::SetCurrentUserStyle(const QString& stylesheet_name) } qApp->setStyleSheet(stylesheet_contents); - - GetQSettings().setValue(QStringLiteral("userstyle/name"), stylesheet_name); } bool Settings::AreUserStylesEnabled() const diff --git a/Source/Core/DolphinQt/Settings.h b/Source/Core/DolphinQt/Settings.h index 5583ed0628..e13eb0c0da 100644 --- a/Source/Core/DolphinQt/Settings.h +++ b/Source/Core/DolphinQt/Settings.h @@ -57,12 +57,15 @@ public: void SetSystemDark(bool dark); bool IsSystemDark(); bool IsThemeDark(); - void SetCurrentUserStyle(const QString& stylesheet_name); - QString GetCurrentUserStyle() const; + void SetUserStyleName(const QString& stylesheet_name); + QString GetUserStyleName() const; void SetUserStylesEnabled(bool enabled); bool AreUserStylesEnabled() const; + // this evaluates the current stylesheet settings and refreshes the GUI with them + void ApplyStyle(); + void GetToolTipStyle(QColor& window_color, QColor& text_color, QColor& emphasis_text_color, QColor& border_color, const QPalette& palette, const QPalette& high_contrast_palette) const; diff --git a/Source/Core/DolphinQt/Settings/InterfacePane.cpp b/Source/Core/DolphinQt/Settings/InterfacePane.cpp index ef0985bfd4..0aa35054de 100644 --- a/Source/Core/DolphinQt/Settings/InterfacePane.cpp +++ b/Source/Core/DolphinQt/Settings/InterfacePane.cpp @@ -254,7 +254,7 @@ void InterfacePane::LoadConfig() ->setCurrentIndex( m_combobox_theme->findText(QString::fromStdString(Config::Get(Config::MAIN_THEME_NAME)))); - const QString userstyle = Settings::Instance().GetCurrentUserStyle(); + const QString userstyle = Settings::Instance().GetUserStyleName(); const int index = m_combobox_userstyle->findData(QFileInfo(userstyle).fileName()); if (index > 0) @@ -298,7 +298,8 @@ void InterfacePane::OnSaveConfig() m_checkbox_use_builtin_title_database->isChecked()); Settings::Instance().SetDebugModeEnabled(m_checkbox_show_debugging_ui->isChecked()); Settings::Instance().SetUserStylesEnabled(m_checkbox_use_userstyle->isChecked()); - Settings::Instance().SetCurrentUserStyle(m_combobox_userstyle->currentData().toString()); + Settings::Instance().SetUserStyleName(m_combobox_userstyle->currentData().toString()); + Settings::Instance().ApplyStyle(); const bool visible = m_checkbox_use_userstyle->isChecked();