def setItem(self, item): """ Set the item to be created. :type item: studiolibrarymaya.BaseItem """ self._item = item self.ui.titleLabel.setText(item.NAME) self.ui.titleIcon.setPixmap(QtGui.QPixmap(item.typeIconPath())) if os.path.exists(item.imageSequencePath()): self.setThumbnailPath(item.imageSequencePath()) elif not item.isTHUMBNAIL_PATH(): self.setThumbnailPath(item.thumbnailPath()) schema = item.saveSchema() if schema: formWidget = studiolibrary.widgets.FormWidget(self) formWidget.setSchema(schema) formWidget.setValidator(item.saveValidator) # Used when overriding the item name = os.path.basename(item.path()) formWidget.setValues({"name": name}) self.ui.optionsFrame.layout().addWidget(formWidget) self._formWidget = formWidget formWidget.validate() else: self.ui.optionsFrame.setVisible(False)
def currentPixmap(self): """ Return the current frame as a QPixmap. :rtype: QtGui.QPixmap """ return QtGui.QPixmap(self.currentFilename())
def setItem(self, item): """ Set the item to be created. :type item: studiolibrarymaya.BaseItem """ self._item = item self.ui.titleLabel.setText(item.MenuName) self.ui.titleIcon.setPixmap(QtGui.QPixmap(item.TypeIconPath)) schema = item.saveSchema() if os.path.exists(item.imageSequencePath()): self.setThumbnailPath(item.imageSequencePath()) elif not item.isDefaultThumbnailPath(): self.setThumbnailPath(item.thumbnailPath()) if schema: formWidget = studiolibrary.widgets.FormWidget(self) formWidget.setSchema(schema) formWidget.setValidator(item.saveValidator) formWidget.setValues({"name": item.name()}) self.ui.optionsFrame.layout().addWidget(formWidget) self._formWidget = formWidget formWidget.validate() else: self.ui.optionsFrame.setVisible(False)
def __init__(self, item, parent=None): """ :type item: studiolibrarymaya.BaseItem :type parent: QtWidgets.QWidget or None """ QtWidgets.QWidget.__init__(self, parent) self.setObjectName("studioLibraryBaseLoadWidget") self.setWindowTitle("Load Item") self.loadUi() self._item = item self._iconPath = "" self._scriptJob = None self._formWidget = None self._infoFormWidget = None self.ui.titleLabel.setText(item.Name) self.ui.titleIcon.setPixmap(QtGui.QPixmap(item.typeIconPath())) # Create the icon group box groupBox = studiolibrary.widgets.GroupBoxWidget( "Icon", self.ui.iconFrame) groupBox.setObjectName("iconGroupBoxWidget") groupBox.setPersistent(True) self.ui.iconTitleFrame.layout().addWidget(groupBox) # Create the thumbnail widget and set the image self.ui.thumbnailButton = studiolibrary.widgets.ImageSequenceWidget( self) self.ui.thumbnailButton.setObjectName("thumbnailButton") self.ui.thumbnailFrame.layout().insertWidget(0, self.ui.thumbnailButton) if os.path.exists(item.imageSequencePath()): self.ui.thumbnailButton.setPath(item.imageSequencePath()) elif os.path.exists(item.thumbnailPath()): self.ui.thumbnailButton.setPath(item.thumbnailPath()) # Create the load widget and set the load schema self._formWidget = studiolibrary.widgets.FormWidget(self) self._formWidget.setObjectName(item.__class__.__name__ + "Form") self._formWidget.setSchema(item.loadSchema()) self._formWidget.setValidator(item.loadValidator) self._formWidget.validate() self.ui.formFrame.layout().addWidget(self._formWidget) try: self.selectionChanged() self.setScriptJobEnabled(True) except NameError as error: logger.exception(error) self.updateThumbnailSize() self._item.loadValueChanged.connect(self._itemValueChanged) self.ui.acceptButton.clicked.connect(self.accept) self.ui.selectionSetButton.clicked.connect(self.showSelectionSetsMenu)
def setValue(self, value): """ Set the path on disc for the image. :type value: str """ self._value = value self._pixmap = QtGui.QPixmap(value) self.update()
def typePixmap(self): """ Return the type pixmap for the plugin. :rtype: QtWidgets.QPixmap """ if not self._typePixmap: iconPath = self.typeIconPath() if iconPath and os.path.exists(iconPath): self._typePixmap = QtGui.QPixmap(iconPath) return self._typePixmap
def typePixmap(self): """ Return the type pixmap for the plugin. :rtype: QtWidgets.QPixmap """ path = self.typeIconPath() pixmap = self._TYPE_PIXMAP_CACHE.get(path) if not pixmap and path and os.path.exists(path): self._TYPE_PIXMAP_CACHE[path] = QtGui.QPixmap(path) return self._TYPE_PIXMAP_CACHE.get(path)
def _thumbnailFromImage(self, image): """ Called after the given image object has finished loading. :type image: QtGui.QImage :rtype: None """ self.clearCache() pixmap = QtGui.QPixmap() pixmap.convertFromImage(image) icon = QtGui.QIcon(pixmap) self._thumbnailIcon = icon if self.itemsWidget(): self.itemsWidget().update()
def createPixmap(self, path, color): """ Create a new Pixmap from the given path. :type path: str :type color: str or QtCore.QColor :rtype: QtCore.QPixmap """ dpi = self.treeWidget().dpi() key = path + color + "DPI-" + str(dpi) pixmap = self.PIXMAP_CACHE.get(key) if not pixmap: width = 20 * dpi height = 18 * dpi if "/" not in path and "\\" not in path: path = studiolibrary.resource.get("icons", path) if not os.path.exists(path): path = self.defaultIconPath() pixmap2 = studioqt.Pixmap(path) pixmap2.setColor(color) pixmap2 = pixmap2.scaled( 16 * dpi, 16 * dpi, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation ) x = (width - pixmap2.width()) / 2 y = (height - pixmap2.height()) / 2 pixmap = QtGui.QPixmap(QtCore.QSize(width, height)) pixmap.fill(QtCore.Qt.transparent) painter = QtGui.QPainter(pixmap) painter.drawPixmap(x, y, pixmap2) painter.end() self.PIXMAP_CACHE[key] = pixmap return pixmap
def __init__(self, item, *args): QtWidgets.QWidget.__init__(self, *args) studioqt.loadUi(self) self._item = item iconGroupBoxWidget = studiolibrary.widgets.GroupBoxWidget( "Icon", self.ui.iconGroup) iconGroupBoxWidget.setObjectName("iconGroupBoxWidget") iconGroupBoxWidget.setPersistent(True) self.ui.iconTitleFrame.layout().addWidget(iconGroupBoxWidget) self._infoWidget = studiolibrary.widgets.FormWidget(self) self._infoWidget.setSchema(item.info()) self.ui.infoFrame.layout().addWidget(self._infoWidget) self._formWidget = studiolibrary.widgets.FormWidget(self) schema = item.loadSchema() if schema: self._formWidget.setSchema(schema) self.ui.formFrame.layout().addWidget(self._formWidget) self.ui.acceptButton.hide() self.ui.acceptButton.setText("Load") self.ui.acceptButton.clicked.connect(self.accept) self.createSequenceWidget() if item.MenuName: self.ui.titleFrame.setVisible(True) self.ui.titleLabel.setText(item.MenuName) else: self.ui.titleFrame.setVisible(False) if item.TypeIconPath: self.ui.titleIcon.setVisible(True) self.ui.iconLabel.setPixmap(QtGui.QPixmap(item.TypeIconPath)) else: self.ui.titleIcon.setVisible(False) self.updateThumbnailSize()
def __init__(self, item, *args): QtWidgets.QWidget.__init__(self, *args) studioqt.loadUi(self) self._item = item iconGroupBoxWidget = studiolibrary.widgets.GroupBoxWidget("Icon", self.ui.iconGroup) iconGroupBoxWidget.setObjectName("iconGroupBoxWidget") iconGroupBoxWidget.setPersistent(True) self.ui.iconTitleFrame.layout().addWidget(iconGroupBoxWidget) self._formWidget = studiolibrary.widgets.FormWidget(self) self.ui.formFrame.layout().addWidget(self._formWidget) schema = item.loadSchema() if schema: self._formWidget.setSchema(item.loadSchema()) self._formWidget.setValidator(self.validator) self.ui.acceptButton.hide() self.ui.acceptButton.setText("Load") self.ui.acceptButton.clicked.connect(self.accept) self.createSequenceWidget() if item.NAME: self.ui.titleFrame.setVisible(True) self.ui.titleLabel.setText(item.NAME) else: self.ui.titleFrame.setVisible(False) if item.TYPE_ICON_PATH: self.ui.titleIcon.setVisible(True) self.ui.titleIcon.setPixmap(QtGui.QPixmap(item.TYPE_ICON_PATH)) else: self.ui.titleIcon.setVisible(False) self._item.dataChanged.connect(self._itemDataChanged) self.updateThumbnailSize()
def dragPixmap(self, item, items): """ Show the drag pixmap for the given item. :type item: studioqt.Item :type items: list[studioqt.Item] :rtype: QtGui.QPixmap """ rect = self.visualRect(self.indexFromItem(item)) pixmap = QtGui.QPixmap() pixmap = pixmap.grabWidget(self, rect) if len(items) > 1: cWidth = 35 cPadding = 5 cText = str(len(items)) cX = pixmap.rect().center().x() - float(cWidth / 2) cY = pixmap.rect().top() + cPadding cRect = QtCore.QRect(cX, cY, cWidth, cWidth) painter = QtGui.QPainter(pixmap) painter.setRenderHint(QtGui.QPainter.Antialiasing) painter.setPen(QtCore.Qt.NoPen) painter.setBrush(self.itemsWidget().backgroundSelectedColor()) painter.drawEllipse(cRect.center(), float(cWidth / 2), float(cWidth / 2)) font = QtGui.QFont('Serif', 12, QtGui.QFont.Light) painter.setFont(font) painter.setPen(self.itemsWidget().textSelectedColor()) painter.drawText(cRect, QtCore.Qt.AlignCenter, str(cText)) return pixmap