Example #1
0
    def mousePressEvent(self, event):
        """Manage the mouse pressing.

        Args:
            event(QMouseEvent): Mouse event.
        """
        QGraphicsView.mousePressEvent(self, event)
        if event.buttons() == Qt.LeftButton:
            self._lastMousePos = event.pos()
Example #2
0
 def mousePressEvent(self, e):
     # シーン上のマウス位置を取得する
     pos = self.mapToScene(e.pos())
     if e.button() == Qt.LeftButton:
         if e.modifiers() == Qt.NoModifier:
             pass
         elif e.modifiers() == Qt.AltModifier:
             self.setDragMode(QGraphicsView.ScrollHandDrag)
     QGraphicsView.mousePressEvent(self, e)
Example #3
0
    def mousePressEvent(self, event):
        """Manage the mouse pressing.

        Args:
            event(QMouseEvent): Mouse event.
        """
        QGraphicsView.mousePressEvent(self, event)
        if event.buttons() == Qt.LeftButton:
            self._lastMousePos = event.pos()
Example #4
0
    def mousePressEvent(self, event, *args, **kwargs):
        """
        Attrs:
            _picking (bool): tells the widget that the user is now attempting
                to pick a value
            _in_gradient_widget (bool) tells the widget that the cursor is
                in the gradient widget
        """
        modifiers = QApplication.keyboardModifiers()
        button = event.button()
        if button in [Qt.LeftButton, Qt.RightButton, Qt.MiddleButton]:
            # move rgba

            # HSV
            self._picking = True
            self._black_select = False
            self._in_gradient_widget = True
            self._orig_pos = QCursor.pos()
            # setup default crosshair
            self.__hideRGBACrosshair(True)
            self.__hideLinearCrosshair(False)

            # RGB
            main_widget = getWidgetAncestor(self, ColorGradientDelegate)
            color = main_widget.color()
            pos = QPoint(0, 0)

            # TODO Check hack after upgrading to 5.15
            # katana is not registering the alt + mmb?
            if modifiers in [Qt.AltModifier, Qt.ControlModifier]:
                # RED
                if button == Qt.LeftButton:
                    pos = QPoint(color.redF() * self.width(), color.redF() * self.height())
                    self.scene().gradient_type = attrs.RED
                # GREEN
                elif button == Qt.MiddleButton:
                    pos = QPoint(color.greenF() * self.width(), color.greenF() * self.height())
                    self.scene().gradient_type = attrs.GREEN
                # BLUE
                elif button == Qt.RightButton:
                    pos = QPoint(color.blueF() * self.width(), color.blueF() * self.height())
                    self.scene().gradient_type = attrs.BLUE

            # HSV
            else:
                if button == Qt.LeftButton:
                    self.__hideRGBACrosshair(False)
                    self.__hideLinearCrosshair(True)
                    self.scene().gradient_type = attrs.RGBA
                # VALUE
                elif button == Qt.MiddleButton:
                    pos = QPoint(color.valueF() * self.width(), color.valueF() * self.height())
                    self.scene().gradient_type = attrs.VALUE
                # SATURATION
                elif button == Qt.RightButton:
                    pos = QPoint(color.saturationF() * self.width(), color.saturationF() * self.height())
                    self.scene().gradient_type = attrs.SATURATION

            # update display label to show selected value
            color_gradient_widget = getWidgetAncestor(self, ColorGradientDelegate)
            color_arg_widgets_dict = color_gradient_widget.header_widget.getWidgetDict()
            if self.scene().gradient_type != attrs.RGBA:
                color_arg_widgets_dict[self.scene().gradient_type].setSelected(True)

            # draw gradient / hide cursor
            self.scene().drawGradient()

            # set up cursor
            self.setCursor(Qt.BlankCursor)
            if pos:
                self.scene().linear_crosshair_item.setCrosshairPos(pos)
                QCursor.setPos(self.mapToGlobal(pos))

        return QGraphicsView.mousePressEvent(self, event, *args, **kwargs)