mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
8d9a4164b4
commit
817bde27aa
@ -4,13 +4,14 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
'''Dialog to edit metadata in bulk'''
|
||||
|
||||
from PyQt4.Qt import SIGNAL, QObject, QDialog, QGridLayout, \
|
||||
QProgressDialog, QCoreApplication, QString
|
||||
QCoreApplication
|
||||
|
||||
from calibre.gui2.dialogs.metadata_bulk_ui import Ui_MetadataBulkDialog
|
||||
from calibre.gui2.dialogs.tag_editor import TagEditor
|
||||
from calibre.ebooks.metadata import string_to_authors, \
|
||||
authors_to_string
|
||||
from calibre.gui2.custom_column_widgets import populate_metadata_page
|
||||
from calibre.gui2.dialogs.progress import ProgressDialog
|
||||
|
||||
class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
|
||||
|
||||
@ -106,12 +107,11 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
|
||||
if len(self.ids) < 1:
|
||||
return QDialog.accept(self)
|
||||
|
||||
pd = QProgressDialog(
|
||||
pd = ProgressDialog(_('Working'),
|
||||
_('Applying changes to %d books. This may take a while.')%len(self.ids),
|
||||
QString(), 0, 0, self)
|
||||
0, 0, self, cancelable=False)
|
||||
pd.setModal(True)
|
||||
pd.show()
|
||||
pd.setValue(0)
|
||||
def upd():
|
||||
QCoreApplication.processEvents()
|
||||
|
||||
@ -164,7 +164,6 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
|
||||
|
||||
if rating != -1:
|
||||
self.db.set_rating(id, 2*rating, notify=False)
|
||||
upd()
|
||||
|
||||
if pub:
|
||||
self.db.set_publisher(id, pub, notify=False)
|
||||
@ -181,10 +180,8 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
|
||||
self.db.remove_format(id, remove_format, index_is_id=True, notify=False)
|
||||
upd()
|
||||
|
||||
|
||||
if do_remove_conv:
|
||||
self.db.delete_conversion_options(id, 'PIPE')
|
||||
upd()
|
||||
|
||||
upd()
|
||||
for w in getattr(self, 'custom_column_widgets', []):
|
||||
@ -195,7 +192,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
|
||||
|
||||
|
||||
finally:
|
||||
pd.cancel()
|
||||
pd.hide()
|
||||
|
||||
return QDialog.accept(self)
|
||||
|
||||
|
@ -13,7 +13,8 @@ class ProgressDialog(QDialog, Ui_Dialog):
|
||||
|
||||
canceled_signal = pyqtSignal()
|
||||
|
||||
def __init__(self, title, msg='', min=0, max=99, parent=None):
|
||||
def __init__(self, title, msg='', min=0, max=99, parent=None,
|
||||
cancelable=True):
|
||||
QDialog.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
self.setWindowTitle(title)
|
||||
@ -26,6 +27,9 @@ class ProgressDialog(QDialog, Ui_Dialog):
|
||||
self.canceled = False
|
||||
|
||||
self.button_box.rejected.connect(self._canceled)
|
||||
if not cancelable:
|
||||
self.button_box.setVisible(False)
|
||||
self.cancelable = cancelable
|
||||
|
||||
def set_msg(self, msg=''):
|
||||
self.message.setText(msg)
|
||||
@ -54,8 +58,14 @@ class ProgressDialog(QDialog, Ui_Dialog):
|
||||
self.title.setText(_('Aborting...'))
|
||||
self.canceled_signal.emit()
|
||||
|
||||
def reject(self):
|
||||
if not self.cancelable:
|
||||
return
|
||||
QDialog.reject(self)
|
||||
|
||||
def keyPressEvent(self, ev):
|
||||
if ev.key() == Qt.Key_Escape:
|
||||
self._canceled()
|
||||
if self.cancelable:
|
||||
self._canceled()
|
||||
else:
|
||||
QDialog.keyPressEvent(self, ev)
|
||||
|
Loading…
x
Reference in New Issue
Block a user