From 7f22be365ca6eb9ba501a81e92b6bd8c48e9c20d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 21 Jan 2018 08:36:45 +0530 Subject: [PATCH] Add an option to disable tooltips in the Tag browser (Preferences->Look & feel->Tag browser) --- src/calibre/gui2/__init__.py | 1 + src/calibre/gui2/preferences/look_feel.py | 1 + src/calibre/gui2/preferences/look_feel.ui | 15 +++++++--- src/calibre/gui2/tag_browser/model.py | 34 ++++++++++++----------- 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index 581a3df134..a6de150153 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -149,6 +149,7 @@ def create_defs(): defs['emblem_position'] = 'left' defs['metadata_diff_mark_rejected'] = False defs['tag_browser_show_counts'] = True + defs['tag_browser_show_tooltips'] = True defs['row_numbers_in_book_list'] = True defs['hidpi'] = 'auto' defs['tag_browser_item_padding'] = 0.5 diff --git a/src/calibre/gui2/preferences/look_feel.py b/src/calibre/gui2/preferences/look_feel.py index 4b538fa566..7ff078c35a 100644 --- a/src/calibre/gui2/preferences/look_feel.py +++ b/src/calibre/gui2/preferences/look_feel.py @@ -398,6 +398,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): r('row_numbers_in_book_list', gprefs) r('tag_browser_old_look', gprefs) r('tag_browser_hide_empty_categories', gprefs) + r('tag_browser_show_tooltips', gprefs) r('bd_show_cover', gprefs) r('bd_overlay_cover_size', gprefs) r('cover_grid_width', gprefs) diff --git a/src/calibre/gui2/preferences/look_feel.ui b/src/calibre/gui2/preferences/look_feel.ui index 1c2ce2b9c3..e725226d23 100644 --- a/src/calibre/gui2/preferences/look_feel.ui +++ b/src/calibre/gui2/preferences/look_feel.ui @@ -931,14 +931,14 @@ then the tags will be displayed each on their own line. - + Use &alternating row colors in the Tag browser - + When checked, calibre will automatically hide any category @@ -972,7 +972,7 @@ if you never want subcategories - + Show &average ratings in the Tag browser @@ -982,7 +982,7 @@ if you never want subcategories - + Show counts for items in the Tag browser. Such as the number of books @@ -1026,6 +1026,13 @@ see the counts by hovering your mouse over any item. + + + + Show &tooltips in the Tag browser + + + diff --git a/src/calibre/gui2/tag_browser/model.py b/src/calibre/gui2/tag_browser/model.py index e0d90fec85..cb7d3667c8 100644 --- a/src/calibre/gui2/tag_browser/model.py +++ b/src/calibre/gui2/tag_browser/model.py @@ -173,7 +173,7 @@ class TagTreeItem(object): # {{{ if role == Qt.FontRole: return bf() if role == Qt.ToolTipRole: - return self.tooltip + return self.tooltip if gprefs['tag_browser_show_tooltips'] else None if role == DRAG_IMAGE_ROLE: self.ensure_icon() return self.icon_state_map[0] @@ -199,21 +199,23 @@ class TagTreeItem(object): # {{{ self.ensure_icon() return self.icon_state_map[tag.state] if role == Qt.ToolTipRole: - tt = [self.tooltip] if self.tooltip else [] - if tag.original_categories: - tt.append('%s:%s' % (','.join(tag.original_categories), tag.original_name)) - else: - tt.append('%s:%s' % (tag.category, tag.original_name)) - ar = self.average_rating - if ar: - tt.append(_('Average rating for books in this category: %.1f') % ar) - elif self.type == self.TAG and ar is not None: - tt.append(_('Books in this category are unrated')) - if self.type == self.TAG and self.tag.category == 'search': - tt.append(_('Search expression:') + ' ' + self.tag.search_expression) - if self.type == self.TAG: - tt.append(_('Number of books: %s') % self.item_count) - return '\n'.join(tt) + if gprefs['tag_browser_show_tooltips']: + tt = [self.tooltip] if self.tooltip else [] + if tag.original_categories: + tt.append('%s:%s' % (','.join(tag.original_categories), tag.original_name)) + else: + tt.append('%s:%s' % (tag.category, tag.original_name)) + ar = self.average_rating + if ar: + tt.append(_('Average rating for books in this category: %.1f') % ar) + elif self.type == self.TAG and ar is not None: + tt.append(_('Books in this category are unrated')) + if self.type == self.TAG and self.tag.category == 'search': + tt.append(_('Search expression:') + ' ' + self.tag.search_expression) + if self.type == self.TAG: + tt.append(_('Number of books: %s') % self.item_count) + return '\n'.join(tt) + return None if role == DRAG_IMAGE_ROLE: self.ensure_icon() return self.icon_state_map[0]