summaryrefslogtreecommitdiffstats
path: root/vcl/inc/IconThemeScanner.hxx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
commit940b4d1848e8c70ab7642901a68594e8016caffc (patch)
treeeb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /vcl/inc/IconThemeScanner.hxx
parentInitial commit. (diff)
downloadlibreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz
libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vcl/inc/IconThemeScanner.hxx')
-rw-r--r--vcl/inc/IconThemeScanner.hxx92
1 files changed, 92 insertions, 0 deletions
diff --git a/vcl/inc/IconThemeScanner.hxx b/vcl/inc/IconThemeScanner.hxx
new file mode 100644
index 000000000..3cbca74a4
--- /dev/null
+++ b/vcl/inc/IconThemeScanner.hxx
@@ -0,0 +1,92 @@
+/* -*- 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 INCLUDED_VCL_ICONTHEMESCANNER_HXX
+#define INCLUDED_VCL_ICONTHEMESCANNER_HXX
+
+#include <vcl/dllapi.h>
+
+#include <rtl/ustring.hxx>
+#include <vcl/IconThemeInfo.hxx>
+
+#include <memory>
+#include <vector>
+
+// forward declaration of unit test class. Required for friend relationship.
+class IconThemeScannerTest;
+
+namespace vcl {
+
+/** This class scans a folder for icon themes and provides the results.
+ */
+class VCL_DLLPUBLIC IconThemeScanner
+{
+public:
+ /** Factory method to create the object.
+ * Provide a path to search for IconThemes.
+ */
+ static std::shared_ptr<IconThemeScanner> Create(const OUString &path);
+
+ /** This method will return the standard path where icon themes are located.
+ */
+ static OUString
+ GetStandardIconThemePath();
+
+ const std::vector<IconThemeInfo>&
+ GetFoundIconThemes() const {return mFoundIconThemes;}
+
+ /** Get the IconThemeInfo for a theme.
+ * If the theme id is not among the found themes, a std::runtime_error will be thrown.
+ * Use IconThemeIsInstalled() to check whether it is available.
+ */
+ const IconThemeInfo& GetIconThemeInfo(const OUString& themeId);
+
+ /** Checks whether the theme with the provided name has been found in the
+ * scanned directory.
+ */
+ bool
+ IconThemeIsInstalled(const OUString& themeId) const;
+
+private:
+ IconThemeScanner();
+
+ /** Scan a directory for icon themes.
+ *
+ * @return
+ * There are several cases when this method will fail:
+ * - The directory does not exist
+ * - There are no files which match the pattern images_xxx.zip
+ */
+ void ScanDirectoryForIconThemes(const OUString &path);
+
+ /** Adds the provided icon theme by path.
+ */
+ bool
+ AddIconThemeByPath(const OUString &path);
+
+ /** Scans the provided directory for icon themes.
+ * The returned strings will contain the URLs to the icon themes.
+ */
+ static std::vector<OUString>
+ ReadIconThemesFromPath(const OUString& dir);
+
+ /** Check whether a single file is valid */
+ static bool
+ FileIsValidIconTheme(const OUString&);
+
+ std::vector<IconThemeInfo> mFoundIconThemes;
+
+ friend class ::IconThemeScannerTest;
+};
+
+} // end namespace vcl
+
+#endif // INCLUDED_VCL_ICONTHEMESCANNER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */