Ejemplo n.º 1
0
 def keyPressEvent(self, event: QKeyEvent):
     super().keyPressEvent(event)
     if self.currentIndex():
         if event.key() == 16777220:
             if self.hasFocus():
                 self.contextMenuShowed.emit()
         elif event.key() == 16777219:
             self.contextMenuDeleted.emit()
Ejemplo n.º 2
0
 def keyPressEvent(self, event: QKeyEvent):
     if event.key() == Qt.Key_Delete:
         item = self.currentItem()
         row_idx = item.row()
         if row_idx < self.rowCount() - 1:
             self.takeItem(row_idx, 0)
             self.takeItem(row_idx, 1)
             self.removeRow(row_idx)
     else:
         super(QTableWidgetMaterial, self).keyPressEvent(event)
Ejemplo n.º 3
0
 def checkKey(self, ev: Qt.QKeyEvent):
     if ev.key() == QtCore.Qt.Key_Backspace:
         if self.activePoints[0] and self.activePoints[1]:
             self.activePoints[1] = False
             self.grphEnd.scene().removeItem(self.ellipsi[1])
             self.grphEnd.show()
         elif self.activePoints[0] and self.activePoints[1] is False:
             self.activePoints[0] = False
             self.grphStart.scene().removeItem(self.ellipsi[0])
             self.grphStart.show()
Ejemplo n.º 4
0
 def keyReleaseEvent(self, _event: QKeyEvent):
     key = _event.key()
     if key == QtCore.Qt.Key_Up:
         self.wizard.zoomIn()
     elif key == QtCore.Qt.Key_Down:
         self.wizard.zoomOut()
     elif key == QtCore.Qt.Key_Left:
         self.wizard.scrollLeft()
     elif key == QtCore.Qt.Key_Right:
         self.wizard.scrollRight()
     else:
         pass
Ejemplo n.º 5
0
    def keyPressEvent(self, evt: QKeyEvent):
        """
        Ignore escape key event, because it would close startup window.
        Any other key will be passed to the super class key event handler for further
        processing.

        :param evt: key event
        :return:
        """
        if evt.key() == QtCore.Qt.Key_Escape:
            pass
        else:
            super().keyPressEvent(evt)
Ejemplo n.º 6
0
    def keyPressEvent(self, evt: QKeyEvent):
        """
        Ignore escape key event, because it would close startup window.
        Any other key will be passed to the super class key event handler for further
        processing.

        :param evt: key event
        :return:
        """
        if evt.key() == QtCore.Qt.Key_Escape:
            self.request_close_dialog()
        else:
            super().keyPressEvent(evt)
Ejemplo n.º 7
0
 def keyReleaseEvent(self, _event: QKeyEvent):
     """
     implement the key interaction
     """
     key = _event.key()
     if key == QtCore.Qt.Key_Up:
         self.wizard.zoomIn()
     elif key == QtCore.Qt.Key_Down:
         self.wizard.zoomOut()
     elif key == QtCore.Qt.Key_Left:
         self.wizard.scrollLeft()
     elif key == QtCore.Qt.Key_Right:
         self.wizard.scrollRight()
     else:
         pass
Ejemplo n.º 8
0
 def keyPressEvent(self, keyPressed: QKeyEvent, *args, **kwargs):
     key = keyPressed.key()
     if key == Qt.Key_Escape:
         self.searchEdit.clearFocus()
         return False
     elif key == Qt.Key_Up:
         self.map.move_on_map(CONST.MOVE_UP)
     elif key == Qt.Key_Down:
         self.map.move_on_map(CONST.MOVE_DOWN)
     elif key == Qt.Key_Left:
         self.map.move_on_map(CONST.MOVE_LEFT)
     elif key == Qt.Key_Right:
         self.map.move_on_map(CONST.MOVE_RIGHT)
     elif key == Qt.Key_PageUp:
         self.map.setScale(CONST.UP_SCALE)
     elif key == Qt.Key_PageDown:
         self.map.setScale(CONST.DOWN_SCALE)
     else:
         return False
Ejemplo n.º 9
0
 def keyPressEvent(self, e: Qt.QKeyEvent):
     if e.key() == Qt.Qt.Key_Escape:
         self.close()
Ejemplo n.º 10
0
 def keyReleaseEvent(self, event: QKeyEvent):
     if event.key() == Qt.Key_Q:
         self.close()
Ejemplo n.º 11
0
    def key_press(self, event: QKeyEvent):

        if event.key() == Qt.Key_L and event.modifiers() & Qt.ControlModifier:
            if not self._spell.enabled():
                return []
            f_param = KeySwitcherParams(self._textedit, self._current_lang,
                                        self._enabled)
            if f_param.exec_():
                self._enabled = f_param.params["enabled"]
                self._current_lang = "ENG" if f_param.params["eng"] else "RUS"
            return []

        if event.key() == Qt.Key_F12:
            self._replace_selection()
            return []

        if not self._enabled:
            return [event]

        if event.key() == Qt.Key_Backspace:
            if self._current_word.strip():
                self._current_word = self._current_word.strip()[:-1]
            return [event]

        char = event.text().strip()

        if not char:
            shift = event.modifiers() & Qt.ShiftModifier
            ctrl = event.modifiers() & Qt.ControlModifier
            if not (shift or ctrl):
                self._current_word = ""
            return [event]

        # ---------------------------------------------------------------------
        # check the current word, if there was any movement, e.g. mouse
        old_cur = self._textedit.textCursor()
        cursor = self._textedit.textCursor()
        cursor.select(QTextCursor.WordUnderCursor)
        word = cursor.selectedText()
        self._textedit.setTextCursor(old_cur)
        if self._current_word.strip() != word.strip():
            self._current_word = ""
            return [event]
        # ---------------------------------------------------------------------

        # detect char language
        char_lang = "UNKNOWN"
        if char.lower() in KeySwitcher.RUSSIAN:
            char_lang = "RUS"
        if char.lower() in KeySwitcher.ENGLISH:
            char_lang = "ENG"

        # add char to current word
        if self._current_lang != char_lang:  # and char_lang != "UNKNOWN":
            char = KeySwitcher.switch_charset(char, self._current_lang)
            event = QKeyEvent(QEvent.KeyPress, event.key(), event.modifiers(),
                              char)
        self._current_word += char

        # early to check language
        if len(self._current_word) < 2:
            return [event]

        # detect language
        rus_chars = 0
        eng_chars = 0
        for char in set(self._current_word.lower()):
            if char in KeySwitcher.RUSSIAN:
                rus_chars += 1
            if char in KeySwitcher.ENGLISH:
                eng_chars += 1
        if rus_chars and eng_chars:
            return [event]

        if not self._ok_locale(
                self._current_word,
                KeySwitcher.switch_charset(self._current_word,
                                           "ENG" if rus_chars else "RUS")):
            return [event] + self._replace_current_word()

        return [event]
Ejemplo n.º 12
0
 def keyPressEvent(self, event: QKeyEvent):
     super().keyPressEvent(event)
     if self.currentIndex():
         if event.key() == 16777219:
             self.model().removeRow(int(self.currentIndex().row()))