mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add a read random book item to the view menu
This commit is contained in:
parent
da12f4f19d
commit
3dc878e911
@ -34,6 +34,13 @@ class ViewAction(InterfaceAction):
|
|||||||
self.qaction.setMenu(self.view_menu)
|
self.qaction.setMenu(self.view_menu)
|
||||||
ac.triggered.connect(self.view_specific_format, type=Qt.QueuedConnection)
|
ac.triggered.connect(self.view_specific_format, type=Qt.QueuedConnection)
|
||||||
|
|
||||||
|
self.view_menu.addSeparator()
|
||||||
|
ac = self.create_action(spec=(_('Read a random book'), 'catalog.png',
|
||||||
|
None, None), attr='action_pick_random')
|
||||||
|
ac.triggered.connect(self.view_random)
|
||||||
|
self.view_menu.addAction(ac)
|
||||||
|
|
||||||
|
|
||||||
def location_selected(self, loc):
|
def location_selected(self, loc):
|
||||||
enabled = loc == 'library'
|
enabled = loc == 'library'
|
||||||
for action in list(self.view_menu.actions())[1:]:
|
for action in list(self.view_menu.actions())[1:]:
|
||||||
@ -151,6 +158,10 @@ class ViewAction(InterfaceAction):
|
|||||||
def view_specific_book(self, index):
|
def view_specific_book(self, index):
|
||||||
self._view_books([index])
|
self._view_books([index])
|
||||||
|
|
||||||
|
def view_random(self, *args):
|
||||||
|
self.gui.iactions['Choose Library'].pick_random()
|
||||||
|
self._view_books([self.gui.library_view.currentIndex()])
|
||||||
|
|
||||||
def _view_books(self, rows):
|
def _view_books(self, rows):
|
||||||
if not rows or len(rows) == 0:
|
if not rows or len(rows) == 0:
|
||||||
self._launch_viewer()
|
self._launch_viewer()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user