tdf#130857 qt weld: Hide widget marked for deletion
[LibreOffice.git] / vcl / inc / IconThemeScanner.hxx
blobe95adf417fdd349f796c909fd85d1685c9a5628d
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 #pragma once
12 #include <vcl/dllapi.h>
14 #include <rtl/ustring.hxx>
15 #include <vcl/IconThemeInfo.hxx>
17 #include <memory>
18 #include <vector>
20 // forward declaration of unit test class. Required for friend relationship.
21 class IconThemeScannerTest;
23 namespace vcl
25 /** This class scans a folder for icon themes and provides the results.
27 class VCL_DLLPUBLIC IconThemeScanner
29 public:
30 /** Factory method to create the object.
31 * Provide a path to search for IconThemes.
33 static std::shared_ptr<IconThemeScanner> Create(std::u16string_view path);
35 /** This method will return the standard path where icon themes are located.
37 static OUString GetStandardIconThemePath();
39 const std::vector<IconThemeInfo>& GetFoundIconThemes() const { return mFoundIconThemes; }
41 /** Get the IconThemeInfo for a theme.
42 * If the theme id is not among the found themes, a std::runtime_error will be thrown.
43 * Use IconThemeIsInstalled() to check whether it is available.
45 const IconThemeInfo& GetIconThemeInfo(const OUString& themeId);
47 /** Checks whether the theme with the provided name has been found in the
48 * scanned directory.
50 bool IconThemeIsInstalled(const OUString& themeId) const;
52 private:
53 IconThemeScanner();
55 /** Scan a directory for icon themes.
57 * @return
58 * There are several cases when this method will fail:
59 * - The directory does not exist
60 * - There are no files which match the pattern images_xxx.zip
62 void ScanDirectoryForIconThemes(std::u16string_view path);
64 /** Adds the provided icon theme by path.
66 bool AddIconThemeByPath(const OUString& path);
68 /** Scans the provided directory for icon themes.
69 * The returned strings will contain the URLs to the icon themes.
71 static std::vector<OUString> ReadIconThemesFromPath(const OUString& dir);
73 /** Check whether a single file is valid */
74 static bool FileIsValidIconTheme(const OUString&);
76 std::vector<IconThemeInfo> mFoundIconThemes;
78 friend class ::IconThemeScannerTest;
81 } // end namespace vcl
83 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */