From 383ff0d5caf779bf3c7af2250a0fadae2209cf58 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 16 Mar 2020 23:44:06 +0100 Subject: [PATCH] Gui: copy config file to resource directory --- src/Gui/{ => 3Dconnexion}/3DConnexion.xml | 0 src/Gui/CMakeLists.txt | 22 ++++++++++++++++++++-- src/Gui/DlgCustomizeSpaceball.cpp | 12 +++++++----- src/Gui/DlgCustomizeSpaceball.h | 4 ++-- 4 files changed, 29 insertions(+), 9 deletions(-) rename src/Gui/{ => 3Dconnexion}/3DConnexion.xml (100%) diff --git a/src/Gui/3DConnexion.xml b/src/Gui/3Dconnexion/3DConnexion.xml similarity index 100% rename from src/Gui/3DConnexion.xml rename to src/Gui/3Dconnexion/3DConnexion.xml diff --git a/src/Gui/CMakeLists.txt b/src/Gui/CMakeLists.txt index 1fe29e1f93..dc0ca11da2 100644 --- a/src/Gui/CMakeLists.txt +++ b/src/Gui/CMakeLists.txt @@ -1380,13 +1380,24 @@ set(FreeCADGui_Scripts RemoteDebugger.py ) +set(FreeCADGui_Configs + 3Dconnexion/3DConnexion.xml +) + add_custom_target(FreeCADGui_Resources ALL - SOURCES ${FreeCADGui_Scripts} + SOURCES ${FreeCADGui_Scripts} ${FreeCADGui_Configs} ) fc_copy_sources(FreeCADGui_Resources ${CMAKE_BINARY_DIR}/Ext/freecad/gui - ${FreeCADGui_Scripts}) + ${FreeCADGui_Scripts} +) + +fc_target_copy_resource(FreeCADGui_Resources + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR} + ${FreeCADGui_Configs} +) INSTALL( FILES @@ -1394,3 +1405,10 @@ INSTALL( DESTINATION Ext/freecad/gui ) + +INSTALL( + FILES + ${FreeCADGui_Configs} + DESTINATION + ${CMAKE_INSTALL_DATADIR}/3Dconnexion +) diff --git a/src/Gui/DlgCustomizeSpaceball.cpp b/src/Gui/DlgCustomizeSpaceball.cpp index c284a97c50..5dc9e3add7 100644 --- a/src/Gui/DlgCustomizeSpaceball.cpp +++ b/src/Gui/DlgCustomizeSpaceball.cpp @@ -78,11 +78,11 @@ void ButtonView::goChangedCommand(const QString& commandName) ButtonModel::ButtonModel(QObject *parent) : QAbstractListModel(parent) { - Load3DConnexionButtons("SpacePilot Pro"); + load3DConnexionButtons("SpacePilot Pro"); } // Process the given Mapping tree to load in the Button mappings. -void ButtonModel::Load3DConnexionButtonMapping(boost::property_tree::ptree ButtonMapTree) +void ButtonModel::load3DConnexionButtonMapping(boost::property_tree::ptree ButtonMapTree) { spaceballButtonGroup()->Clear(); @@ -136,7 +136,7 @@ void ButtonModel::Load3DConnexionButtonMapping(boost::property_tree::ptree Butto // Optionally preload Button model with 3DConnexion configuration to match Solidworks // For now the Button mapping file (3DConnexion.xml) is held the same folder as the FreeCAD executable. -void ButtonModel::Load3DConnexionButtons(const char *RequiredDeviceName) +void ButtonModel::load3DConnexionButtons(const char *RequiredDeviceName) { try { @@ -144,7 +144,9 @@ void ButtonModel::Load3DConnexionButtons(const char *RequiredDeviceName) boost::property_tree::ptree DeviceTree; // exception thrown if no file found - read_xml("3DConnexion.xml", tree); + std::string path = App::Application::getResourceDir(); + path += "3Dconnexion/3DConnexion.xml"; + read_xml(path.c_str(), tree); BOOST_FOREACH(const boost::property_tree::ptree::value_type &ButtonMap, tree.get_child("")) { @@ -173,7 +175,7 @@ void ButtonModel::Load3DConnexionButtons(const char *RequiredDeviceName) // If we found the required devices ButtonMap if (!DeviceTree.empty()) { - Load3DConnexionButtonMapping(DeviceTree); + load3DConnexionButtonMapping(DeviceTree); } } catch (const std::exception& e) diff --git a/src/Gui/DlgCustomizeSpaceball.h b/src/Gui/DlgCustomizeSpaceball.h index b46780071f..234fb9012e 100644 --- a/src/Gui/DlgCustomizeSpaceball.h +++ b/src/Gui/DlgCustomizeSpaceball.h @@ -67,8 +67,8 @@ namespace Gui void goMacroRemoved(const QByteArray& macroName); void goClear(); private: - void Load3DConnexionButtonMapping(boost::property_tree::ptree ButtonMapTree); - void Load3DConnexionButtons(const char *RequiredDeviceName); + void load3DConnexionButtonMapping(boost::property_tree::ptree ButtonMapTree); + void load3DConnexionButtons(const char *RequiredDeviceName); ParameterGrp::handle spaceballButtonGroup() const; QString getLabel(const int &number) const; };