@@ -70,7 +70,7 @@ static auto kde_get_theme() -> std::string const
|
||||
home + "/.config/kdedefaults/kdeglobals",
|
||||
};
|
||||
|
||||
for (auto p : paths) {
|
||||
for (auto const &p : paths) {
|
||||
std::ifstream f(p);
|
||||
if (!f)
|
||||
continue;
|
||||
@@ -326,9 +326,8 @@ IconTheme::IconTheme(std::filesystem::path const &themes_directory_path)
|
||||
}
|
||||
|
||||
IconRegistry::IconRegistry()
|
||||
: m_preferred_theme(get_current_icon_theme())
|
||||
{
|
||||
m_preferred_theme = get_current_icon_theme();
|
||||
|
||||
std::vector<std::filesystem::path> theme_directory_paths;
|
||||
|
||||
{
|
||||
@@ -346,21 +345,27 @@ IconRegistry::IconRegistry()
|
||||
| std::views::transform([](auto &&s) {
|
||||
return std::filesystem::path(s.begin(), s.end())
|
||||
/ "icons";
|
||||
})
|
||||
| std::views::filter([](auto &&p) {
|
||||
if (!std::filesystem::is_directory(p))
|
||||
return false;
|
||||
if (std::filesystem::directory_iterator(p)
|
||||
== std::filesystem::directory_iterator {})
|
||||
return false;
|
||||
return true;
|
||||
}),
|
||||
std::back_inserter(theme_directory_paths));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::filesystem::path const paths[] {
|
||||
std::array<std::filesystem::path, 3> const paths {
|
||||
"/usr/share/pixmaps",
|
||||
"/usr/local/share/icons",
|
||||
"/usr/share/icons",
|
||||
};
|
||||
for (auto const &path : paths) {
|
||||
if (std::filesystem::exists(path))
|
||||
theme_directory_paths.push_back(path);
|
||||
}
|
||||
std::copy_if(paths.begin(), paths.end(), theme_directory_paths.begin(),
|
||||
[](auto const path) { return std::filesystem::exists(path); });
|
||||
}
|
||||
|
||||
for (auto &&path : theme_directory_paths
|
||||
@@ -368,7 +373,7 @@ IconRegistry::IconRegistry()
|
||||
return std::filesystem::is_directory(path);
|
||||
})) {
|
||||
try {
|
||||
m_themes.push_back({ path });
|
||||
m_themes.push_back(IconTheme(path));
|
||||
} catch (...) {
|
||||
}
|
||||
}
|
||||
@@ -383,14 +388,8 @@ IconRegistry::IconRegistry()
|
||||
|
||||
std::stable_partition(
|
||||
m_themes.begin(), m_themes.end(), [&](auto const &t) {
|
||||
bool found { false };
|
||||
for (auto const &e : t.names()) {
|
||||
if (e == *m_preferred_theme) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return found;
|
||||
return std::any_of(t.names().begin(), t.names().end(),
|
||||
[&](auto const &e) { return e == *m_preferred_theme; });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user