Пример #1
0
    def mousePressEvent(self, e: QMouseEvent):
        self.parent().select(self)
        n = self.node(e.pos())

        if n is not None:
            self.__line = self.__create_line(n)
            self.__action = Action.CONNECTING
            if self.__label is not None and self.__label.node() is not n:
                self.parent().delete_label(self.__label)
                self.__label = None
            return

        if self.__label is not None:
            self.parent().delete_label(self.__label)
            self.__label = None

        if self._resizable:
            if abs(e.x() - self.width()) < 8 + Block.padding \
                    and abs(e.y() - self.height()) < 8 + Block.padding \
                    and self._check_action(Action.RESIZE):
                self.__origin = e.pos()
                self.__action = Action.RESIZE
                return
        if self._check_action(Action.DRAG):
            self.__origin = e.pos()
            self.__action = Action.DRAG
Пример #2
0
 def mousePressEvent(self, e: QMouseEvent):
     BlockManager.deselect_all()
     if e.button() == Qt.LeftButton:
         self.__moving = True
         self.__origin = e.pos()
         self.setCursor(Qt.DragMoveCursor)
     elif e.button() == Qt.RightButton:
         self.show_popup(e.pos())
Пример #3
0
 def mousePressEvent(self, e: QMouseEvent):
     BlockManager.deselect_all()
     if e.button() == Qt.LeftButton:
         self.__moving = True
         self.__origin = e.pos()
         self.setCursor(Qt.DragMoveCursor)
     elif e.button() == Qt.RightButton:
         self.show_popup(e.pos())
Пример #4
0
    def mouseMoveEvent(self, e: QMouseEvent):
        if self.__action == Action.DRAG:
            dx = e.x() - self.__origin.x()
            dy = e.y() - self.__origin.y()
            self.set_pos(self.x() + dx, self.y() + dy)
        elif self.__action == Action.RESIZE:
            self.set_size(e.x(), e.y())
        elif self.__action == Action.CONNECTING and self.__line is not None:
            p = QPoint(e.x() + self.x(), e.y() + self.y())

            n = self.parent().get_node(p)
            if n is not None and n.compatible(self.__line.n1):
                self.__line.status(True)
            else:
                self.__line.status(False)

            self.__line.update(p)

        else:
            n = self.node(e.pos())
            if self.__label is None and n is not None:
                self.__label = self.parent().create_label(self.node_name(n), n)
            elif self.__label is not None and self.__label.node() is not n and n is not None:
                self.parent().delete_label(self.__label)
                self.__label = self.parent().create_label(self.node_name(n), n)
            elif n is None:
                self.parent().delete_label(self.__label)
                self.__label = None
Пример #5
0
 def mousePressEvent(self, e: QMouseEvent):
     self.__block.select()
     n = self._check_nodes(e.pos())
     if n is not None:
         print('Node found')
         return
     if e.button() == Qt.LeftButton:
         if self._resizable:
             if self._check_corner(e.pos()) and self._check_action(Action.RESIZE):
                 self.__origin = e.pos()
                 self.__action = Action.RESIZE
                 self.setCursor(Qt.SizeFDiagCursor)
                 return
         if self._check_action(Action.DRAG):
             self.__origin = e.pos()
             self.__action = Action.DRAG
             self.setCursor(Qt.DragMoveCursor)
Пример #6
0
 def mousePressEvent(self, e: QMouseEvent):
     self.__block.select()
     n = self._check_nodes(e.pos())
     if n is not None:
         print('Node found')
         return
     if e.button() == Qt.LeftButton:
         if self._resizable:
             if self._check_corner(e.pos()) and self._check_action(
                     Action.RESIZE):
                 self.__origin = e.pos()
                 self.__action = Action.RESIZE
                 self.setCursor(Qt.SizeFDiagCursor)
                 return
         if self._check_action(Action.DRAG):
             self.__origin = e.pos()
             self.__action = Action.DRAG
             self.setCursor(Qt.DragMoveCursor)
Пример #7
0
 def mousePressEvent(self, event):
     """Reimplement Qt method only on non-linux platforms"""
     if os.name != 'posix' and event.button() == Qt.MidButton:
         self.setFocus()
         event = QMouseEvent(QEvent.MouseButtonPress, event.pos(),
                             Qt.LeftButton, Qt.LeftButton, Qt.NoModifier)
         QsciScintilla.mousePressEvent(self, event)
         QsciScintilla.mouseReleaseEvent(self, event)
         self.paste()
     else:
         QsciScintilla.mousePressEvent(self, event)
Пример #8
0
 def mousePressEvent(self, event):
     """Reimplement Qt method"""
     if os.name != 'posix' and event.button() == Qt.MidButton:
         self.setFocus()
         event = QMouseEvent(QEvent.MouseButtonPress, event.pos(),
                             Qt.LeftButton, Qt.LeftButton, Qt.NoModifier)
         QPlainTextEdit.mousePressEvent(self, event)
         QPlainTextEdit.mouseReleaseEvent(self, event)
         self.paste()
     else:
         QPlainTextEdit.mousePressEvent(self, event)
