mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Port usage of QString and various miscellaneous imports that no longer work
This commit is contained in:
parent
04e342c072
commit
098f178dfc
@ -18,6 +18,8 @@ __copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
# them to check that they work. This can probably be made part of python
|
# them to check that they work. This can probably be made part of python
|
||||||
# setup.py check.
|
# setup.py check.
|
||||||
|
|
||||||
|
# QT5XX: Check that DeviceCategoryEditor and TagListEditor work
|
||||||
|
|
||||||
# QT5XX: Delete this file after migration is completed
|
# QT5XX: Delete this file after migration is completed
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -12,7 +12,7 @@ from urllib import unquote
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from cssutils import CSSParser
|
from cssutils import CSSParser
|
||||||
from PyQt5.Qt import (pyqtProperty, QString, QEventLoop, Qt, QSize, QTimer,
|
from PyQt5.Qt import (pyqtProperty, QEventLoop, Qt, QSize, QTimer,
|
||||||
pyqtSlot)
|
pyqtSlot)
|
||||||
from PyQt5.QtWebKitWidgets import QWebPage, QWebView
|
from PyQt5.QtWebKitWidgets import QWebPage, QWebView
|
||||||
|
|
||||||
@ -130,14 +130,14 @@ class Page(QWebPage): # {{{
|
|||||||
|
|
||||||
def _pass_json_value_getter(self):
|
def _pass_json_value_getter(self):
|
||||||
val = json.dumps(self.bridge_value)
|
val = json.dumps(self.bridge_value)
|
||||||
return QString(val)
|
return val
|
||||||
|
|
||||||
def _pass_json_value_setter(self, value):
|
def _pass_json_value_setter(self, value):
|
||||||
# Qt WebKit in Qt 4.x adds extra null bytes to the end of the string
|
# Qt WebKit in Qt 4.x adds extra null bytes to the end of the string
|
||||||
# if the JSON contains non-BMP characters
|
# if the JSON contains non-BMP characters
|
||||||
self.bridge_value = json.loads(unicode(value).rstrip('\0'))
|
self.bridge_value = json.loads(unicode(value).rstrip('\0'))
|
||||||
|
|
||||||
_pass_json_value = pyqtProperty(QString, fget=_pass_json_value_getter,
|
_pass_json_value = pyqtProperty(str, fget=_pass_json_value_getter,
|
||||||
fset=_pass_json_value_setter)
|
fset=_pass_json_value_setter)
|
||||||
|
|
||||||
def load_js(self):
|
def load_js(self):
|
||||||
|
@ -12,8 +12,8 @@ from future_builtins import map
|
|||||||
from math import floor
|
from math import floor
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from PyQt5.Qt import (QObject, QPainter, Qt, QSize, QString, QTimer,
|
from PyQt5.Qt import (
|
||||||
pyqtProperty, QEventLoop, QPixmap, QRect, pyqtSlot)
|
QObject, QPainter, Qt, QSize, QTimer, pyqtProperty, QEventLoop, QPixmap, QRect, pyqtSlot)
|
||||||
from PyQt5.QtWebKit import QWebSettings
|
from PyQt5.QtWebKit import QWebSettings
|
||||||
from PyQt5.QtWebKitWidgets import QWebView, QWebPage
|
from PyQt5.QtWebKitWidgets import QWebView, QWebPage
|
||||||
|
|
||||||
@ -125,12 +125,12 @@ class PDFWriter(QObject):
|
|||||||
|
|
||||||
def _pass_json_value_getter(self):
|
def _pass_json_value_getter(self):
|
||||||
val = json.dumps(self.bridge_value)
|
val = json.dumps(self.bridge_value)
|
||||||
return QString(val)
|
return val
|
||||||
|
|
||||||
def _pass_json_value_setter(self, value):
|
def _pass_json_value_setter(self, value):
|
||||||
self.bridge_value = json.loads(unicode(value))
|
self.bridge_value = json.loads(unicode(value))
|
||||||
|
|
||||||
_pass_json_value = pyqtProperty(QString, fget=_pass_json_value_getter,
|
_pass_json_value = pyqtProperty(str, fget=_pass_json_value_getter,
|
||||||
fset=_pass_json_value_setter)
|
fset=_pass_json_value_setter)
|
||||||
|
|
||||||
@pyqtSlot(result=unicode)
|
@pyqtSlot(result=unicode)
|
||||||
|
@ -11,7 +11,7 @@ Write content to PDF.
|
|||||||
import os, shutil, json
|
import os, shutil, json
|
||||||
|
|
||||||
from PyQt5.Qt import (QEventLoop, QObject, QPrinter, QSizeF, Qt, QPainter,
|
from PyQt5.Qt import (QEventLoop, QObject, QPrinter, QSizeF, Qt, QPainter,
|
||||||
QPixmap, QTimer, pyqtProperty, QString, QSize)
|
QPixmap, QTimer, pyqtProperty, QSize)
|
||||||
from PyQt5.QtWebKit import QWebSettings
|
from PyQt5.QtWebKit import QWebSettings
|
||||||
from PyQt5.QtWebKitWidgets import QWebView, QWebPage
|
from PyQt5.QtWebKitWidgets import QWebView, QWebPage
|
||||||
|
|
||||||
@ -221,12 +221,12 @@ class PDFWriter(QObject): # {{{
|
|||||||
|
|
||||||
def _pass_json_value_getter(self):
|
def _pass_json_value_getter(self):
|
||||||
val = json.dumps(self.bridge_value)
|
val = json.dumps(self.bridge_value)
|
||||||
return QString(val)
|
return val
|
||||||
|
|
||||||
def _pass_json_value_setter(self, value):
|
def _pass_json_value_setter(self, value):
|
||||||
self.bridge_value = json.loads(unicode(value))
|
self.bridge_value = json.loads(unicode(value))
|
||||||
|
|
||||||
_pass_json_value = pyqtProperty(QString, fget=_pass_json_value_getter,
|
_pass_json_value = pyqtProperty(str, fget=_pass_json_value_getter,
|
||||||
fset=_pass_json_value_setter)
|
fset=_pass_json_value_setter)
|
||||||
|
|
||||||
def setup_printer(self, outpath):
|
def setup_printer(self, outpath):
|
||||||
|
@ -6,7 +6,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from PyQt5.Qt import QString, QModelIndex
|
from PyQt5.Qt import QModelIndex
|
||||||
|
|
||||||
from calibre.gui2.convert.single import (Config, sort_formats_by_preference,
|
from calibre.gui2.convert.single import (Config, sort_formats_by_preference,
|
||||||
GroupModel, gprefs, get_output_formats)
|
GroupModel, gprefs, get_output_formats)
|
||||||
@ -120,7 +120,7 @@ class BulkConfig(Config):
|
|||||||
preferred_output_format and preferred_output_format \
|
preferred_output_format and preferred_output_format \
|
||||||
in output_formats else sort_formats_by_preference(output_formats,
|
in output_formats else sort_formats_by_preference(output_formats,
|
||||||
[prefs['output_format']])[0]
|
[prefs['output_format']])[0]
|
||||||
self.output_formats.addItems(list(map(QString, [x.upper() for x in
|
self.output_formats.addItems(list(map(unicode, [x.upper() for x in
|
||||||
output_formats])))
|
output_formats])))
|
||||||
self.output_formats.setCurrentIndex(output_formats.index(preferred_output_format))
|
self.output_formats.setCurrentIndex(output_formats.index(preferred_output_format))
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
import cPickle, shutil
|
import cPickle, shutil
|
||||||
|
|
||||||
from PyQt5.Qt import QString, QAbstractListModel, Qt, QVariant, QFont, QModelIndex
|
from PyQt5.Qt import QAbstractListModel, Qt, QVariant, QFont, QModelIndex
|
||||||
|
|
||||||
from calibre.gui2 import ResizableDialog, NONE, gprefs
|
from calibre.gui2 import ResizableDialog, NONE, gprefs
|
||||||
from calibre.ebooks.conversion.config import (GuiRecommendations, save_specifics,
|
from calibre.ebooks.conversion.config import (GuiRecommendations, save_specifics,
|
||||||
@ -254,9 +254,9 @@ class Config(ResizableDialog, Ui_Dialog):
|
|||||||
preferred_output_format in output_formats else \
|
preferred_output_format in output_formats else \
|
||||||
sort_formats_by_preference(output_formats,
|
sort_formats_by_preference(output_formats,
|
||||||
[prefs['output_format']])[0]
|
[prefs['output_format']])[0]
|
||||||
self.input_formats.addItems(list(map(QString, [x.upper() for x in
|
self.input_formats.addItems(list(map(unicode, [x.upper() for x in
|
||||||
input_formats])))
|
input_formats])))
|
||||||
self.output_formats.addItems(list(map(QString, [x.upper() for x in
|
self.output_formats.addItems(list(map(unicode, [x.upper() for x in
|
||||||
output_formats])))
|
output_formats])))
|
||||||
self.input_formats.setCurrentIndex(input_formats.index(input_format))
|
self.input_formats.setCurrentIndex(input_formats.index(input_format))
|
||||||
self.output_formats.setCurrentIndex(output_formats.index(preferred_output_format))
|
self.output_formats.setCurrentIndex(output_formats.index(preferred_output_format))
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
from PyQt5.QtGui import QDialog
|
|
||||||
|
from PyQt5.Qt import QDialog
|
||||||
|
|
||||||
from calibre.gui2.dialogs.conversion_error_ui import Ui_ConversionErrorDialog
|
from calibre.gui2.dialogs.conversion_error_ui import Ui_ConversionErrorDialog
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt, QString
|
from PyQt5.Qt import Qt, QDialog, QListWidgetItem
|
||||||
from PyQt5.QtGui import QDialog, QListWidgetItem
|
|
||||||
|
|
||||||
from calibre.gui2.dialogs.device_category_editor_ui import Ui_DeviceCategoryEditor
|
from calibre.gui2.dialogs.device_category_editor_ui import Ui_DeviceCategoryEditor
|
||||||
from calibre.gui2 import question_dialog, error_dialog
|
from calibre.gui2 import question_dialog, error_dialog
|
||||||
@ -11,9 +10,9 @@ class ListWidgetItem(QListWidgetItem):
|
|||||||
|
|
||||||
def __init__(self, txt):
|
def __init__(self, txt):
|
||||||
QListWidgetItem.__init__(self, txt)
|
QListWidgetItem.__init__(self, txt)
|
||||||
self.initial_value = QString(txt)
|
self.initial_value = txt
|
||||||
self.current_value = QString(txt)
|
self.current_value = txt
|
||||||
self.previous_value = QString(txt)
|
self.previous_value = txt
|
||||||
|
|
||||||
def data(self, role):
|
def data(self, role):
|
||||||
if role == Qt.DisplayRole:
|
if role == Qt.DisplayRole:
|
||||||
@ -30,7 +29,7 @@ class ListWidgetItem(QListWidgetItem):
|
|||||||
def setData(self, role, data):
|
def setData(self, role, data):
|
||||||
if role == Qt.EditRole:
|
if role == Qt.EditRole:
|
||||||
self.previous_value = self.current_value
|
self.previous_value = self.current_value
|
||||||
self.current_value = data.toString()
|
self.current_value = data
|
||||||
QListWidgetItem.setData(self, role, data)
|
QListWidgetItem.setData(self, role, data)
|
||||||
|
|
||||||
def text(self):
|
def text(self):
|
||||||
@ -68,7 +67,7 @@ class DeviceCategoryEditor(QDialog, Ui_DeviceCategoryEditor):
|
|||||||
for tag in sorted(self.all_tags.keys(), key=key):
|
for tag in sorted(self.all_tags.keys(), key=key):
|
||||||
item = ListWidgetItem(tag)
|
item = ListWidgetItem(tag)
|
||||||
item.setData(Qt.UserRole, self.all_tags[tag])
|
item.setData(Qt.UserRole, self.all_tags[tag])
|
||||||
item.setFlags (item.flags() | Qt.ItemIsEditable)
|
item.setFlags(item.flags() | Qt.ItemIsEditable)
|
||||||
self.available_tags.addItem(item)
|
self.available_tags.addItem(item)
|
||||||
|
|
||||||
if tag_to_match is not None:
|
if tag_to_match is not None:
|
||||||
|
@ -3,7 +3,7 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
|
|
||||||
|
|
||||||
from PyQt5.QtGui import QDialog
|
from PyQt5.Qt import QDialog
|
||||||
|
|
||||||
from calibre.gui2.dialogs.saved_search_editor_ui import Ui_SavedSearchEditor
|
from calibre.gui2.dialogs.saved_search_editor_ui import Ui_SavedSearchEditor
|
||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
|
|
||||||
from PyQt5.Qt import (Qt, QDialog, QTableWidgetItem, QIcon, QByteArray,
|
from PyQt5.Qt import (Qt, QDialog, QTableWidgetItem, QIcon, QByteArray, QSize)
|
||||||
QString, QSize)
|
|
||||||
|
|
||||||
from calibre.gui2.dialogs.tag_list_editor_ui import Ui_TagListEditor
|
from calibre.gui2.dialogs.tag_list_editor_ui import Ui_TagListEditor
|
||||||
from calibre.gui2 import question_dialog, error_dialog, info_dialog, gprefs
|
from calibre.gui2 import question_dialog, error_dialog, info_dialog, gprefs
|
||||||
@ -12,9 +11,9 @@ class NameTableWidgetItem(QTableWidgetItem):
|
|||||||
|
|
||||||
def __init__(self, txt):
|
def __init__(self, txt):
|
||||||
QTableWidgetItem.__init__(self, txt)
|
QTableWidgetItem.__init__(self, txt)
|
||||||
self.initial_value = QString(txt)
|
self.initial_value = txt
|
||||||
self.current_value = QString(txt)
|
self.current_value = txt
|
||||||
self.previous_value = QString(txt)
|
self.previous_value = txt
|
||||||
|
|
||||||
def data(self, role):
|
def data(self, role):
|
||||||
if role == Qt.DisplayRole:
|
if role == Qt.DisplayRole:
|
||||||
@ -27,7 +26,7 @@ class NameTableWidgetItem(QTableWidgetItem):
|
|||||||
def setData(self, role, data):
|
def setData(self, role, data):
|
||||||
if role == Qt.EditRole:
|
if role == Qt.EditRole:
|
||||||
self.previous_value = self.current_value
|
self.previous_value = self.current_value
|
||||||
self.current_value = data.toString()
|
self.current_value = data
|
||||||
QTableWidgetItem.setData(self, role, data)
|
QTableWidgetItem.setData(self, role, data)
|
||||||
|
|
||||||
def text(self):
|
def text(self):
|
||||||
@ -113,7 +112,7 @@ class TagListEditor(QDialog, Ui_TagListEditor):
|
|||||||
self.count_col.setIcon(self.blank_icon)
|
self.count_col.setIcon(self.blank_icon)
|
||||||
|
|
||||||
# Capture clicks on the horizontal header to sort the table columns
|
# Capture clicks on the horizontal header to sort the table columns
|
||||||
hh = self.table.horizontalHeader();
|
hh = self.table.horizontalHeader()
|
||||||
hh.setClickable(True)
|
hh.setClickable(True)
|
||||||
hh.sectionClicked.connect(self.header_clicked)
|
hh.sectionClicked.connect(self.header_clicked)
|
||||||
hh.sectionResized.connect(self.table_column_resized)
|
hh.sectionResized.connect(self.table_column_resized)
|
||||||
@ -127,16 +126,16 @@ class TagListEditor(QDialog, Ui_TagListEditor):
|
|||||||
for row,tag in enumerate(sorted(self.all_tags.keys(), key=sorter)):
|
for row,tag in enumerate(sorted(self.all_tags.keys(), key=sorter)):
|
||||||
item = NameTableWidgetItem(tag)
|
item = NameTableWidgetItem(tag)
|
||||||
item.setData(Qt.UserRole, self.all_tags[tag])
|
item.setData(Qt.UserRole, self.all_tags[tag])
|
||||||
item.setFlags (item.flags() | Qt.ItemIsSelectable | Qt.ItemIsEditable)
|
item.setFlags(item.flags() | Qt.ItemIsSelectable | Qt.ItemIsEditable)
|
||||||
self.table.setItem(row, 0, item)
|
self.table.setItem(row, 0, item)
|
||||||
if tag == tag_to_match:
|
if tag == tag_to_match:
|
||||||
select_item = item
|
select_item = item
|
||||||
item = CountTableWidgetItem(self.counts[tag])
|
item = CountTableWidgetItem(self.counts[tag])
|
||||||
# only the name column can be selected
|
# only the name column can be selected
|
||||||
item.setFlags (item.flags() & ~(Qt.ItemIsSelectable|Qt.ItemIsEditable))
|
item.setFlags(item.flags() & ~(Qt.ItemIsSelectable|Qt.ItemIsEditable))
|
||||||
self.table.setItem(row, 1, item)
|
self.table.setItem(row, 1, item)
|
||||||
item = QTableWidgetItem('')
|
item = QTableWidgetItem('')
|
||||||
item.setFlags (item.flags() & ~(Qt.ItemIsSelectable|Qt.ItemIsEditable))
|
item.setFlags(item.flags() & ~(Qt.ItemIsSelectable|Qt.ItemIsEditable))
|
||||||
self.table.setItem(row, 2, item)
|
self.table.setItem(row, 2, item)
|
||||||
|
|
||||||
# Scroll to the selected item if there is one
|
# Scroll to the selected item if there is one
|
||||||
@ -266,7 +265,7 @@ class TagListEditor(QDialog, Ui_TagListEditor):
|
|||||||
self.count_col.setIcon(self.blank_icon)
|
self.count_col.setIcon(self.blank_icon)
|
||||||
self.was_col.setIcon(self.blank_icon)
|
self.was_col.setIcon(self.blank_icon)
|
||||||
|
|
||||||
def do_sort_by_count (self):
|
def do_sort_by_count(self):
|
||||||
self.count_order = 1 if self.count_order == 0 else 0
|
self.count_order = 1 if self.count_order == 0 else 0
|
||||||
self.table.sortByColumn(1, self.count_order)
|
self.table.sortByColumn(1, self.count_order)
|
||||||
self.count_col.setIcon(self.down_arrow_icon if self.count_order
|
self.count_col.setIcon(self.down_arrow_icon if self.count_order
|
||||||
|
@ -12,7 +12,7 @@ from Queue import Empty, Queue
|
|||||||
|
|
||||||
from PyQt5.Qt import (QAbstractTableModel, QVariant, QModelIndex, Qt,
|
from PyQt5.Qt import (QAbstractTableModel, QVariant, QModelIndex, Qt,
|
||||||
QTimer, pyqtSignal, QIcon, QDialog, QAbstractItemDelegate, QApplication,
|
QTimer, pyqtSignal, QIcon, QDialog, QAbstractItemDelegate, QApplication,
|
||||||
QSize, QStyleOptionProgressBarV2, QString, QStyle, QToolTip, QFrame,
|
QSize, QStyleOptionProgressBar, QStyle, QToolTip, QFrame,
|
||||||
QHBoxLayout, QVBoxLayout, QSizePolicy, QLabel, QCoreApplication, QAction,
|
QHBoxLayout, QVBoxLayout, QSizePolicy, QLabel, QCoreApplication, QAction,
|
||||||
QByteArray, QSortFilterProxyModel)
|
QByteArray, QSortFilterProxyModel)
|
||||||
|
|
||||||
@ -387,7 +387,7 @@ class ProgressBarDelegate(QAbstractItemDelegate): # {{{
|
|||||||
return QSize(120, 30)
|
return QSize(120, 30)
|
||||||
|
|
||||||
def paint(self, painter, option, index):
|
def paint(self, painter, option, index):
|
||||||
opts = QStyleOptionProgressBarV2()
|
opts = QStyleOptionProgressBar()
|
||||||
opts.rect = option.rect
|
opts.rect = option.rect
|
||||||
opts.minimum = 1
|
opts.minimum = 1
|
||||||
opts.maximum = 100
|
opts.maximum = 100
|
||||||
@ -396,7 +396,7 @@ class ProgressBarDelegate(QAbstractItemDelegate): # {{{
|
|||||||
if not ok:
|
if not ok:
|
||||||
percent = 0
|
percent = 0
|
||||||
opts.progress = percent
|
opts.progress = percent
|
||||||
opts.text = QString(_('Unavailable') if percent == 0 else '%d%%'%percent)
|
opts.text = (_('Unavailable') if percent == 0 else '%d%%'%percent)
|
||||||
QApplication.style().drawControl(QStyle.CE_ProgressBar, opts, painter)
|
QApplication.style().drawControl(QStyle.CE_ProgressBar, opts, painter)
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
|
|
||||||
from PyQt5.QtGui import QGraphicsView
|
from PyQt5.Qt import QGraphicsView, QSize
|
||||||
from PyQt5.QtCore import QSize
|
|
||||||
|
|
||||||
class BookView(QGraphicsView):
|
class BookView(QGraphicsView):
|
||||||
|
|
||||||
|
@ -2,10 +2,9 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
import collections, itertools, glob
|
import collections, itertools, glob
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt, QByteArray, pyqtSignal
|
from PyQt5.Qt import (
|
||||||
from PyQt5.QtGui import QGraphicsRectItem, QGraphicsScene, QPen, \
|
Qt, QByteArray, pyqtSignal, QGraphicsRectItem, QGraphicsScene, QPen,
|
||||||
QBrush, QColor, QFontDatabase, \
|
QBrush, QColor, QFontDatabase, QGraphicsItem, QGraphicsLineItem)
|
||||||
QGraphicsItem, QGraphicsLineItem
|
|
||||||
|
|
||||||
from calibre.gui2.lrf_renderer.text import TextBlock, FontLoader, COLOR, PixmapItem
|
from calibre.gui2.lrf_renderer.text import TextBlock, FontLoader, COLOR, PixmapItem
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
import sys, logging, os, traceback, time
|
import sys, logging, os, traceback, time
|
||||||
|
|
||||||
from PyQt5.QtGui import QKeySequence, QPainter, QDialog, QSpinBox, QSlider, QIcon
|
from PyQt5.Qt import (
|
||||||
from PyQt5.QtCore import Qt, QCoreApplication, QThread
|
QKeySequence, QPainter, QDialog, QSpinBox, QSlider, QIcon, Qt, QCoreApplication, QThread, QScrollBar)
|
||||||
|
|
||||||
from calibre import __appname__, setup_cli_handlers, islinux, isbsd
|
from calibre import __appname__, setup_cli_handlers, islinux, isbsd
|
||||||
from calibre.ebooks.lrf.lrfparser import LRFDocument
|
from calibre.ebooks.lrf.lrfparser import LRFDocument
|
||||||
@ -162,7 +162,6 @@ class Main(MainWindow, Ui_MainWindow):
|
|||||||
self.renderer.lrf.device_info.height
|
self.renderer.lrf.device_info.height
|
||||||
hdelta = self.tool_bar.height()+3
|
hdelta = self.tool_bar.height()+3
|
||||||
|
|
||||||
from PyQt5.QtGui import QScrollBar
|
|
||||||
s = QScrollBar(self)
|
s = QScrollBar(self)
|
||||||
scrollbar_adjust = min(s.width(), s.height())
|
scrollbar_adjust = min(s.width(), s.height())
|
||||||
self.graphics_view.resize_for(width+scrollbar_adjust, height+scrollbar_adjust)
|
self.graphics_view.resize_for(width+scrollbar_adjust, height+scrollbar_adjust)
|
||||||
|
@ -2,9 +2,9 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
import sys, collections, operator, copy, re
|
import sys, collections, operator, copy, re
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt, QRectF, QString
|
from PyQt5.Qt import (
|
||||||
from PyQt5.QtGui import QFont, QColor, QPixmap, QGraphicsPixmapItem, \
|
Qt, QRectF, QFont, QColor, QPixmap, QGraphicsPixmapItem, QGraphicsItem,
|
||||||
QGraphicsItem, QFontMetrics, QPen, QBrush, QGraphicsRectItem
|
QFontMetrics, QPen, QBrush, QGraphicsRectItem)
|
||||||
|
|
||||||
from calibre.ebooks.lrf.fonts import LIBERATION_FONT_MAP
|
from calibre.ebooks.lrf.fonts import LIBERATION_FONT_MAP
|
||||||
from calibre.ebooks.BeautifulSoup import Tag
|
from calibre.ebooks.BeautifulSoup import Tag
|
||||||
@ -565,7 +565,7 @@ class Line(QGraphicsItem):
|
|||||||
class Word(object):
|
class Word(object):
|
||||||
|
|
||||||
def __init__(self, string, width, height, ts, font, valign):
|
def __init__(self, string, width, height, ts, font, valign):
|
||||||
self.string, self.width, self.height = QString(string), width, height
|
self.string, self.width, self.height = string, width, height
|
||||||
self.font = font
|
self.font = font
|
||||||
self.text_color = ts.textcolor
|
self.text_color = ts.textcolor
|
||||||
self.highlight = False
|
self.highlight = False
|
||||||
|
@ -12,7 +12,7 @@ from functools import partial
|
|||||||
|
|
||||||
from PyQt5.Qt import QComboBox, Qt, QLineEdit, pyqtSlot, QDialog, \
|
from PyQt5.Qt import QComboBox, Qt, QLineEdit, pyqtSlot, QDialog, \
|
||||||
pyqtSignal, QCompleter, QAction, QKeySequence, QTimer, \
|
pyqtSignal, QCompleter, QAction, QKeySequence, QTimer, \
|
||||||
QString, QIcon, QMenu
|
QIcon, QMenu
|
||||||
|
|
||||||
from calibre.gui2 import config, error_dialog, question_dialog, gprefs
|
from calibre.gui2 import config, error_dialog, question_dialog, gprefs
|
||||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||||
@ -84,8 +84,8 @@ class SearchBox2(QComboBox): # {{{
|
|||||||
|
|
||||||
c = self.line_edit.completer()
|
c = self.line_edit.completer()
|
||||||
c.setCompletionMode(c.PopupCompletion)
|
c.setCompletionMode(c.PopupCompletion)
|
||||||
c.highlighted[QString].connect(self.completer_used)
|
c.highlighted[str].connect(self.completer_used)
|
||||||
c.activated[QString].connect(self.history_selected)
|
c.activated[str].connect(self.history_selected)
|
||||||
|
|
||||||
self.line_edit.key_pressed.connect(self.key_pressed, type=Qt.DirectConnection)
|
self.line_edit.key_pressed.connect(self.key_pressed, type=Qt.DirectConnection)
|
||||||
self.activated.connect(self.history_selected)
|
self.activated.connect(self.history_selected)
|
||||||
|
@ -10,7 +10,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from PyQt5.Qt import (Qt, QIcon, QWidget, QHBoxLayout, QVBoxLayout, QShortcut,
|
from PyQt5.Qt import (Qt, QIcon, QWidget, QHBoxLayout, QVBoxLayout, QShortcut,
|
||||||
QKeySequence, QToolButton, QString, QLabel, QFrame, QTimer,
|
QKeySequence, QToolButton, QLabel, QFrame, QTimer,
|
||||||
QMenu, QPushButton, QActionGroup)
|
QMenu, QPushButton, QActionGroup)
|
||||||
|
|
||||||
from calibre.gui2 import error_dialog, question_dialog
|
from calibre.gui2 import error_dialog, question_dialog
|
||||||
@ -370,7 +370,7 @@ class TagBrowserWidget(QWidget): # {{{
|
|||||||
self.item_search.initialize('tag_browser_search')
|
self.item_search.initialize('tag_browser_search')
|
||||||
self.item_search.lineEdit().returnPressed.connect(self.do_find)
|
self.item_search.lineEdit().returnPressed.connect(self.do_find)
|
||||||
self.item_search.lineEdit().textEdited.connect(self.find_text_changed)
|
self.item_search.lineEdit().textEdited.connect(self.find_text_changed)
|
||||||
self.item_search.activated[QString].connect(self.do_find)
|
self.item_search.activated[str].connect(self.do_find)
|
||||||
self.item_search.completer().setCaseSensitivity(Qt.CaseSensitive)
|
self.item_search.completer().setCaseSensitivity(Qt.CaseSensitive)
|
||||||
|
|
||||||
parent.tags_view = TagsView(parent)
|
parent.tags_view = TagsView(parent)
|
||||||
|
@ -9,7 +9,7 @@ Logic for setting up conversion jobs
|
|||||||
|
|
||||||
import cPickle, os
|
import cPickle, os
|
||||||
|
|
||||||
from PyQt5.Qt import QDialog, QProgressDialog, QString, QTimer
|
from PyQt5.Qt import QDialog, QProgressDialog, QTimer
|
||||||
|
|
||||||
from calibre.ptempfile import PersistentTemporaryFile
|
from calibre.ptempfile import PersistentTemporaryFile
|
||||||
from calibre.gui2 import warning_dialog, question_dialog
|
from calibre.gui2 import warning_dialog, question_dialog
|
||||||
@ -151,7 +151,7 @@ class QueueBulk(QProgressDialog):
|
|||||||
def __init__(self, parent, book_ids, output_format, queue, db, user_recs,
|
def __init__(self, parent, book_ids, output_format, queue, db, user_recs,
|
||||||
args, use_saved_single_settings=True):
|
args, use_saved_single_settings=True):
|
||||||
QProgressDialog.__init__(self, '',
|
QProgressDialog.__init__(self, '',
|
||||||
QString(), 0, len(book_ids), parent)
|
None, 0, len(book_ids), parent)
|
||||||
self.setWindowTitle(_('Queueing books for bulk conversion'))
|
self.setWindowTitle(_('Queueing books for bulk conversion'))
|
||||||
self.book_ids, self.output_format, self.queue, self.db, self.args, self.user_recs = \
|
self.book_ids, self.output_format, self.queue, self.db, self.args, self.user_recs = \
|
||||||
book_ids, output_format, queue, db, args, user_recs
|
book_ids, output_format, queue, db, args, user_recs
|
||||||
|
@ -82,15 +82,7 @@ class PlainTextEdit(QPlainTextEdit):
|
|||||||
ans = c.selectedText().replace(PARAGRAPH_SEPARATOR, '\n')
|
ans = c.selectedText().replace(PARAGRAPH_SEPARATOR, '\n')
|
||||||
# QTextCursor pads the return value of selectedText with null bytes if
|
# QTextCursor pads the return value of selectedText with null bytes if
|
||||||
# non BMP characters such as 0x1f431 are present.
|
# non BMP characters such as 0x1f431 are present.
|
||||||
if hasattr(ans, 'rstrip'):
|
return ans.rstrip('\0')
|
||||||
ans = ans.rstrip('\0')
|
|
||||||
else: # QString
|
|
||||||
try:
|
|
||||||
while ans[-1] == '\0':
|
|
||||||
ans.chop(1)
|
|
||||||
except IndexError:
|
|
||||||
pass # ans is an empty string
|
|
||||||
return ans
|
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def copy(self):
|
def copy(self):
|
||||||
|
@ -10,7 +10,7 @@ from functools import partial
|
|||||||
|
|
||||||
from PyQt5.Qt import (QSize, QSizePolicy, QUrl, Qt, pyqtProperty,
|
from PyQt5.Qt import (QSize, QSizePolicy, QUrl, Qt, pyqtProperty,
|
||||||
QPainter, QPalette, QBrush, QDialog, QColor, QPoint, QImage, QRegion,
|
QPainter, QPalette, QBrush, QDialog, QColor, QPoint, QImage, QRegion,
|
||||||
QIcon, QAction, QMenu, QString, pyqtSignal, QApplication, pyqtSlot)
|
QIcon, QAction, QMenu, pyqtSignal, QApplication, pyqtSlot)
|
||||||
from PyQt5.QtWebKitWidgets import QWebPage, QWebView
|
from PyQt5.QtWebKitWidgets import QWebPage, QWebView
|
||||||
from PyQt5.QtWebKit import QWebSettings, QWebElement
|
from PyQt5.QtWebKit import QWebSettings, QWebElement
|
||||||
|
|
||||||
@ -225,12 +225,12 @@ class Document(QWebPage): # {{{
|
|||||||
|
|
||||||
def _pass_json_value_getter(self):
|
def _pass_json_value_getter(self):
|
||||||
val = json.dumps(self.bridge_value)
|
val = json.dumps(self.bridge_value)
|
||||||
return QString(val)
|
return val
|
||||||
|
|
||||||
def _pass_json_value_setter(self, value):
|
def _pass_json_value_setter(self, value):
|
||||||
self.bridge_value = json.loads(unicode(value))
|
self.bridge_value = json.loads(unicode(value))
|
||||||
|
|
||||||
_pass_json_value = pyqtProperty(QString, fget=_pass_json_value_getter,
|
_pass_json_value = pyqtProperty(str, fget=_pass_json_value_getter,
|
||||||
fset=_pass_json_value_setter)
|
fset=_pass_json_value_setter)
|
||||||
|
|
||||||
def after_load(self, last_loaded_path=None):
|
def after_load(self, last_loaded_path=None):
|
||||||
|
@ -195,6 +195,10 @@ class OptionSet(object):
|
|||||||
src = src.decode('utf-8')
|
src = src.decode('utf-8')
|
||||||
src = src.replace(u'PyQt5.QtCore', u'PyQt4.QtCore')
|
src = src.replace(u'PyQt5.QtCore', u'PyQt4.QtCore')
|
||||||
exec src in options
|
exec src in options
|
||||||
|
except RuntimeError:
|
||||||
|
try:
|
||||||
|
src = src.replace('PyQt' + '4', 'PyQt5')
|
||||||
|
exec src in options
|
||||||
except:
|
except:
|
||||||
print 'Failed to parse options string:'
|
print 'Failed to parse options string:'
|
||||||
print repr(src)
|
print repr(src)
|
||||||
@ -228,8 +232,6 @@ class OptionSet(object):
|
|||||||
if val is val is True or val is False or val is None or \
|
if val is val is True or val is False or val is None or \
|
||||||
isinstance(val, (int, float, long, basestring)):
|
isinstance(val, (int, float, long, basestring)):
|
||||||
return repr(val)
|
return repr(val)
|
||||||
if val.__class__.__name__ == 'QString':
|
|
||||||
return repr(unicode(val))
|
|
||||||
pickle = cPickle.dumps(val, -1)
|
pickle = cPickle.dumps(val, -1)
|
||||||
return 'cPickle.loads(%s)'%repr(pickle)
|
return 'cPickle.loads(%s)'%repr(pickle)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user