1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #ifndef INCLUDED_VCL_ICONTHEMESCANNER_HXX
11 #define INCLUDED_VCL_ICONTHEMESCANNER_HXX
13 #include <vcl/dllapi.h>
15 #include <rtl/ustring.hxx>
16 #include <vcl/IconThemeInfo.hxx>
21 // forward declaration of unit test class. Required for friend relationship.
22 class IconThemeScannerTest
;
26 /** This class scans a folder for icon themes and provides the results.
28 class VCL_DLLPUBLIC IconThemeScanner
31 /** Factory method to create the object.
32 * Provide a path to search for IconThemes.
34 static std::shared_ptr
<IconThemeScanner
> Create(std::u16string_view path
);
36 /** This method will return the standard path where icon themes are located.
38 static OUString
GetStandardIconThemePath();
40 const std::vector
<IconThemeInfo
>& GetFoundIconThemes() const { return mFoundIconThemes
; }
42 /** Get the IconThemeInfo for a theme.
43 * If the theme id is not among the found themes, a std::runtime_error will be thrown.
44 * Use IconThemeIsInstalled() to check whether it is available.
46 const IconThemeInfo
& GetIconThemeInfo(const OUString
& themeId
);
48 /** Checks whether the theme with the provided name has been found in the
51 bool IconThemeIsInstalled(const OUString
& themeId
) const;
56 /** Scan a directory for icon themes.
59 * There are several cases when this method will fail:
60 * - The directory does not exist
61 * - There are no files which match the pattern images_xxx.zip
63 void ScanDirectoryForIconThemes(std::u16string_view path
);
65 /** Adds the provided icon theme by path.
67 bool AddIconThemeByPath(const OUString
& path
);
69 /** Scans the provided directory for icon themes.
70 * The returned strings will contain the URLs to the icon themes.
72 static std::vector
<OUString
> ReadIconThemesFromPath(const OUString
& dir
);
74 /** Check whether a single file is valid */
75 static bool FileIsValidIconTheme(const OUString
&);
77 std::vector
<IconThemeInfo
> mFoundIconThemes
;
79 friend class ::IconThemeScannerTest
;
82 } // end namespace vcl
84 #endif // INCLUDED_VCL_ICONTHEMESCANNER_HXX
86 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */