From f5334df8777ee5e55596c54e2d53a7bca6114231 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 12 Apr 2014 08:07:26 +0530 Subject: [PATCH] Port WebKit imports and QChar WebKit has been split up into QtWebKit and QtWebKitWidgets. Change imports accordingly. Replace use of QChar since it no longer exists in PyQt5 --- src/calibre/constants.py | 5 -- src/calibre/ebooks/__init__.py | 2 +- src/calibre/ebooks/lrf/html/table_as_image.py | 2 +- src/calibre/ebooks/oeb/polish/stats.py | 2 +- src/calibre/ebooks/pdf/render/from_html.py | 3 +- src/calibre/ebooks/pdf/writer.py | 3 +- src/calibre/gui2/book_details.py | 2 +- src/calibre/gui2/comments_editor.py | 72 +++++++++---------- src/calibre/gui2/dialogs/book_info.py | 2 +- src/calibre/gui2/metadata/single_download.py | 2 +- src/calibre/gui2/store/web_control.py | 2 +- src/calibre/gui2/store/web_store_dialog.ui | 4 +- src/calibre/gui2/toc/location.py | 3 +- src/calibre/gui2/tweak_book/preview.py | 2 +- src/calibre/gui2/viewer/documentview.py | 3 +- src/calibre/gui2/viewer/inspector.py | 2 +- src/calibre/gui2/viewer/printing.py | 2 +- src/calibre/gui2/viewer/table_popup.py | 2 +- src/calibre/test_build.py | 2 +- src/calibre/web/jsbrowser/browser.py | 3 +- 20 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/calibre/constants.py b/src/calibre/constants.py index 8d187215ca..510b28cd6a 100644 --- a/src/calibre/constants.py +++ b/src/calibre/constants.py @@ -298,8 +298,3 @@ def get_windows_user_locale_name(): return None return u'_'.join(buf.value.split(u'-')[:2]) -def is_modern_webkit(): - # Check if we are using QtWebKit >= 2.3 - from PyQt5.QtWebKit import qWebKitMajorVersion - return qWebKitMajorVersion() >= 537 - diff --git a/src/calibre/ebooks/__init__.py b/src/calibre/ebooks/__init__.py index b7c6d7816e..d530d7dd65 100644 --- a/src/calibre/ebooks/__init__.py +++ b/src/calibre/ebooks/__init__.py @@ -130,7 +130,7 @@ def render_html_svg_workaround(path_to_html, log, width=590, height=750): def render_html(path_to_html, width=590, height=750, as_xhtml=True): - from PyQt5.QtWebKit import QWebPage + from PyQt5.QtWebKitWidgets import QWebPage from PyQt5.Qt import QEventLoop, QPalette, Qt, QUrl, QSize from calibre.gui2 import is_ok_to_use_qt if not is_ok_to_use_qt(): diff --git a/src/calibre/ebooks/lrf/html/table_as_image.py b/src/calibre/ebooks/lrf/html/table_as_image.py index ef9d43113a..00e381bc6c 100644 --- a/src/calibre/ebooks/lrf/html/table_as_image.py +++ b/src/calibre/ebooks/lrf/html/table_as_image.py @@ -9,7 +9,7 @@ Render HTML tables as images. import os, tempfile, atexit, shutil from PyQt5.Qt import QUrl, QApplication, QSize, QEventLoop, \ QPainter, QImage, QObject, Qt -from PyQt5.QtWebKit import QWebPage +from PyQt5.QtWebKitWidgets import QWebPage class HTMLTableRenderer(QObject): diff --git a/src/calibre/ebooks/oeb/polish/stats.py b/src/calibre/ebooks/oeb/polish/stats.py index 7cebdbedf5..4c6a3b0801 100644 --- a/src/calibre/ebooks/oeb/polish/stats.py +++ b/src/calibre/ebooks/oeb/polish/stats.py @@ -14,7 +14,7 @@ from collections import defaultdict from cssutils import CSSParser from PyQt5.Qt import (pyqtProperty, QString, QEventLoop, Qt, QSize, QTimer, pyqtSlot) -from PyQt5.QtWebKit import QWebPage, QWebView +from PyQt5.QtWebKitWidgets import QWebPage, QWebView from calibre.constants import iswindows from calibre.ebooks.oeb.display.webview import load_html diff --git a/src/calibre/ebooks/pdf/render/from_html.py b/src/calibre/ebooks/pdf/render/from_html.py index bb02f9ed22..03b9e8bda8 100644 --- a/src/calibre/ebooks/pdf/render/from_html.py +++ b/src/calibre/ebooks/pdf/render/from_html.py @@ -14,7 +14,8 @@ from collections import defaultdict from PyQt5.Qt import (QObject, QPainter, Qt, QSize, QString, QTimer, pyqtProperty, QEventLoop, QPixmap, QRect, pyqtSlot) -from PyQt5.QtWebKit import QWebView, QWebPage, QWebSettings +from PyQt5.QtWebKit import QWebSettings +from PyQt5.QtWebKitWidgets import QWebView, QWebPage from calibre import fit_image from calibre.constants import iswindows diff --git a/src/calibre/ebooks/pdf/writer.py b/src/calibre/ebooks/pdf/writer.py index 48f9d9ce41..0e3ec4bd80 100644 --- a/src/calibre/ebooks/pdf/writer.py +++ b/src/calibre/ebooks/pdf/writer.py @@ -12,7 +12,8 @@ import os, shutil, json from PyQt5.Qt import (QEventLoop, QObject, QPrinter, QSizeF, Qt, QPainter, QPixmap, QTimer, pyqtProperty, QString, QSize) -from PyQt5.QtWebKit import QWebView, QWebPage, QWebSettings +from PyQt5.QtWebKit import QWebSettings +from PyQt5.QtWebKitWidgets import QWebView, QWebPage from calibre.ptempfile import PersistentTemporaryDirectory from calibre.ebooks.pdf.pageoptions import (unit, paper_size) diff --git a/src/calibre/gui2/book_details.py b/src/calibre/gui2/book_details.py index c6c2641680..46a36f05a8 100644 --- a/src/calibre/gui2/book_details.py +++ b/src/calibre/gui2/book_details.py @@ -11,7 +11,7 @@ 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) -from PyQt5.QtWebKit import QWebView +from PyQt5.QtWebKitWidgets import QWebView from calibre import fit_image from calibre.gui2.dnd import (dnd_has_image, dnd_get_image, dnd_get_files, diff --git a/src/calibre/gui2/comments_editor.py b/src/calibre/gui2/comments_editor.py index 08015347ac..4f989da7de 100644 --- a/src/calibre/gui2/comments_editor.py +++ b/src/calibre/gui2/comments_editor.py @@ -12,10 +12,10 @@ import sip from PyQt5.Qt import (QApplication, QFontInfo, QSize, QWidget, QPlainTextEdit, QToolBar, QVBoxLayout, QAction, QIcon, Qt, QTabWidget, QUrl, QFormLayout, - QSyntaxHighlighter, QColor, QChar, QColorDialog, QMenu, QDialog, QLabel, + QSyntaxHighlighter, QColor, QColorDialog, QMenu, QDialog, QLabel, QHBoxLayout, QKeySequence, QLineEdit, QDialogButtonBox, QPushButton, QCheckBox) -from PyQt5.QtWebKit import QWebView, QWebPage +from PyQt5.QtWebKitWidgets import QWebView, QWebPage from calibre.ebooks.chardet import xml_to_unicode from calibre import xml_replace_entities, prepare_string_for_xml @@ -443,7 +443,7 @@ class Highlighter(QSyntaxHighlighter): def highlightBlock(self, text): state = self.previousBlockState() - len_ = text.length() + len_ = len(text) start = 0 pos = 0 @@ -452,7 +452,7 @@ class Highlighter(QSyntaxHighlighter): if state == State_Comment: start = pos while pos < len_: - if text.mid(pos, 3) == "-->": + if text[pos:pos+3] == u"-->": pos += 3 state = State_Text break @@ -463,9 +463,9 @@ class Highlighter(QSyntaxHighlighter): elif state == State_DocType: start = pos while pos < len_: - ch = text.at(pos) + ch = text[pos] pos += 1 - if ch == QChar('>'): + if ch == u'>': state = State_Text break self.setFormat(start, pos - start, self.colors['doctype']) @@ -474,12 +474,12 @@ class Highlighter(QSyntaxHighlighter): elif state == State_TagStart: start = pos + 1 while pos < len_: - ch = text.at(pos) + ch = text[pos] pos += 1 - if ch == QChar('>'): + if ch == u'>': state = State_Text break - if not ch.isSpace(): + if not ch.isspace(): pos -= 1 state = State_TagName break @@ -488,13 +488,13 @@ class Highlighter(QSyntaxHighlighter): elif state == State_TagName: start = pos while pos < len_: - ch = text.at(pos) + ch = text[pos] pos += 1 - if ch.isSpace(): + if ch.isspace(): pos -= 1 state = State_InsideTag break - if ch == QChar('>'): + if ch == u'>': state = State_Text break self.setFormat(start, pos - start, self.colors['tag']) @@ -504,17 +504,17 @@ class Highlighter(QSyntaxHighlighter): start = pos while pos < len_: - ch = text.at(pos) + ch = text[pos] pos += 1 - if ch == QChar('/'): + if ch == u'/': continue - if ch == QChar('>'): + if ch == u'>': state = State_Text break - if not ch.isSpace(): + if not ch.isspace(): pos -= 1 state = State_AttributeName break @@ -524,14 +524,14 @@ class Highlighter(QSyntaxHighlighter): start = pos while pos < len_: - ch = text.at(pos) + ch = text[pos] pos += 1 - if ch == QChar('='): + if ch == u'=': state = State_AttributeValue break - if ch in (QChar('>'), QChar('/')): + if ch in (u'>', u'/'): state = State_InsideTag break @@ -543,20 +543,20 @@ class Highlighter(QSyntaxHighlighter): # find first non-space character while pos < len_: - ch = text.at(pos) + ch = text[pos] pos += 1 # handle opening single quote - if ch == QChar("'"): + if ch == u"'": state = State_SingleQuote break # handle opening double quote - if ch == QChar('"'): + if ch == u'"': state = State_DoubleQuote break - if not ch.isSpace(): + if not ch.isspace(): break if state == State_AttributeValue: @@ -564,10 +564,10 @@ class Highlighter(QSyntaxHighlighter): # just stop at non-space or tag delimiter start = pos while pos < len_: - ch = text.at(pos) - if ch.isSpace(): + ch = text[pos] + if ch.isspace(): break - if ch in (QChar('>'), QChar('/')): + if ch in (u'>', u'/'): break pos += 1 state = State_InsideTag @@ -578,9 +578,9 @@ class Highlighter(QSyntaxHighlighter): start = pos while pos < len_: - ch = text.at(pos) + ch = text[pos] pos += 1 - if ch == QChar("'"): + if ch == u"'": break state = State_InsideTag @@ -592,9 +592,9 @@ class Highlighter(QSyntaxHighlighter): start = pos while pos < len_: - ch = text.at(pos) + ch = text[pos] pos += 1 - if ch == QChar('"'): + if ch == u'"': break state = State_InsideTag @@ -604,19 +604,19 @@ class Highlighter(QSyntaxHighlighter): else: # State_Text and default while pos < len_: - ch = text.at(pos) - if ch == QChar('<'): - if text.mid(pos, 4) == "