Manage data files dialog: Add a button to cancel remaining books when managing multiple books. Fixes #2112424 ['Manage Data Files' on multiple books](https://bugs.launchpad.net/calibre/+bug/2112424)

This commit is contained in:
Kovid Goyal 2025-06-04 09:58:59 +05:30
parent b78b98970a
commit ddcc2c4bbd
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 14 additions and 2 deletions

View File

@ -110,9 +110,12 @@ class EditMetadataAction(InterfaceActionWithLibraryDrop):
from calibre.gui2.dialogs.data_files_manager import DataFilesManager
db = self.gui.current_db
ids = self.gui.library_view.get_selected_ids()
num = len(ids)
for book_id in ids:
d = DataFilesManager(db, book_id, self.gui)
d = DataFilesManager(db, book_id, self.gui, num - 1)
d.exec()
if d.num_left < 1:
break
cr = self.gui.library_view.currentIndex().row()
self.gui.library_view.model().refresh_ids(ids, cr)

View File

@ -222,8 +222,9 @@ class ListView(QListView):
class DataFilesManager(Dialog):
def __init__(self, db, book_id, parent=None):
def __init__(self, db, book_id, parent=None, num_left=0):
self.db = db.new_api
self.num_left = num_left
self.book_title = title = self.db.field_for('title', book_id) or _('Unknown')
self.book_id = book_id
super().__init__(_('Manage data files for {}').format(title), 'manage-data-files-xx',
@ -291,11 +292,19 @@ class DataFilesManager(Dialog):
trash = _('Recycle bin')
b.setToolTip(_('Move all selected files to the system {trash}.\nThey can be restored from there if needed').format(trash=trash))
self.bb.addButton(b, QDialogButtonBox.ButtonRole.ActionRole)
if self.num_left > 0:
b = QPushButton(_('Cancel remaining books'), self)
self.bb.addButton(b, QDialogButtonBox.ButtonRole.RejectRole)
b.clicked.connect(self.cancel_remaining)
self.current_changed()
self.resize(self.sizeHint())
self.fview.setFocus(Qt.FocusReason.OtherFocusReason)
def cancel_remaining(self):
self.num_left = 0
self.reject()
def context_menu(self, pos):
m = QMenu(self)
idx = self.fview.indexAt(pos)