Salome HOME
Issue #1309 Management of icons - corrections for PythonAddons plugin, to load icons...
[modules/shaper.git] / src / ModuleBase / ModuleBase_IconFactory.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModuleBase_IconFactory.h
4 // Created:     28 Jul 2015
5 // Author:      Vitaly SMETANNIKOV
6
7 #ifndef ModuleBase_IconFactory_H
8 #define ModuleBase_IconFactory_H
9
10 #include "ModuleBase.h"
11 #include <ModelAPI_Object.h>
12
13 #include <QPixmap>
14 #include <QIcon>
15 #include <QImage>
16
17 /**\class ModuleBase_IconFactory
18  * \ingroup GUI
19  * \brief This is a class which provides icons of objects for object browser 
20  */
21 class MODULEBASE_EXPORT ModuleBase_IconFactory
22 {
23 public:
24   /// Returns icons factory instance
25   static ModuleBase_IconFactory* get();
26
27   /// Returns Icon for the given object
28   /// \param theObj an object
29   virtual QIcon getIcon(ObjectPtr theObj);
30
31   /// Finds an icon for the given value. The icon is loaded: firstly from qrc file,
32   /// then by the icon path. If the path contains ":" , it will be treated as absolute path to
33   /// the icon, or relative path from the plugin library
34   /// \param theValue an icon information
35   /// \return a loaded or empty icon
36   static QIcon loadIcon(const QString& theValue);
37
38   /// Finds a pixmap for the given value. It is loaded: firstly from qrc file,
39   /// then by the absolute path. If the pixmap is not loaded, it is searched in relative plugin path
40   /// \param theValue a pixmap information
41   /// \return a loaded or empty pixmap
42   static QPixmap loadPixmap(const QString& theValue);
43
44   /// Finds an image for the given value. It is loaded: firstly from qrc file,
45   /// then by the absolute path. If the image is not loaded, it is searched in relative plugin path
46   /// \param theValue a image information
47   /// \return a loaded or empty pixmap
48   static QImage loadImage(const QString& theValue);
49
50 protected:
51   ModuleBase_IconFactory();
52
53   /// Set the current icons factory instance
54   /// \param theFactory a new factory
55   static void setFactory(ModuleBase_IconFactory* theFactory);
56 };
57
58 #endif