From b1fbfcf2a47ea06652fef5af77906426a2e86eb6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 19 Jul 2014 17:09:57 +0530 Subject: [PATCH] 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) --- src/calibre/ebooks/metadata/book/render.py | 19 +++-- src/calibre/gui2/preferences/look_feel.py | 3 + src/calibre/gui2/preferences/look_feel.ui | 86 ++++++++++++---------- 3 files changed, 62 insertions(+), 46 deletions(-) diff --git a/src/calibre/ebooks/metadata/book/render.py b/src/calibre/ebooks/metadata/book/render.py index 9c2c655225..95534ef2db 100644 --- a/src/calibre/ebooks/metadata/book/render.py +++ b/src/calibre/ebooks/metadata/book/render.py @@ -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'%s'%(a(link), a(link), aut)) + authors.append(u'%s'%(lt, link, aut)) else: authors.append(aut) ans.append((field, row % (name, u' & '.join(authors)))) diff --git a/src/calibre/gui2/preferences/look_feel.py b/src/calibre/gui2/preferences/look_feel.py index a0402695a3..87b2564c95 100644 --- a/src/calibre/gui2/preferences/look_feel.py +++ b/src/calibre/gui2/preferences/look_feel.py @@ -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 diff --git a/src/calibre/gui2/preferences/look_feel.ui b/src/calibre/gui2/preferences/look_feel.ui index 30c602019a..f99204c001 100644 --- a/src/calibre/gui2/preferences/look_feel.ui +++ b/src/calibre/gui2/preferences/look_feel.ui @@ -623,16 +623,6 @@ A value of zero means calculate automatically. - - - - Use &Roman numerals for series - - - true - - - @@ -684,7 +674,51 @@ A value of zero means calculate automatically. - + + + + + + Show &cover in the book details panel + + + + + + + Show the size of the book's cover in pixels + + + Show cover &size + + + + + + + Use &Roman numerals for series + + + true + + + + + + + Qt::Horizontal + + + + 20 + 0 + + + + + + + @@ -707,40 +741,16 @@ Manage Authors. You can use the values {author} and - - - - - - - Show &cover in the book details panel - - - - - + - Show the size of the book's cover in pixels + Search the calibre library for the author, instead of opening a link - Show cover &size + Search &calibre library for author - - - - Qt::Horizontal - - - - 20 - 0 - - - -