mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add button to automatically fill in Author sort field from Author field
This commit is contained in:
parent
04a5bf16bd
commit
9e9e10c388
1
setup.py
1
setup.py
@ -256,7 +256,6 @@ if __name__ == '__main__':
|
||||
with open('images.qrc', 'wb') as f:
|
||||
f.write(manifest)
|
||||
subprocess.check_call(['pyrcc4', '-o', images, 'images.qrc'])
|
||||
os.remove('images.qrc')
|
||||
else:
|
||||
print 'Images are up to date'
|
||||
finally:
|
||||
|
@ -241,7 +241,7 @@ class OPF(MetaInformation):
|
||||
|
||||
def get_title(self):
|
||||
title = self.soup.package.metadata.find('dc:title')
|
||||
if title:
|
||||
if title and title.string:
|
||||
return self.ENTITY_PATTERN.sub(entity_to_unicode, title.string).strip()
|
||||
return self.default_title.strip()
|
||||
|
||||
|
@ -145,6 +145,8 @@ class MetadataSingleDialog(QDialog, Ui_MetadataSingleDialog):
|
||||
self.edit_tags)
|
||||
QObject.connect(self.remove_series_button, SIGNAL('clicked()'),
|
||||
self.remove_unused_series)
|
||||
QObject.connect(self.auto_author_sort, SIGNAL('clicked()'),
|
||||
self.deduce_author_sort)
|
||||
self.connect(self.swap_button, SIGNAL('clicked()'), self.swap_title_author)
|
||||
self.timeout = float(prefs['network_timeout'])
|
||||
self.title.setText(db.title(row))
|
||||
@ -195,6 +197,16 @@ class MetadataSingleDialog(QDialog, Ui_MetadataSingleDialog):
|
||||
if not pm.isNull():
|
||||
self.cover.setPixmap(pm)
|
||||
|
||||
def deduce_author_sort(self):
|
||||
au = unicode(self.authors.text())
|
||||
tokens = au.split()
|
||||
for x in (',', ';'):
|
||||
if x in tokens:
|
||||
tokens.remove(x)
|
||||
if tokens:
|
||||
tokens = [tokens[-1]+';'] + tokens[:-1]
|
||||
self.author_sort.setText(u' '.join(tokens))
|
||||
|
||||
def swap_title_author(self):
|
||||
title = self.title.text()
|
||||
self.title.setText(self.authors.text())
|
||||
|
@ -5,7 +5,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>796</width>
|
||||
<width>923</width>
|
||||
<height>715</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -116,11 +116,29 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2" >
|
||||
<widget class="QLineEdit" name="author_sort" >
|
||||
<property name="toolTip" >
|
||||
<string>Specify how the author(s) of this book should be sorted. For example Charles Dickens should be sorted as Dickens, Charles.</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" >
|
||||
<item>
|
||||
<widget class="QLineEdit" name="author_sort" >
|
||||
<property name="toolTip" >
|
||||
<string>Specify how the author(s) of this book should be sorted. For example Charles Dickens should be sorted as Dickens, Charles.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="auto_author_sort" >
|
||||
<property name="toolTip" >
|
||||
<string>Automatically create the author sort entry based on the current author entry</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset resource="../images.qrc" >
|
||||
<normaloff>:/images/auto_author_sort.svg</normaloff>:/images/auto_author_sort.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0" >
|
||||
<widget class="QLabel" name="label_6" >
|
||||
|
1472
src/calibre/gui2/images/auto_author_sort.svg
Normal file
1472
src/calibre/gui2/images/auto_author_sort.svg
Normal file
File diff suppressed because it is too large
Load Diff
After Width: | Height: | Size: 46 KiB |
Loading…
x
Reference in New Issue
Block a user