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: add support for scalable icons directory

It tries to conform the freedesktop's convention.

Changeset 8b93351c8e71

Parent 93553bb87e95

by Yuya Nishihara

Changes to 2 files · Browse files at 8b93351c8e71 Showing diff from parent 93553bb87e95 Diff from another changeset...

Change 1 of 1 Show Entire File icons/​README.txt Stacked
 
4
5
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
@@ -4,3 +4,31 @@
   This software may be used and distributed according to the terms of the  GNU General Public License version 2, incorporated herein by reference. + +Directory Structure +------------------- + +Icon files should be placed according to xdg-theme-like structure:: + + scalable/actions/*.svg ... icons for any size + 24x24/actions/*.png ...... fine-tuned bitmap icons (24x24) + *.ico .................... icons mainly used by shell extention or hgtk + +See also: +http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html + +Icon Naming +----------- + +- Commonly-used icon should have the same name as xdg icons, so that it + can be replaced by the system theme. + + e.g. `actions/document-new.svg`, `status/folder-open.svg` + +- Icon for Mercurial/TortoiseHg-specific operation should be prefixed by + `hg-` or `thg-`, in order to avoid conflict with the system theme. + + e.g. `actions/hg-incoming.svg`, `actions/thg-sync.svg` + +See also: +http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
 
260
261
262
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263
264
265
 
274
275
276
277
 
 
278
279
280
 
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
 
289
290
291
 
292
293
294
295
296
@@ -260,6 +260,21 @@
    return None   +# http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html +_SCALABLE_ICON_PATHS = [(QSize(), 'scalable/actions', '.svg'), + (QSize(22, 22), '22x22/actions', '.png'), + (QSize(24, 24), '24x24/actions', '.png')] + +def _findscalableicon(name): + """Find icon from qrc by using freedesktop-like icon lookup""" + o = QIcon() + for size, subdir, sfx in _SCALABLE_ICON_PATHS: + path = ':/icons/%s/%s%s' % (subdir, name, sfx) + if QFile.exists(path): + o.addFile(path, size) + if not o.isNull(): + return o +  def geticon(name):   """   Return a QIcon for the specified name. (the given 'name' parameter @@ -274,7 +289,8 @@
  try:   return _iconcache[name]   except KeyError: - _iconcache[name] = _findicon(name) or QIcon(':/icons/fallback.svg') + _iconcache[name] = (_findscalableicon(name) or _findicon(name) + or QIcon(':/icons/fallback.svg'))   return _iconcache[name]    _pixmapcache = {}