Add a tweak to control many_libraries

This commit is contained in:
Kovid Goyal 2013-02-27 19:18:32 +05:30
parent b2850f9ed5
commit 712d846090
2 changed files with 9 additions and 2 deletions

View File

@ -524,3 +524,10 @@ preselect_first_completion = False
# that starts with numbers and is a little slower. # that starts with numbers and is a little slower.
numeric_collation = False numeric_collation = False
#: Sort the list of libraries alphabetically
# The list of libraries in the Copy to Library and Quick Switch menus are
# normally sorted by most used. However, if there are more than a certain
# number of such libraries, the sorting becomes alphabetic. You can set that
# number here. The default is ten libraries.
many_libraries = 10

View File

@ -15,7 +15,7 @@ from PyQt4.Qt import (QMenu, Qt, QInputDialog, QToolButton, QDialog,
from calibre import isbytestring, sanitize_file_name_unicode from calibre import isbytestring, sanitize_file_name_unicode
from calibre.constants import (filesystem_encoding, iswindows, from calibre.constants import (filesystem_encoding, iswindows,
get_portable_base) get_portable_base)
from calibre.utils.config import prefs from calibre.utils.config import prefs, tweaks
from calibre.utils.icu import sort_key from calibre.utils.icu import sort_key
from calibre.gui2 import (gprefs, warning_dialog, Dispatcher, error_dialog, from calibre.gui2 import (gprefs, warning_dialog, Dispatcher, error_dialog,
question_dialog, info_dialog, open_local_file, choose_dir) question_dialog, info_dialog, open_local_file, choose_dir)
@ -73,7 +73,7 @@ class LibraryUsageStats(object): # {{{
locs = list(self.stats.keys()) locs = list(self.stats.keys())
if lpath in locs: if lpath in locs:
locs.remove(lpath) locs.remove(lpath)
limit = 10 limit = tweaks['many_libraries']
key = sort_key if len(locs) > limit else lambda x:self.stats[x] key = sort_key if len(locs) > limit else lambda x:self.stats[x]
locs.sort(key=key, reverse=len(locs)<=limit) locs.sort(key=key, reverse=len(locs)<=limit)
for loc in locs: for loc in locs: