From fabf0e621f6a9224671664be9655dd945922685b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 7 May 2021 07:33:01 +0530 Subject: [PATCH] Fix #1927537 [Clicking Copy in the Auto merged window copies explanation text](https://bugs.launchpad.net/calibre/+bug/1927537) --- src/calibre/gui2/__init__.py | 4 ++-- src/calibre/gui2/actions/add.py | 2 +- src/calibre/gui2/dialogs/message_box.py | 13 +++++++------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index a0615d4e88..d79817039c 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -456,10 +456,10 @@ def question_dialog(parent, title, msg, det_msg='', show_copy_button=False, def info_dialog(parent, title, msg, det_msg='', show=False, - show_copy_button=True): + show_copy_button=True, only_copy_details=False): from calibre.gui2.dialogs.message_box import MessageBox d = MessageBox(MessageBox.INFO, title, msg, det_msg, parent=parent, - show_copy_button=show_copy_button) + show_copy_button=show_copy_button, only_copy_details=only_copy_details) if show: return d.exec_() diff --git a/src/calibre/gui2/actions/add.py b/src/calibre/gui2/actions/add.py index e97f6f4d6a..b99b156558 100644 --- a/src/calibre/gui2/actions/add.py +++ b/src/calibre/gui2/actions/add.py @@ -585,7 +585,7 @@ class AddAction(InterfaceAction): _('Incoming book formats were processed and merged into your ' 'calibre database according to your auto-merge ' 'settings. Click "Show details" to see the list of merged books.'), - det_msg='\n'.join(lines), show=True) + det_msg='\n'.join(lines), show=True, only_copy_details=True) if adder.number_of_books_added > 0 or adder.merged_books: # The formats of the current book could have changed if diff --git a/src/calibre/gui2/dialogs/message_box.py b/src/calibre/gui2/dialogs/message_box.py index c5ce4ecdbc..5684e081ad 100644 --- a/src/calibre/gui2/dialogs/message_box.py +++ b/src/calibre/gui2/dialogs/message_box.py @@ -83,9 +83,11 @@ class MessageBox(QDialog): # {{{ show_copy_button=True, parent=None, default_yes=True, yes_text=None, no_text=None, yes_icon=None, no_icon=None, - add_abort_button=False + add_abort_button=False, + only_copy_details=False ): QDialog.__init__(self, parent) + self.only_copy_details = only_copy_details self.aborted = False if q_icon is None: icon = { @@ -170,11 +172,10 @@ class MessageBox(QDialog): # {{{ self.resize(self.sizeHint()) def copy_to_clipboard(self, *args): - QApplication.clipboard().setText( - 'calibre, version %s\n%s: %s\n\n%s' % - (__version__, unicode_type(self.windowTitle()), - unicode_type(self.msg.text()), - unicode_type(self.det_msg.toPlainText()))) + text = self.det_msg.toPlainText() + if not self.only_copy_details: + text = f'calibre, version {__version__}\n{self.windowTitle()}: {self.msg.text()}\n\n{text}' + QApplication.clipboard().setText(text) if hasattr(self, 'ctc_button'): self.ctc_button.setText(_('Copied'))