mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add a tweak to control many_libraries
This commit is contained in:
parent
b2850f9ed5
commit
712d846090
@ -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
|
||||||
|
|
||||||
|
@ -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:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user