Add an option to optimize the calibre UI for use with large numbers of libraries. With this option, the Quick Switch and Copy to Library menus will remember more than just 25 libraries and the libraries will be sorted alphabetically instead of by most frequently used. Option is under Preferences->Behavior. Fixes #1133691 (feature request: again: sort entries in "quick switch")

This commit is contained in:
Kovid Goyal 2013-02-27 14:12:59 +05:30
parent 6776554115
commit f3f4bdb023
4 changed files with 20 additions and 3 deletions

View file

@ -110,6 +110,7 @@
defs['tags_browser_category_icons'] = {}
defs['cover_browser_reflections'] = True
defs['extra_row_spacing'] = 0
defs['many_libraries'] = False
del defs
# }}}

View file

@ -16,6 +16,7 @@
from calibre.constants import (filesystem_encoding, iswindows,
get_portable_base)
from calibre.utils.config import prefs
from calibre.utils.icu import sort_key
from calibre.gui2 import (gprefs, warning_dialog, Dispatcher, error_dialog,
question_dialog, info_dialog, open_local_file, choose_dir)
from calibre.library.database2 import LibraryDatabase2
@ -46,7 +47,7 @@ def write_stats(self):
locs = list(self.stats.keys())
locs.sort(cmp=lambda x, y: cmp(self.stats[x], self.stats[y]),
reverse=True)
for key in locs[25:]:
for key in locs[(10000 if gprefs['many_libraries'] else 25):]:
self.stats.pop(key)
gprefs.set('library_usage_stats', self.stats)
@ -72,8 +73,10 @@ def locations(self, db):
locs = list(self.stats.keys())
if lpath in locs:
locs.remove(lpath)
locs.sort(cmp=lambda x, y: cmp(self.stats[x], self.stats[y]),
reverse=True)
if gprefs['many_libraries']:
locs.sort(key=sort_key)
else:
locs.sort(key=lambda x: self.stats[x], reverse=True)
for loc in locs:
yield self.pretty(loc), loc

View file

@ -60,6 +60,7 @@ def genesis(self, gui):
signal.connect(self.internally_viewed_formats_changed)
r('bools_are_tristate', db.prefs, restart_required=True)
r('many_libraries', gprefs, restart_required=True)
r = self.register
choices = [(_('Default'), 'default'), (_('Compact Metadata'), 'alt1'),
(_('All on 1 tab'), 'alt2')]

View file

@ -284,6 +284,18 @@ If not checked, the values can be Yes or No.</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="opt_many_libraries">
<property name="toolTip">
<string>Optimizes the interface for use with a large number of libraries. calibre will
now remeber unlimited numbers of libraries in its Quick Switch and Copy to Library
menus, and the libraries will be sorted alphabetically.</string>
</property>
<property name="text">
<string>Optimize for use with many &amp;libraries (Requires restart)</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources>