Show a busy cursor while processing auto add books

This commit is contained in:
Kovid Goyal 2016-11-01 14:35:46 +05:30
parent f3eb39d49b
commit fee04ccc5f

View File

@ -11,7 +11,7 @@ import os, tempfile, shutil, time
from threading import Thread, Event from threading import Thread, Event
from future_builtins import map from future_builtins import map
from PyQt5.Qt import (QFileSystemWatcher, QObject, Qt, pyqtSignal, QTimer) from PyQt5.Qt import (QFileSystemWatcher, QObject, Qt, pyqtSignal, QTimer, QApplication, QCursor)
from calibre import prints from calibre import prints
from calibre.ptempfile import PersistentTemporaryDirectory from calibre.ptempfile import PersistentTemporaryDirectory
@ -203,7 +203,17 @@ class AutoAdder(QObject):
if hasattr(self, 'worker'): if hasattr(self, 'worker'):
self.worker.join() self.worker.join()
def __enter__(self):
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
def __exit__(self, *args):
QApplication.restoreOverrideCursor()
def add_to_db(self, data): def add_to_db(self, data):
with self:
self.do_add(data)
def do_add(self, data):
from calibre.ebooks.metadata.opf2 import OPF from calibre.ebooks.metadata.opf2 import OPF
gui = self.parent() gui = self.parent()