Пример #9
0
 def mousePressEvent(self, event):
     """Reimplement Qt method"""
     if os.name != 'posix' and event.button() == Qt.MidButton:
         self.setFocus()
         event = QMouseEvent(QEvent.MouseButtonPress, event.pos(),
                             Qt.LeftButton, Qt.LeftButton, Qt.NoModifier)
         QPlainTextEdit.mousePressEvent(self, event)
         QPlainTextEdit.mouseReleaseEvent(self, event)
         self.paste()
     else:
         QPlainTextEdit.mousePressEvent(self, event)
Пример #10
0
 def mousePressEvent(self, event):
     """Reimplement Qt method"""
     if event.button() == Qt.MidButton:
         self.setFocus()
         event = QMouseEvent(QEvent.MouseButtonPress, event.pos(),
                             Qt.LeftButton, Qt.LeftButton, Qt.NoModifier)
         QsciScintilla.mousePressEvent(self, event)
         QsciScintilla.mouseReleaseEvent(self, event)
         self.paste()
     else:
         QsciScintilla.mousePressEvent(self, event)
Пример #11
0
 def mouseMoveEvent(self, e: QMouseEvent):
     if self.__action == Action.DRAG:
         dx = e.x() - self.__origin.x()
         dy = e.y() - self.__origin.y()
         self.set_pos(self.x() + dx, self.y() + dy)
     elif self.__action == Action.RESIZE:
         self.set_size(e.x(), e.y())
     else:
         if self._resizable and self.__corner_path.translated(
                 self.width(), self.height()).contains(e.pos()):
             self.setCursor(Qt.SizeFDiagCursor)
         else:
             self.setCursor(Qt.ArrowCursor)
Пример #12
0
    def mousePressEvent(self, event):
        """
        Select misspelled word after right click
        otherwise left clik + right click is needed.

        Originally from John Schember spellchecker
        """
        if event.button() == Qt.RightButton:
            # Rewrite the mouse event to a left button event so the cursor is
            # moved to the location of the pointer.
            event = QMouseEvent(QEvent.MouseButtonPress, event.pos(),
                Qt.LeftButton, Qt.LeftButton, Qt.NoModifier)
        QtGui.QTextEdit.mousePressEvent(self, event)
Пример #13
0
    def mousePressEvent(self, event):
        """
        Select misspelled word after right click
        otherwise left clik + right click is needed.

        Originally from John Schember spellchecker
        """
        if event.button() == Qt.RightButton:
            # Rewrite the mouse event to a left button event so the cursor is
            # moved to the location of the pointer.
            event = QMouseEvent(QEvent.MouseButtonPress, event.pos(),
                                Qt.LeftButton, Qt.LeftButton, Qt.NoModifier)
        QtGui.QTextEdit.mousePressEvent(self, event)
Пример #14
0
 def mousePressEvent(self, event):
     """
     Re-implemented to handle the mouse press event.
     event: the mouse press event (QMouseEvent)
     """
     if event.button() == Qt.MidButton:
         text = self.selectedText()
         # Simulating left mouse button:
         event = QMouseEvent(QMouseEvent.MouseButtonPress, event.pos(), Qt.LeftButton, Qt.LeftButton, Qt.NoModifier)
         ConsoleBaseWidget.mousePressEvent(self, event)
         if self.new_input_line:
             self.on_new_line()
         self.insert_text(text)
         event.accept()
     else:
         ConsoleBaseWidget.mousePressEvent(self, event)
Пример #15
0
 def mousePressEvent(self, event: QtGui.QMouseEvent):
     self.setMovable(self.tabAt(event.pos()) not in (0, 1))
     super().mousePressEvent(event)
Пример #16
0
 def mouseMoveEvent(self, e: QMouseEvent):
     if self.__moving:
         dx = e.x() - self.__origin.x()
         dy = e.y() - self.__origin.y()
         self.__origin = e.pos()
         self.translate(dx, dy)
Пример #17
0
 def mousePressEvent(self, e: QMouseEvent):
     print(self.get_border(e.pos()))
Пример #18
0
 def mouseMoveEvent(self, e: QMouseEvent):
     self.setCursor(self.get_cursor(e.pos()))
Пример #19
0
 def mouseMoveEvent(self, e: QMouseEvent):
     self.setCursor(self.get_cursor(e.pos()))
Пример #20
0
 def mousePressEvent(self, e: QMouseEvent):
     print(self.get_border(e.pos()))
Пример #21
0
 def mouseMoveEvent(self, e: QMouseEvent):
     if self.__moving:
         dx = e.x() - self.__origin.x()
         dy = e.y() - self.__origin.y()
         self.__origin = e.pos()
         self.translate(dx, dy)
Пример #22
0
 def mouseMoveEvent(self, e: QMouseEvent):
     if self.__action == Action.DRAG:
         dx = e.x() - self.__origin.x()
         dy = e.y() - self.__origin.y()
         self.set_pos(self.x() + dx, self.y() + dy)
     elif self.__action == Action.RESIZE:
         self.set_size(e.x(), e.y())
     else:
         if self._resizable and self.__corner_path.translated(self.width(), self.height()).contains(e.pos()):
             self.setCursor(Qt.SizeFDiagCursor)
         else:
             self.setCursor(Qt.ArrowCursor)