Example #1
0
    def focusInEvent(self, focus_event):
        super(GBaseModelView, self).focusInEvent(focus_event)
        if QApplication.queryKeyboardModifiers() & QtCore.Qt.ControlModifier:
            self.setDragMode(self.RubberBandDrag)
        else:
            self.setDragMode(self.ScrollHandDrag)

        if QApplication.queryKeyboardModifiers() & QtCore.Qt.ShiftModifier:
            self.shift_pressed = True
        else:
            self.shift_pressed = False
Example #2
0
    def paintEvent(self, a0: QtGui.QPaintEvent) -> None:
        p = QtGui.QPainter(self)
        p.setRenderHint(QtGui.QPainter.RenderHint.HighQualityAntialiasing)
        p.fillRect(0, 0, self.width(), self.height(), Map.Background)

        bs = self._blocksize()
        sx, sy = self.deltaxy()

        if self.boxRows * self.boxCols > len(self.data.data):
            for v in self.data.data.values():
                MapDataRenderer.paint(v, v in self.selector, self.scale,
                                      v.x * int(bs) + self.viewOrigin[0],
                                      v.y * int(bs) + self.viewOrigin[1], p)
        else:
            for y in range(self.boxRows):
                for x in range(self.boxCols):
                    tmp = self._getVirtualCell(x, y)
                    if tmp and tmp.valid():
                        MapDataRenderer.paint(tmp, tmp in self.selector,
                                              self.scale,
                                              x * int(bs) + sx - bs,
                                              y * int(bs) + sy - bs, p)

        self.selector.paint(p)
        self.dragger.paint(p)
        self.hover.paint(p)
        for i in range(0, len(self.pressPosPath)):
            s, e = self.pressPosPath[i], self.pressPosPath[
                i < len(self.pressPosPath) - 1 and i + 1 or 0]
            p.drawLine(s[0], s[1], e[0], e[1])

        w = 0
        if self.showRuler:
            w = Ruler.Width
            self.ruler.paint(p)

        if FLAGS.get('show_keys', False):
            vis = []
            QApplication.queryKeyboardModifiers(
            ) & QtCore.Qt.KeyboardModifier.ControlModifier and vis.append(
                '\u2318' if sys.platform == 'darwin' else 'Ctrl')
            QApplication.queryKeyboardModifiers(
            ) & QtCore.Qt.KeyboardModifier.ShiftModifier and vis.append(
                "Shift")
            if vis:
                p.setFont(Map.BigFont())
                p.drawText(w + 2, w + Map.BigFont().pointSize(), '-'.join(vis))

        p.end()
        return super().paintEvent(a0)
Example #3
0
    def mouseMoveEvent(self, event):

        QGraphicsView.mouseMoveEvent(self, event)

        scenePos = self.mapToScene(event.pos())

        if self.showCrossair == True:
            self.mouseCoords = scenePos
            self.scene.invalidate(self.sceneRect(),
                                  QGraphicsScene.ForegroundLayer)

        if event.buttons() == Qt.LeftButton:
            (x, y) = self.clipScenePos(scenePos)

            if self.dragSelectionStart:
                start = self.dragSelectionStart
                if not self.dragSelectionRect:
                    self.dragSelectionRect = self.scene.addRect(
                        start[0], start[1], x - start[0], y - start[1],
                        self.dragSelectionStyle)
                self.dragSelectionRect.setRect(start[0], start[1],
                                               x - start[0], y - start[1])
                return

            if Qt.ControlModifier & QApplication.queryKeyboardModifiers():
                return

            self.tools.mouseMove(x, y)
Example #4
0
 def keyPressEvent(self, a0):
     if a0.key(
     ) == Qt.Key_Return and not QApplication.queryKeyboardModifiers(
     ) == Qt.ShiftModifier:
         self.on_send()
     else:
         QTextEdit.keyPressEvent(self.inputTextEdit, a0)
Example #5
0
    def selectOp(self, x, y):
        """
        Selection operation.
        """

        self.logfile.info("[SELECTION][DOUBLE-CLICK] Selection starts..")

        if self.tools.tool in ["RULER", "DEEPEXTREME"]:
            return

        if not (Qt.ShiftModifier & QApplication.queryKeyboardModifiers()):
            self.resetSelection()

        selected_blob = self.annotations.clickedBlob(x, y)

        if selected_blob:
            if selected_blob in self.selected_blobs:
                self.removeFromSelectedList(selected_blob)
            else:
                self.addToSelectedList(selected_blob)
                self.updateInfoPanel.emit(selected_blob)

        if len(self.selected_blobs) == 1:
            self.newSelection.emit()
        self.logfile.info("[SELECTION][DOUBLE-CLICK] Selection ends.")
Example #6
0
 def keyPressEvent(self, keyEvent):
     key = keyEvent.key()
     if (
             key == Qt.Key_Enter or key == Qt.Key_Return
     ) and not QApplication.queryKeyboardModifiers() == Qt.ShiftModifier:
         self.callback and self.callback()
     else:
         self.super.keyPressEvent(keyEvent)
    def mouseMoveEvent(self,event):
        pos=self.dataPos()

        modifiers=QApplication.queryKeyboardModifiers()
        if modifiers == Qt.ControlModifier:

            self._has_moved=True
            super(QGraphicsResizableRect, self).mouseMoveEvent(event)
            string=str(self.pos()).split("(")[1][:-1]
Example #8
0
    def mouseMoveEvent(self, event):
        pos = self.dataPos()

        modifiers = QApplication.queryKeyboardModifiers()
        if modifiers == Qt.ControlModifier:

            self._has_moved = True
            super(QGraphicsResizableRect, self).mouseMoveEvent(event)
            string = str(self.pos()).split("(")[1][:-1]
Example #9
0
    def mousePressEvent(self, e):

        self.check()
        if QApplication.queryKeyboardModifiers() == Qt.ControlModifier:
            if self.text is not None:
                self.check_func("lol")
                url = "https://docs.python.org/3/library/functions.html#" + self.text
                word = self.text
                self.parent.parent.showBrowser(url, word)
        QApplication.restoreOverrideCursor()
        super().mousePressEvent(e)
Example #10
0
    def mousePressEvent(self, e: QMouseEvent):
        super().mousePressEvent(e)
        return
        # self.check()
        if QApplication.queryKeyboardModifiers() == Qt.ControlModifier:

            super().mousePressEvent(e)
            self.text = self.textUnderCursor()
            if self.text is not None:
                word = self.text
                # self.parent.parent.showBrowser(url, word)

                # tag = self.jump_to_def(word)
                # print(tag[0])
                # if tag[0]:
                # print("INFO INFO INFO")
                # print(tag[1])

                # self.parent.jumpToDef(tag[1])

                # if self.check_func(self.textUnderCursor(), True):
                #     extraSelections = self.highlightCurrentLine()
                #     selection = QTextEdit.ExtraSelection()
                #     selection.format.setFontUnderline(True)
                #     selection.format.setUnderlineColor(QColor("#00d2ff"))
                #     selection.format.setForeground(QColor("#00d2ff"))
                #     selection.format.setProperty(QTextFormat.FullWidthSelection, True)
                #     selection.cursor = self.textCursor()
                #     selection.cursor.clearSelection()
                #     selection.cursor.select(QTextCursor.WordUnderCursor)
                #     extraSelections.append(selection)
                #     self.setExtraSelections(extraSelections)
                #     self.text = self.textUnderCursor()
                #
                #     # cursor = QCursor(Qt.PointingHandCursor)
                #
                #     # QApplication.setOverrideCursor(cursor)
                #     # QApplication.changeOverrideCursor(cursor)
                #
                # else:
                #     self.text = None
        else:
            super().mousePressEvent(e)
        QApplication.restoreOverrideCursor()
Example #11
0
    def timerEvent(self, ev) -> None:
        if ev.timerId() == self._mouse_move_timer:
            buttons = QApplication.mouseButtons()
            if not buttons & Qt.LeftButton:
                # dispose the widget when the mouse button is released
                self.hide()
                self.killTimer(self._mouse_move_timer)
                self._mouse_move_timer = None
            else:
                # update the mouse position
                pos = QCursor.pos()
                x = pos.x() + 16
                y = pos.y() - 12
                self.move(x, y)

                # FIXME: Qt-bug? .keyboardModifiers() doesn't update until
                # the mouse is moved. .queryKeyboardModifiers() reads
                # straight from the input device and updates properly.
                modifiers = QApplication.queryKeyboardModifiers()

                old_text = self._text

                if modifiers & Qt.ControlModifier and modifiers & Qt.ShiftModifier:
                    self._text = "Link"
                elif modifiers & Qt.ControlModifier:
                    self._text = "Copy"
                elif modifiers & Qt.ShiftModifier:
                    self._text = "Move"
                elif modifiers & Qt.AltModifier:
                    self._text = "Link"
                else:
                    self._text = None

                if old_text != self._text:
                    if self._text is None:
                        # print("Hide")
                        self.hide()
                    else:
                        # print("Show")
                        self.show()
                        self.repaint()
Example #12
0
    def timerEvent(self, ev) -> None:
        if ev.timerId() == self._mouse_move_timer:
            buttons = QApplication.mouseButtons()
            if not buttons & Qt.LeftButton:
                # dispose the widget when the mouse button is released
                self.hide()
                self.killTimer(self._mouse_move_timer)
                self._mouse_move_timer = None
            else:
                # update the mouse position
                pos = QCursor.pos()
                x = pos.x() + 16
                y = pos.y() - 12
                self.move(x, y)

                # FIXME: Qt-bug? .keyboardModifiers() doesn't update until
                # the mouse is moved. .queryKeyboardModifiers() reads
                # straight from the input device and updates properly.
                modifiers = QApplication.queryKeyboardModifiers()

                old_text = self._text

                if modifiers & Qt.ControlModifier and modifiers & Qt.ShiftModifier:
                    self._text = "Link"
                elif modifiers & Qt.ControlModifier:
                    self._text = "Copy"
                elif modifiers & Qt.ShiftModifier:
                    self._text = "Move"
                elif modifiers & Qt.AltModifier:
                    self._text = "Link"
                else:
                    self._text = None

                if old_text != self._text:
                    if self._text is None:
                        # print("Hide")
                        self.hide()
                    else:
                        # print("Show")
                        self.show()
                        self.repaint()
