Ejemplo n.º 1
0
    def paintEvent(self, event):
        """
        Render the UI.
        """
        if self._mode == self.MODE_OFF:
            return
        
        painter = QtGui.QPainter()
        painter.begin(self)
        try:
            # set up semi transparent backdrop
            painter.setRenderHint(QtGui.QPainter.Antialiasing)
            overlay_color = QtGui.QColor(30, 30, 30, 100)
            painter.setBrush( QtGui.QBrush(overlay_color))
            painter.setPen(QtGui.QPen(overlay_color))
            painter.drawRect(0, 0, painter.device().width(), painter.device().height())

            # show the spinner
            painter.translate((painter.device().width() / 2) - 10, 
                              (painter.device().height() / 2) - 10)
            
            pen = QtGui.QPen(QtGui.QColor(self._bundle.style_constants["SG_HIGHLIGHT_COLOR"]))
            pen.setWidth(1)
            painter.setPen(pen)

            r = QtCore.QRectF(0.0, 0.0, 20.0, 20.0)
            start_angle = (0 + self._spin_angle) * 4 * 16
            span_angle = 340 * 16 

            painter.drawArc(r, start_angle, span_angle)
            
        finally:
            painter.end()
Ejemplo n.º 2
0
    def paint(self, painter, style_options, model_index):
        """
        Paint method to handle all cells that are not being currently edited.

        :param painter:         The painter instance to use when painting
        :param style_options:   The style options to use when painting
        :param model_index:     The index in the data model that needs to be painted
        """
        sg_item = shotgun_model.get_sg_data(model_index)

        original_tn = model_index.data(self._ORIGINAL_THUMBNAIL)
        pinned_tn = model_index.data(self._PINNED_THUMBNAIL)
        filter_tn = model_index.data(self._FILTER_THUMBNAIL)

        # for performance reasons, we are not creating a widget every time
        # but merely moving the same widget around.
        paint_widget = self._get_painter_widget(model_index, self.parent())
        if not paint_widget:
            # just paint using the base implementation:
            QtGui.QStyledItemDelegate.paint(self, painter, style_options,
                                            model_index)
            return

        # make sure that the widget that is just used for painting isn't visible otherwise
        # it'll appear in the wrong place!
        paint_widget.setVisible(False)

        # call out to have the widget set the right values
        self._on_before_paint(paint_widget, model_index, style_options)

        # now paint!
        painter.save()
        try:
            paint_widget.resize(style_options.rect.size())
            painter.translate(style_options.rect.topLeft())
            # note that we set the render flags NOT to render the background of the widget
            # this makes it consistent with the way the editor widget is mounted inside
            # each element upon hover.

            paint_widget.render(painter,
                                QtCore.QPoint(0, 0),
                                renderFlags=QtGui.QWidget.DrawChildren)

            if self.tray_view.rv_mode.index_is_pinned(model_index.row()):
                painter.drawPixmap(
                    paint_widget.width() - self.pin_pixmap.width(), 0,
                    self.pin_pixmap)

            if not sg_item.get('version.Version.id') and not sg_item.get(
                    'image') and not sg_item.get(
                        'cut.Cut.version.Version.image'):
                target = QtCore.QRectF(0.0, 0.0, paint_widget.width(),
                                       paint_widget.height())
                source = QtCore.QRectF(0, 0, self.missing_pixmap.width(),
                                       self.missing_pixmap.height())
                # painter.drawPixmap(target, self.missing_pixmap, source)
                painter.fillRect(0, 0, paint_widget.width(),
                                 paint_widget.height(),
                                 QtGui.QColor(10, 0, 0, 255))
                painter.drawText(
                    0, 5, 100, 100,
                    QtCore.Qt.AlignHCenter | QtCore.Qt.AlignCenter, 'MISSING')

            mini_data = self.tray_view.rv_mode.cached_mini_cut_data

            if mini_data.active and painter:
                if mini_data.focus_clip == model_index.row():
                    painter.setPen(self._pen)
                    ws = paint_widget.size()
                    painter.drawRect(1, 1, ws.width() - 2, ws.height() - 2)

                if mini_data.first_clip > model_index.row(
                ) or mini_data.last_clip < model_index.row():
                    painter.fillRect(0, 0, paint_widget.width(),
                                     paint_widget.height(),
                                     QtGui.QColor(0, 0, 0, 220))

        finally:
            painter.restore()