From 6daf4d61b9402a65c133b989ebcb374ce16f52aa Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 16 Jul 2015 15:31:51 +0530 Subject: [PATCH] Edit Book: Nicer error message when user tries to rename files in a format that does not support it, such as AZW3 --- src/calibre/gui2/tweak_book/file_list.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/calibre/gui2/tweak_book/file_list.py b/src/calibre/gui2/tweak_book/file_list.py index 5cd95187fe..c7dc18ed9f 100644 --- a/src/calibre/gui2/tweak_book/file_list.py +++ b/src/calibre/gui2/tweak_book/file_list.py @@ -478,6 +478,12 @@ class FileList(QTreeWidget): self.merge_requested.emit(category, names, d.ans) def edit_current_item(self): + if not current_container().SUPPORTS_FILENAMES: + error_dialog(self, _('Cannot rename'), _( + '%s books do not support file renaming as they do not use file names' + ' internally. The filenames you see are automatically generated from the' + ' internal structures of the original file.') % current_container().book_type.upper(), show=True) + return if self.currentItem() is not None: self.editItem(self.currentItem()) @@ -502,6 +508,12 @@ class FileList(QTreeWidget): return QTreeWidget.keyPressEvent(self, ev) def request_bulk_rename(self): + if not current_container().SUPPORTS_FILENAMES: + error_dialog(self, _('Cannot rename'), _( + '%s books do not support file renaming as they do not use file names' + ' internally. The filenames you see are automatically generated from the' + ' internal structures of the original file.') % current_container().book_type.upper(), show=True) + return names = {unicode(item.data(0, NAME_ROLE) or '') for item in self.selectedItems()} bad = names & current_container().names_that_must_not_be_changed if bad: