]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_IconFactory.cpp
Salome HOME
Issue #2052: Modification of parameters don't work (sketch, extrusion)
[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   return QIcon(loadPixmap(theValue));
44 }
45
46 QPixmap ModuleBase_IconFactory::loadPixmap(const QString& theValue)
47 {
48   QPixmap aPixmap(theValue);
49
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);
55   }
56   return aPixmap;
57 }
58
59 QImage ModuleBase_IconFactory::loadImage(const QString& theValue)
60 {
61   QImage anImage(theValue);
62
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);
68   }
69   return anImage;
70 }