예제 #1
0
    def __init__(self, main_window, menu, plugin):
        """
		Constructor

		Arguments:
		main_window -- the main window
		menu -- the menu into which the action should be inserted
		plugin -- the name of the plugin
		"""

        self.main_window = main_window
        icon = QtGui.QIcon(plugins.plugin_icon_large(plugin))
        self.plugin = plugin
        QtWidgets.QAction.__init__(self, icon, "Add %s" % plugin, menu)
        self.triggered.connect(self.add_plugin)
예제 #2
0
	def __init__(self, main_window, menu, plugin):

		"""
		Constructor

		Arguments:
		main_window -- the main window
		menu -- the menu into which the action should be inserted
		plugin -- the name of the plugin
		"""

		self.main_window = main_window
		icon = QtGui.QIcon(plugins.plugin_icon_large(plugin))
		self.plugin = plugin
		QtGui.QAction.__init__(self, icon, "Add %s" % plugin, menu)
		self.triggered.connect(self.add_plugin)
예제 #3
0
	def build(self):

		"""
		desc:
			Populates the toolbar with items.
		"""

		# This function is called first when no experiment has been loaded yet.
		try:
			self.experiment
		except:
			return
		self.clear()
		if self.orientation() == QtCore.Qt.Vertical:
			self.addWidget(toolbar_items_label(self, _(u'Commonly used')))
		# Add the core items
		self.add_content([toolbar_items_item(self, item) \
			for item in self.experiment.core_items])
		# Create a dictionary of plugins by category. We also maintain a list
		# to preserve the order of the categories.
		cat_dict = OrderedDict()
		for plugin in plugins.list_plugins():
			cat = plugins.plugin_category(plugin)
			if cat not in cat_dict:
				cat_dict[cat] = []
			cat_dict[cat].append(plugin)
		# Add the plugins
		for cat, cat_plugins in cat_dict.items():
			self.addSeparator()
			if self.orientation() == QtCore.Qt.Vertical:
				self.addWidget(toolbar_items_label(self, cat))
			content = []
			for plugin in cat_plugins:
				debug.msg(u"adding plugin '%s'" % plugin)
				pixmap = self.theme.qpixmap(plugins.plugin_icon_large(plugin))
				content.append(toolbar_items_item(self, plugin, pixmap))
			self.add_content(content)
예제 #4
0
    def build(self):
        """
		desc:
			Populates the toolbar with items.
		"""

        # This function is called first when no experiment has been loaded yet.
        try:
            self.experiment
        except:
            return
        self.clear()
        if self.orientation() == QtCore.Qt.Vertical:
            self.addWidget(toolbar_items_label(self, _(u'Commonly used')))
        # Add the core items
        self.add_content([toolbar_items_item(self, item) \
         for item in self.experiment.core_items])
        # Create a dictionary of plugins by category. We also maintain a list
        # to preserve the order of the categories.
        cat_dict = OrderedDict()
        for plugin in plugins.list_plugins():
            cat = plugins.plugin_category(plugin)
            if cat not in cat_dict:
                cat_dict[cat] = []
            cat_dict[cat].append(plugin)
        # Add the plugins
        for cat, cat_plugins in cat_dict.items():
            self.addSeparator()
            if self.orientation() == QtCore.Qt.Vertical:
                self.addWidget(toolbar_items_label(self, cat))
            content = []
            for plugin in cat_plugins:
                debug.msg(u"adding plugin '%s'" % plugin)
                pixmap = self.theme.qpixmap(plugins.plugin_icon_large(plugin))
                content.append(toolbar_items_item(self, plugin, pixmap))
            self.add_content(content)