コード例 #1
0
ファイル: AQS.py プロジェクト: deavid/pineboo
    def ColorDialog_getColor(self, color=None, parent=None, name=None):
        from PyQt5.QtWidgets import QColorDialog
        from PyQt5.QtGui import QColor

        if color is None:
            color = QColor.black()

        if isinstance(color, str):
            color = QColor()

        cL = QColorDialog(color, parent)
        return cL.getColor()
コード例 #2
0
    def ColorDialog_getColor(self, color=None, parent=None, name=None):
        from PyQt5.QtWidgets import QColorDialog
        from PyQt5.QtGui import QColor

        if color is None:
            color = QColor.black()

        if isinstance(color, str):
            color = QColor()

        cL = QColorDialog(color, parent)
        return cL.getColor()
コード例 #3
0
    def paintEvent(self, event):
        if self.fScene is None:
            QFrame.paintEvent(self, event)
            return

        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing,
                              bool(options.antialiasing == ANTIALIASING_FULL))

        # Brightness-aware out-of-canvas shading
        bg_color = self.fViewBg
        bg_black = bg_color.black()
        bg_shade = -12 if bg_black < 127 else 12
        r, g, b, _ = bg_color.getRgb()
        bg_color = QColor(r + bg_shade, g + bg_shade, b + bg_shade)

        frameWidth = self.fFrameWidth
        if self.fUseCustomPaint:
            # Inner shadow
            color = QColor.fromHsv(40, 0,
                                   255 - max(210, bg_color.black(), bg_black))
            painter.setBrush(Qt.transparent)
            painter.setPen(color)
            painter.drawRect(
                QRectF(0.5, 0.5,
                       self.width() - 1,
                       self.height() - 1))

            # Background
            painter.setBrush(bg_color)
            painter.setPen(bg_color)
            painter.drawRect(
                QRectF(1.5, 1.5,
                       self.width() - 3,
                       self.height() - 3))
        else:
            use_rounding = int(frameWidth > 1)

            rounding = 0.5 * use_rounding
            painter.setBrush(bg_color)
            painter.setPen(bg_color)
            painter.drawRoundedRect(
                QRectF(0.5 + frameWidth, 0.5 + frameWidth,
                       self.width() - 1 - frameWidth * 2,
                       self.height() - 1 - frameWidth * 2), rounding, rounding)

            clipPath = QPainterPath()
            rounding = 1.0 * use_rounding
            clipPath.addRoundedRect(
                QRectF(frameWidth, frameWidth,
                       self.width() - frameWidth * 2,
                       self.height() - frameWidth * 2), rounding, rounding)
            painter.setClipPath(clipPath)

        self.fScene.render(painter, self.fRenderTarget, self.fRenderSource,
                           Qt.KeepAspectRatio)

        # Allow cursor frame to look joined with minicanvas frame
        painter.setClipping(False)

        width = self.fViewRect[self._kRectWidth] / self.fScale
        height = self.fViewRect[self._kRectHeight] / self.fScale

        # cursor
        lineHinting = self.fViewPen.widthF() / 2
        x = self.fViewRect[self._kRectX] + self.fInitialX
        y = self.fViewRect[self._kRectY] + self.fInitialY
        scr_x = floor(x)
        scr_y = floor(y)
        rect = QRectF(scr_x + lineHinting, scr_y + lineHinting,
                      ceil(width + x - scr_x) - lineHinting * 2,
                      ceil(height + y - scr_y) - lineHinting * 2)

        if self.fRubberBandBlending == self._RUBBERBAND_BLENDING_PLUS:
            painter.setCompositionMode(QPainter.CompositionMode_Plus)
        elif self.fRubberBandBlending == self._RUBBERBAND_BLENDING_DIFF:
            painter.setCompositionMode(QPainter.CompositionMode_Difference)

        painter.setBrush(self.fViewBrush)
        painter.setPen(Qt.NoPen)
        painter.drawRect(rect)

        painter.setCompositionMode(QPainter.CompositionMode_SourceOver)
        painter.setBrush(Qt.NoBrush)
        painter.setPen(self.fViewPen)
        painter.drawRect(rect)

        if self.fUseCustomPaint:
            event.accept()
        else:
            QFrame.paintEvent(self, event)