[Libreoffice-commits] core.git: include/vcl vcl/source vcl/unx

Caolán McNamara caolanm at redhat.com
Mon Nov 14 13:51:14 UTC 2016


 include/vcl/IconThemeSelector.hxx         |    3 ++-
 include/vcl/settings.hxx                  |    2 +-
 vcl/source/app/IconThemeSelector.cxx      |   11 ++++++++---
 vcl/source/app/settings.cxx               |    4 ++--
 vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx |    9 +--------
 5 files changed, 14 insertions(+), 15 deletions(-)

New commits:
commit 6e32e575829160b3c51ebbb67231baec7135afd3
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Nov 14 13:49:01 2016 +0000

    Resolves: tdf#103915 when global dark theme is set fall back to breeze_dark
    
    otherwise don't assume a desired iconset ending in *dark means breeze_dark
    is a good fallback
    
    Change-Id: Ia294a86e17a2c390b503d5200dfc7195759afa00

diff --git a/include/vcl/IconThemeSelector.hxx b/include/vcl/IconThemeSelector.hxx
index 70b000b..0fcd66d 100644
--- a/include/vcl/IconThemeSelector.hxx
+++ b/include/vcl/IconThemeSelector.hxx
@@ -63,7 +63,7 @@ public:
     SetUseHighContrastTheme(bool);
 
     void
-    SetPreferredIconTheme(const OUString&);
+    SetPreferredIconTheme(const OUString&, bool bDarkIconTheme);
 
     bool
     operator==(const vcl::IconThemeSelector&) const;
@@ -85,6 +85,7 @@ private:
 
     OUString mPreferredIconTheme;
     bool mUseHighContrastTheme;
+    bool mPreferDarkIconTheme;
 
     friend class ::IconThemeSelectorTest;
 };
diff --git a/include/vcl/settings.hxx b/include/vcl/settings.hxx
index 74197f1..fd28810 100644
--- a/include/vcl/settings.hxx
+++ b/include/vcl/settings.hxx
@@ -548,7 +548,7 @@ public:
     /** Set a preferred icon theme.
      * This theme will be preferred in GetAutomaticallyChosenIconTheme()
      */
-    void                            SetPreferredIconTheme(const OUString&);
+    void                            SetPreferredIconTheme(const OUString&, bool bDarkIconTheme = false);
 
     const DialogStyle&              GetDialogStyle() const;
     void                            SetDialogStyle( const DialogStyle& rStyle );
diff --git a/vcl/source/app/IconThemeSelector.cxx b/vcl/source/app/IconThemeSelector.cxx
index 556d31a..95ee517 100644
--- a/vcl/source/app/IconThemeSelector.cxx
+++ b/vcl/source/app/IconThemeSelector.cxx
@@ -43,7 +43,8 @@ bool icon_theme_is_in_installed_themes(const OUString& theme,
 } // end anonymous namespace
 
 IconThemeSelector::IconThemeSelector()
-: mUseHighContrastTheme(false)
+    : mUseHighContrastTheme(false)
+    , mPreferDarkIconTheme(false)
 {
 }
 
@@ -83,7 +84,7 @@ IconThemeSelector::SelectIconThemeForDesktopEnvironment(
             return mPreferredIconTheme;
         }
         //if a dark variant is preferred, and we didn't have an exact match, then try our one and only dark theme
-        if (mPreferredIconTheme.endsWith("_dark") && icon_theme_is_in_installed_themes("breeze_dark", installedThemes)) {
+        if (mPreferDarkIconTheme && icon_theme_is_in_installed_themes("breeze_dark", installedThemes)) {
             return OUString("breeze_dark");
         }
     }
@@ -121,9 +122,10 @@ IconThemeSelector::SetUseHighContrastTheme(bool v)
 }
 
 void
-IconThemeSelector::SetPreferredIconTheme(const OUString& theme)
+IconThemeSelector::SetPreferredIconTheme(const OUString& theme, bool bDarkIconTheme)
 {
     mPreferredIconTheme = theme;
+    mPreferDarkIconTheme = bDarkIconTheme;
 }
 
 bool
@@ -135,6 +137,9 @@ IconThemeSelector::operator==(const vcl::IconThemeSelector& other) const
     if (mPreferredIconTheme != other.mPreferredIconTheme) {
         return false;
     }
+    if (mPreferDarkIconTheme != other.mPreferDarkIconTheme) {
+        return false;
+    }
     if (mUseHighContrastTheme != other.mUseHighContrastTheme) {
         return false;
     }
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index 03aac21..b8c5167 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -3026,9 +3026,9 @@ StyleSettings::GetHighContrastMode() const
 }
 
 void
-StyleSettings::SetPreferredIconTheme(const OUString& theme)
+StyleSettings::SetPreferredIconTheme(const OUString& theme, bool bDarkIconTheme)
 {
-    mxData->mIconThemeSelector->SetPreferredIconTheme(theme);
+    mxData->mIconThemeSelector->SetPreferredIconTheme(theme, bDarkIconTheme);
 }
 
 void
diff --git a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
index 286e4a2..e9250ed 100644
--- a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
@@ -2726,14 +2726,7 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings )
                             "gtk-application-prefer-dark-theme", &bDarkIconTheme,
                             nullptr );
     OUString sIconThemeName(OUString::createFromAscii(pIconThemeName));
-    if (sIconThemeName.endsWithIgnoreAsciiCase("-dark", &sIconThemeName) ||
-        sIconThemeName.endsWithIgnoreAsciiCase("_dark", &sIconThemeName))
-    {
-        bDarkIconTheme = true;
-    }
-    if (bDarkIconTheme)
-        sIconThemeName += "_dark";
-    aStyleSet.SetPreferredIconTheme(sIconThemeName);
+    aStyleSet.SetPreferredIconTheme(sIconThemeName, bDarkIconTheme);
     g_free( pIconThemeName );
 
     aStyleSet.SetToolbarIconSize( ToolbarIconSize::Large );


More information about the Libreoffice-commits mailing list