mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Add from ISBN: Add a checkbox to automatically convert obsolete ISBN 10 to ISBN 13. Fixes #2092483 [Add from ISBN: Option to convert to ISBN13](https://bugs.launchpad.net/calibre/+bug/2092483)
This commit is contained in:
parent
7e1796eafd
commit
a78460f09f
@ -10,7 +10,7 @@ import os
|
|||||||
from qt.core import QApplication, QCheckBox, QDialog, QDialogButtonBox, QHBoxLayout, QIcon, QLabel, QLineEdit, QPlainTextEdit, QPushButton, Qt, QVBoxLayout
|
from qt.core import QApplication, QCheckBox, QDialog, QDialogButtonBox, QHBoxLayout, QIcon, QLabel, QLineEdit, QPlainTextEdit, QPushButton, Qt, QVBoxLayout
|
||||||
|
|
||||||
from calibre.constants import iswindows
|
from calibre.constants import iswindows
|
||||||
from calibre.ebooks.metadata import check_isbn
|
from calibre.ebooks.metadata import check_isbn, normalize_isbn
|
||||||
from calibre.gui2 import error_dialog, gprefs, question_dialog
|
from calibre.gui2 import error_dialog, gprefs, question_dialog
|
||||||
|
|
||||||
|
|
||||||
@ -69,6 +69,9 @@ class AddFromISBN(QDialog):
|
|||||||
self._check_for_existing = ce = QCheckBox(_('Check for books with the same ISBN already in library'), self)
|
self._check_for_existing = ce = QCheckBox(_('Check for books with the same ISBN already in library'), self)
|
||||||
ce.setChecked(gprefs.get('add from ISBN dup check', False))
|
ce.setChecked(gprefs.get('add from ISBN dup check', False))
|
||||||
l.addWidget(ce)
|
l.addWidget(ce)
|
||||||
|
self._convert_to_13 = c13 = QCheckBox(_('Convert ISBN-10 to ISBN-13 automatically'), self)
|
||||||
|
c13.setChecked(gprefs.get('convert_isbn_10_to_13', False))
|
||||||
|
l.addWidget(c13)
|
||||||
|
|
||||||
l.addStretch(10)
|
l.addStretch(10)
|
||||||
|
|
||||||
@ -85,11 +88,17 @@ class AddFromISBN(QDialog):
|
|||||||
def check_for_existing(self):
|
def check_for_existing(self):
|
||||||
return self._check_for_existing.isChecked()
|
return self._check_for_existing.isChecked()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def convert_to_13(self):
|
||||||
|
return self._convert_to_13.isChecked()
|
||||||
|
|
||||||
def accept(self, *args):
|
def accept(self, *args):
|
||||||
tags = str(self.add_tags.text()).strip().split(',')
|
tags = str(self.add_tags.text()).strip().split(',')
|
||||||
tags = list(filter(None, [x.strip() for x in tags]))
|
tags = list(filter(None, [x.strip() for x in tags]))
|
||||||
gprefs['add from ISBN tags'] = tags
|
with gprefs:
|
||||||
gprefs['add from ISBN dup check'] = self.check_for_existing
|
gprefs['add from ISBN tags'] = tags
|
||||||
|
gprefs['add from ISBN dup check'] = self.check_for_existing
|
||||||
|
gprefs['convert_isbn_10_to_13'] = self.convert_to_13
|
||||||
self.set_tags = tags
|
self.set_tags = tags
|
||||||
bad = set()
|
bad = set()
|
||||||
for line in str(self.isbn_box.toPlainText()).strip().splitlines():
|
for line in str(self.isbn_box.toPlainText()).strip().splitlines():
|
||||||
@ -113,6 +122,8 @@ class AddFromISBN(QDialog):
|
|||||||
if prefix == 'isbn':
|
if prefix == 'isbn':
|
||||||
isbn = check_isbn(parts[0])
|
isbn = check_isbn(parts[0])
|
||||||
if isbn is not None:
|
if isbn is not None:
|
||||||
|
if gprefs['convert_isbn_10_to_13']:
|
||||||
|
isbn = normalize_isbn(isbn)
|
||||||
isbn = isbn.upper()
|
isbn = isbn.upper()
|
||||||
if isbn not in self.isbns:
|
if isbn not in self.isbns:
|
||||||
self.isbns.append(isbn)
|
self.isbns.append(isbn)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user