Book details panel: Add an option to make clicking on the author name search the calibre library for the author instead of opening the wikipedia page for the author. To use it got to Preferences->Look & Feel->Book Details. Fixes #1344799 [[Enhancement] make author (in book details) a link/clickable for search in calibre](https://bugs.launchpad.net/calibre/+bug/1344799)

This commit is contained in:
Kovid Goyal 2014-07-19 17:09:57 +05:30
parent b6787fc6b1
commit b1fbfcf2a4
3 changed files with 62 additions and 46 deletions

View File

@ -144,16 +144,19 @@ def mi_to_html(mi, field_list=None, default_author_link=None, use_roman_numbers=
if mi.author_link_map[aut]:
link = mi.author_link_map[aut]
elif default_author_link:
vals = {'author': aut.replace(' ', '+')}
try:
vals['author_sort'] = mi.author_sort_map[aut].replace(' ', '+')
except:
vals['author_sort'] = aut.replace(' ', '+')
link = formatter.safe_format(
default_author_link, vals, '', vals)
if default_author_link == 'search-calibre':
link = search_href('authors', aut)
lt = a(_('Search the calibre library for books by %s') % aut)
else:
vals = {'author': aut.replace(' ', '+')}
try:
vals['author_sort'] = mi.author_sort_map[aut].replace(' ', '+')
except:
vals['author_sort'] = aut.replace(' ', '+')
link = lt = a(formatter.safe_format(default_author_link, vals, '', vals))
aut = p(aut)
if link:
authors.append(u'<a calibre-data="authors" title="%s" href="%s">%s</a>'%(a(link), a(link), aut))
authors.append(u'<a calibre-data="authors" title="%s" href="%s">%s</a>'%(lt, link, aut))
else:
authors.append(aut)
ans.append((field, row % (name, u' & '.join(authors))))

View File

@ -199,6 +199,9 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
r('default_author_link', gprefs)
r('tag_browser_dont_collapse', gprefs, setting=CommaSeparatedList)
self.search_library_for_author_button.clicked.connect(
lambda : self.opt_default_author_link.setText('search-calibre'))
choices = set([k for k in db.field_metadata.all_field_keys()
if (db.field_metadata[k]['is_category'] and
(db.field_metadata[k]['datatype'] in ['text', 'series', 'enumeration']) and

View File

@ -623,16 +623,6 @@ A value of zero means calculate automatically.</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="opt_use_roman_numerals_for_series_number">
<property name="text">
<string>Use &amp;Roman numerals for series</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0" rowspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
@ -684,7 +674,51 @@ A value of zero means calculate automatically.</string>
</layout>
</widget>
</item>
<item row="0" column="0">
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout">
<item>
<widget class="QCheckBox" name="opt_bd_show_cover">
<property name="text">
<string>Show &amp;cover in the book details panel</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="opt_bd_overlay_cover_size">
<property name="toolTip">
<string>Show the size of the book's cover in pixels</string>
</property>
<property name="text">
<string>Show cover &amp;size</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="opt_use_roman_numerals_for_series_number">
<property name="text">
<string>Use &amp;Roman numerals for series</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_bd1">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="0" column="0" colspan="2">
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="label">
@ -707,40 +741,16 @@ Manage Authors. You can use the values {author} and
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout">
<item>
<widget class="QCheckBox" name="opt_bd_show_cover">
<property name="text">
<string>Show &amp;cover in the book details panel</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="opt_bd_overlay_cover_size">
<widget class="QPushButton" name="search_library_for_author_button">
<property name="toolTip">
<string>Show the size of the book's cover in pixels</string>
<string>Search the calibre library for the author, instead of opening a link</string>
</property>
<property name="text">
<string>Show cover &amp;size</string>
<string>Search &amp;calibre library for author</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_bd1">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>