mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
Book details panel: Adda copy all action to the right click menu. Fixes #1633477 [[Enhancement] Context Menu in Book Details window](https://bugs.launchpad.net/calibre/+bug/1633477)
This commit is contained in:
parent
491108e980
commit
52a757e715
@ -12,7 +12,7 @@ from functools import partial
|
||||
from PyQt5.Qt import (QPixmap, QSize, QWidget, Qt, pyqtSignal, QUrl, QIcon,
|
||||
QPropertyAnimation, QEasingCurve, QApplication, QFontInfo, QAction,
|
||||
QSizePolicy, QPainter, QRect, pyqtProperty, QLayout, QPalette, QMenu,
|
||||
QPen, QColor)
|
||||
QPen, QColor, QMimeData)
|
||||
from PyQt5.QtWebKitWidgets import QWebView
|
||||
|
||||
from calibre import fit_image
|
||||
@ -38,6 +38,16 @@ def css():
|
||||
return _css
|
||||
|
||||
|
||||
def copy_all(web_view):
|
||||
web_view = getattr(web_view, 'details', web_view)
|
||||
mf = web_view.page().mainFrame()
|
||||
c = QApplication.clipboard()
|
||||
md = QMimeData()
|
||||
md.setText(mf.toPlainText())
|
||||
md.setHtml(mf.toHtml())
|
||||
c.setMimeData(md)
|
||||
|
||||
|
||||
def render_html(mi, css, vertical, widget, all_fields=False, render_data_func=None): # {{{
|
||||
table, comment_fields = (render_data_func or render_data)(mi, all_fields=all_fields,
|
||||
use_roman_numbers=config['use_roman_numerals_for_series_number'])
|
||||
@ -132,6 +142,7 @@ def details_context_menu_event(view, ev, book_info): # {{{
|
||||
for action in list(menu.actions()):
|
||||
if action is not ca:
|
||||
menu.removeAction(action)
|
||||
menu.addAction(QIcon(I('edit-copy.png')), _('Copy &all'), partial(copy_all, book_info))
|
||||
if not r.isNull():
|
||||
if url.startswith('format:'):
|
||||
parts = url.split(':')
|
||||
|
Loading…
x
Reference in New Issue
Block a user