Gui: copy config file to resource directory

This commit is contained in:
wmayer
2020-03-16 23:44:06 +01:00
parent 570368ed73
commit 383ff0d5ca
4 changed files with 29 additions and 9 deletions

View File

@@ -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
)

View File

@@ -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)

View File

@@ -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;
};