Loading pkgs/by-name/fr/freecad/0003-Gui-take-in-account-module-path-argument.patchdeleted 100644 → 0 +0 −149 Original line number Diff line number Diff line From 23ddb6ff148ec5c27da050ba0eb7a2e449b8450b Mon Sep 17 00:00:00 2001 From: Yury Shvedov <yury.shvedov@kaspersky.com> Date: Mon, 4 Nov 2024 14:22:22 +0300 Subject: [PATCH] Gui: take in account module-path argument Use paths passed with `--module-path` argument to search for preference packs Change-Id: If168dbd99a826757290ee6b918f5b712305fe2bb --- src/Gui/DlgPreferencePackManagementImp.cpp | 16 +++++---- src/Gui/PreferencePackManager.cpp | 39 +++++++++++++++++----- src/Gui/PreferencePackManager.h | 5 +++ 3 files changed, 44 insertions(+), 16 deletions(-) diff --git a/src/Gui/DlgPreferencePackManagementImp.cpp b/src/Gui/DlgPreferencePackManagementImp.cpp index a1a0dad41a..50f3982f21 100644 --- a/src/Gui/DlgPreferencePackManagementImp.cpp +++ b/src/Gui/DlgPreferencePackManagementImp.cpp @@ -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); + } } } } diff --git a/src/Gui/PreferencePackManager.cpp b/src/Gui/PreferencePackManager.cpp index dfc54240c0..83e32fa05e 100644 --- a/src/Gui/PreferencePackManager.cpp +++ b/src/Gui/PreferencePackManager.cpp @@ -30,6 +30,7 @@ #endif #include <boost/filesystem.hpp> +#include <boost/algorithm/string.hpp> #include <QDir> #include "PreferencePackManager.h" @@ -134,12 +135,11 @@ void PreferencePack::applyConfigChanges() const } PreferencePackManager::PreferencePackManager() + : _preferencePackPaths(modPaths()) { - auto modPath = fs::path(App::Application::getUserAppDataDir()) / "Mod"; auto savedPath = fs::path(App::Application::getUserAppDataDir()) / "SavedPreferencePacks"; auto resourcePath = fs::path(App::Application::getResourceDir()) / "Gui" / "PreferencePacks"; - _preferencePackPaths.push_back(resourcePath); - _preferencePackPaths.push_back(modPath); + _preferencePackPaths.insert(_preferencePackPaths.begin(), resourcePath); _preferencePackPaths.push_back(savedPath); rescan(); @@ -232,6 +232,26 @@ void Gui::PreferencePackManager::importConfig(const std::string& packName, rescan(); } +// TODO(Shvedov): Is this suitable place for this method? It is more generic, +// and maybe more suitable place at Application? +std::vector<boost::filesystem::path> Gui::PreferencePackManager::modPaths() const +{ + auto userModPath = fs::path(App::Application::getUserAppDataDir()) / "Mod"; + + auto& config = App::Application::Config(); + auto additionalModules = config.find("AdditionalModulePaths"); + std::vector<boost::filesystem::path> result; + + if (additionalModules != config.end()) { + boost::split(result, + additionalModules->second, + boost::is_any_of(";"), + boost::token_compress_on); + } + result.emplace_back(userModPath); + return result; +} + void Gui::PreferencePackManager::FindPreferencePacksInPackage(const fs::path &mod) { try { @@ -528,7 +548,6 @@ std::vector<PreferencePackManager::TemplateFile> PreferencePackManager::template // (alternate spellings are provided for packages using CamelCase and snake_case, and both major English dialects) auto resourcePath = fs::path(App::Application::getResourceDir()) / "Gui"; - auto modPath = fs::path(App::Application::getUserAppDataDir()) / "Mod"; std::string group = "Built-In"; if (fs::exists(resourcePath) && fs::is_directory(resourcePath)) { @@ -536,11 +555,13 @@ std::vector<PreferencePackManager::TemplateFile> PreferencePackManager::template std::copy(localFiles.begin(), localFiles.end(), std::back_inserter(_templateFiles)); } - if (fs::exists(modPath) && fs::is_directory(modPath)) { - for (const auto& mod : fs::directory_iterator(modPath)) { - group = mod.path().filename().string(); - const auto localFiles = scanForTemplateFiles(group, mod); - std::copy(localFiles.begin(), localFiles.end(), std::back_inserter(_templateFiles)); + for (const auto& modPath : modPaths()) { + if (fs::exists(modPath) && fs::is_directory(modPath)) { + for (const auto& mod : fs::directory_iterator(modPath)) { + group = mod.path().filename().string(); + const auto localFiles = scanForTemplateFiles(group, mod); + std::copy(localFiles.begin(), localFiles.end(), std::back_inserter(_templateFiles)); + } } } diff --git a/src/Gui/PreferencePackManager.h b/src/Gui/PreferencePackManager.h index 301e160df2..e5776e47a0 100644 --- a/src/Gui/PreferencePackManager.h +++ b/src/Gui/PreferencePackManager.h @@ -191,6 +191,11 @@ namespace Gui { */ void importConfig(const std::string &packName, const boost::filesystem::path &path); + /** + * Get a list of all mod directories. + */ + std::vector<boost::filesystem::path> modPaths() const; + private: void FindPreferencePacksInPackage(const boost::filesystem::path& mod); -- 2.44.1 pkgs/by-name/fr/freecad/package.nix +24 −9 Original line number Diff line number Diff line Loading @@ -6,11 +6,11 @@ doxygen, eigen, fetchFromGitHub, fetchpatch, fmt, gfortran, gts, hdf5, libf2c, libGLU, libredwg, libsForQt5, Loading @@ -37,6 +37,7 @@ qtVersion ? 5, qt5, qt6, nix-update-script, }: let inherit (python311Packages) Loading Loading @@ -64,13 +65,13 @@ in freecad-utils.makeCustomizable ( stdenv.mkDerivation (finalAttrs: { pname = "freecad"; version = "1.0.0"; version = "1.0.1"; src = fetchFromGitHub { owner = "FreeCAD"; repo = "FreeCAD"; rev = finalAttrs.version; hash = "sha256-u7RYSImUMAgKaAQSAGCFha++RufpZ/QuHAirbSFOUCI="; hash = "sha256-VFTNawXxu2ofjj2Frg4OfVhiMKFywBhm7lZunP85ZEQ="; fetchSubmodules = true; }; Loading @@ -80,6 +81,8 @@ freecad-utils.makeCustomizable ( ninja pkg-config gfortran swig doxygen wrapGAppsHook3 ] ++ lib.optionals (qtVersion == 5) [ Loading @@ -92,7 +95,6 @@ freecad-utils.makeCustomizable ( [ boost coin3d doxygen eigen fmt gitpython # for addon manager Loading @@ -100,7 +102,6 @@ freecad-utils.makeCustomizable ( hdf5 libGLU libXmu libf2c matplotlib medfile mpi Loading @@ -114,7 +115,6 @@ freecad-utils.makeCustomizable ( python pyyaml # (at least for) PyrateWorkbench scipy swig vtk xercesc yaml-cpp Loading Loading @@ -152,7 +152,10 @@ freecad-utils.makeCustomizable ( patches = [ ./0001-NIXOS-don-t-ignore-PYTHONPATH.patch ./0002-FreeCad-OndselSolver-pkgconfig.patch ./0003-Gui-take-in-account-module-path-argument.patch (fetchpatch { url = "https://github.com/FreeCAD/FreeCAD/commit/8e04c0a3dd9435df0c2dec813b17d02f7b723b19.patch?full_index=1"; hash = "sha256-H6WbJFTY5/IqEdoi5N+7D4A6pVAmZR4D+SqDglwS18c="; }) ]; cmakeFlags = Loading Loading @@ -206,11 +209,20 @@ freecad-utils.makeCustomizable ( postFixup = '' mv $out/share/doc $out ln -s $out/doc $out/share/doc ln -s $out/bin/FreeCAD $out/bin/freecad ln -s $out/bin/FreeCADCmd $out/bin/freecadcmd ''; passthru.tests = callPackage ./tests { }; passthru = { tests = callPackage ./tests { }; updateScript = nix-update-script { extraArgs = [ "--version-regex" "([0-9.]+)" ]; }; }; meta = { homepage = "https://www.freecad.org"; Loading @@ -232,7 +244,10 @@ freecad-utils.makeCustomizable ( right at home with FreeCAD. ''; license = lib.licenses.lgpl2Plus; maintainers = with lib.maintainers; [ srounce ]; maintainers = with lib.maintainers; [ srounce grimmauld ]; platforms = lib.platforms.linux; }; }) Loading Loading
pkgs/by-name/fr/freecad/0003-Gui-take-in-account-module-path-argument.patchdeleted 100644 → 0 +0 −149 Original line number Diff line number Diff line From 23ddb6ff148ec5c27da050ba0eb7a2e449b8450b Mon Sep 17 00:00:00 2001 From: Yury Shvedov <yury.shvedov@kaspersky.com> Date: Mon, 4 Nov 2024 14:22:22 +0300 Subject: [PATCH] Gui: take in account module-path argument Use paths passed with `--module-path` argument to search for preference packs Change-Id: If168dbd99a826757290ee6b918f5b712305fe2bb --- src/Gui/DlgPreferencePackManagementImp.cpp | 16 +++++---- src/Gui/PreferencePackManager.cpp | 39 +++++++++++++++++----- src/Gui/PreferencePackManager.h | 5 +++ 3 files changed, 44 insertions(+), 16 deletions(-) diff --git a/src/Gui/DlgPreferencePackManagementImp.cpp b/src/Gui/DlgPreferencePackManagementImp.cpp index a1a0dad41a..50f3982f21 100644 --- a/src/Gui/DlgPreferencePackManagementImp.cpp +++ b/src/Gui/DlgPreferencePackManagementImp.cpp @@ -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); + } } } } diff --git a/src/Gui/PreferencePackManager.cpp b/src/Gui/PreferencePackManager.cpp index dfc54240c0..83e32fa05e 100644 --- a/src/Gui/PreferencePackManager.cpp +++ b/src/Gui/PreferencePackManager.cpp @@ -30,6 +30,7 @@ #endif #include <boost/filesystem.hpp> +#include <boost/algorithm/string.hpp> #include <QDir> #include "PreferencePackManager.h" @@ -134,12 +135,11 @@ void PreferencePack::applyConfigChanges() const } PreferencePackManager::PreferencePackManager() + : _preferencePackPaths(modPaths()) { - auto modPath = fs::path(App::Application::getUserAppDataDir()) / "Mod"; auto savedPath = fs::path(App::Application::getUserAppDataDir()) / "SavedPreferencePacks"; auto resourcePath = fs::path(App::Application::getResourceDir()) / "Gui" / "PreferencePacks"; - _preferencePackPaths.push_back(resourcePath); - _preferencePackPaths.push_back(modPath); + _preferencePackPaths.insert(_preferencePackPaths.begin(), resourcePath); _preferencePackPaths.push_back(savedPath); rescan(); @@ -232,6 +232,26 @@ void Gui::PreferencePackManager::importConfig(const std::string& packName, rescan(); } +// TODO(Shvedov): Is this suitable place for this method? It is more generic, +// and maybe more suitable place at Application? +std::vector<boost::filesystem::path> Gui::PreferencePackManager::modPaths() const +{ + auto userModPath = fs::path(App::Application::getUserAppDataDir()) / "Mod"; + + auto& config = App::Application::Config(); + auto additionalModules = config.find("AdditionalModulePaths"); + std::vector<boost::filesystem::path> result; + + if (additionalModules != config.end()) { + boost::split(result, + additionalModules->second, + boost::is_any_of(";"), + boost::token_compress_on); + } + result.emplace_back(userModPath); + return result; +} + void Gui::PreferencePackManager::FindPreferencePacksInPackage(const fs::path &mod) { try { @@ -528,7 +548,6 @@ std::vector<PreferencePackManager::TemplateFile> PreferencePackManager::template // (alternate spellings are provided for packages using CamelCase and snake_case, and both major English dialects) auto resourcePath = fs::path(App::Application::getResourceDir()) / "Gui"; - auto modPath = fs::path(App::Application::getUserAppDataDir()) / "Mod"; std::string group = "Built-In"; if (fs::exists(resourcePath) && fs::is_directory(resourcePath)) { @@ -536,11 +555,13 @@ std::vector<PreferencePackManager::TemplateFile> PreferencePackManager::template std::copy(localFiles.begin(), localFiles.end(), std::back_inserter(_templateFiles)); } - if (fs::exists(modPath) && fs::is_directory(modPath)) { - for (const auto& mod : fs::directory_iterator(modPath)) { - group = mod.path().filename().string(); - const auto localFiles = scanForTemplateFiles(group, mod); - std::copy(localFiles.begin(), localFiles.end(), std::back_inserter(_templateFiles)); + for (const auto& modPath : modPaths()) { + if (fs::exists(modPath) && fs::is_directory(modPath)) { + for (const auto& mod : fs::directory_iterator(modPath)) { + group = mod.path().filename().string(); + const auto localFiles = scanForTemplateFiles(group, mod); + std::copy(localFiles.begin(), localFiles.end(), std::back_inserter(_templateFiles)); + } } } diff --git a/src/Gui/PreferencePackManager.h b/src/Gui/PreferencePackManager.h index 301e160df2..e5776e47a0 100644 --- a/src/Gui/PreferencePackManager.h +++ b/src/Gui/PreferencePackManager.h @@ -191,6 +191,11 @@ namespace Gui { */ void importConfig(const std::string &packName, const boost::filesystem::path &path); + /** + * Get a list of all mod directories. + */ + std::vector<boost::filesystem::path> modPaths() const; + private: void FindPreferencePacksInPackage(const boost::filesystem::path& mod); -- 2.44.1
pkgs/by-name/fr/freecad/package.nix +24 −9 Original line number Diff line number Diff line Loading @@ -6,11 +6,11 @@ doxygen, eigen, fetchFromGitHub, fetchpatch, fmt, gfortran, gts, hdf5, libf2c, libGLU, libredwg, libsForQt5, Loading @@ -37,6 +37,7 @@ qtVersion ? 5, qt5, qt6, nix-update-script, }: let inherit (python311Packages) Loading Loading @@ -64,13 +65,13 @@ in freecad-utils.makeCustomizable ( stdenv.mkDerivation (finalAttrs: { pname = "freecad"; version = "1.0.0"; version = "1.0.1"; src = fetchFromGitHub { owner = "FreeCAD"; repo = "FreeCAD"; rev = finalAttrs.version; hash = "sha256-u7RYSImUMAgKaAQSAGCFha++RufpZ/QuHAirbSFOUCI="; hash = "sha256-VFTNawXxu2ofjj2Frg4OfVhiMKFywBhm7lZunP85ZEQ="; fetchSubmodules = true; }; Loading @@ -80,6 +81,8 @@ freecad-utils.makeCustomizable ( ninja pkg-config gfortran swig doxygen wrapGAppsHook3 ] ++ lib.optionals (qtVersion == 5) [ Loading @@ -92,7 +95,6 @@ freecad-utils.makeCustomizable ( [ boost coin3d doxygen eigen fmt gitpython # for addon manager Loading @@ -100,7 +102,6 @@ freecad-utils.makeCustomizable ( hdf5 libGLU libXmu libf2c matplotlib medfile mpi Loading @@ -114,7 +115,6 @@ freecad-utils.makeCustomizable ( python pyyaml # (at least for) PyrateWorkbench scipy swig vtk xercesc yaml-cpp Loading Loading @@ -152,7 +152,10 @@ freecad-utils.makeCustomizable ( patches = [ ./0001-NIXOS-don-t-ignore-PYTHONPATH.patch ./0002-FreeCad-OndselSolver-pkgconfig.patch ./0003-Gui-take-in-account-module-path-argument.patch (fetchpatch { url = "https://github.com/FreeCAD/FreeCAD/commit/8e04c0a3dd9435df0c2dec813b17d02f7b723b19.patch?full_index=1"; hash = "sha256-H6WbJFTY5/IqEdoi5N+7D4A6pVAmZR4D+SqDglwS18c="; }) ]; cmakeFlags = Loading Loading @@ -206,11 +209,20 @@ freecad-utils.makeCustomizable ( postFixup = '' mv $out/share/doc $out ln -s $out/doc $out/share/doc ln -s $out/bin/FreeCAD $out/bin/freecad ln -s $out/bin/FreeCADCmd $out/bin/freecadcmd ''; passthru.tests = callPackage ./tests { }; passthru = { tests = callPackage ./tests { }; updateScript = nix-update-script { extraArgs = [ "--version-regex" "([0-9.]+)" ]; }; }; meta = { homepage = "https://www.freecad.org"; Loading @@ -232,7 +244,10 @@ freecad-utils.makeCustomizable ( right at home with FreeCAD. ''; license = lib.licenses.lgpl2Plus; maintainers = with lib.maintainers; [ srounce ]; maintainers = with lib.maintainers; [ srounce grimmauld ]; platforms = lib.platforms.linux; }; }) Loading