mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
E-book viewer: Fix regression that prevented pasting of text with formatting from the viewer. Fixes #1428018 [no copying with formatting in built-in ebook reader](https://bugs.launchpad.net/calibre/+bug/1428018)
This commit is contained in:
parent
899e66319a
commit
094449a000
@ -8,9 +8,10 @@ import os, math, json
|
|||||||
from base64 import b64encode
|
from base64 import b64encode
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from PyQt5.Qt import (QSize, QSizePolicy, QUrl, Qt, pyqtProperty,
|
from PyQt5.Qt import (
|
||||||
QPainter, QPalette, QBrush, QDialog, QColor, QPoint, QImage, QRegion,
|
QSize, QSizePolicy, QUrl, Qt, pyqtProperty, QPainter, QPalette, QBrush,
|
||||||
QIcon, QAction, QMenu, pyqtSignal, QApplication, pyqtSlot, QKeySequence)
|
QDialog, QColor, QPoint, QImage, QRegion, QIcon, QAction, QMenu,
|
||||||
|
pyqtSignal, QApplication, pyqtSlot, QKeySequence, QMimeData)
|
||||||
from PyQt5.QtWebKitWidgets import QWebPage, QWebView
|
from PyQt5.QtWebKitWidgets import QWebPage, QWebView
|
||||||
from PyQt5.QtWebKit import QWebSettings, QWebElement
|
from PyQt5.QtWebKit import QWebSettings, QWebElement
|
||||||
|
|
||||||
@ -674,7 +675,13 @@ class DocumentView(QWebView): # {{{
|
|||||||
return self.document.selectedText().replace(u'\u00ad', u'').strip()
|
return self.document.selectedText().replace(u'\u00ad', u'').strip()
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
QApplication.clipboard().setText(self.selected_text)
|
self.document.triggerAction(self.document.Copy)
|
||||||
|
c = QApplication.clipboard()
|
||||||
|
html = c.text('html')[0].replace(u'\u00ad', u'').strip()
|
||||||
|
md = QMimeData()
|
||||||
|
md.setText(self.selected_text)
|
||||||
|
md.setHtml(html)
|
||||||
|
QApplication.clipboard().setMimeData(md)
|
||||||
|
|
||||||
def selection_changed(self):
|
def selection_changed(self):
|
||||||
if self.manager is not None:
|
if self.manager is not None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user