From: nds Date: Fri, 15 Apr 2016 13:20:59 +0000 (+0300) Subject: #1309 Management of icons: parallel icon of SketchPlugin is loaded from it. X-Git-Tag: V_2.3.0~210 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=850c69a0ff7f33757ba655ac14efeb339dc2059e;p=modules%2Fshaper.git #1309 Management of icons: parallel icon of SketchPlugin is loaded from it. --- diff --git a/src/Config/Config_XMLReader.cpp b/src/Config/Config_XMLReader.cpp index c08238a08..11b2c5890 100644 --- a/src/Config/Config_XMLReader.cpp +++ b/src/Config/Config_XMLReader.cpp @@ -40,12 +40,9 @@ Config_XMLReader::Config_XMLReader(const std::string& theXmlFileName) * the problem: application may be launched using python executable, * to use environment variable (at least for the current moment) */ - if (prefix.empty()) { - char* anEnv = getenv("PLUGINS_CONFIG_FILE"); - if (anEnv) { - prefix = std::string(anEnv); - } - } + if (prefix.empty()) + prefix = pluginConfigFile(); + #ifdef WIN32 prefix += "\\"; #else @@ -62,6 +59,16 @@ Config_XMLReader::~Config_XMLReader() xmlFreeDoc(myXmlDoc); } +std::string Config_XMLReader::pluginConfigFile() +{ + std::string aValue; + char* anEnv = getenv("PLUGINS_CONFIG_FILE"); + if (anEnv) { + aValue = std::string(anEnv); + } + return aValue; +} + void Config_XMLReader::readAll() { xmlNodePtr aRoot = findRoot(); diff --git a/src/Config/Config_XMLReader.h b/src/Config/Config_XMLReader.h index 258af0cd5..c983e3a49 100644 --- a/src/Config/Config_XMLReader.h +++ b/src/Config/Config_XMLReader.h @@ -43,6 +43,11 @@ class Config_XMLReader */ CONFIG_EXPORT Config_XMLReader(const std::string& theXmlFile); CONFIG_EXPORT virtual ~Config_XMLReader(); + /*! + * Returns value of PLUGINS_CONFIG_FILE env variable, a path to the plugins.xml file + * \return string value + */ + CONFIG_EXPORT static std::string pluginConfigFile(); /*! * Read all nodes in associated xml file, * recursively if processChildren(xmlNode) is true for the xmlNode. diff --git a/src/ModuleBase/ModuleBase_IconFactory.cpp b/src/ModuleBase/ModuleBase_IconFactory.cpp index 479e681cc..2e8311e52 100644 --- a/src/ModuleBase/ModuleBase_IconFactory.cpp +++ b/src/ModuleBase/ModuleBase_IconFactory.cpp @@ -4,9 +4,12 @@ // Created: 28 Jul 2015 // Author: Vitaly SMETANNIKOV - #include "ModuleBase_IconFactory.h" +#include "Config_XMLReader.h" + +#include + ModuleBase_IconFactory* MYIconFactory = 0; @@ -37,11 +40,14 @@ QIcon ModuleBase_IconFactory::getIcon(ObjectPtr theIcon) QIcon ModuleBase_IconFactory::loadIcon(const QString& theValue) { - QIcon anIcon(theValue); - - if (anIcon.isNull()) { - + QPixmap aPixmap(theValue); + + if (aPixmap.isNull()) { + std::string aPluginPath = Config_XMLReader::pluginConfigFile(); + QString anIconPath = QString::fromStdString(aPluginPath) + QDir::separator() + + theValue; + if (QFile::exists(anIconPath)) + aPixmap = QPixmap(anIconPath); } - - return anIcon; + return QIcon(aPixmap); }