def keyReleaseEvent(self, event: QKeyEvent) -> None: super().keyReleaseEvent(event) if event.key() == Qt.Key_Alt: self.list_input_files.setDragEnabled(False) elif event.key() in [Qt.Key_Shift, Qt.Key_Control]: self._enable_cross_selection = False
def keyReleaseEvent(self, event: QKeyEvent): if event.key() == Qt.Key.Key_Delete: self.DeleteSelected() if event.key() == Qt.Key.Key_D and event.modifiers() == Qt.Modifier.CTRL: self.DuplicateSelected() super().keyReleaseEvent(event)
def rotate_selected(scene: QGraphicsScene, e: QKeyEvent): for item in scene.selectedItems(): if e.key() == Qt.Key_Right: item.setRotation( (item.rotation() + 1 + (2 * (e.modifiers() == Qt.ShiftModifier))) % 360) elif e.key() == Qt.Key_Left: item.setRotation( (item.rotation() - 1 - (2 * (e.modifiers() == Qt.ShiftModifier))) % 360)
def keyPressEvent(self, event: QKeyEvent) -> None: if event.key() == Qt.Key_Escape: self.modlist.setFocus() self.searchbar.setText('') elif event.matches(QKeySequence.Find): self.searchbar.setFocus() elif event.matches(QKeySequence.Paste): self.pasteEvent() # TODO: enhancement: add start game / start script merger shortcuts else: super().keyPressEvent(event)
def keyPressEvent(self, e: QKeyEvent) -> None: if len(self.scene().selectedItems()) > 0: if e.key() == Qt.Key_Delete: OperationTools.delete_selected(self.scene(), self.gim) self.changed.emit() elif e.key() == Qt.Key_Right or e.key() == Qt.Key_Left: OperationTools.rotate_selected(self.scene(), e) self.changed.emit() elif e.key() in [Qt.Key_W, Qt.Key_S, Qt.Key_A, Qt.Key_D]: OperationTools.rescale_selected(self.scene(), e) self.changed.emit()
def rescale_selected(scene: QGraphicsScene, e: QKeyEvent): for item in scene.selectedItems(): transform = item.transform() if e.key() == Qt.Key_W: transform.scale(1, 1.01) elif e.key() == Qt.Key_S: transform.scale(1, 0.99) elif e.key() == Qt.Key_D: transform.scale(1.01, 1) elif e.key() == Qt.Key_A: transform.scale(0.99, 1) item.setTransform(transform)
def hide_on_confirm(event: QtGui.QKeyEvent) -> None: key = event.key() if key == QtCore.Qt.Key.Key_Return or key == QtCore.Qt.Key.Key_Enter: self._value_spinbox.clear_focus() self._value_spinbox.hide() else: base_key_release_event(event)
def keyPressEvent(self, event: QKeyEvent) -> None: shift = event.modifiers() & Qt.ShiftModifier == Qt.ShiftModifier key = event.key() if key == Qt.Key_Up: if shift: self.signal_key_selection_pressed.emit(KeyType.UP) else: self.signal_key_cursor_pressed.emit(KeyType.UP) elif key == Qt.Key_Down: if shift: self.signal_key_selection_pressed.emit(KeyType.DOWN) else: self.signal_key_cursor_pressed.emit(KeyType.DOWN) elif key == Qt.Key_Left: if shift: self.signal_key_selection_pressed.emit(KeyType.LEFT) else: self.signal_key_cursor_pressed.emit(KeyType.LEFT) elif key == Qt.Key_Right: if shift: self.signal_key_selection_pressed.emit(KeyType.RIGHT) else: self.signal_key_cursor_pressed.emit(KeyType.RIGHT) elif key == Qt.Key_PageUp: if shift: self.signal_key_selection_pressed.emit(KeyType.PAGE_UP) else: self.signal_key_cursor_pressed.emit(KeyType.PAGE_UP) elif key == Qt.Key_PageDown: if shift: self.signal_key_selection_pressed.emit(KeyType.PAGE_DOWN) else: self.signal_key_cursor_pressed.emit(KeyType.PAGE_DOWN) elif key == Qt.Key_Home: if shift: self.signal_key_selection_pressed.emit(KeyType.HOME) else: self.signal_key_cursor_pressed.emit(KeyType.HOME) elif key == Qt.Key_End: if shift: self.signal_key_selection_pressed.emit(KeyType.END) else: self.signal_key_cursor_pressed.emit(KeyType.END)
def keyPressEvent(self, event: QtGui.QKeyEvent): super(MainWidget, self).keyPressEvent(event) if event.key() == QtCore.Qt.Key_Left or event.key( ) == QtCore.Qt.Key_Right: self.__selected_left = not self.__selected_left if self.__selected_left: self.__left_image_widget.setStyleSheet( "background-color: yellow") self.__right_image_widget.setStyleSheet( "background-color: black") else: self.__right_image_widget.setStyleSheet( "background-color: yellow") self.__left_image_widget.setStyleSheet( "background-color: black") elif event.key() == QtCore.Qt.Key_Return: self.__next_button_click() elif event.key() == QtCore.Qt.Key_Delete: self.__delete_selected()
def keyPressEvent(self, event: QKeyEvent): # pylint: disable=invalid-name; """Keyboard event handler.""" if event.key() == Qt.Key_Escape and self.play_button.isChecked(): self.play_button.toggle() self.browser_button.setChecked((True, False)[self.reset_browser]) elif (event.key() in [16777220, 16777221] and self.view.g_rect.rect().width() > 0): self.view.got_rect.emit((self.view.g_rect.rect().topLeft(), self.view.g_rect.rect().bottomRight())) if self.view.g_rect.pen().color() == Qt.red: new_pix = self.pixmap.pixmap().copy(self.crop_rect) if self.pixmap_is_scaled: new_pix = new_pix.transformed( self.view.transform().inverted()[0], Qt.SmoothTransformation) self.update_pixmap(new_pix) elif self.view.g_rect.pen().color() == Qt.magenta: self.annotate_rect() self.view.annotation = False for _ in (self.label, self.save_button, self.no_save_button): _.show() self.view.reset()
def keyPressEvent(self, event: QKeyEvent): if event.key() == Qt.Key_Delete: if len(self.selectedItems()) > 0: for item in self.selectedItems(): index = item.index particle_data = self._particle_data[self.current_frame_index] particle_data.remove_particle(index) particle_data.remove_trajectory(index) if self.current_frame_index + 1 in self._particle_data: next_particle_data = self._particle_data[self.current_frame_index + 1] next_particle_data.remove_trajectory(index) del self.particle_group_items[index] self.removeItem(item) if index in self.trajectory_items[self.current_frame_index]: self.removeItem(self.trajectory_items[self.current_frame_index][index]) # 更新展需要更新轨迹的帧 self.updated_frame_index = {i for i in self.updated_frame_index if i < self.current_frame_index} self.calc_trajectory() super(VideoScene, self).keyPressEvent(event)
def keyPressEvent(self, event: QKeyEvent) -> None: if event.key() == Qt.Key_Escape: self.selectionModel().clear() elif event.matches(QKeySequence.Delete): asyncio.create_task(self.deleteSelectedMods()) elif event.modifiers( ) & Qt.ControlModifier == Qt.ControlModifier and event.key( ) == Qt.Key_Up: asyncio.create_task(self.changeSelectedModsPriority(1)) elif event.modifiers( ) & Qt.ControlModifier == Qt.ControlModifier and event.key( ) == Qt.Key_Down: asyncio.create_task(self.changeSelectedModsPriority(-1)) elif event.modifiers( ) & Qt.ControlModifier == Qt.ControlModifier and event.key( ) == Qt.Key_P: index = self.selectionModel().selectedRows()[0] index = index.sibling(index.row(), 5) if index.flags() & Qt.ItemIsEditable: self.setCurrentIndex(index) self.edit(index) else: super().keyPressEvent(event)
def keyPressEvent(self, a0: QtGui.QKeyEvent) -> None: if a0.key() == QtCore.Qt.Key_Q: self.hide() super(LargePreview, self).keyPressEvent(a0)
def keyPressEvent(self, event: QKeyEvent) -> None: if event.key() == Qt.Key_Minus: self.setDateTime( QDateTime(QDate(1970, 1, 1), QTime(0, 0, 0), Qt.UTC)) # = 0 timestamp super().keyPressEvent(event)
def keyPressEvent(self, event : QtGui.QKeyEvent): super(MainWidget, self).keyPressEvent(event) if event.key() == QtGui.QKeySequence.fromString("Space",QtGui.QKeySequence.SequenceFormat.NativeText): pass else: exit(0)