summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Lippert <drtl@fastmail.fm>2015-02-21 21:39:45 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-05-27 13:39:51 +0000
commite586f2c7de035d2768f96e51b89c63e9377fd403 (patch)
treefb691f040ff9d09bcc312e3d3fdd7e905ccb00ee
parentf34c1e9ba7d831c42c89d3c59d501ce6cc858dbe (diff)
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/14574 Reviewed-by: Yousuf Philips <philipz85@hotmail.com> Tested-by: Yousuf Philips <philipz85@hotmail.com> (cherry picked from commit 2a0118a98fc39dfed56fb7904733f63f6a2d6fe8) Reviewed-on: https://gerrit.libreoffice.org/15925 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--include/vcl/IconThemeInfo.hxx3
-rw-r--r--include/vcl/IconThemeSelector.hxx4
-rw-r--r--vcl/qa/cppunit/app/test_IconThemeInfo.cxx24
-rw-r--r--vcl/qa/cppunit/app/test_IconThemeSelector.cxx4
-rw-r--r--vcl/source/app/IconThemeInfo.cxx20
-rw-r--r--vcl/source/app/IconThemeSelector.cxx7
6 files changed, 50 insertions, 12 deletions
diff --git a/include/vcl/IconThemeInfo.hxx b/include/vcl/IconThemeInfo.hxx
index 8d9c0e345a16..f1f2fa99e4f7 100644
--- a/include/vcl/IconThemeInfo.hxx
+++ b/include/vcl/IconThemeInfo.hxx
@@ -29,6 +29,9 @@ class VCL_DLLPUBLIC IconThemeInfo {
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.
* This method will throw a std::runtime_error if the URL cannot be properly parsed.
* Check the URL with UrlCanBeParsed() first.
diff --git a/include/vcl/IconThemeSelector.hxx b/include/vcl/IconThemeSelector.hxx
index 8f9d98b6da4a..990e3ec3fa30 100644
--- a/include/vcl/IconThemeSelector.hxx
+++ b/include/vcl/IconThemeSelector.hxx
@@ -76,10 +76,6 @@ private:
static OUString
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 */
static const OUString
FALLBACK_ICON_THEME_ID;
diff --git a/vcl/qa/cppunit/app/test_IconThemeInfo.cxx b/vcl/qa/cppunit/app/test_IconThemeInfo.cxx
index 2a199d27793a..416f8e22abc2 100644
--- a/vcl/qa/cppunit/app/test_IconThemeInfo.cxx
+++ b/vcl/qa/cppunit/app/test_IconThemeInfo.cxx
@@ -36,6 +36,12 @@ class IconThemeInfoTest : public CppUnit::TestFixture
ThemeIdIsDetectedFromFileNameWithUnderscore();
void
+ DisplayNameForHicontrastIsHighContrast();
+
+ void
+ DisplayNameForTango_testingIsTangoTesting();
+
+ void
ExceptionIsThrownWhenIdCannotBeDetermined1();
void
@@ -114,6 +120,24 @@ IconThemeInfoTest::ExceptionIsThrownWhenIdCannotBeDetermined2()
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
CPPUNIT_TEST_SUITE_REGISTRATION(IconThemeInfoTest);
diff --git a/vcl/qa/cppunit/app/test_IconThemeSelector.cxx b/vcl/qa/cppunit/app/test_IconThemeSelector.cxx
index 40ff352778fb..e32ccd209c8e 100644
--- a/vcl/qa/cppunit/app/test_IconThemeSelector.cxx
+++ b/vcl/qa/cppunit/app/test_IconThemeSelector.cxx
@@ -80,7 +80,7 @@ IconThemeSelectorTest::GetFakeInstalledThemes()
r.push_back(a);
a.mThemeId = "oxygen";
r.push_back(a);
- a.mThemeId = vcl::IconThemeSelector::HIGH_CONTRAST_ICON_THEME_ID;
+ a.mThemeId = "hicontrast";
r.push_back(a);
return r;
}
@@ -122,7 +122,7 @@ IconThemeSelectorTest::ThemeIsOverriddenByHighContrastMode()
std::vector<vcl::IconThemeInfo> themes = GetFakeInstalledThemes();
OUString selected = s.SelectIconTheme(themes, "tango");
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);
selected = s.SelectIconTheme(themes, "tango");
CPPUNIT_ASSERT_EQUAL_MESSAGE("'tango' theme is no longer overridden by high contrast mode",
diff --git a/vcl/source/app/IconThemeInfo.cxx b/vcl/source/app/IconThemeInfo.cxx
index 869eb85e40db..f3d054b066ce 100644
--- a/vcl/source/app/IconThemeInfo.cxx
+++ b/vcl/source/app/IconThemeInfo.cxx
@@ -13,8 +13,17 @@
#include <stdexcept>
#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 {
+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
filename_from_url(const OUString& url)
{
@@ -26,7 +35,7 @@ filename_from_url(const OUString& url)
return filename;
}
-}
+} // end anonymous namespace
namespace vcl {
@@ -111,6 +120,14 @@ IconThemeInfo::ThemeIdToDisplayName(const OUString& themeId)
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
OUString r;
sal_Unicode firstLetter = themeId[0];
@@ -121,6 +138,7 @@ IconThemeInfo::ThemeIdToDisplayName(const OUString& themeId)
else {
r = themeId;
}
+
return r;
}
diff --git a/vcl/source/app/IconThemeSelector.cxx b/vcl/source/app/IconThemeSelector.cxx
index f7971dd17e1a..4ef0031f12d6 100644
--- a/vcl/source/app/IconThemeSelector.cxx
+++ b/vcl/source/app/IconThemeSelector.cxx
@@ -17,9 +17,6 @@
namespace vcl {
/*static*/ const OUString
-IconThemeSelector::HIGH_CONTRAST_ICON_THEME_ID("hicontrast");
-
-/*static*/ const OUString
IconThemeSelector::FALLBACK_ICON_THEME_ID("tango");
namespace {
@@ -99,8 +96,8 @@ IconThemeSelector::SelectIconTheme(
const OUString& theme) const
{
if (mUseHighContrastTheme) {
- if (icon_theme_is_in_installed_themes(HIGH_CONTRAST_ICON_THEME_ID, installedThemes)) {
- return HIGH_CONTRAST_ICON_THEME_ID;
+ if (icon_theme_is_in_installed_themes(IconThemeInfo::HIGH_CONTRAST_ID, installedThemes)) {
+ return IconThemeInfo::HIGH_CONTRAST_ID;
}
}