Esempio n. 1
0
 def keyPressEvent(self, a0: QtGui.QKeyEvent) -> None:
     m = self.getActiveMarker()
     if m is not None and a0.modifiers() == QtCore.Qt.NoModifier:
         if a0.key() in [QtCore.Qt.Key_Down, QtCore.Qt.Key_Left]:
             m.frequencyInput.keyPressEvent(
                 QtGui.QKeyEvent(a0.type(), QtCore.Qt.Key_Down,
                                 a0.modifiers()))
         elif a0.key() in [QtCore.Qt.Key_Up, QtCore.Qt.Key_Right]:
             m.frequencyInput.keyPressEvent(
                 QtGui.QKeyEvent(a0.type(), QtCore.Qt.Key_Up,
                                 a0.modifiers()))
     else:
         super().keyPressEvent(a0)
Esempio n. 2
0
    def replay_movie(self, _, event: QEvent):
        key_event = QKeyEvent(event)
        if key_event.type(
        ) == QKeyEvent.KeyPress and not key_event.isAutoRepeat():
            self.movie.stop()
            self.movie.start()
            effect = QGraphicsDropShadowEffect()
            effect.setBlurRadius(20)
            effect.setXOffset(0)
            effect.setYOffset(0)
            effect.setColor(Qt.red)
            self.gif_progress_bar.setGraphicsEffect(effect)

        if key_event.type() == QKeyEvent.KeyRelease:
            self.gif_progress_bar.setGraphicsEffect(None)
Esempio n. 3
0
	def keyPressEvent(self, event):
		key = event.key()
		cursor = self.textCursor()
		if key == Qt.Key_Backspace and event.modifiers() & Qt.GroupSwitchModifier:
			# Workaround for https://bugreports.qt.io/browse/QTBUG-49771
			event = QKeyEvent(event.type(), event.key(),
				event.modifiers() ^ Qt.GroupSwitchModifier)
		if key == Qt.Key_Tab:
			documentIndentMore(self.document(), cursor)
		elif key == Qt.Key_Backtab:
			documentIndentLess(self.document(), cursor)
		elif key == Qt.Key_Return and not cursor.hasSelection():
			if event.modifiers() & Qt.ShiftModifier:
				# Insert Markdown-style line break
				markupClass = self.tab.getActiveMarkupClass()
				if markupClass == MarkdownMarkup:
					cursor.insertText('  ')
			if event.modifiers() & Qt.ControlModifier:
				cursor.insertText('\n')
				self.ensureCursorVisible()
			else:
				self.handleReturn(cursor)
		else:
			if event.text() and self.tableModeEnabled:
				cursor.beginEditBlock()
			QTextEdit.keyPressEvent(self, event)
			if event.text() and self.tableModeEnabled:
				cursor.endEditBlock()
Esempio n. 4
0
 def keyPressEvent(self, event):
     key = event.key()
     cursor = self.textCursor()
     if key == Qt.Key_Backspace and event.modifiers(
     ) & Qt.GroupSwitchModifier:
         # Workaround for https://bugreports.qt.io/browse/QTBUG-49771
         event = QKeyEvent(event.type(), event.key(),
                           event.modifiers() ^ Qt.GroupSwitchModifier)
     if key == Qt.Key_Tab:
         documentIndentMore(self.document(), cursor)
     elif key == Qt.Key_Backtab:
         documentIndentLess(self.document(), cursor)
     elif key == Qt.Key_Return:
         markupClass = self.tab.getActiveMarkupClass()
         if event.modifiers() & Qt.ControlModifier:
             cursor.insertText('\n')
             self.ensureCursorVisible()
         elif self.tableModeEnabled and tablemode.handleReturn(
                 cursor,
                 markupClass,
                 newRow=(event.modifiers() & Qt.ShiftModifier)):
             self.setTextCursor(cursor)
             self.ensureCursorVisible()
         else:
             if event.modifiers(
             ) & Qt.ShiftModifier and markupClass == MarkdownMarkup:
                 # Insert Markdown-style line break
                 cursor.insertText('  ')
             self.handleReturn(cursor)
     else:
         if event.text() and self.tableModeEnabled:
             cursor.beginEditBlock()
         QTextEdit.keyPressEvent(self, event)
         if event.text() and self.tableModeEnabled:
             cursor.endEditBlock()
