diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py index dee1b2bfa8..e6b23d8157 100644 --- a/src/calibre/gui2/main.py +++ b/src/calibre/gui2/main.py @@ -6,7 +6,8 @@ from functools import partial from PyQt4.QtCore import Qt, SIGNAL, QObject, QCoreApplication, QUrl, QTimer from PyQt4.QtGui import QPixmap, QColor, QPainter, QMenu, QIcon, QMessageBox, \ QToolButton, QDialog, QDesktopServices, QFileDialog, \ - QSystemTrayIcon, QApplication, QKeySequence, QAction + QSystemTrayIcon, QApplication, QKeySequence, QAction, \ + QProgressDialog from PyQt4.QtSvg import QSvgRenderer from calibre import __version__, __appname__, islinux, sanitize_file_name, \ @@ -566,8 +567,23 @@ class Main(MainWindow, Ui_MainWindow): root = choose_dir(self, 'recursive book import root dir dialog', 'Select root folder') if not root: return - duplicates = self.library_view.model().db.recursive_import(root, single) - + progress = QProgressDialog('', '&'+_('Stop'), + 0, 0, self) + progress.setWindowModality(Qt.ApplicationModal) + progress.setWindowTitle(_('Adding books recursively...')) + progress.show() + def callback(msg): + if msg != '.': + progress.setLabelText((_('Added ')+msg) if msg else _('Searching...')) + stop = progress.wasCanceled() + QApplication.processEvents() + QApplication.sendPostedEvents() + QApplication.flush() + return stop + try: + duplicates = self.library_view.model().db.recursive_import(root, single, callback=callback) + finally: + progress.close() if duplicates: files = _('

Books with the same title as the following already exist in the database. Add them anyway?