def setColor(self, color): """ Sets the icon and color for this item. @param color QColor instance @return None """ self.color = color self.setIcon(colorIcon(color))
def setupColors(self): """ Configures the colors and icons of the message type items. """ getValue = self.settings.value defaultColor = QColor(0, 0, 0) brushItems = [(name, getValue('%s/color' % name, defaultColor)) for name in messageTypeNames()] self.brushMap = brushMap = dict(brushItems) items = self.messageTypeDisplay.listItems() for item in items: color = QColor(brushMap[str(item.text())]) item.setData(Qt.DecorationRole, QVariant(color)) item.setIcon(colorIcon(color))
def setupColors(self): """ Configures the colors and icons of the message type items. """ getValue = self.settings.value defaultColor = QColor(0,0,0) brushItems = [(name, getValue('%s/color' % name, defaultColor)) for name in messageTypeNames()] self.brushMap = brushMap = dict(brushItems) items = self.messageTypeDisplay.listItems() for item in items: color = QColor(brushMap[str(item.text())]) item.setData(Qt.DecorationRole, QVariant(color)) item.setIcon(colorIcon(color))
def on_typesList_itemDoubleClicked(self, item): """ Displays a dialog for selecting the color of a message type. If the user selects a new color, we update the type list icon and color, the message table foreground, and possibly the message detail foreground. """ currentColor = QColor(item.data(Qt.DecorationRole)) newColor = QColorDialog.getColor(currentColor, self) if newColor.isValid(): item.setData(Qt.DecorationRole, QVariant(newColor)) item.setIcon(colorIcon(newColor)) self.brushMap[str(item.text())] = itemBrush = QBrush(newColor) self.messagesModel.reset() self.settings.setValue('%s/color' % item.text(), newColor) messageDetail = self.messageDetail typeItem = messageDetail.item(1, 1) # yuk if typeItem.text() == item.text(): for row in range(messageDetail.rowCount()): for col in range(messageDetail.columnCount()): item = messageDetail.item(row, col) item.setForeground(itemBrush)
def setColor(o, v): o.color = color = QColor(v) o.setIcon(colorIcon(color))
def selector(self): widget = getattr(self, target) color = QColorDialog.getColor(widget.color, self) if color.isValid(): widget.color = color widget.setIcon(colorIcon(color))