Kaydet (Commit) 2a0118a9 authored tarafından Tobias Lippert's avatar Tobias Lippert Kaydeden (comit) Yousuf Philips

tdf#88675 Fix display names for hicontrast and tango_testing

The special cases for the icon themes with the filenames
"images_hicontrast.zip" and "images_tango_testing.zip" are now handled.
They will be displayed as "High Contrast" and "Tango Testing"
respectively.

Change-Id: Ia3c2b8b57809db9c5ed132c42a412157e91b2599
Reviewed-on: https://gerrit.libreoffice.org/14574Reviewed-by: 's avatarYousuf Philips <philipz85@hotmail.com>
Tested-by: 's avatarYousuf Philips <philipz85@hotmail.com>
üst 0cdab3fc
...@@ -29,6 +29,9 @@ class VCL_DLLPUBLIC IconThemeInfo { ...@@ -29,6 +29,9 @@ class VCL_DLLPUBLIC IconThemeInfo {
public: public:
/** The name of the icon theme to use for high contrast mode */
static const OUString HIGH_CONTRAST_ID;
/** Construct an IconThemeInfo from the URL to a file. /** Construct an IconThemeInfo from the URL to a file.
* This method will throw a std::runtime_error if the URL cannot be properly parsed. * This method will throw a std::runtime_error if the URL cannot be properly parsed.
* Check the URL with UrlCanBeParsed() first. * Check the URL with UrlCanBeParsed() first.
......
...@@ -76,10 +76,6 @@ private: ...@@ -76,10 +76,6 @@ private:
static OUString static OUString
ReturnFallback(const std::vector<IconThemeInfo>& installedThemes); ReturnFallback(const std::vector<IconThemeInfo>& installedThemes);
/** The name of the icon theme to use for high contrast mode */
static const OUString
HIGH_CONTRAST_ICON_THEME_ID;
/** The name of the icon theme which is used as fallback */ /** The name of the icon theme which is used as fallback */
static const OUString static const OUString
FALLBACK_ICON_THEME_ID; FALLBACK_ICON_THEME_ID;
......
...@@ -35,6 +35,12 @@ class IconThemeInfoTest : public CppUnit::TestFixture ...@@ -35,6 +35,12 @@ class IconThemeInfoTest : public CppUnit::TestFixture
void void
ThemeIdIsDetectedFromFileNameWithUnderscore(); ThemeIdIsDetectedFromFileNameWithUnderscore();
void
DisplayNameForHicontrastIsHighContrast();
void
DisplayNameForTango_testingIsTangoTesting();
void void
ExceptionIsThrownWhenIdCannotBeDetermined1(); ExceptionIsThrownWhenIdCannotBeDetermined1();
...@@ -114,6 +120,24 @@ IconThemeInfoTest::ExceptionIsThrownWhenIdCannotBeDetermined2() ...@@ -114,6 +120,24 @@ IconThemeInfoTest::ExceptionIsThrownWhenIdCannotBeDetermined2()
CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception was thrown", true, thrown); CPPUNIT_ASSERT_EQUAL_MESSAGE("Exception was thrown", true, thrown);
} }
void
IconThemeInfoTest::DisplayNameForHicontrastIsHighContrast()
{
OUString id("hicontrast");
OUString expected("High Contrast");
OUString displayName = vcl::IconThemeInfo::ThemeIdToDisplayName(id);
CPPUNIT_ASSERT_EQUAL(expected, displayName);
}
void
IconThemeInfoTest::DisplayNameForTango_testingIsTangoTesting()
{
OUString id("tango_testing");
OUString expected("Tango Testing");
OUString displayName = vcl::IconThemeInfo::ThemeIdToDisplayName(id);
CPPUNIT_ASSERT_EQUAL(expected, displayName);
}
// Put the test suite in the registry // Put the test suite in the registry
CPPUNIT_TEST_SUITE_REGISTRATION(IconThemeInfoTest); CPPUNIT_TEST_SUITE_REGISTRATION(IconThemeInfoTest);
......
...@@ -80,7 +80,7 @@ IconThemeSelectorTest::GetFakeInstalledThemes() ...@@ -80,7 +80,7 @@ IconThemeSelectorTest::GetFakeInstalledThemes()
r.push_back(a); r.push_back(a);
a.mThemeId = "oxygen"; a.mThemeId = "oxygen";
r.push_back(a); r.push_back(a);
a.mThemeId = vcl::IconThemeSelector::HIGH_CONTRAST_ICON_THEME_ID; a.mThemeId = "hicontrast";
r.push_back(a); r.push_back(a);
return r; return r;
} }
...@@ -122,7 +122,7 @@ IconThemeSelectorTest::ThemeIsOverriddenByHighContrastMode() ...@@ -122,7 +122,7 @@ IconThemeSelectorTest::ThemeIsOverriddenByHighContrastMode()
std::vector<vcl::IconThemeInfo> themes = GetFakeInstalledThemes(); std::vector<vcl::IconThemeInfo> themes = GetFakeInstalledThemes();
OUString selected = s.SelectIconTheme(themes, "tango"); OUString selected = s.SelectIconTheme(themes, "tango");
CPPUNIT_ASSERT_EQUAL_MESSAGE("'tango' theme is overridden by high contrast mode", CPPUNIT_ASSERT_EQUAL_MESSAGE("'tango' theme is overridden by high contrast mode",
vcl::IconThemeSelector::HIGH_CONTRAST_ICON_THEME_ID, selected); OUString("hicontrast"), selected);
s.SetUseHighContrastTheme(false); s.SetUseHighContrastTheme(false);
selected = s.SelectIconTheme(themes, "tango"); selected = s.SelectIconTheme(themes, "tango");
CPPUNIT_ASSERT_EQUAL_MESSAGE("'tango' theme is no longer overridden by high contrast mode", CPPUNIT_ASSERT_EQUAL_MESSAGE("'tango' theme is no longer overridden by high contrast mode",
......
...@@ -13,8 +13,17 @@ ...@@ -13,8 +13,17 @@
#include <stdexcept> #include <stdexcept>
#include <algorithm> #include <algorithm>
// constants for theme ids and display names. Only the theme id for hicontrast is used
// outside of this class and hence made public.
const OUString vcl::IconThemeInfo::HIGH_CONTRAST_ID = "hicontrast";
namespace { namespace {
static const OUString HIGH_CONTRAST_DISPLAY_NAME = "High Contrast";
static const OUString TANGO_TESTING_ID = "tango_testing";
static const OUString TANGO_TESTING_DISPLAY_NAME = "Tango Testing";
OUString OUString
filename_from_url(const OUString& url) filename_from_url(const OUString& url)
{ {
...@@ -26,7 +35,7 @@ filename_from_url(const OUString& url) ...@@ -26,7 +35,7 @@ filename_from_url(const OUString& url)
return filename; return filename;
} }
} } // end anonymous namespace
namespace vcl { namespace vcl {
...@@ -111,6 +120,14 @@ IconThemeInfo::ThemeIdToDisplayName(const OUString& themeId) ...@@ -111,6 +120,14 @@ IconThemeInfo::ThemeIdToDisplayName(const OUString& themeId)
throw std::runtime_error("IconThemeInfo::ThemeIdToDisplayName() called with invalid id."); throw std::runtime_error("IconThemeInfo::ThemeIdToDisplayName() called with invalid id.");
} }
// sepcial cases
if (themeId.equalsIgnoreAsciiCase(HIGH_CONTRAST_ID)) {
return HIGH_CONTRAST_DISPLAY_NAME;
}
else if (themeId.equalsIgnoreAsciiCase(TANGO_TESTING_ID)) {
return TANGO_TESTING_DISPLAY_NAME;
}
// make the first letter uppercase // make the first letter uppercase
OUString r; OUString r;
sal_Unicode firstLetter = themeId[0]; sal_Unicode firstLetter = themeId[0];
...@@ -121,6 +138,7 @@ IconThemeInfo::ThemeIdToDisplayName(const OUString& themeId) ...@@ -121,6 +138,7 @@ IconThemeInfo::ThemeIdToDisplayName(const OUString& themeId)
else { else {
r = themeId; r = themeId;
} }
return r; return r;
} }
......
...@@ -16,9 +16,6 @@ ...@@ -16,9 +16,6 @@
namespace vcl { namespace vcl {
/*static*/ const OUString
IconThemeSelector::HIGH_CONTRAST_ICON_THEME_ID("hicontrast");
/*static*/ const OUString /*static*/ const OUString
IconThemeSelector::FALLBACK_ICON_THEME_ID("tango"); IconThemeSelector::FALLBACK_ICON_THEME_ID("tango");
...@@ -99,8 +96,8 @@ IconThemeSelector::SelectIconTheme( ...@@ -99,8 +96,8 @@ IconThemeSelector::SelectIconTheme(
const OUString& theme) const const OUString& theme) const
{ {
if (mUseHighContrastTheme) { if (mUseHighContrastTheme) {
if (icon_theme_is_in_installed_themes(HIGH_CONTRAST_ICON_THEME_ID, installedThemes)) { if (icon_theme_is_in_installed_themes(IconThemeInfo::HIGH_CONTRAST_ID, installedThemes)) {
return HIGH_CONTRAST_ICON_THEME_ID; return IconThemeInfo::HIGH_CONTRAST_ID;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment