1 #include "SalomeApprc_utils.h"
3 void AddComponents_from_salomeappdir(const QDir& salomeappdir, SUIT_ResourceMgr* ResMgr)
5 QFileInfoList salomexd_list = salomeappdir.entryInfoList(QStringList() << "*.salomexd",QDir::Files);
6 foreach(QFileInfo filename, salomexd_list)
8 QFile file( filename.filePath() );
9 if ( !file.open( QFile::ReadOnly ) )
11 qWarning() << "file " << filename.fileName() << " is not accessible";
15 QJsonDocument document = QJsonDocument::fromJson( file.readAll() );
16 if ( document.isNull() )
18 qWarning() << "invalid json file. Filename: " << filename.fileName();
21 QJsonObject salomexd_dict = document.object();
22 QJsonValue components = salomexd_dict.value( "components");
24 QString root(salomeappdir.path() + "/__SALOME_EXT__");
25 if ( components.isArray() )
27 // In the case that we have a list of components. We consider that all of them are GUI module
28 foreach ( auto comp, components.toArray())
30 AddGuiComponent(comp.toString(), root, ResMgr);
35 // In the case that we have a dict of several component group
36 QJsonObject compObj = components.toObject();
37 foreach ( QString key, compObj.keys() )
39 if ( QString::compare(key, ITERACTIVE_EXTCOMPONENT_KEY) == 0 )
41 foreach (auto comp, compObj.value(key).toArray() )
42 AddGuiComponent(comp.toString(), root, ResMgr);
49 void AddComponents_from_salomemodules(const QString& salomemodules, const QDir& salomeappdir, SUIT_ResourceMgr* ResMgr)
51 QRegularExpression sep(":|,");
52 QStringList components_list = salomemodules.split(sep,QString::SkipEmptyParts);
53 foreach (QString comp, components_list)
55 QString comp_root_dir = Qtx::getenv(comp + "_ROOT_DIR");
58 qWarning() << comp_root_dir;
59 if (comp_root_dir.isEmpty())
60 comp_root_dir = salomeappdir.path() + "/__SALOME_EXT__";
61 AddGuiComponent(comp, comp_root_dir, ResMgr);
66 void AddGuiComponent(const QString& comp, const QString& CompRoot, SUIT_ResourceMgr* ResMgr)
68 QStringList CompsResMgr = ResMgr->stringValue("launch", "user_modules").split(";", QString::SkipEmptyParts);
69 ResMgr->setValue( "user_modules", comp, CompRoot );
72 CompsResMgr.removeDuplicates();
73 ResMgr->setValue( "launch", "user_modules", CompsResMgr.join( ";" ) );