mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Implement #1341 (add view in explorer/filebrowser as right click option)
This commit is contained in:
parent
e412e3e3ec
commit
f8476eed6d
@ -563,13 +563,19 @@ class BooksView(TableView):
|
||||
if col > -1:
|
||||
self.setItemDelegateForColumn(col, self.rating_delegate)
|
||||
|
||||
def set_context_menu(self, edit_metadata, send_to_device, convert, view):
|
||||
def set_context_menu(self, edit_metadata, send_to_device, convert, view, save, open_folder):
|
||||
self.setContextMenuPolicy(Qt.DefaultContextMenu)
|
||||
self.context_menu = QMenu(self)
|
||||
self.context_menu.addAction(edit_metadata)
|
||||
self.context_menu.addAction(send_to_device)
|
||||
self.context_menu.addAction(convert)
|
||||
if edit_metadata is not None:
|
||||
self.context_menu.addAction(edit_metadata)
|
||||
if send_to_device is not None:
|
||||
self.context_menu.addAction(send_to_device)
|
||||
if convert is not None:
|
||||
self.context_menu.addAction(convert)
|
||||
self.context_menu.addAction(view)
|
||||
self.context_menu.addAction(save)
|
||||
if open_folder is not None:
|
||||
self.context_menu.addAction(open_folder)
|
||||
|
||||
def contextMenuEvent(self, event):
|
||||
self.context_menu.popup(event.globalPos())
|
||||
|
@ -193,6 +193,9 @@ class Main(MainWindow, Ui_MainWindow):
|
||||
QObject.connect(self.action_view, SIGNAL("triggered(bool)"), self.view_book)
|
||||
QObject.connect(self.view_menu.actions()[0], SIGNAL("triggered(bool)"), self.view_book)
|
||||
QObject.connect(self.view_menu.actions()[1], SIGNAL("triggered(bool)"), self.view_specific_format)
|
||||
self.connect(self.action_open_containing_folder, SIGNAL('triggered(bool)'), self.view_folder)
|
||||
self.action_open_containing_folder.setShortcut(Qt.Key_O)
|
||||
self.action_sync.setShortcut(Qt.Key_D)
|
||||
self.action_sync.setMenu(sm)
|
||||
self.action_edit.setMenu(md)
|
||||
self.action_save.setMenu(self.save_menu)
|
||||
@ -222,7 +225,11 @@ class Main(MainWindow, Ui_MainWindow):
|
||||
QObject.connect(self.advanced_search_button, SIGNAL('clicked(bool)'), self.do_advanced_search)
|
||||
|
||||
####################### Library view ########################
|
||||
self.library_view.set_context_menu(self.action_edit, self.action_sync, self.action_convert, self.action_view)
|
||||
self.library_view.set_context_menu(self.action_edit, self.action_sync,
|
||||
self.action_convert, self.action_view,
|
||||
self.action_save, self.action_open_containing_folder)
|
||||
self.memory_view.set_context_menu(None, None, None, self.action_view, self.action_save, None)
|
||||
self.card_view.set_context_menu(None, None, None, self.action_view, self.action_save, None)
|
||||
QObject.connect(self.library_view, SIGNAL('files_dropped(PyQt_PyObject)'),
|
||||
self.files_dropped)
|
||||
for func, target in [
|
||||
@ -1004,6 +1011,18 @@ class Main(MainWindow, Ui_MainWindow):
|
||||
else:
|
||||
return
|
||||
|
||||
def view_folder(self, *args):
|
||||
rows = self.current_view().selectionModel().selectedRows()
|
||||
if self.current_view() is self.library_view:
|
||||
if not rows or len(rows) == 0:
|
||||
d = error_dialog(self, _('Cannot open folder'), _('No book selected'))
|
||||
d.exec_()
|
||||
return
|
||||
for row in rows:
|
||||
path = self.library_view.model().db.abspath(row.row())
|
||||
QDesktopServices.openUrl(QUrl('file:'+path))
|
||||
|
||||
|
||||
def view_book(self, triggered):
|
||||
rows = self.current_view().selectionModel().selectedRows()
|
||||
if self.current_view() is self.library_view:
|
||||
@ -1152,11 +1171,13 @@ class Main(MainWindow, Ui_MainWindow):
|
||||
self.action_edit.setEnabled(True)
|
||||
self.action_convert.setEnabled(True)
|
||||
self.view_menu.actions()[1].setEnabled(True)
|
||||
self.action_open_containing_folder.setEnabled(True)
|
||||
else:
|
||||
self.action_sync.setEnabled(False)
|
||||
self.action_edit.setEnabled(False)
|
||||
self.action_convert.setEnabled(False)
|
||||
self.view_menu.actions()[1].setEnabled(False)
|
||||
self.action_open_containing_folder.setEnabled(False)
|
||||
|
||||
def device_job_exception(self, job):
|
||||
'''
|
||||
|
@ -560,6 +560,15 @@
|
||||
<string>V</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_open_containing_folder" >
|
||||
<property name="icon" >
|
||||
<iconset resource="images.qrc" >
|
||||
<normaloff>:/images/document_open.svg</normaloff>:/images/document_open.svg</iconset>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Open containing folder</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
Loading…
x
Reference in New Issue
Block a user