Beispiel #1
0
    def load_extensions(self):
        """Load active extensions in topological order."""
        root = self.root_directory()
        if not root in sys.path:
            sys.path.append(root)

        for ext in [
                ext for ext in self._extensions_ordered
                if not ext in self.inactive_extensions()
        ]:
            try:
                # measure loading time
                start = perf_counter()
                # Try importing the module. Will fail here if there's
                # no Python module in the subdirectory or loading the module
                # produces errors
                module = importlib.import_module(ext)
                # Add extension's icons dir (if present) to icon search path
                icon_path = os.path.join(self.root_directory(), ext, 'icons')
                if os.path.isdir(icon_path):
                    search_paths = QDir.searchPaths('icons')
                    QDir.setSearchPaths('icons', [icon_path] + search_paths)
                # Instantiate the extension,
                # this will fail if the module is no valid extension
                # (doesn't have an Extension class) or has other errors in it
                extension = module.Extension(self, ext)
                end = perf_counter()
                extension.set_load_time("{:.2f} ms".format(
                    (end - start) * 1000))
                self._extensions[ext] = extension
            except Exception as e:
                self._failed_extensions[ext] = sys.exc_info()
Beispiel #2
0
    def load_extensions(self):
        """Load active extensions in topological order."""
        root = self.root_directory()
        if not root in sys.path:
            sys.path.append(root)

        for ext in [ext for ext  in self._extensions_ordered
            if not ext in self.inactive_extensions()]:
            try:
                # measure loading time
                start = perf_counter()
                # Try importing the module. Will fail here if there's
                # no Python module in the subdirectory or loading the module
                # produces errors
                module = importlib.import_module(ext)
                # Add extension's icons dir (if present) to icon search path
                icon_path = os.path.join(self.root_directory(), ext, 'icons')
                if os.path.isdir(icon_path):
                    search_paths = QDir.searchPaths('icons')
                    QDir.setSearchPaths('icons', [icon_path] + search_paths)
                # Instantiate the extension,
                # this will fail if the module is no valid extension
                # (doesn't have an Extension class) or has other errors in it
                extension = module.Extension(self, ext)
                end = perf_counter()
                extension.set_load_time(
                    "{:.2f} ms".format((end - start) * 1000))
                self._extensions[ext] = extension
            except Exception as e:
                self._failed_extensions[ext] = sys.exc_info()
Beispiel #3
0
def initialize():
    """Initialize support for the icons. Called on app startup."""

    # find the icons in this directory, after that also search in the included
    # icon theme folders (this fallback is used if the "Use system icons"
    # setting is enabled, but the system does not provide a certain icon.
    QIcon.setThemeSearchPaths(QIcon.themeSearchPaths() + __path__)
    d = __path__[0]
    path = []
    path.extend(__path__)
    for p in (os.path.join(d, 'TangoExt', 'scalable'),
              os.path.join(d, 'TangoExt'),
              os.path.join(d, 'Tango', 'scalable'),
              os.path.join(d, 'Tango')):
        if os.path.isdir(p):
            path.append(p)
    QDir.setSearchPaths("icons", path)

    update_theme()
Beispiel #4
0
def initialize():
    """Initialize support for the icons. Called on app startup."""

    # find the icons in this directory, after that also search in the included
    # icon theme folders (this fallback is used if the "Use system icons"
    # setting is enabled, but the system does not provide a certain icon.
    d = __path__[0]
    path = []
    path.extend(__path__)
    for p in (os.path.join(d, 'TangoExt',
                           'scalable'), os.path.join(d, 'TangoExt'),
              os.path.join(d, 'Tango', 'scalable'), os.path.join(d, 'Tango')):
        if os.path.isdir(p):
            path.append(p)
    QDir.setSearchPaths("icons", path)

    # use our icon theme (that builds on Tango) if there are no system icons
    if (not QIcon.themeName() or QIcon.themeName() == "hicolor"
            or not QSettings().value("system_icons", True, bool)):
        QIcon.setThemeSearchPaths(QIcon.themeSearchPaths() + __path__)
        QIcon.setThemeName("TangoExt")
Beispiel #5
0
def initialize():
    """Initialize support for the icons. Called on app startup."""

    # find the icons in this directory, after that also search in the included
    # icon theme folders (this fallback is used if the "Use system icons"
    # setting is enabled, but the system does not provide a certain icon.
    d = __path__[0]
    path = []
    path.extend(__path__)
    for p in (os.path.join(d, 'TangoExt', 'scalable'),
              os.path.join(d, 'TangoExt'),
              os.path.join(d, 'Tango', 'scalable'),
              os.path.join(d, 'Tango')):
        if os.path.isdir(p):
            path.append(p)
    QDir.setSearchPaths("icons", path)

    # use our icon theme (that builds on Tango) if there are no system icons
    if (not QIcon.themeName() or QIcon.themeName() == "hicolor"
        or not QSettings().value("system_icons", True, bool)):
        QIcon.setThemeSearchPaths(QIcon.themeSearchPaths() + __path__)
        QIcon.setThemeName("TangoExt")