Salome HOME
2e8311e523940c4cffed70404601dc48a820ffad
[modules/shaper.git] / src / ModuleBase / ModuleBase_IconFactory.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModuleBase_IconFactory.cpp
4 // Created:     28 Jul 2015
5 // Author:      Vitaly SMETANNIKOV
6
7 #include "ModuleBase_IconFactory.h"
8
9 #include "Config_XMLReader.h"
10
11 #include <QDir>
12
13 ModuleBase_IconFactory* MYIconFactory = 0;
14
15
16 ModuleBase_IconFactory::ModuleBase_IconFactory()
17 {
18   setFactory(this);
19 }
20
21 void ModuleBase_IconFactory::setFactory(ModuleBase_IconFactory* theFactory)
22 {
23   if (MYIconFactory)
24     delete MYIconFactory;
25   MYIconFactory = theFactory;
26 }
27
28 ModuleBase_IconFactory* ModuleBase_IconFactory::get()
29 {
30   if (!MYIconFactory) {
31     MYIconFactory = new ModuleBase_IconFactory();
32   }
33   return MYIconFactory;
34 }
35
36 QIcon ModuleBase_IconFactory::getIcon(ObjectPtr theIcon)
37 {
38   return QIcon();
39 }
40
41 QIcon ModuleBase_IconFactory::loadIcon(const QString& theValue)
42 {
43   QPixmap aPixmap(theValue);
44
45   if (aPixmap.isNull()) {
46     std::string aPluginPath = Config_XMLReader::pluginConfigFile();
47     QString anIconPath = QString::fromStdString(aPluginPath) + QDir::separator() +
48                          theValue;
49     if (QFile::exists(anIconPath))
50       aPixmap = QPixmap(anIconPath);
51   }
52   return QIcon(aPixmap);
53 }