def setIconColor(self, color): """ Set the icon color for the search widget icon. :type color: QtGui.QColor :rtype: None """ icon = self._iconButton.icon() icon = studioqt.Icon(icon) icon.setColor(color) self._iconButton.setIcon(icon) icon = self._clearButton.icon() icon = studioqt.Icon(icon) icon.setColor(color) self._clearButton.setIcon(icon)
def setIconColor(self, color): """ Set the icon colors to the current foregroundRole. :type color: QtGui.QColor :rtype: None """ for action in self.actions(): icon = action.icon() icon = studioqt.Icon(icon) icon.setColor(color) action.setIcon(icon)
def thumbnailIcon(self): """ Overriding this method add support for dynamic icon colors. :rtype: QtGui.QIcon """ customPath = self.customIconPath() if customPath and "/" not in customPath and "\\" not in customPath: customPath = studiolibrary.resource.get("icons", customPath) color = self.iconColor() if not color: color = self.DEFAULT_ICON_COLOR key = customPath + color icon = self._THUMBNAIL_ICON_CACHE.get(key) if not icon: color1 = studioqt.Color.fromString(color) pixmap1 = studioqt.Pixmap(self.THUMBNAIL_PATH) pixmap1.setColor(color1) pixmap1 = pixmap1.scaled( 128, 128, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation ) color2 = studioqt.Color.fromString("rgb(255,255,255,150)") pixmap2 = studioqt.Pixmap(customPath) pixmap2.setColor(color2) pixmap2 = pixmap2.scaled( 64, 64, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation ) x = (128 - pixmap2.width()) / 2 y = (128 - pixmap2.height()) / 2 painter = QtGui.QPainter(pixmap1) painter.drawPixmap(x, y+5, pixmap2) painter.end() icon = studioqt.Icon(pixmap1) self._THUMBNAIL_ICON_CACHE[key] = icon return self._THUMBNAIL_ICON_CACHE.get(key)
def updateIconColor(self): """ Update the icon colors to the current foregroundRole. :rtype: None """ color = self.palette().color(self._iconButton.foregroundRole()) color = studioqt.Color.fromColor(color) icon = self._iconButton.icon() icon = studioqt.Icon(icon) icon.setColor(color) self._iconButton.setIcon(icon)
def thumbnailIcon(self): """ Overriding this method add support for dynamic icon colors. :rtype: QtGui.QIcon """ path = studiolibrary.resource.get("icons/folder_item.png") icon = studioqt.Icon(path) if self.iconColor(): color = studioqt.Color.fromString(self.iconColor()) icon.setColor(color) return icon
def setIconColor(self, color): for action in self.actions(): icon = action.icon() icon = studioqt.Icon(icon) icon.setColor(color) action.setIcon(icon)