Example #13
0
    def mousePressEvent(self, e):

        self.check()
        if QApplication.queryKeyboardModifiers() == Qt.ControlModifier:

            super().mousePressEvent(e)
            self.text = self.textUnderCursor()
            if self.text is not None:
                word = self.text
                # self.parent.parent.showBrowser(url, word)

                if self.check_func(self.textUnderCursor(), True):
                    extraSelections = self.highlightCurrentLine()
                    selection = QTextEdit.ExtraSelection()
                    selection.format.setFontUnderline(True)
                    selection.format.setUnderlineColor(QColor("#00d2ff"))
                    selection.format.setForeground(QColor("#00d2ff"))
                    selection.format.setProperty(
                        QTextFormat.FullWidthSelection, True)
                    selection.cursor = self.textCursor()
                    selection.cursor.clearSelection()
                    selection.cursor.select(QTextCursor.WordUnderCursor)
                    extraSelections.append(selection)
                    self.setExtraSelections(extraSelections)
                    self.text = self.textUnderCursor()

                    # cursor = QCursor(Qt.PointingHandCursor)

                    # QApplication.setOverrideCursor(cursor)
                    # QApplication.changeOverrideCursor(cursor)

                else:
                    self.text = None
        else:
            super().mousePressEvent(e)
        QApplication.restoreOverrideCursor()
Example #14
0
 def mousePressEvent(self, event):
     modifiers = QApplication.queryKeyboardModifiers()
     if modifiers == Qt.ControlModifier:
         QApplication.setOverrideCursor(Qt.ClosedHandCursor)
Example #15
0
 def is_control_pressed(self):
     return QApplication.queryKeyboardModifiers() == Qt.ControlModifier
Example #16
0
 def is_shift_pressed(self):
     return QApplication.queryKeyboardModifiers() == Qt.ShiftModifier
Example #17
0
    def mouseMoveEvent(self, QMouseEvent):

        # font = textCursor.block().charFormat().font()
        # metrics = QFontMetrics(font)
        #
        # b = self.document().findBlockByLineNumber(0)
        #
        # cursor = QTextCursor(b)
        #
        # cursor.select(QTextCursor.BlockUnderCursor)
        #
        # cursor.removeSelectedText()
        #
        # height = metrics.height() + 2
        # y = QMouseEvent.pos().y()
        #print(y, height)
        #print(y/height)
        cursor_main = self.cursorForPosition(QMouseEvent.pos())
        if QApplication.queryKeyboardModifiers() == Qt.ControlModifier:

            cursor_main.select(QTextCursor.WordUnderCursor)
            text = cursor_main.selectedText()
            self.text = text
            if self.text is not None:
                url = "https://docs.python.org/3/library/functions.html#" + self.text
                word = self.text
                # self.parent.parent.showBrowser(url, word)

                if self.check_func(word):
                    extraSelections = self.highlightCurrentLine()
                    selection = QTextEdit.ExtraSelection()
                    selection.format.setFontUnderline(True)
                    selection.format.setUnderlineColor(QColor("#00d2ff"))
                    selection.format.setForeground(QColor("#00d2ff"))
                    selection.format.setProperty(
                        QTextFormat.FullWidthSelection, True)
                    selection.cursor = self.cursorForPosition(
                        QMouseEvent.pos())
                    selection.cursor.select(QTextCursor.WordUnderCursor)
                    extraSelections.append(selection)
                    self.setExtraSelections(extraSelections)
                    cursor = QCursor(Qt.PointingHandCursor)
                    # tooltip = QToolTip()
                    QToolTip.setFont(
                        QFont(editor["ToolTipFont"],
                              editor["ToolTipFontSize"]))
                    word_shown = eval(word).__doc__

                    if len(word_shown) > 2000:
                        word_shown = word_shown[:2000]

                    QToolTip.showText(QCursor.pos(), "{}".format(word_shown))
                    QApplication.setOverrideCursor(cursor)
                    QApplication.changeOverrideCursor(cursor)
                else:
                    self.returnCursorToNormal()
            else:

                pass
        else:
            self.returnCursorToNormal()
            extraSelections = self.highlightCurrentLine()
            self.setExtraSelections(extraSelections)

        super().mouseMoveEvent(QMouseEvent)
Example #18
0
 def is_alt_pressed(self):
     return QApplication.queryKeyboardModifiers() == Qt.AltModifier
 def mousePressEvent(self,event):
     modifiers=QApplication.queryKeyboardModifiers()
     if modifiers == Qt.ControlModifier:
         QApplication.setOverrideCursor(Qt.ClosedHandCursor)