vcl: 'horizontically'
[LibreOffice.git] / include / vcl / IconThemeInfo.hxx
blobec116ca2f4fcaf214cc66af26194af467f02167a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #ifndef INCLUDED_VCL_ICONTHEMEINFO_HXX
11 #define INCLUDED_VCL_ICONTHEMEINFO_HXX
13 #include <vcl/dllapi.h>
14 #include <tools/gen.hxx>
15 #include <rtl/ustring.hxx>
17 #include <vector>
19 // forward declaration of unit test classes. Required for friend relationship.
20 class IconThemeInfoTest;
21 class IconThemeSelectorTest;
22 class IconThemeScannerTest;
24 namespace vcl
26 /** This class provides information about an icon theme.
28 class VCL_DLLPUBLIC IconThemeInfo
30 public:
31 /** The name of the icon theme to use for high contrast mode */
32 static constexpr OUStringLiteral HIGH_CONTRAST_ID = u"sifr";
34 /** Construct an IconThemeInfo from the URL to a file.
35 * This method will throw a std::runtime_error if the URL cannot be properly parsed.
36 * Check the URL with UrlCanBeParsed() first.
38 IconThemeInfo(const OUString& urlToFile);
40 const OUString& GetDisplayName() const { return mDisplayName; }
42 const OUString& GetThemeId() const { return mThemeId; }
44 const OUString& GetUrlToFile() const { return mUrlToFile; }
46 /** Obtain the icon size by theme name.
47 * @internal
48 * It is not clear where this information belongs to. The sizes were hard-coded before they moved here.
49 * Maybe there is a way to determine the sizes from the icon theme packages.
51 static Size SizeByThemeName(std::u16string_view);
53 /** Check whether an IconThemeInfo can be constructed from a URL */
54 static bool UrlCanBeParsed(const OUString& url);
56 /** Find an icon theme by its id in a vector.
57 * Throws a runtime_error if the theme is not contained in the vector
59 static const vcl::IconThemeInfo&
60 FindIconThemeById(const std::vector<vcl::IconThemeInfo>& themes, const OUString& themeId);
62 /** Check whether a theme with a specified id is in a vector of IconThemeInfo */
63 static bool IconThemeIsInVector(const std::vector<vcl::IconThemeInfo>& themes,
64 const OUString& themeId);
66 private:
67 /** private constructor for testing purposes only */
68 IconThemeInfo();
70 /** Determine the icon theme name from the filename
71 * If the name has an underscore, the name is taken from the first underscore to the last dot,
72 * e.g., images_oxygen.zip becomes oxygen
73 * If the name does not have an underscore in it, the whole name until the last dot is returned,
74 * e.g. default.zip becomes default
76 static OUString FileNameToThemeId(const OUString&);
78 /** Creates the display name for the given id of a file.
79 * Currently, we only uppercase the id.
81 static OUString ThemeIdToDisplayName(const OUString&);
83 /** The name which is presented to the user */
84 OUString mDisplayName;
85 /** The theme id. This id is used in ... to determine the file name */
86 OUString mThemeId;
87 /** The url to the icon theme package */
88 OUString mUrlToFile;
90 friend class ::IconThemeInfoTest;
91 friend class ::IconThemeScannerTest;
92 friend class ::IconThemeSelectorTest;
95 } // namespace vcl
97 #endif // INCLUDED_VCL_ICONTHEMEINFO_HXX