diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2018-11-02 19:20:51 +0100 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2018-11-05 14:40:43 +0100 |
commit | b0dbd78d010509fa9048126fd3ff24afde687136 (patch) | |
tree | edee539276dfa98f2acd43e07bd4ed71ad06eafb /vcl | |
parent | b932577ba0325144bcdeb91725a51000f7ef3eca (diff) |
Strip _dark and _svg iconset filenames for display
The new display name code handles _dark and _svg like an property
or extension. It strips both from the back of the base filename
and adds them in brackets to the display name as (SVG), (dark)
and (SVG + dark).
This way we can drop the special handling for breeze_dark and
sifr_dark display names.
Change-Id: I0ebc8392582d7240b51528078de9d81b36e5a9e9
Reviewed-on: https://gerrit.libreoffice.org/62788
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/app/IconThemeInfo.cxx | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/vcl/source/app/IconThemeInfo.cxx b/vcl/source/app/IconThemeInfo.cxx index 95f1a358c93a..4dce3f7756f9 100644 --- a/vcl/source/app/IconThemeInfo.cxx +++ b/vcl/source/app/IconThemeInfo.cxx @@ -20,10 +20,6 @@ const OUStringLiteral vcl::IconThemeInfo::HIGH_CONTRAST_ID("sifr"); namespace { -static const OUStringLiteral BREEZE_DARK_ID("breeze_dark"); -static const OUStringLiteral BREEZE_DARK_DISPLAY_NAME("Breeze Dark"); -static const OUStringLiteral SIFR_DARK_ID("sifr_dark"); -static const OUStringLiteral SIFR_DARK_DISPLAY_NAME("Sifr Dark"); static const OUStringLiteral KARASA_JAGA_ID("karasa_jaga"); static const OUStringLiteral KARASA_JAGA_DISPLAY_NAME("Karasa Jaga"); static const OUStringLiteral HELPIMG_FAKE_THEME("helpimg"); @@ -122,30 +118,38 @@ IconThemeInfo::ThemeIdToDisplayName(const OUString& themeId) throw std::runtime_error("IconThemeInfo::ThemeIdToDisplayName() called with invalid id."); } - // special cases - if (themeId.equalsIgnoreAsciiCase(BREEZE_DARK_ID)) { - return BREEZE_DARK_DISPLAY_NAME; - } - else if (themeId.equalsIgnoreAsciiCase(SIFR_DARK_ID)) { - return SIFR_DARK_DISPLAY_NAME; - } + // Strip _svg and _dark filename "extensions" + OUString aDisplayName = themeId; - else if (themeId.equalsIgnoreAsciiCase(KARASA_JAGA_ID)) { - return KARASA_JAGA_DISPLAY_NAME; - } + bool bIsSvg = aDisplayName.endsWith("_svg", &aDisplayName); + bool bIsDark = aDisplayName.endsWith("_dark", &aDisplayName); + if (!bIsSvg && bIsDark) + bIsSvg = aDisplayName.endsWith("_svg", &aDisplayName); - // make the first letter uppercase - OUString r; - sal_Unicode firstLetter = themeId[0]; - if (rtl::isAsciiLowerCase(firstLetter)) { - r = OUString(sal_Unicode(rtl::toAsciiUpperCase(firstLetter))); - r += themeId.copy(1); + // special cases + if (aDisplayName.equalsIgnoreAsciiCase(KARASA_JAGA_ID)) { + aDisplayName = KARASA_JAGA_DISPLAY_NAME; } - else { - r = themeId; + else + { + // make the first letter uppercase + sal_Unicode firstLetter = aDisplayName[0]; + if (rtl::isAsciiLowerCase(firstLetter)) + { + OUString aUpper(sal_Unicode(rtl::toAsciiUpperCase(firstLetter))); + aUpper += aDisplayName.copy(1); + aDisplayName = aUpper; + } } - return r; + if (bIsSvg && bIsDark) + aDisplayName += " (SVG + dark)"; + else if (bIsSvg) + aDisplayName += " (SVG)"; + else if (bIsDark) + aDisplayName += " (dark)"; + + return aDisplayName; } namespace |