Package: python-taurus Version: 3.0.0-1 Severity: important Tags: patch all icons of taurus are included in Qt resources files,
the logic use to find the icons was wrong, relying on a tango-icons directory which is not installed during the build process. This makes all taurus programs almost unusable... The upstream fixed the problem to my request y exploring the Qt resource file instead of relying on the tango-icons directory -- System Information: Debian Release: 7.0 APT prefers unstable APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental') Architecture: i386 (i686) Kernel: Linux 3.2.0-4-486
From: =?UTF-8?q?Picca=20Fr=C3=A9d=C3=A9ric-Emmanuel?= <[email protected]> Date: Fri, 18 Jan 2013 21:13:40 +0100 Subject: upstream fix tango icon resources --- .../qt/qtgui/resource/taurus_resource_utils.py | 94 +++++++++----------- 1 file changed, 44 insertions(+), 50 deletions(-) diff --git a/lib/taurus/qt/qtgui/resource/taurus_resource_utils.py b/lib/taurus/qt/qtgui/resource/taurus_resource_utils.py index 5976544..42f8438 100644 --- a/lib/taurus/qt/qtgui/resource/taurus_resource_utils.py +++ b/lib/taurus/qt/qtgui/resource/taurus_resource_utils.py @@ -47,7 +47,6 @@ DevHealth = taurus.core.TaurusSWDevHealth Size = Qt.QSize __INITIALIZED = False -__INITIALIZED_THEME = False # Theme capacity was only added in Qt 4.6 __THEME_CAPACITY = hasattr(Qt.QIcon, "fromTheme") # Uncomment the following line to force NOT to use OS theme. @@ -66,60 +65,47 @@ __3DQS = Size(3*__DW, __DH) def __init(): global __INITIALIZED + global __THEME_MEMBERS if __INITIALIZED: return - + + #register only the tango-icons rcc files (and initialize the THEME_MEMBERS) res_dir = os.path.dirname(os.path.abspath(__file__)) Qt.QDir.addSearchPath("resource", res_dir) - - for res_file in [ f for f in os.listdir(res_dir) if f.endswith(".rcc") ]: - if not Qt.QResource.registerResource("resource:" + res_file): - __LOGGER.info("Failed to load resource %s" % res_file) + prefix = 'qrc_tango_icons_' + suffix = '.rcc' + lp, ls = len(prefix),len(suffix) + theme_members = {} + other_rcc_files = [] + for f in os.listdir(res_dir): + if f.endswith(suffix): + if f.startswith(prefix): + if Qt.QResource.registerResource("resource:" + f): + d = f[lp:-ls] + theme_members[d] = [str(e)[:-4] for e in Qt.QDir(":%s"%d).entryList() if str(e).endswith('.svg')] + else: + __LOGGER.info("Failed to load resource %s" % f) + else: + other_rcc_files.append(f) #we remember these and will register later + __THEME_MEMBERS = theme_members + + #register the rest of the resource files + for f in other_rcc_files: + if not Qt.QResource.registerResource("resource:" + f): + __LOGGER.info("Failed to load resource %s" % f) __INITIALIZED = True __init() -def __init_theme_members(): - global __INITIALIZED_THEME - global __THEME_MEMBERS - global __THEME_CAPACITY - global __LOGGER - - if __INITIALIZED_THEME: return __THEME_MEMBERS - - app = Qt.QApplication.instance() - if app is None and __THEME_CAPACITY: - raise Exception("Cannot calculate theme without QApplication instance") - - res_dir = os.path.dirname(os.path.abspath(__file__)) - theme_icon_dir = os.path.join(res_dir, "tango-icons") - members = {} - for d in os.listdir(theme_icon_dir): - abs_dir = os.path.join(theme_icon_dir, d) - if d[0] == "." or not os.path.isdir(abs_dir): - continue - elems = [] - for elem in os.listdir(abs_dir): - abs_elem = os.path.join(abs_dir, elem) - idx = elem.rfind(".svg") - if elem[0] == "." or idx < 0 or not os.path.isfile(abs_elem): - continue - elems.append(elem[:idx]) - members[d] = elems - - __THEME_MEMBERS = members - - __INITIALIZED_THEME = True - return __THEME_MEMBERS - def getThemeMembers(): """Returns the current icon theme elements :return: the current icon theme elements in a dictionary where each key is a group name and the value is a sequence of theme icon name. :rtype: dict<str,seq<str>>""" - return __init_theme_members() + global __THEME_MEMBERS + return __THEME_MEMBERS def getPixmap(key, size=None): """Returns a PyQt4.QtGui.QPixmap object for the given key and size @@ -168,13 +154,17 @@ def getThemePixmap(key, size=None): :return: (PyQt4.QtGui.QPixmap) a PyQt4.QtGui.QPixmap for the given key and size""" global __THEME_CAPACITY - if __THEME_CAPACITY and Qt.QIcon.hasThemeIcon(key): - size = size or 48 - return Qt.QIcon.fromTheme(key).pixmap(size, size) - + global __LOGGER + if __THEME_CAPACITY: + if Qt.QIcon.hasThemeIcon(key): + size = size or 48 + return Qt.QIcon.fromTheme(key).pixmap(size, size) + else: + __LOGGER.debug('Theme pixmap "%s" not supported. Trying to provide a fallback...',key) for member, items in getThemeMembers().items(): if not key in items: continue return getPixmap(":/%s/%s.svg" % (member, key), size) + __LOGGER.debug('Theme pixmap "%s" not supported.', key) return Qt.QPixmap() def getThemeIcon(key): @@ -192,12 +182,16 @@ def getThemeIcon(key): :return: (PyQt4.QtGui.QIcon) a PyQt4.QtGui.QIcon for the given key""" global __THEME_CAPACITY - if __THEME_CAPACITY and Qt.QIcon.hasThemeIcon(key): - return Qt.QIcon.fromTheme(key) - + global __LOGGER + if __THEME_CAPACITY: + if Qt.QIcon.hasThemeIcon(key): + return Qt.QIcon.fromTheme(key) + else: + __LOGGER.debug('Theme icon "%s" not supported. Trying to provide a fallback...',key) for member, items in getThemeMembers().items(): if not key in items: continue return Qt.QIcon(":/%s/%s.svg" % (member, key)) + __LOGGER.debug('Theme icon "%s" not supported.', key) return Qt.QIcon() def getStandardIcon(key, widget=None): @@ -205,7 +199,7 @@ def getStandardIcon(key, widget=None): QStyle.StandardPixmap enumeration member. The widget argument is optional and can also be used to aid the determination of the icon. - :param key: (QStyle.StandardPixmap) a standard pixmap which can follow some existing GUI style or guidelin + :param key: (QStyle.StandardPixmap) a standard pixmap which can follow some existing GUI style or guideline :param widget: (Qt.QWidget) the widget argument (optional) can also be used to aid the determination of the icon. :return: (PyQt4.QtGui.QIcon) a PyQt4.QtGui.QIcon for the given key""" @@ -220,7 +214,7 @@ def getStandardIcon(key, widget=None): __IDX_ELEM_TYPE_ICON, __IDX_ELEM_TYPE_SIZE, __IDX_ELEM_TYPE_TOOLTIP = range(3) # New default role map -# Elements are: icon theme, prefered size, description/tooltip +# Elements are: icon theme, preferred size, description/tooltip _ELEM_TYPE_MAP = { ElemType.Name : ("folder", __3DQS, None), ElemType.Device : ("applications-system", Size(210, __DH), "Tango device name"), ElemType.DeviceAlias : ("applications-system", Size(140, __DH), "Tango device alias"), @@ -354,4 +348,4 @@ def getSWDevHealthPixmap(elemHealth, size=None): if data is None: return themeName = data[__IDX_HEALTH_ICON] - return getThemePixmap(themeName, size) \ No newline at end of file + return getThemePixmap(themeName, size)

