Skip to content

Commit

Permalink
Add an option to disable tooltips in the Tag browser (Preferences->Lo…
Browse files Browse the repository at this point in the history
…ok & feel->Tag browser)
  • Loading branch information
kovidgoyal committed Jan 21, 2018
1 parent 80599a0 commit 7f22be3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/calibre/gui2/__init__.py
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/calibre/gui2/preferences/look_feel.py
Expand Up @@ -398,6 +398,7 @@ def genesis(self, gui):
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)
Expand Down
15 changes: 11 additions & 4 deletions src/calibre/gui2/preferences/look_feel.ui
Expand Up @@ -931,14 +931,14 @@ then the tags will be displayed each on their own line.</string>
</property>
</widget>
</item>
<item row="10" column="0" colspan="2">
<item row="11" column="0" colspan="2">
<widget class="QCheckBox" name="opt_tag_browser_old_look">
<property name="text">
<string>Use &amp;alternating row colors in the Tag browser</string>
</property>
</widget>
</item>
<item row="11" column="0" colspan="2">
<item row="12" column="0" colspan="2">
<widget class="QCheckBox" name="opt_tag_browser_hide_empty_categories">
<property name="toolTip">
<string>When checked, calibre will automatically hide any category
Expand Down Expand Up @@ -972,7 +972,7 @@ if you never want subcategories</string>
</property>
</widget>
</item>
<item row="8" column="0">
<item row="9" column="0">
<widget class="QCheckBox" name="opt_show_avg_rating">
<property name="text">
<string>Show &amp;average ratings in the Tag browser</string>
Expand All @@ -982,7 +982,7 @@ if you never want subcategories</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<item row="10" column="0" colspan="2">
<widget class="QCheckBox" name="opt_tag_browser_show_counts">
<property name="toolTip">
<string>Show counts for items in the Tag browser. Such as the number of books
Expand Down Expand Up @@ -1026,6 +1026,13 @@ see the counts by hovering your mouse over any item.</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="opt_tag_browser_show_tooltips">
<property name="text">
<string>Show &amp;tooltips in the Tag browser</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="cover_browser_tab">
Expand Down
34 changes: 18 additions & 16 deletions src/calibre/gui2/tag_browser/model.py
Expand Up @@ -173,7 +173,7 @@ def category_data(self, role):
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]
Expand All @@ -199,21 +199,23 @@ def tag_data(self, role):
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]
Expand Down

0 comments on commit 7f22be3

Please sign in to comment.