]> SALOME platform Git repositories - tools/eficas.git/blob - InterfaceQT/utilIcons.py
Salome HOME
CCAR: merge de la version 1.14 dans la branche principale
[tools/eficas.git] / InterfaceQT / utilIcons.py
1 # -*- coding: utf-8 -*-
2
3 from qt import QPixmap
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     def getPixmap(self, key):
17         """
18         Public method to retrieve a pixmap.
19         
20         @param key name of the wanted pixmap (string)
21         @return the requested pixmap (QPixmap)
22         """
23         try:
24             return self.pixmapCache[key]
25         except KeyError:
26             self.pixmapCache[key] = QPixmap.fromMimeSource(key)
27             return self.pixmapCache[key]
28             
29 pixCache = PixmapCache()
30
31 def getPixmap(key, cache = pixCache):
32     """
33     Module function to retrieve a pixmap.
34     
35     @param key name of the wanted pixmap (string)
36     @return the requested pixmap (QPixmap)
37     """
38     return cache.getPixmap(key)
39     
40     
41
42 from qt import QMimeSourceFactory
43
44 def initializeMimeSourceFactory():
45     """
46     Function to initialize the default mime source factory.
47     
48     """
49     defaultFactory = QMimeSourceFactory.defaultFactory()
50     repini=os.path.dirname(os.path.abspath(__file__))
51     defaultFactory.addFilePath(repini+"/../Editeur/icons") #CS_pbruno todo (config)
52