def add_books(self): # TODO # Remember file addition modality # If a file is added from here, it should not be removed # from the libary in case of a database refresh dialog_prompt = self._translate('Main_UI', 'Add books to database') ebooks_string = self._translate('Main_UI', 'eBooks') opened_files = QtWidgets.QFileDialog.getOpenFileNames( self, dialog_prompt, self.settings['last_open_path'], f'{ebooks_string} ({self.available_parsers})') if not opened_files[0]: return self.settingsDialog.okButton.setEnabled(False) self.reloadLibrary.setEnabled(False) self.settings['last_open_path'] = os.path.dirname(opened_files[0][0]) self.sorterProgress.setVisible(True) self.statusMessage.setText(self._translate('Main_UI', 'Adding books...')) self.thread = BackGroundBookAddition( opened_files[0], self.database_path, False, self) self.thread.finished.connect(self.move_on) self.thread.start()
def finished_iterating(self): # The books the search thread has found # are now in self.thread.valid_files if not self.thread.valid_files: return # Hey, messaging is important, okay? self.parent.sorterProgress.setVisible(True) self.parent.statusMessage.setText('Parsing files') # We now create a new thread to put those files into the database self.thread = BackGroundBookAddition( self.thread.valid_files, self.database_path, True, self.parent) self.thread.finished.connect(self.parent.move_on) self.thread.start()
def finished_iterating(self): # The books the search thread has found # are now in self.thread.valid_files if not self.thread.valid_files: self.main_window.move_on() return # Hey, messaging is important, okay? self.main_window.statusBar.setVisible(True) self.main_window.sorterProgress.setVisible(True) self.main_window.statusMessage.setText( self._translate('SettingsUI', 'Parsing files')) # We now create a new thread to put those files into the database self.thread = BackGroundBookAddition( self.thread.valid_files, self.database_path, 'automatic', self.main_window) self.thread.finished.connect(self.main_window.move_on) self.thread.start()
def add_books(self): dialog_prompt = self._translate('Main_UI', 'Add books to database') ebooks_string = self._translate('Main_UI', 'eBooks') opened_files = QtWidgets.QFileDialog.getOpenFileNames( self, dialog_prompt, self.settings['last_open_path'], f'{ebooks_string}({self.available_parsers})') if not opened_files[0]: return self.settingsDialog.okButton.setEnabled(False) self.libraryToolBar.reloadLibraryButton.setEnabled(False) self.settings['last_open_path'] = os.path.dirname(opened_files[0][0]) self.statusBar.setVisible(True) self.sorterProgress.setVisible(True) self.statusMessage.setText(self._translate('Main_UI', 'Adding books...')) self.thread = BackGroundBookAddition( opened_files[0], self.database_path, 'manual', self) self.thread.finished.connect( lambda: self.move_on(self.thread.errors)) self.thread.start()