mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
View button: Add an action to the right click menu that always opens the book with the calibre viewer, regardless of the preferences
This commit is contained in:
parent
1d0d413f8f
commit
94c36e1d37
@ -40,6 +40,7 @@ class ViewAction(InterfaceAction):
|
|||||||
action_type = 'current'
|
action_type = 'current'
|
||||||
action_add_menu = True
|
action_add_menu = True
|
||||||
action_menu_clone_qaction = True
|
action_menu_clone_qaction = True
|
||||||
|
force_internal_viewer = False
|
||||||
|
|
||||||
def genesis(self):
|
def genesis(self):
|
||||||
self.persistent_files = []
|
self.persistent_files = []
|
||||||
@ -49,6 +50,7 @@ class ViewAction(InterfaceAction):
|
|||||||
cm = partial(self.create_menu_action, self.view_menu)
|
cm = partial(self.create_menu_action, self.view_menu)
|
||||||
self.view_specific_action = cm('specific', _('View specific format'),
|
self.view_specific_action = cm('specific', _('View specific format'),
|
||||||
shortcut='Alt+V', triggered=self.view_specific_format)
|
shortcut='Alt+V', triggered=self.view_specific_format)
|
||||||
|
self.internal_view_action = cm('internal', _('View with calibre viewer'), triggered=self.view_internal)
|
||||||
self.action_pick_random = cm('pick random', _('Read a random book'),
|
self.action_pick_random = cm('pick random', _('Read a random book'),
|
||||||
icon='random.png', triggered=self.view_random)
|
icon='random.png', triggered=self.view_random)
|
||||||
self.clear_sep1 = self.view_menu.addSeparator()
|
self.clear_sep1 = self.view_menu.addSeparator()
|
||||||
@ -149,7 +151,7 @@ class ViewAction(InterfaceAction):
|
|||||||
ext = os.path.splitext(name)[1].upper().replace('.',
|
ext = os.path.splitext(name)[1].upper().replace('.',
|
||||||
'').replace('ORIGINAL_', '')
|
'').replace('ORIGINAL_', '')
|
||||||
viewer = 'lrfviewer' if ext == 'LRF' else 'ebook-viewer'
|
viewer = 'lrfviewer' if ext == 'LRF' else 'ebook-viewer'
|
||||||
internal = ext in config['internally_viewed_formats']
|
internal = self.force_internal_viewer or ext in config['internally_viewed_formats']
|
||||||
self._launch_viewer(name, viewer, internal)
|
self._launch_viewer(name, viewer, internal)
|
||||||
|
|
||||||
def view_specific_format(self, triggered):
|
def view_specific_format(self, triggered):
|
||||||
@ -231,6 +233,13 @@ class ViewAction(InterfaceAction):
|
|||||||
rows = self.gui.current_view().selectionModel().selectedRows()
|
rows = self.gui.current_view().selectionModel().selectedRows()
|
||||||
self._view_books(rows)
|
self._view_books(rows)
|
||||||
|
|
||||||
|
def view_internal(self, triggered):
|
||||||
|
try:
|
||||||
|
self.force_internal_viewer = True
|
||||||
|
self.view_book(triggered)
|
||||||
|
finally:
|
||||||
|
self.force_internal_viewer = False
|
||||||
|
|
||||||
def view_triggered(self, index):
|
def view_triggered(self, index):
|
||||||
self._view_books([index])
|
self._view_books([index])
|
||||||
|
|
||||||
@ -313,4 +322,3 @@ class ViewAction(InterfaceAction):
|
|||||||
paths = self.gui.current_view().model().paths(rows)
|
paths = self.gui.current_view().model().paths(rows)
|
||||||
for path in paths:
|
for path in paths:
|
||||||
self.view_device_book(path)
|
self.view_device_book(path)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user