Copy to library menu move copy by path to top for more than 50 libraries

Copy to library menu: Move the choose library by path option to the
start of the menu if there are more than 50 libraries.
This commit is contained in:
Kovid Goyal 2013-10-22 09:54:05 +05:30
parent 7e56f63c33
commit e360e989cf

View File

@ -280,6 +280,9 @@ class CopyToLibraryAction(InterfaceAction):
return return
db = self.gui.library_view.model().db db = self.gui.library_view.model().db
locations = list(self.stats.locations(db)) locations = list(self.stats.locations(db))
if len(locations) > 50:
self.menu.addAction(_('Choose library by path...'), self.choose_library)
self.menu.addSeparator()
for name, loc in locations: for name, loc in locations:
self.menu.addAction(name, partial(self.copy_to_library, self.menu.addAction(name, partial(self.copy_to_library,
loc)) loc))
@ -287,7 +290,8 @@ class CopyToLibraryAction(InterfaceAction):
partial(self.copy_to_library, loc, delete_after=True)) partial(self.copy_to_library, loc, delete_after=True))
self.menu.addSeparator() self.menu.addSeparator()
self.menu.addAction(_('Choose library by path...'), self.choose_library) if len(locations) <= 50:
self.menu.addAction(_('Choose library by path...'), self.choose_library)
self.qaction.setVisible(bool(locations)) self.qaction.setVisible(bool(locations))
def choose_library(self): def choose_library(self):