Edit Book: Bulk file rename dialog: Remember last used prefix

This commit is contained in:
Kovid Goyal 2017-11-11 23:02:27 +05:30
parent d5640ec8b7
commit 0e79f5a1c3
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -74,7 +74,9 @@ def get_bulk_rename_settings(parent, number, msg=None, sanitize=sanitize_file_na
d.l = l = QFormLayout(d) d.l = l = QFormLayout(d)
d.setLayout(l) d.setLayout(l)
d.prefix = p = QLineEdit(d) d.prefix = p = QLineEdit(d)
prefix = prefix or {k:v for k, __, v in CATEGORIES}.get(category, _('Chapter-')) default_prefix = {k:v for k, __, v in CATEGORIES}.get(category, _('Chapter-'))
previous = tprefs.get('file-list-bulk-rename-prefix', {})
prefix = prefix or previous.get(category, default_prefix)
p.setText(prefix) p.setText(prefix)
p.selectAll() p.selectAll()
d.la = la = QLabel(msg or _( d.la = la = QLabel(msg or _(
@ -90,6 +92,8 @@ def get_bulk_rename_settings(parent, number, msg=None, sanitize=sanitize_file_na
if d.exec_() == d.Accepted: if d.exec_() == d.Accepted:
prefix = sanitize(unicode(d.prefix.text())) prefix = sanitize(unicode(d.prefix.text()))
previous[category] = prefix
tprefs.set('file-list-bulk-rename-prefix', previous)
num = d.num.value() num = d.num.value()
fmt = '%d' fmt = '%d'
if leading_zeros: if leading_zeros: