示例#1
0
    def eventFilter(self, watched, event: QtGui.QMouseEvent) -> bool:
        if isinstance(watched, CellWidget):
            if event.type() == QtCore.QEvent.MouseButtonPress:
                if event.buttons() == QtCore.Qt.LeftButton:
                    # start drag if it is possible
                    if self.dragAndDrop and watched.getPiece() \
                            and watched.getPiece().color == self.board.turn:
                        self._dragWidget = _DragWidget(self)
                        self._dragWidget.setAutoFillBackground(True)
                        self._dragWidget.setFixedSize(watched.size())
                        self._dragWidget.setScaledContents(True)
                        self._dragWidget.setStyleSheet(
                            "background: transparent;")
                        self._dragWidget.setPixmap(
                            QtGui.QPixmap(
                                f":/images/{'_'.join(watched.objectName().split('_')[1:])}.png"
                            ))

                        rect = self._dragWidget.geometry()
                        rect.moveCenter(QtGui.QCursor.pos())
                        self._dragWidget.setGeometry(rect)

                        watched.setChecked(not watched.isChecked())
                        return True

                elif event.buttons() == QtCore.Qt.RightButton:
                    # mark cell if it is possible
                    if self.accessibleSides != NO_SIDE:
                        watched.setMarked(not watched.marked)

        return watched.event(event)
 def mousePressEvent(self, e: QMouseEvent):
     if e.buttons() & (Qt.RightButton | Qt.LeftButton):
         print("mousePressEvent in Item...")
         self.__m_lastMouseButton = self.__cloneMouseEvent(e)
         self.__m_lastMouseButton.ignore()
         e.accept()
         self.update()
 def mouseMoveEvent(self, e: QMouseEvent):
     if e.buttons() & (Qt.RightButton | Qt.LeftButton):
         qDebug("mouseMoveEvent in Item...")
         self.__m_lastMouseMove = self.__cloneMouseEvent(e)
         self.__m_lastMouseMove.ignore()
         e.accept()
         self.update()
示例#4
0
    def mouseMoveEvent(self,
                       event: QtGui.QMouseEvent) -> None:  # pragma: no cover
        if (not event.buttons() & QtCore.Qt.LeftButton
                or (event.pos() - self.drag_start_pos).manhattanLength() <
                QtWidgets.QApplication.startDragDistance()):
            return super().mouseMoveEvent(event)
        index = self.tabAt(event.pos())
        if index == -1:
            return super().mouseMoveEvent(event)

        rect = self.tabRect(index)
        pixmap = QtGui.QPixmap(rect.size())
        self.render(pixmap, QtCore.QPoint(), QtGui.QRegion(rect))

        mime_data = QtCore.QMimeData()
        mime_data.setData("application/x-pew2tabbar",
                          QtCore.QByteArray().number(index))

        drag = QtGui.QDrag(self)
        drag.setMimeData(mime_data)
        drag.setPixmap(pixmap)
        drag.setDragCursor(
            QtGui.QCursor(QtCore.Qt.DragMoveCursor).pixmap(),
            QtCore.Qt.MoveAction)
        drag.exec_(QtCore.Qt.MoveAction)
    def mouseMoveEvent(self, event: QtGui.QMouseEvent):
        if event.buttons(
        ) == QtCore.Qt.RightButton and self.editState == PlyEditEnum.DRAW_PLANE:
            self.geoEngine.planeFromVector(
                self.camera.getRayGridIntersecton(
                    QtGui.QVector2D(event.localPos())))

        if event.buttons() == QtCore.Qt.LeftButton:
            self.camera.rotate(self.camera.mousePos,
                               QtGui.QVector2D(event.localPos()))
            self.camera.mousePos = QtGui.QVector2D(event.localPos())

        if event.buttons(
        ) == QtCore.Qt.RightButton and self.camera.isPanEnabled:
            self.camera.pan(self.camera.mousePos,
                            QtGui.QVector2D(event.localPos()))
        self.update()
 def __cloneMouseEvent(self, e: QMouseEvent):
     event_type = e.type()
     local_pos = e.localPos()
     button = e.button()
     buttons = e.buttons()
     modifiers = e.modifiers()
     clone = QMouseEvent(event_type, local_pos, button, buttons, modifiers)
     clone.ignore()
     return clone
