def keyPressEvent(self,event): #Scrolls through list_widget. May (probably) not the best way to do this with Qt/PyQt. #Still looking for a cleaner alternative if event.key() == Qt.Key_Down or Qt.Key_Up: self.list_widget.keyPressEvent(event) self.setFocus() #Key to toggle hidden if event.key() == Qt.Key_Q: self.toggle_hidden() #Path Input if event.key() == Qt.Key_Shift: #Try-Except prevents multiple input bars from opening up try: if self.line_edit is None: self.get_input() except AttributeError: self.get_input() #Backwards Traversal if event.key() == Qt.Key_Backspace: self.path.back_traverse() self.path_label.setText(self.path.path) self.path_update_event() #Go to home directory if event.key() == Qt.Key_Home: self.path.path = self.home self.path_label.setText(self.path.path) self.path_update_event() #Go to selection if event.key() == Qt.Key_Return: self.list_view_enter() #Delete File if event.key() == Qt.Key_Delete: self.delete_prompt() #Copy file to clipboard - no delete if event.key() == Qt.Key_C and Qt.ControlModifier: self.path.copy_file_name = self.list_widget.currentItem().text() self.path.copy_path = self.path.path + '/' + self.path.copy_file_name self.path.copy_flag = True self.path.del_flag = False #Copy file to clipboard - delete if event.key() == Qt.Key_X and Qt.ControlModifier: self.path.copy_file_name = self.list_widget.currentItem().text() self.path.copy_path = self.path.path + '/' + self.path.copy_file_name self.path.copy_flag = True self.path.del_flag = True #Paste copy if event.key() == Qt.Key_V and Qt.ControlModifier: if self.path.copy_flag: if not self.path.del_flag: filemanage.copy_file(self.path.copy_path, self.path.copy_file_name, self.path.path, self.path.del_flag) self.path_update_event() else: self.delete_prompt('cut_paste')
def cut_confirm_pressed(self): filemanage.copy_file(self.path.copy_path, self.path.copy_file_name, self.path.path, self.path.del_flag) self.path_update_event() self.dconf_label.releaseKeyboard() self.dconf_label.close() self.setFocus()