Salome HOME
CCAR: merge de la version 1.14 dans la branche principale
[tools/eficas.git] / InterfaceQT4 / utilIcons.py
1 # -*- coding: utf-8 -*-
2
3 from PyQt4.QtGui import QPixmap, QIcon
4 import os
5
6 class PixmapCache:
7     """
8     Class implementing a pixmap cache for icons.
9     """
10     def __init__(self):
11         """
12         Constructor
13         """
14         self.pixmapCache = {}
15
16
17     def getPixmap(self, key):
18         """
19         Public method to retrieve a pixmap.
20         
21         @param key name of the wanted pixmap (string)
22         @return the requested pixmap (QPixmap)
23         """
24         if (1==1):
25         #try:
26             key="/local/pnoyret/Install_Eficas/EficasV1/InterfaceQT/icons/"+key
27             return QPixmap(key)
28             #return self.pixmapCache[key]
29         #except KeyError:
30         else :
31             self.pixmapCache[key] = QPixmap.fromMimeSource(key)
32             return self.pixmapCache[key]
33             
34 pixCache = PixmapCache()
35
36 def getPixmap(key, cache = pixCache):
37     """
38     Module function to retrieve a pixmap.
39     
40     @param key name of the wanted pixmap (string)
41     @return the requested pixmap (QPixmap)
42     """
43     return cache.getPixmap(key)
44     
45 def getIcon(key):
46     key="/local/pnoyret/Install_Eficas/EficasV1/InterfaceQT/icons/"+key
47     return QIcon(key)
48     
49
50 #from PyQt4.Qt3Support import Q3MimeSourceFactory
51
52 #def initializeMimeSourceFactory():
53     """
54     Function to initialize the default mime source factory.
55     
56     """
57 #    defaultFactory = Q3MimeSourceFactory.defaultFactory()
58 #    repini=os.path.dirname(os.path.abspath(__file__))
59 #    defaultFactory.addFilePath(repini+"/../Editeur/icons") #CS_pbruno todo (config)
60