def defaultThumbnailIcon(self): """ Get the default thumbnail icon. :rtype: QtGui.QIcon """ return QtGui.QIcon(self.defaultThumbnailPath())
def setIcon(self, column, icon, color=None): """ Set the icon to be displayed in the given column. :type column: int or str :type icon: QtGui.QIcon :type color: QtGui.QColor or None :rtype: None """ # Safe guard for when the class is being used without the gui. isAppRunning = bool(QtWidgets.QApplication.instance()) if not isAppRunning: return if isinstance(icon, basestring): if not os.path.exists(icon): color = color or studioqt.Color(255, 255, 255, 20) icon = studiolibrary.resource.icon("image", color=color) else: icon = QtGui.QIcon(icon) if isinstance(column, basestring): self._icon[column] = icon else: self._pixmap[column] = None QtWidgets.QTreeWidgetItem.setIcon(self, column, icon) self.updateIcon()
def setBadge(self, x, y, w, h, color=None): """ Set a for the icon. :type x: int :type y: int :type w: int :type h: int :type color: QtGui.QColor or None """ color = color or QtGui.QColor(240, 100, 100) size = self.actualSize(QtCore.QSize(256, 256)) pixmap = self.pixmap(size) painter = QtGui.QPainter(pixmap) pen = QtGui.QPen(color) pen.setWidth(0) painter.setPen(pen) painter.setBrush(color) painter.setRenderHint(QtGui.QPainter.Antialiasing) painter.drawEllipse(x, y, w, h) painter.end() icon = QtGui.QIcon(pixmap) self.swap(icon)
def currentIcon(self): """ Returns the current frame as a QIcon. :rtype: QtGui.QIcon """ return QtGui.QIcon(self.currentFilename())
def selectContentAction(item, parent=None): """ :param item: mayabaseitem.MayaBaseItem :param parent: QtWidgets.QMenu """ arrowIcon = QtGui.QIcon(ARROW_ICON_PATH) action = QtWidgets.QAction(arrowIcon, "Select content", parent) action.triggered.connect(item.selectContent) return action
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 createAction(cls, menu, libraryWindow): """ Return the action to be displayed when the user ks the "plus" icon. :type menu: QtWidgets.QMenu :type libraryWindow: studiolibrary.LibraryWindow :rtype: QtCore.QAction """ if cls.NAME: icon = QtGui.QIcon(cls.ICON_PATH) callback = partial(cls.showSaveWidget, libraryWindow) action = QtWidgets.QAction(icon, cls.NAME, menu) action.triggered.connect(callback) return action
def setColor(self, color, size=None): """ :type color: QtGui.QColor :rtype: None """ icon = self size = size or icon.actualSize(QtCore.QSize(256, 256)) pixmap = icon.pixmap(size) if not self.isNull(): painter = QtGui.QPainter(pixmap) painter.setCompositionMode(QtGui.QPainter.CompositionMode_SourceIn) painter.setBrush(color) painter.setPen(color) painter.drawRect(pixmap.rect()) painter.end() icon = QtGui.QIcon(pixmap) self.swap(icon)
def thumbnailIcon(self): """ Return the thumbnail icon. :rtype: QtGui.QIcon """ thumbnailPath = self.thumbnailPath() if not self._thumbnailIcon: if self.ENABLE_THUMBNAIL_THREAD and not self._workerStarted: self._workerStarted = True self._worker.setPath(thumbnailPath) self.ThreadPool.start(self._worker) self._thumbnailIcon = self.defaultThumbnailIcon() else: self._thumbnailIcon = QtGui.QIcon(thumbnailPath) return self._thumbnailIcon
def __init__( self, item, parent=None, namespaces=None, enableSelectContent=True, ): """ :type item: studiolibrarymaya.BaseItem :type parent: QtWidgets.QMenu or None :type namespaces: list[str] or None :type enableSelectContent: bool """ parent = parent or item.libraryWindow() QtWidgets.QMenu.__init__(self, "Selection Sets", parent) icon = QtGui.QIcon(setsitem.SetsItem.ICON_PATH) self.setIcon(icon) self._item = item self._namespaces = namespaces self._enableSelectContent = enableSelectContent self.reload()