def _get_color(self, color: Color) -> qg.QColor: qt_color = self._color_cache.get(color, None) if qt_color is None: if len(color) == 7: qt_color = qg.QColor(color) # '#RRGGBB' elif len(color) == 9: rgb = color[1:7] alpha = color[7:9] qt_color = qg.QColor(f"#{alpha}{rgb}") # '#AARRGGBB' else: raise TypeError(color) self._color_cache[color] = qt_color return qt_color
def drawForeground(self, painter: qg.QPainter, rect: qc.QRectF) -> None: if self._is_loading and self._loading_overlay: painter.save() painter.fillRect(rect, qg.QColor("#aa000000")) painter.setWorldMatrixEnabled(False) r = self.viewport().rect() painter.setBrush(qc.Qt.NoBrush) painter.setPen(qc.Qt.white) painter.drawText(r.center(), "Loading...") painter.restore()
def drawForeground(self, painter: qg.QPainter, rect: qc.QRectF) -> None: super().drawForeground(painter, rect) if self._selected_items: item = self._selected_items[self._selected_index] r = item.sceneTransform().mapRect(item.boundingRect()) painter.fillRect(r, qg.QColor(0, 255, 0, 100))