def _populate_layer_list(self): self.layers.blockSignals(True) self.layers.clear() for layer in self._render_context.layers.values(): name = layer.layer item = qw.QListWidgetItem() self.layers.addItem(item) checkbox = qw.QCheckBox(name) checkbox.setCheckState(qc.Qt.Checked if layer.is_visible else qc.Qt.Unchecked) checkbox.stateChanged.connect(self._layers_updated) text_color = '#FFFFFF' if is_dark_color(layer.color, 0.4) else '#000000' checkbox.setStyleSheet(f'color: {text_color}; background-color: {layer.color}') self.layers.setItemWidget(item, checkbox) self.layers.blockSignals(False)
def _populate_layer_list(self): self.layers.blockSignals(True) self.layers.clear() for layer in self._render_context.layers.values(): name = layer.layer item = qw.QListWidgetItem(name) item.setCheckState(qc.Qt.Checked) item.setBackground(qg.QColor(layer.color)) if is_dark_color(layer.color, 0.4): item.setForeground(qg.QColor('#FFFFFF')) else: item.setForeground(qg.QColor(qg.QColor('#000000'))) self.layers.addItem(item) self.layers.blockSignals(False)