Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

qtlib: now geticon() searches common icons path

Changeset e6d11086aee9

Parent 58867a469288

by Yuya Nishihara

Changes to one file · Browse files at e6d11086aee9 Showing diff from parent 58867a469288 Diff from another changeset...

 
14
15
16
17
 
18
19
20
 
149
150
151
152
153
 
 
 
 
 
154
 
155
156
157
158
159
 
 
 
 
 
160
161
162
 
14
15
16
 
17
18
19
20
 
149
150
151
 
 
152
153
154
155
156
157
158
159
 
 
 
 
160
161
162
163
164
165
166
167
@@ -14,7 +14,7 @@
 from PyQt4 import Qsci  from mercurial import extensions, util   -from tortoisehg.util import hglib +from tortoisehg.util import hglib, paths  from tortoisehg.hgqt.i18n import _  from hgext.color import _styles   @@ -149,14 +149,19 @@
   def geticon(name):   """ - Return a QIcon for the resource named 'name.(svg|png)' (the given - 'name' parameter must *not* provide the extension). + Return a QIcon for the specified name. (the given 'name' parameter + must *not* provide the extension). + + This searches for the icon from Qt resource or icons directory, + named as 'name.(svg|png|ico)'.   """ + # TODO: icons should be placed at single location before release   def findicon(name): - for ext in ('svg', 'png', 'ico'): - path = ':/icons/%s.%s' % (name, ext) - if QtCore.QFile.exists(path): - return QtGui.QIcon(path) + for pfx in (':/icons', paths.get_icon_path()): + for ext in ('svg', 'png', 'ico'): + path = '%s/%s.%s' % (pfx, name, ext) + if QtCore.QFile.exists(path): + return QtGui.QIcon(path)     return QtGui.QIcon(':/icons/fallback.svg')