Esempio n. 5
0
 def advance(_: QObject, event: QKeyEvent) -> bool:
     if event.type(
     ) == QKeyEvent.KeyPress and not event.isAutoRepeat():
         if should_quit or not slide_spec.get(
                 'disable-advance', False):
             self.advance_slide(should_quit)
             return True
     return False
Esempio n. 6
0
 def space_callback(self, _: QObject, event: QKeyEvent) -> bool:
     event_type = event.type()
     if event_type == QKeyEvent.KeyPress and not event.isAutoRepeat():
         self.start_recording()
         return True
     if event_type == QKeyEvent.KeyRelease:
         self.stop_recording()
         return True
     return False
 def __makeKeyEvent(self, measure_editor: BaseMeasureEditor,
                    evt: QtGui.QKeyEvent) -> QtGui.QKeyEvent:
     measure_evt = QtGui.QKeyEvent(evt.type(), evt.key(), evt.modifiers(),
                                   evt.nativeScanCode(),
                                   evt.nativeVirtualKey(),
                                   evt.nativeModifiers(), evt.text(),
                                   evt.isAutoRepeat(), evt.count())
     measure_evt.setAccepted(False)
     return measure_evt
Esempio n. 8
0
 def keyPressEvent(self, event: QKeyEvent) -> None:
     try:
         print(event.type())
         if event.key() in (Qt.Key_Plus):
             print('key plus pressed, ignore')
             ev.ignore()
             return True
     except:
         pass
Esempio n. 9
0
 def space_callback(self, _: QObject, event: QKeyEvent) -> bool:
     event_type = event.type()
     if event_type == QKeyEvent.KeyPress and not event.isAutoRepeat():
         self.recording_consumer.start_recording()
         return True
     if event_type == QKeyEvent.KeyRelease:
         self.recording_consumer.stop_recording()
         self.update_signal_widgets()
         return True
     return False
Esempio n. 10
0
    def eventFilter(self, obj, event: QtGui.QKeyEvent):
        if obj is not self.ui.recordsTableView:
            return False
        if event.type() != QtCore.QEvent.KeyPress:
            return False

        if event.key() == QtCore.Qt.Key_Delete:
            self._remove_selected_records()
            return True

        return False
Esempio n. 11
0
 def keyPressEvent(self, event: QtGui.QKeyEvent):
     """Bugfix, disables SHIFT+RETURN misbehaviour."""
     if (event.key() == QtCore.Qt.Key_Enter or event.key() == 16777220) and \
        ((event.modifiers() & QtCore.Qt.ShiftModifier) == QtCore.Qt.ShiftModifier):
         # clone object but without shift
         # current modifiers & all possible modifiers, but SHIFT,ALT,CTRL
         event = QtGui.QKeyEvent(
             event.type(), event.key(),
             event.modifiers() & QtCore.Qt.MetaModifier
             & QtCore.Qt.KeypadModifier, event.text(), event.isAutoRepeat(),
             event.count())
     super().keyPressEvent(event)
Esempio n. 12
0
 def keyPressEvent(self, a0: QtGui.QKeyEvent) -> None:
     if a0.type() == QtCore.QEvent.KeyPress:
         if a0.key() == QtCore.Qt.Key_Up and self.nextFrequency != -1:
             a0.accept()
             self.setText(str(self.nextFrequency))
             self.editingFinished.emit()  # self.text())
             return
         if a0.key() == QtCore.Qt.Key_Down and self.previousFrequency != -1:
             a0.accept()
             self.setText(str(self.previousFrequency))
             self.editingFinished.emit()  # self.text())
             return
     super().keyPressEvent(a0)
Esempio n. 13
0
    def keyPressEvent(self, event: QKeyEvent):
        if event.type() == QKeyEvent.KeyPress:
            if event.key() == Qt.Key_Up:
                return
            if event.key() == Qt.Key_Backspace:
                cursor: QTextCursor = self.textCursor()
                self.on_backspace_pressed(cursor)
                return
            if event.key() == Qt.Key_Return:
                cursor: QTextCursor = self.textCursor()
                self.on_return_pressed(cursor)
                return

        #super().keyPressEvent(event)
        self.on_text_pressed(event.text())
