vcl/inc/IconThemeSelector.hxx        |    3 ++-
 vcl/source/app/IconThemeSelector.cxx |   13 ++++++++++---
 vcl/source/app/settings.cxx          |    9 +++++++--
 3 files changed, 19 insertions(+), 6 deletions(-)

New commits:
commit 4aef8133f522be2f2d51456990cd64faaa90d080
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Thu May 19 11:08:50 2022 +0100
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Thu May 19 23:49:19 2022 +0200

    icon-theme not dynamically changing to match desktop if set to 'auto'
    
    Change-Id: Id5700cff1000fe4b6df6e73c1ce9ff4f206e0a96
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134613
    Tested-by: Jenkins
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/vcl/inc/IconThemeSelector.hxx b/vcl/inc/IconThemeSelector.hxx
index 7e2dfc0da1dd..8dab03d3a8d2 100644
--- a/vcl/inc/IconThemeSelector.hxx
+++ b/vcl/inc/IconThemeSelector.hxx
@@ -62,7 +62,8 @@ public:
     void
     SetUseHighContrastTheme(bool);
 
-    void
+    /** Returns true if the PreferredIconTheme was changed */
+    bool
     SetPreferredIconTheme(const OUString&, bool bDarkIconTheme);
 
     bool
diff --git a/vcl/source/app/IconThemeSelector.cxx 
b/vcl/source/app/IconThemeSelector.cxx
index 253242bcd5ad..5abb7b29d5df 100644
--- a/vcl/source/app/IconThemeSelector.cxx
+++ b/vcl/source/app/IconThemeSelector.cxx
@@ -124,13 +124,20 @@ IconThemeSelector::SetUseHighContrastTheme(bool v)
     mUseHighContrastTheme = v;
 }
 
-void
+bool
 IconThemeSelector::SetPreferredIconTheme(const OUString& theme, bool 
bDarkIconTheme)
 {
     // lower case theme name, and (tdf#120175) replace - with _
     // see icon-themes/README
-    mPreferredIconTheme = theme.toAsciiLowerCase().replace('-','_');
-    mPreferDarkIconTheme = bDarkIconTheme;
+    OUString sIconTheme = theme.toAsciiLowerCase().replace('-','_');
+
+    const bool bChanged = mPreferredIconTheme != sIconTheme || 
mPreferDarkIconTheme != bDarkIconTheme;
+    if (bChanged)
+    {
+        mPreferredIconTheme = sIconTheme;
+        mPreferDarkIconTheme = bDarkIconTheme;
+    }
+    return bChanged;
 }
 
 bool
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index 0e64a4269e35..186013ebc999 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -184,7 +184,7 @@ struct ImplStyleData
     std::shared_ptr<vcl::IconThemeSelector>
                                     mIconThemeSelector;
 
-    OUString                   mIconTheme;
+    OUString                        mIconTheme;
     bool                            mbSkipDisabledInMenus;
     bool                            mbHideDisabledMenuItems;
     bool                            mbPreferredContextMenuShortcuts;
@@ -3139,7 +3139,12 @@ StyleSettings::GetHighContrastMode() const
 void
 StyleSettings::SetPreferredIconTheme(const OUString& theme, bool 
bDarkIconTheme)
 {
-    mxData->mIconThemeSelector->SetPreferredIconTheme(theme, bDarkIconTheme);
+    const bool bChanged = 
mxData->mIconThemeSelector->SetPreferredIconTheme(theme, bDarkIconTheme);
+    if (bChanged)
+    {
+        // clear this so it is recalculated if it was selected as the 
automatic theme
+        mxData->mIconTheme.clear();
+    }
 }
 
 void

Reply via email to