Example #1
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

		# Remove old items
		self.clear()

		if self.orientation() == QtCore.Qt.Vertical:
			self.addWidget(toolbar_items_label(self, u'Commonly used'))

		# Add the core items
		content = []
		for item in self.experiment.core_items:
			w = toolbar_items_item(self, item, self.theme.qpixmap(item,
				size=cfg.toolbar_size))
			content.append(w)
		self.add_content(content)

		# Create a dictionary of plugins by category. We also maintain a list
		# to preserve the order of the categories.
		cat_list = []
		cat_dict = {}
		for plugin in libopensesame.plugins.list_plugins():
			cat = libopensesame.plugins.plugin_category(plugin)
			if cat not in cat_dict:
				cat_dict[cat] = []
				cat_list.append(cat)
			cat_dict[cat].append(plugin)

		# Add the plugins
		for cat in cat_list:
			self.addSeparator()
			if self.orientation() == QtCore.Qt.Vertical:
				self.addWidget(toolbar_items_label(self, cat))
			content = []
			for plugin in cat_dict[cat]:
				debug.msg(u"adding plugin '%s'" % plugin)
				if cfg.toolbar_size == 16:
					pixmap = QtGui.QPixmap(
						libopensesame.plugins.plugin_icon_small(plugin))
				else:
					pixmap = QtGui.QPixmap(
						libopensesame.plugins.plugin_icon_large(plugin))
				w = toolbar_items_item(self, plugin, pixmap)
				content.append(w)
			self.add_content(content)
Example #2
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)
Example #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)