示例#7
0
    def mouseMoveEvent(self, event: QtGui.QMouseEvent):
        if event.buttons() == QtCore.Qt.LeftButton:
            diff = QtGui.QVector2D(event.localPos()) - self.m_mousePos
            self.m_mousePos = QtGui.QVector2D(event.localPos())

            angle = diff.length() / 2.0
            axis = QtGui.QVector3D(diff.y(), diff.x(), 0.0)
            self.m_viewRotation = QtGui.QQuaternion.fromAxisAndAngle(
                axis, angle) * self.m_viewRotation

            self.update()
        event.accept()
示例#8
0
 def mousePressEvent(self, e: QtGui.QMouseEvent):
     self.position = QPoint(e.globalX() - self.geometry().x(),
                            e.globalY() - self.geometry().y())
     if not self.m_isEditing:
         return
     if not self.m_infocus:
         return
     if not e.buttons() and QtCore.Qt.LeftButton:
         self.setCursorShape(e.pos())
         return
     if e.button() == QtCore.Qt.RightButton:
         self.popupShow(e.pos())
         e.accept()
示例#9
0
 def mousePressEvent(self, event: QMouseEvent):
     self.isPressed = True
     self.mousePos = event.x(), event.y()
     if event.buttons() & Qt.MiddleButton:
         for i, w in enumerate(self.interestings[::-1]):
             if not w.isVisible():
                 del self.interestings[i]
         print(len(self.interestings))
         t = Interesting()
         t.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint
                          | Qt.CustomizeWindowHint)
         t.setWindowTitle("lucifer")
         t.show()
         self.interestings.append(t)
示例#10
0
    def view_mouse_press_event(self, event: QMouseEvent):
        if event.buttons(
        ) == Qt.LeftButton and not self.action_timeout.isActive():
            idx = self.project_view.indexAt(event.pos())
            name = idx.siblingAtColumn(Kg.NAME).data(Qt.DisplayRole)
            self._current_project_name = name
            _id = idx.siblingAtColumn(Kg.ID).data(Qt.DisplayRole)
            LOGGER.debug('Project %s Id %s selected', name, _id)
            self.action_timeout.start()

            if _id:
                self.request_project(_id)

        self.org_view_mouse_press_event(event)
示例#11
0
    def mouseMoveEvent(self, event: QtGui.QMouseEvent):
        """Implementation.

    Handles panning the editor view.
    """

        if event.buttons() & Qt.MiddleButton:
            delta = self._lastMousePos - event.pos()
            hBar = self.horizontalScrollBar()
            vBar = self.verticalScrollBar()
            hBar.setValue(hBar.value() + delta.x())
            vBar.setValue(vBar.value() + delta.y())
            self._lastMousePos = event.pos()

        super().mouseMoveEvent(event)
    def mousePressEvent(self, event: QtGui.QMouseEvent):
        self.makeCurrent()
        self.camera.mousePos = QtGui.QVector2D(event.localPos())

        if event.buttons(
        ) == QtCore.Qt.RightButton and self.editState == PlyEditEnum.DRAW_PLANE:
            click_pos = self.camera.getRayGridIntersecton(self.camera.mousePos)
            self.geoEngine.startPoint = click_pos
            self.geoEngine.movePoint = click_pos
            self.geoEngine.setObject(TMPPlane())
            self.geoEngine.setScaleByScalar(0.0)
            self.geoEngine.setTranslationByVector(click_pos)
            self.draw_list.append(self.geoEngine.currentObject)

        self.update()
示例#13
0
    def mouseMoveEvent(self, event: QMouseEvent):
        if not event.buttons() and Qt.LeftButton:
            return
        # Test if item is drag enabled
        clicked_item = self.itemAt(self.__dragStartPosition)
        if clicked_item and not bool(clicked_item.flags()
                                     & Qt.ItemIsDragEnabled):
            return
        if (event.pos() - self.__dragStartPosition
            ).manhattanLength() < QApplication.startDragDistance():
            return

        drag: QDrag = QDrag(self)
        mimeData: QMimeData = QMimeData()
        mimeData.setText('operation')

        drag.setMimeData(mimeData)
        drag.exec_()
 def mouseMoveEvent(self, e: QMouseEvent):
     if e.buttons() & Qt.RightButton:
         self.__m_lastMouseMove = self.__cloneMouseEvent(e)
         self.__m_lastMouseMove.ignore()
         e.accept()
         self.update()
