Gui: take in account module-path argument

Use paths passed with `--module-path` argument to search for preference
packs

Change-Id: If168dbd99a826757290ee6b918f5b712305fe2bb
This commit is contained in:
Yury Shvedov
2024-11-04 14:22:22 +03:00
committed by wwmayer
parent 960f4e4d63
commit 7a1ac850e2
3 changed files with 44 additions and 16 deletions

View File

@@ -54,7 +54,7 @@ void DlgPreferencePackManagementImp::showEvent(QShowEvent* event)
// but can only disable individual installed packs (though we can completely uninstall the pack's
// containing Addon by redirecting to the Addon Manager).
auto savedPreferencePacksDirectory = fs::path(App::Application::getUserAppDataDir()) / "SavedPreferencePacks";
auto modDirectory = fs::path(App::Application::getUserAppDataDir()) / "Mod";
auto modDirectories = Application::Instance->prefPackManager()->modPaths();
auto resourcePath = fs::path(App::Application::getResourceDir()) / "Gui" / "PreferencePacks";
// The displayed tree has two levels: at the toplevel is either "User-Saved Packs" or the name
@@ -66,12 +66,14 @@ void DlgPreferencePackManagementImp::showEvent(QShowEvent* event)
auto builtinPacks = getPacksFromDirectory(resourcePath);
std::map<std::string, std::vector<std::string>> installedPacks;
if (fs::exists(modDirectory) && fs::is_directory(modDirectory)) {
for (const auto& mod : fs::directory_iterator(modDirectory)) {
auto packs = getPacksFromDirectory(mod);
if (!packs.empty()) {
auto modName = mod.path().filename().string();
installedPacks.emplace(modName, packs);
for (const auto& modDirectory : modDirectories) {
if (fs::exists(modDirectory) && fs::is_directory(modDirectory)) {
for (const auto& mod : fs::directory_iterator(modDirectory)) {
auto packs = getPacksFromDirectory(mod);
if (!packs.empty()) {
auto modName = mod.path().filename().string();
installedPacks.emplace(modName, packs);
}
}
}
}