1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModuleBase_IconFactory.cpp
4 // Created: 28 Jul 2015
5 // Author: Vitaly SMETANNIKOV
7 #include "ModuleBase_IconFactory.h"
9 #include "Config_XMLReader.h"
13 ModuleBase_IconFactory* MYIconFactory = 0;
16 ModuleBase_IconFactory::ModuleBase_IconFactory()
21 void ModuleBase_IconFactory::setFactory(ModuleBase_IconFactory* theFactory)
25 MYIconFactory = theFactory;
28 ModuleBase_IconFactory* ModuleBase_IconFactory::get()
31 MYIconFactory = new ModuleBase_IconFactory();
36 QIcon ModuleBase_IconFactory::getIcon(ObjectPtr theIcon)
41 QIcon ModuleBase_IconFactory::loadIcon(const QString& theValue)
43 return QIcon(loadPixmap(theValue));
46 QPixmap ModuleBase_IconFactory::loadPixmap(const QString& theValue)
48 QPixmap aPixmap(theValue);
50 if (aPixmap.isNull()) {
51 std::string aPluginPath = Config_XMLReader::pluginConfigFile();
52 QString aPath = QString::fromStdString(aPluginPath) + QDir::separator() + theValue;
53 if (QFile::exists(aPath))
54 aPixmap = QPixmap(aPath);
59 QImage ModuleBase_IconFactory::loadImage(const QString& theValue)
61 QImage anImage(theValue);
63 if (anImage.isNull()) {
64 std::string aPluginPath = Config_XMLReader::pluginConfigFile();
65 QString aPath = QString::fromStdString(aPluginPath) + QDir::separator() + theValue;
66 if (QFile::exists(aPath))
67 anImage = QImage(aPath);