summaryrefslogtreecommitdiff
path: root/include/vcl/IconThemeInfo.hxx
diff options
context:
space:
mode:
authorTobias Lippert <drtl@fastmail.fm>2014-02-09 00:53:28 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-02-21 17:23:50 +0000
commit076a7eacca48f203f0a8b9aa537e88fea9a88409 (patch)
treecd95446ac0b80b29658fa2a44030dacb5304a63d /include/vcl/IconThemeInfo.hxx
parent1ec263e25d8606c70ac2089d5ceea22750d25daf (diff)
Bug #63962 Dynamically scan the config directory for icon themes
The hard-coded icon themes have been replaced by a dynamic list which is filled by scanning the config directory Conflicts: include/vcl/settings.hxx vcl/source/app/settings.cxx vcl/source/window/window.cxx Change-Id: Ie3680ffe27d06e375acf22753e036cb6ddabc4ed Reviewed-on: https://gerrit.libreoffice.org/7935 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'include/vcl/IconThemeInfo.hxx')
-rw-r--r--include/vcl/IconThemeInfo.hxx97
1 files changed, 97 insertions, 0 deletions
diff --git a/include/vcl/IconThemeInfo.hxx b/include/vcl/IconThemeInfo.hxx
new file mode 100644
index 000000000000..f745884e8cdc
--- /dev/null
+++ b/include/vcl/IconThemeInfo.hxx
@@ -0,0 +1,97 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef VCL_ICONTHEMEINFO_HXX_
+#define VCL_ICONTHEMEINFO_HXX_
+
+#include <vcl/dllapi.h>
+// for Size
+#include <tools/gen.hxx>
+#include <rtl/ustring.hxx>
+
+#include <vector>
+
+// forward declaration of unit test classes. Required for friend relationship.
+class IconThemeInfoTest;
+class IconThemeSelectorTest;
+class IconThemeScannerTest;
+
+namespace vcl {
+
+/** This class provides information about an icon theme.
+ */
+class SAL_DLLPUBLIC_EXPORT IconThemeInfo {
+
+public:
+
+ /** 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.
+ */
+ IconThemeInfo(const OUString& urlToFile);
+
+ const OUString& GetDisplayName() const {return mDisplayName;}
+
+ const OUString& GetThemeId() const { return mThemeId; }
+
+ const OUString& GetUrlToFile() const { return mUrlToFile; }
+
+ /** Obtain the icon size by theme name.
+ * @internal
+ * It is not clear where this information belongs to. The sizes were hard-coded before they moved here.
+ * Maybe there is a way to determine the sizes from the icon theme packages.
+ */
+ static Size SizeByThemeName(const OUString&);
+
+ /** Check whether a IconThemeInfo can be constructed from an URL */
+ static bool UrlCanBeParsed(const OUString& url);
+
+ /** Find an icon theme by its id in a vector.
+ * Throws a runtime_error if the theme is not contained in the vector
+ */
+ static const vcl::IconThemeInfo&
+ FindIconThemeById(const std::vector<vcl::IconThemeInfo>& themes, const OUString& themeId);
+
+ /** Check whether a theme with a specified id is in a vector of IconThemeInfo */
+ static bool
+ IconThemeIsInVector(const std::vector<vcl::IconThemeInfo>& themes, const OUString& themeId);
+
+private:
+ /** private constructor for testing purposes only */
+ IconThemeInfo();
+
+ /** Determine the icon theme name from the filename
+ * If the name has an underscore, the name is taken from the first underscore to the last dot,
+ * e.g., images_oxygen.zip becomes oxygen
+ * If the name does not have an underscore in it, the whole name until the last dot is returned,
+ * e.g. default.zip becomes default
+ */
+ static OUString FileNameToThemeId(const OUString&);
+
+ /** Creates the display name for the given id of a file.
+ * Currently, we only uppercase the id.
+ */
+ static OUString ThemeIdToDisplayName(const OUString&);
+
+ /** The name which is presented to the user */
+ OUString mDisplayName;
+ /** The theme id. This id is used in ... to determine the file name */
+ OUString mThemeId;
+ /** The url to the icon theme package */
+ OUString mUrlToFile;
+
+ friend class ::IconThemeInfoTest;
+ friend class ::IconThemeScannerTest;
+ friend class ::IconThemeSelectorTest;
+};
+
+} // namespace vcl
+
+
+#endif /* VCL_ICONTHEMEINFO_HXX_ */