Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9.3, 2.0, and 2.0.1

stable qtlib: move findicon() to module scope

Also changed it to return None instead of fallback.svg.

Changeset 93553bb87e95

Parent a26ce41e8d78

by Yuya Nishihara

Changes to one file · Browse files at 93553bb87e95 Showing diff from parent a26ce41e8d78 Diff from another changeset...

 
249
250
251
 
 
 
 
 
 
 
 
 
 
 
252
253
254
 
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
 
278
279
280
 
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
 
271
272
273
 
 
 
 
 
 
 
 
 
 
 
274
275
276
 
277
278
279
280
@@ -249,6 +249,17 @@
   _iconcache = {}   +def _findicon(name): + # TODO: icons should be placed at single location before release + for pfx in (':/icons', os.path.join(paths.get_icon_path(), 'svg'), + paths.get_icon_path()): + for ext in ('svg', 'png', 'ico'): + path = '%s/%s.%s' % (pfx, name, ext) + if QFile.exists(path): + return QIcon(path) + + return None +  def geticon(name):   """   Return a QIcon for the specified name. (the given 'name' parameter @@ -260,21 +271,10 @@
  if QIcon.hasThemeIcon(name):   return QIcon.fromTheme(name)   - # TODO: icons should be placed at single location before release - def findicon(name): - for pfx in (':/icons', os.path.join(paths.get_icon_path(), 'svg'), - paths.get_icon_path()): - for ext in ('svg', 'png', 'ico'): - path = '%s/%s.%s' % (pfx, name, ext) - if QFile.exists(path): - return QIcon(path) - - return QIcon(':/icons/fallback.svg') -   try:   return _iconcache[name]   except KeyError: - _iconcache[name] = findicon(name) + _iconcache[name] = _findicon(name) or QIcon(':/icons/fallback.svg')   return _iconcache[name]    _pixmapcache = {}