def addNewItem(self, name, icon=None): if not name in self.itemsListName: item = QListWidgetItem() if icon: item.setIcon(icon) item.setText(name) self.addItem(item) self.itemsList.append(item) self.itemsListName.append(name) return item
def addItemsCompleter(self, list_, icon=None): for text in list_: if not text in self.itemsListName: item = QListWidgetItem() if icon != None: item.setIcon(icon) item.setText(text) self.addItem(item) self.itemsList.append(item) self.itemsListName.append(item.text())
def createWidgets(self): self.listWidget = QListWidget() for row, (gid, name) in enumerate(self.state.model.normalGroups()): item = QListWidgetItem(name) item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsUserCheckable | Qt.ItemIsEnabled) item.setBackground(self.palette().base() if row % 2 else self.palette().alternateBase()) item.setCheckState(Qt.Unchecked) item.setData(Qt.UserRole, gid) item.setIcon(QIcon(":/groups.svg")) self.listWidget.addItem(item) self.tooltips.append((self.listWidget, "List of Normal Groups")) self.buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
def updateGroups(self): self.groupsList.clear() eid = self.state.viewAllPanel.view.selectedEid if eid is not None: for gid, name, linked in self.state.model.groupsForEid( eid, withLinks=True): item = QListWidgetItem(name) item.setData(Qt.UserRole, gid) item.setIcon( QIcon(":/grouplink.svg" if linked else ":/groups.svg")) self.groupsList.addItem(item) if self.groupsList.count(): self.groupsList.setCurrentRow(0) self.updateUi() self.state.viewFilteredPanel.groupChanged()
def __init__(self, obj=None): """Initialize task panel.""" self.form = Gui.PySideUic.loadUi(TASKPAGE) self.tabs = self.form.RenderTabs self.tabs.setCurrentIndex(0) self.layout = self.tabs.findChild(QFormLayout, "FieldsLayout") self.material_type_combo = self.form.findChild(QComboBox, "MaterialType") # Initialize material name combo self.material_combo = self.form.MaterialNameLayout.itemAt(0).widget() self.existing_materials = { obj.Label: obj for obj in App.ActiveDocument.Objects if is_valid_material(obj) } self.material_combo.addItems(list(self.existing_materials.keys())) self.material_combo.currentTextChanged.connect( self.on_material_name_changed) # Initialize material type combo # Note: itemAt(0) is label, itemAt(1) is combo self.material_type_combo = self.form.findChild(QComboBox, "MaterialType") material_type_set = [MaterialSettingsTaskPanel.NONE_MATERIAL_TYPE ] + list(STD_MATERIALS) self.material_type_combo.addItems(material_type_set) self.material_type_combo.currentTextChanged.connect( self.on_material_type_changed) self._set_layout_visible("FieldsLayout", False) self.fields = [] # Initialize Father layout self._set_layout_visible("FatherLayout", False) self.father_field = self.form.FatherLayout.itemAt(1).widget() # Initialize Passthru Renderers selector rdrwidget = self.form.findChild(QListWidget, "Renderers") for rdr in VALID_RENDERERS: item = QListWidgetItem() item.setText(rdr) item.setIcon(QIcon(os.path.join(ICONDIR, f"{rdr}.svg"))) rdrwidget.addItem(item) rdrwidget.setViewMode(QListView.IconMode) rdrwidget.setIconSize(QSize(48, 48)) rdrwidget.setMaximumWidth(96) rdrwidget.setSpacing(6) rdrwidget.setMovement(QListView.Static) rdrwidget.currentTextChanged.connect( self.on_passthrough_renderer_changed) self.passthru_rdr = rdrwidget self.passthru = self.form.findChild(QPlainTextEdit, "PassthroughEdit") self.passthru.textChanged.connect(self.on_passthrough_text_changed) self.passthru_cache = {} self._set_layout_visible("PassthruLayout", False) # Get selected material and initialize material type combo with it selection = {obj.Label for obj in Gui.Selection.getSelection()} selected_materials = selection & self.existing_materials.keys() try: selected_material = selected_materials.pop() except KeyError: pass else: self.material_combo.setCurrentText(selected_material)