diff --git a/resources/default_tweaks.py b/resources/default_tweaks.py
index e3a606327a..4ae0278133 100644
--- a/resources/default_tweaks.py
+++ b/resources/default_tweaks.py
@@ -55,16 +55,9 @@ author_sort_copy_method = 'invert'
# categories_use_field_for_author_name = 'author_sort'
categories_use_field_for_author_name = 'author'
-# Control how the tags pane displays categories containing many items. If the
-# number of items is larger than categories_collapse_more_than, a sub-category
-# will be added. If sorting by name, then the subcategories can be organized by
-# first letter (categories_collapse_model = 'first letter') or into equal-sized
-# groups (categories_collapse_model = 'partition'). If sorting by average rating
-# or by popularity, then 'partition' is always used. The addition of
-# subcategories can be disabled by setting categories_collapse_model='disable'.
-# When using partition, the format of the subcategory label is controlled by a
-# template: categories_collapsed_name_template if sorting by name,
-# categories_collapsed_rating_template if sorting by average rating, and
+# When partitioning the tags browser, the format of the subcategory label is
+# controlled by a template: categories_collapsed_name_template if sorting by
+# name, categories_collapsed_rating_template if sorting by average rating, and
# categories_collapsed_popularity_template if sorting by popularity. There are
# two variables available to the template: first and last. The variable 'first'
# is the initial item in the subcategory, and the variable 'last' is the final
@@ -76,12 +69,6 @@ categories_use_field_for_author_name = 'author'
# avg_rating: the averate rating of all the books referencing this item
# sort: the sort value. For authors, this is the author_sort for that author
# category: the category (e.g., authors, series) that the item is in.
-# Possible values:
-# category_collapse_model: 'disable', 'first letter', 'partition'
-# categories_collapse_more_than: a number greater than or equal to 0
-# the templates: any valid template using only 'first' and 'last'
-categories_collapse_model = 'first letter'
-categories_collapse_more_than = 50
categories_collapsed_name_template = '{first.sort:shorten(4,'',0)} - {last.sort:shorten(4,'',0)}'
categories_collapsed_rating_template = '{first.avg_rating:4.2f:ifempty(0)} - {last.avg_rating:4.2f:ifempty(0)}'
categories_collapsed_popularity_template = '{first.count:d} - {last.count:d}'
diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py
index 1c99d9d9d5..8c62304f09 100644
--- a/src/calibre/gui2/__init__.py
+++ b/src/calibre/gui2/__init__.py
@@ -53,6 +53,8 @@ gprefs.defaults['toolbar_icon_size'] = 'medium'
gprefs.defaults['toolbar_text'] = 'auto'
gprefs.defaults['show_child_bar'] = False
gprefs.defaults['font'] = None
+gprefs.defaults['tags_browser_partition_method'] = 'first letter'
+gprefs.defaults['tags_browser_collapse_at'] = 50
# }}}
diff --git a/src/calibre/gui2/preferences/look_feel.py b/src/calibre/gui2/preferences/look_feel.py
index de1116c231..263d19325d 100644
--- a/src/calibre/gui2/preferences/look_feel.py
+++ b/src/calibre/gui2/preferences/look_feel.py
@@ -57,6 +57,11 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
(_('Never'), 'never')]
r('toolbar_text', gprefs, choices=choices)
+ choices = [(_('Disabled'), 'disabled'), (_('By first letter'), 'first letter'),
+ (_('Partitioned'), 'partition')]
+ r('tags_browser_partition_method', gprefs, choices=choices)
+ r('tags_browser_collapse_at', gprefs)
+
self.current_font = None
self.change_font_button.clicked.connect(self.change_font)
@@ -113,6 +118,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
def refresh_gui(self, gui):
gui.search.search_as_you_type(config['search_as_you_type'])
self.update_font_display()
+ gui.tags_view.reread_collapse_parameters()
if __name__ == '__main__':
app = QApplication([])
diff --git a/src/calibre/gui2/preferences/look_feel.ui b/src/calibre/gui2/preferences/look_feel.ui
index 8e57f8c17e..36a45b8dce 100644
--- a/src/calibre/gui2/preferences/look_feel.ui
+++ b/src/calibre/gui2/preferences/look_feel.ui
@@ -7,7 +7,7 @@
0
0
670
- 385
+ 420
@@ -141,7 +141,37 @@
- -
+
-
+
+
+ Tags browser: partitioning method:
+
+
+ opt_tags_browser_partition_method
+
+
+
+ -
+
+
+ -
+
+
+ Tags browser - collapse when more items than:
+
+
+ opt_tags_browser_collapse_at
+
+
+
+ -
+
+
+ 1000000
+
+
+
+ -
&Toolbar
@@ -183,7 +213,7 @@
- -
+
-
-
@@ -204,14 +234,14 @@
- -
+
-
Change &font (needs restart)
- -
+
-
Qt::Vertical
diff --git a/src/calibre/gui2/tag_view.py b/src/calibre/gui2/tag_view.py
index 538d16cd85..8d42e51dfc 100644
--- a/src/calibre/gui2/tag_view.py
+++ b/src/calibre/gui2/tag_view.py
@@ -17,7 +17,7 @@ from PyQt4.Qt import Qt, QTreeView, QApplication, pyqtSignal, QFont, QSize, \
QShortcut, QKeySequence, SIGNAL
from calibre.ebooks.metadata import title_sort
-from calibre.gui2 import config, NONE
+from calibre.gui2 import config, NONE, gprefs
from calibre.library.field_metadata import TagsIcons, category_icon_map
from calibre.utils.config import tweaks
from calibre.utils.icu import sort_key, upper, lower, strcmp
@@ -94,10 +94,10 @@ class TagsView(QTreeView): # {{{
self.setDropIndicatorShown(True)
self.setAutoExpandDelay(500)
self.pane_is_visible = False
- if tweaks['categories_collapse_more_than'] == 0:
+ if gprefs['tags_browser_collapse_at'] == 0:
self.collapse_model = 'disable'
else:
- self.collapse_model = tweaks['categories_collapse_model']
+ self.collapse_model = gprefs['tags_browser_partition_method']
def set_pane_is_visible(self, to_what):
pv = self.pane_is_visible
@@ -105,6 +105,13 @@ class TagsView(QTreeView): # {{{
if to_what and not pv:
self.recount()
+ def reread_collapse_parameters(self):
+ if gprefs['tags_browser_collapse_at'] == 0:
+ self.collapse_model = 'disable'
+ else:
+ self.collapse_model = gprefs['tags_browser_partition_method']
+ self.set_new_model(self._model.get_filter_categories_by())
+
def set_database(self, db, tag_match, sort_by):
self.hidden_categories = config['tag_browser_hidden_categories']
self._model = TagsModel(db, parent=self,
@@ -204,6 +211,7 @@ class TagsView(QTreeView): # {{{
self.collapse_model = category
if changed:
self.set_new_model(self._model.get_filter_categories_by())
+ gprefs['tags_browser_partition_method'] = category
elif action == 'defaults':
self.hidden_categories.clear()
config.set('tag_browser_hidden_categories', self.hidden_categories)
@@ -709,7 +717,7 @@ class TagsModel(QAbstractItemModel): # {{{
if data is None:
return False
row_index = -1
- collapse = tweaks['categories_collapse_more_than']
+ collapse = gprefs['tags_browser_collapse_at']
collapse_model = self.collapse_model
if collapse == 0:
collapse_model = 'disable'