[Libreoffice-commits] core.git: include/vcl vcl/qa vcl/source
Tobias Lippert
drtl at fastmail.fm
Wed May 27 05:24:51 PDT 2015
include/vcl/IconThemeInfo.hxx | 3 +++
include/vcl/IconThemeSelector.hxx | 4 ----
vcl/qa/cppunit/app/test_IconThemeInfo.cxx | 24 ++++++++++++++++++++++++
vcl/qa/cppunit/app/test_IconThemeSelector.cxx | 4 ++--
vcl/source/app/IconThemeInfo.cxx | 20 +++++++++++++++++++-
vcl/source/app/IconThemeSelector.cxx | 7 ++-----
6 files changed, 50 insertions(+), 12 deletions(-)
New commits:
commit 2a0118a98fc39dfed56fb7904733f63f6a2d6fe8
Author: Tobias Lippert <drtl at fastmail.fm>
Date: Sat Feb 21 21:39:45 2015 +0100
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 at hotmail.com>
Tested-by: Yousuf Philips <philipz85 at hotmail.com>
diff --git a/include/vcl/IconThemeInfo.hxx b/include/vcl/IconThemeInfo.hxx
index 8d9c0e3..f1f2fa9 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 8f9d98b..990e3ec 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 2a199d2..416f8e2 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 40ff352..e32ccd2 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 9531bf4..da07e2c 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 1a31f41..235ba1f 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;
}
}
More information about the Libreoffice-commits
mailing list