示例#15
0
 def mousePressEvent(self, event: QtGui.QMouseEvent):
     if event.buttons() == QtCore.Qt.LeftButton:
         self.m_mousePos = QtGui.QVector2D(event.localPos())
示例#16
0
文件: card.py 项目: yenru0/cardnorm
 def mouseDoubleClickEvent(self, event: QMouseEvent):
     if event.buttons() & Qt.RightButton:
         self.close()
     elif event.buttons() & Qt.MiddleButton:
         pass
示例#17
0
    def mouseMoveEvent(self, e: QtGui.QMouseEvent):
        QWidget.mouseMoveEvent(self, e)
        if not self.m_isEditing:
            return
        if not self.m_infocus:
            return
        if not e.buttons() and QtCore.Qt.LeftButton:
            p = QPoint(e.x() + self.geometry().x(),
                       e.y() + self.geometry().y())
            self.setCursorShape(p)
            return

        if (self.mode == Mode.MOVE or self.mode
                == Mode.NONE) and e.buttons() and QtCore.Qt.LeftButton:
            toMove = e.globalPos() - self.position
            if toMove.x() < 0: return
            if toMove.y() < 0: return
            if toMove.x() > self.parentWidget().width() - self.width(): return
            self.move(toMove)
            self.newGeometry.emit(self.geometry())
            self.parentWidget().repaint()
            return
        if (self.mode != Mode.MOVE) and e.buttons() and QtCore.Qt.LeftButton:
            if self.mode == Mode.RESIZETL:  # Left - Top
                newwidth = e.globalX() - self.position.x() - self.geometry().x(
                )
                newheight = e.globalY() - self.position.y() - self.geometry(
                ).y()
                toMove = e.globalPos() - self.position
                self.resize(self.geometry().width() - newwidth,
                            self.geometry().height() - newheight)
                self.move(toMove.x(), toMove.y())
            elif self.mode == Mode.RESIZETR:  # Right - Top
                newheight = e.globalY() - self.position.y() - self.geometry(
                ).y()
                toMove = e.globalPos() - self.position
                self.resize(e.x(), self.geometry().height() - newheight)
                self.move(self.x(), toMove.y())
            elif self.mode == Mode.RESIZEBL:  # Left - Bottom
                newwidth = e.globalX() - self.position.x() - self.geometry().x(
                )
                toMove = e.globalPos() - self.position
                self.resize(self.geometry().width() - newwidth, e.y())
                self.move(toMove.x(), self.y())
            elif self.mode == Mode.RESIZEB:  # Bottom
                self.resize(self.width(), e.y())
            elif self.mode == Mode.RESIZEL:  # Left
                newwidth = e.globalX() - self.position.x() - self.geometry().x(
                )
                toMove = e.globalPos() - self.position
                self.resize(self.geometry().width() - newwidth, self.height())
                self.move(toMove.x(), self.y())
            elif self.mode == Mode.RESIZET:  # Top
                newheight = e.globalY() - self.position.y() - self.geometry(
                ).y()
                toMove = e.globalPos() - self.position
                self.resize(self.width(), self.geometry().height() - newheight)
                self.move(self.x(), toMove.y())
            elif self.mode == Mode.RESIZER:  # Right
                self.resize(e.x(), self.height())
            elif self.mode == Mode.RESIZEBR:  # Right - Bottom
                self.resize(e.x(), e.y())
            self.parentWidget().repaint()
        self.newGeometry.emit(self.geometry())


# class MainWindow(QMainWindow):
#     def __init__(self):
#         super().__init__()

#         self.showMaximized()
#         lab1 = QLabel("Label1")
#         lab2 = QLabel("Label2")
#         con1 = TContainer(self, QPoint(10,10), lab1)
#         con2 = TContainer(self, QPoint(20,50), lab2)

# if __name__ == '__main__':
#     app = QApplication(sys.argv)
#     ex = MainWindow()
#     sys.exit(app.exec_())