From e2089096647513c5cb1826afc9e598d78f6fc1a6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 9 Aug 2021 11:56:45 +0530 Subject: [PATCH] Edit metadata dialog: When pasting into the identifiers field if the clipboard contains a URL paste it directly as a URL identifier. Fixes #1938752 [Pasting url identifiers results in Invalid ISBN dialog](https://bugs.launchpad.net/calibre/+bug/1938752) --- src/calibre/gui2/metadata/basic_widgets.py | 3 +++ src/calibre/gui2/metadata/single.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/metadata/basic_widgets.py b/src/calibre/gui2/metadata/basic_widgets.py index ba59876dc3..4591d3bde9 100644 --- a/src/calibre/gui2/metadata/basic_widgets.py +++ b/src/calibre/gui2/metadata/basic_widgets.py @@ -1642,6 +1642,9 @@ class IdentifiersEdit(QLineEdit, ToMetadataMixin): identifier_found = self.parse_clipboard_for_identifier() if identifier_found: return + text = unicode_type(QApplication.clipboard().text()).strip() + if text.startswith('http://') or text.startswith('https://'): + return self.paste_prefix('url') try: prefix = gprefs['paste_isbn_prefixes'][0] except IndexError: diff --git a/src/calibre/gui2/metadata/single.py b/src/calibre/gui2/metadata/single.py index 73ce01919d..a634b8905d 100644 --- a/src/calibre/gui2/metadata/single.py +++ b/src/calibre/gui2/metadata/single.py @@ -251,7 +251,7 @@ class MetadataSingleDialogBase(QDialog): self.paste_isbn_button = b = RightClickButton(self) b.setToolTip('

' + _('Paste the contents of the clipboard into the ' - 'identifiers prefixed with isbn:. Or right click, ' + 'identifiers prefixed with isbn: or url:. Or right click, ' 'to choose a different prefix.') + '

') b.setIcon(QIcon(I('edit-paste.png'))) b.clicked.connect(self.identifiers.paste_identifier)