mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix for incompatibility with PyQt 5.6
For some odd reason PyQt 5.6 renames QUrl.None to QUrl.None_ None is not a keyword in python 2, so I assume this has to do with python 3 compatibility
This commit is contained in:
parent
94806c60db
commit
57450e54e6
@ -24,6 +24,11 @@ from calibre.utils.localization import get_lang
|
||||
from calibre.utils.filenames import expanduser
|
||||
from calibre.utils.file_type_icons import EXT_MAP
|
||||
|
||||
try:
|
||||
NO_URL_FORMATTING = QUrl.None_
|
||||
except AttributeError:
|
||||
NO_URL_FORMATTING = QUrl.None
|
||||
|
||||
# Setup gprefs {{{
|
||||
gprefs = JSONConfig('gui')
|
||||
defs = gprefs.defaults
|
||||
|
@ -21,7 +21,7 @@ from calibre.gui2.dnd import (dnd_has_image, dnd_get_image, dnd_get_files,
|
||||
from calibre.ebooks import BOOK_EXTENSIONS
|
||||
from calibre.ebooks.metadata.book.base import (field_metadata, Metadata)
|
||||
from calibre.ebooks.metadata.book.render import mi_to_html
|
||||
from calibre.gui2 import (config, open_url, pixmap_to_data, gprefs, rating_font)
|
||||
from calibre.gui2 import (config, open_url, pixmap_to_data, gprefs, rating_font, NO_URL_FORMATTING)
|
||||
from calibre.utils.config import tweaks
|
||||
from calibre.utils.localization import is_rtl
|
||||
|
||||
@ -110,7 +110,7 @@ def details_context_menu_event(view, ev, book_info): # {{{
|
||||
p = view.page()
|
||||
mf = p.mainFrame()
|
||||
r = mf.hitTestContent(ev.pos())
|
||||
url = unicode(r.linkUrl().toString(QUrl.None)).strip()
|
||||
url = unicode(r.linkUrl().toString(NO_URL_FORMATTING)).strip()
|
||||
menu = p.createStandardContextMenu()
|
||||
ca = view.pageAction(p.Copy)
|
||||
for action in list(menu.actions()):
|
||||
@ -478,7 +478,7 @@ class BookInfo(QWebView):
|
||||
self._link_clicked = True
|
||||
if unicode(link.scheme()) in ('http', 'https'):
|
||||
return open_url(link)
|
||||
link = unicode(link.toString(QUrl.None))
|
||||
link = unicode(link.toString(NO_URL_FORMATTING))
|
||||
self.link_clicked.emit(link)
|
||||
|
||||
def turnoff_scrollbar(self, *args):
|
||||
|
@ -19,7 +19,7 @@ from PyQt5.QtWebKitWidgets import QWebView, QWebPage
|
||||
|
||||
from calibre.ebooks.chardet import xml_to_unicode
|
||||
from calibre import xml_replace_entities, prepare_string_for_xml
|
||||
from calibre.gui2 import open_url, error_dialog, choose_files, gprefs
|
||||
from calibre.gui2 import open_url, error_dialog, choose_files, gprefs, NO_URL_FORMATTING
|
||||
from calibre.utils.soupparser import fromstring
|
||||
from calibre.utils.config import tweaks
|
||||
from calibre.utils.imghdr import what
|
||||
@ -211,7 +211,7 @@ class EditorWidget(QWebView): # {{{
|
||||
return
|
||||
url = self.parse_link(link)
|
||||
if url.isValid():
|
||||
url = unicode(url.toString(QUrl.None))
|
||||
url = unicode(url.toString(NO_URL_FORMATTING))
|
||||
self.setFocus(Qt.OtherFocusReason)
|
||||
if is_image:
|
||||
self.exec_command('insertHTML',
|
||||
|
@ -9,10 +9,10 @@ __docformat__ = 'restructuredtext en'
|
||||
from PyQt5.Qt import (
|
||||
QCoreApplication, QModelIndex, QTimer, Qt, pyqtSignal, QWidget,
|
||||
QGridLayout, QDialog, QPixmap, QSize, QPalette, QShortcut, QKeySequence,
|
||||
QSplitter, QVBoxLayout, QCheckBox, QPushButton, QIcon, QBrush, QUrl)
|
||||
QSplitter, QVBoxLayout, QCheckBox, QPushButton, QIcon, QBrush)
|
||||
from PyQt5.QtWebKitWidgets import QWebView
|
||||
|
||||
from calibre.gui2 import gprefs
|
||||
from calibre.gui2 import gprefs, NO_URL_FORMATTING
|
||||
from calibre import fit_image
|
||||
from calibre.gui2.book_details import render_html, details_context_menu_event
|
||||
from calibre.gui2.widgets import CoverView
|
||||
@ -114,7 +114,7 @@ class BookInfo(QDialog):
|
||||
pass
|
||||
|
||||
def link_clicked(self, qurl):
|
||||
link = unicode(qurl.toString(QUrl.None))
|
||||
link = unicode(qurl.toString(NO_URL_FORMATTING))
|
||||
self.link_delegate(link)
|
||||
|
||||
def done(self, r):
|
||||
|
@ -20,7 +20,7 @@ from PyQt5.Qt import (
|
||||
QStyledItemDelegate, QTextDocument, QRectF, QIcon, Qt, QApplication,
|
||||
QDialog, QVBoxLayout, QLabel, QDialogButtonBox, QStyle, QStackedWidget,
|
||||
QWidget, QTableView, QGridLayout, QFontInfo, QPalette, QTimer, pyqtSignal,
|
||||
QAbstractTableModel, QSize, QListView, QPixmap, QModelIndex, QUrl,
|
||||
QAbstractTableModel, QSize, QListView, QPixmap, QModelIndex,
|
||||
QAbstractListModel, QRect, QTextBrowser, QStringListModel, QMenu,
|
||||
QCursor, QHBoxLayout, QPushButton, QSizePolicy)
|
||||
from PyQt5.QtWebKitWidgets import QWebView
|
||||
@ -31,7 +31,7 @@ from calibre.utils.logging import GUILog as Log
|
||||
from calibre.ebooks.metadata.sources.identify import urls_from_identifiers
|
||||
from calibre.ebooks.metadata.book.base import Metadata
|
||||
from calibre.ebooks.metadata.opf2 import OPF
|
||||
from calibre.gui2 import error_dialog, rating_font, gprefs
|
||||
from calibre.gui2 import error_dialog, rating_font, gprefs, NO_URL_FORMATTING
|
||||
from calibre.gui2.progress_indicator import draw_snake_spinner
|
||||
from calibre.utils.date import (utcnow, fromordinal, format_date,
|
||||
UNDEFINED_DATE, as_utc)
|
||||
@ -324,7 +324,7 @@ class Comments(QWebView): # {{{
|
||||
|
||||
def link_clicked(self, url):
|
||||
from calibre.gui2 import open_url
|
||||
if unicode(url.toString(QUrl.None)).startswith('http://'):
|
||||
if unicode(url.toString(NO_URL_FORMATTING)).startswith('http://'):
|
||||
open_url(url)
|
||||
|
||||
def turnoff_scrollbar(self, *args):
|
||||
|
@ -9,12 +9,12 @@ __docformat__ = 'restructuredtext en'
|
||||
import os
|
||||
from urlparse import urlparse
|
||||
|
||||
from PyQt5.Qt import QNetworkCookieJar, QNetworkProxy, QUrl
|
||||
from PyQt5.Qt import QNetworkCookieJar, QNetworkProxy
|
||||
from PyQt5.QtWebKitWidgets import QWebView, QWebPage
|
||||
|
||||
from calibre import USER_AGENT, get_proxies
|
||||
from calibre.ebooks import BOOK_EXTENSIONS
|
||||
from calibre.gui2 import choose_save_file
|
||||
from calibre.gui2 import choose_save_file, NO_URL_FORMATTING
|
||||
from calibre.gui2.ebook_download import show_download_info
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
from calibre.utils.filenames import ascii_filename
|
||||
@ -69,7 +69,7 @@ class NPWebView(QWebView):
|
||||
if not self.gui:
|
||||
return
|
||||
|
||||
url = unicode(request.url().toString(QUrl.None))
|
||||
url = unicode(request.url().toString(NO_URL_FORMATTING))
|
||||
cf = self.get_cookies()
|
||||
|
||||
filename = get_download_filename(url, cf)
|
||||
|
@ -9,11 +9,12 @@ __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
import sys
|
||||
|
||||
from PyQt5.Qt import (
|
||||
QIcon, Qt, QSplitter, QListWidget, QTextBrowser, QPalette, QUrl, QMenu,
|
||||
QIcon, Qt, QSplitter, QListWidget, QTextBrowser, QPalette, QMenu,
|
||||
QListWidgetItem, pyqtSignal, QApplication, QStyledItemDelegate)
|
||||
|
||||
from calibre.ebooks.oeb.polish.check.base import WARN, INFO, DEBUG, ERROR, CRITICAL
|
||||
from calibre.ebooks.oeb.polish.check.main import run_checks, fix_errors
|
||||
from calibre.gui2 import NO_URL_FORMATTING
|
||||
from calibre.gui2.tweak_book import tprefs
|
||||
from calibre.gui2.tweak_book.widgets import BusyCursor
|
||||
|
||||
@ -111,7 +112,7 @@ class Check(QSplitter):
|
||||
msg, _('Click to run a check on the book'), _('Run check')))
|
||||
|
||||
def link_clicked(self, url):
|
||||
url = unicode(url.toString(QUrl.None))
|
||||
url = unicode(url.toString(NO_URL_FORMATTING))
|
||||
if url == 'activate:item':
|
||||
self.current_item_activated()
|
||||
elif url == 'run:check':
|
||||
|
@ -26,7 +26,7 @@ from calibre.constants import iswindows
|
||||
from calibre.ebooks.oeb.polish.parsing import parse
|
||||
from calibre.ebooks.oeb.base import serialize, OEB_DOCS
|
||||
from calibre.ptempfile import PersistentTemporaryDirectory
|
||||
from calibre.gui2 import error_dialog, open_url
|
||||
from calibre.gui2 import error_dialog, open_url, NO_URL_FORMATTING
|
||||
from calibre.gui2.tweak_book import current_container, editors, tprefs, actions, TOP
|
||||
from calibre.gui2.viewer.documentview import apply_settings
|
||||
from calibre.gui2.viewer.config import config
|
||||
@ -221,7 +221,7 @@ class NetworkAccessManager(QNetworkAccessManager):
|
||||
self.cache.setMaximumCacheSize(0)
|
||||
|
||||
def createRequest(self, operation, request, data):
|
||||
url = unicode(request.url().toString(QUrl.None))
|
||||
url = unicode(request.url().toString(NO_URL_FORMATTING))
|
||||
if operation == self.GetOperation and url.startswith('file://'):
|
||||
path = url[7:]
|
||||
if iswindows and path.startswith('/'):
|
||||
@ -418,7 +418,7 @@ class WebView(QWebView):
|
||||
p = self.page()
|
||||
mf = p.mainFrame()
|
||||
r = mf.hitTestContent(ev.pos())
|
||||
url = unicode(r.linkUrl().toString(QUrl.None)).strip()
|
||||
url = unicode(r.linkUrl().toString(NO_URL_FORMATTING)).strip()
|
||||
ca = self.pageAction(QWebPage.Copy)
|
||||
if ca.isEnabled():
|
||||
menu.addAction(ca)
|
||||
|
@ -11,7 +11,7 @@ from PyQt5.Qt import (QDialog, QPixmap, QUrl, QScrollArea, QLabel, QSizePolicy,
|
||||
QDialogButtonBox, QVBoxLayout, QPalette, QApplication, QSize, QIcon,
|
||||
Qt, QTransform)
|
||||
|
||||
from calibre.gui2 import choose_save_file, gprefs
|
||||
from calibre.gui2 import choose_save_file, gprefs, NO_URL_FORMATTING
|
||||
|
||||
class ImageView(QDialog):
|
||||
|
||||
@ -102,7 +102,7 @@ class ImageView(QDialog):
|
||||
if geom is not None:
|
||||
self.restoreGeometry(geom)
|
||||
try:
|
||||
self.current_image_name = unicode(self.current_url.toString(QUrl.None)).rpartition('/')[-1]
|
||||
self.current_image_name = unicode(self.current_url.toString(NO_URL_FORMATTING)).rpartition('/')[-1]
|
||||
except AttributeError:
|
||||
self.current_image_name = self.current_url
|
||||
title = _('View Image: %s')%self.current_image_name
|
||||
|
Loading…
x
Reference in New Issue
Block a user