Esempio n. 14
0
 def eventFilter(self, obj, event: QtGui.QKeyEvent) -> bool:
     if obj is self.lineNumberArea and event.type() == QtCore.QEvent.Paint:
         self.drawLineNumbers()
         return True
     return False
Esempio n. 15
0
    def keyPressEvent(self, event: QtGui.QKeyEvent):
        if event.type() != QtCore.QEvent.KeyPress: event.ignore()
        else:
            # if self.mode.value == QwwMode.EPUB.value:
            # 	event.ignore()
            if event.key() == QtCore.Qt.Key_Control:
                self.ctrlOn = True
                return

            if self.ctrlOn is True:
                print('KeyPress + Ctrl')
                if event.key() in [QtCore.Qt.Key_0]:
                    super().page().mainFrame().setZoomFactor(1)
                if event.key() in [QtCore.Qt.Key_Plus]:
                    super().page().mainFrame().setZoomFactor(
                        super().page().mainFrame().zoomFactor() * 1.10)
                if event.key() in [QtCore.Qt.Key_Minus]:
                    super().page().mainFrame().setZoomFactor(
                        super().page().mainFrame().zoomFactor() * 0.90)

                if self.mode.value == QwwMode.CBZ.value:
                    ""
                elif self.mode.value == QwwMode.EPUB.value:
                    if event.key() in [QtCore.Qt.Key_C]:
                        pyperclip.copy(super().page().selectedText())
            else:
                try:
                    if self.mode.value == QwwMode.CBZ.value:
                        zoom = super().page().mainFrame().zoomFactor()
                        if zoom != 1:
                            position = super().page().mainFrame(
                            ).scrollPosition()
                            if event.key() in [
                                    QtCore.Qt.Key_PageDown,
                                    QtCore.Qt.Key_PageUp
                            ]:
                                super().page().mainFrame().setZoomFactor(1)
                                self.updatePositionCbz(0)
                            elif event.key() in [QtCore.Qt.Key_Left]:
                                super().page().mainFrame().setScrollPosition(
                                    QtCore.QPoint(position.x() - 5,
                                                  position.y()))
                            elif event.key() in [QtCore.Qt.Key_Right]:
                                super().page().mainFrame().setScrollPosition(
                                    QtCore.QPoint(position.x() + 5,
                                                  position.y()))
                            elif event.key() in [QtCore.Qt.Key_Up]:
                                super().page().mainFrame().setScrollPosition(
                                    QtCore.QPoint(position.x(),
                                                  position.y() - 5))
                            elif event.key() in [QtCore.Qt.Key_Down]:
                                super().page().mainFrame().setScrollPosition(
                                    QtCore.QPoint(position.x(),
                                                  position.y() + 5))
                            return
                        passed = 0
                        if event.key() in [
                                QtCore.Qt.Key_Left, QtCore.Qt.Key_Up,
                                QtCore.Qt.Key_PageUp
                        ]:
                            passed = -1
                        elif event.key() in [
                                QtCore.Qt.Key_Right, QtCore.Qt.Key_Down,
                                QtCore.Qt.Key_PageDown
                        ]:
                            passed = 1
                        self.updatePositionCbz(passed)
                    elif self.mode.value == QwwMode.EPUB.value:
                        passed = 0
                        if event.key() in [
                                QtCore.Qt.Key_Left, QtCore.Qt.Key_Up,
                                QtCore.Qt.Key_PageUp
                        ]:
                            passed = super().height() * -1
                        elif event.key() in [
                                QtCore.Qt.Key_Right, QtCore.Qt.Key_Down,
                                QtCore.Qt.Key_PageDown
                        ]:
                            passed = super().height()
                        self.updatePositionEpub(passed)
                except Exception:
                    traceback.print_exc()
Esempio n. 16
0
 def keyPressEvent(self, event: QKeyEvent):
     if event.type() == QKeyEvent.KeyPress \
             and event.matches(QKeySequence.Copy):
         self.copy_selection_to_clipboard()
     else:
         super().keyPressEvent(event)