Changeset 8b93351c8e71…
Parent 93553bb87e95…
by
Changes to 2 files · Browse files at 8b93351c8e71 Showing diff from parent 93553bb87e95 Diff from another changeset...
@@ -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,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 = {}
|
Loading...