'
__docformat__ = 'restructuredtext en'
-from PyQt4.Qt import Qt, QAbstractListModel, QVariant, SIGNAL
+from PyQt4.Qt import Qt, QAbstractListModel, QVariant, QModelIndex
from calibre.gui2.convert.page_setup_ui import Ui_Form
from calibre.gui2.convert import Widget
@@ -59,7 +59,7 @@ class PageSetupWidget(Widget, Ui_Form):
for x in (self.opt_input_profile, self.opt_output_profile):
x.setMouseTracking(True)
- self.connect(x, SIGNAL('entered(QModelIndex)'), self.show_desc)
+ x.entered[(QModelIndex)].connect(self.show_desc)
self.initialize_options(get_option, get_help, db, book_id)
it = unicode(self.opt_input_profile.toolTip())
self.opt_input_profile.setToolTip(''+it.replace('t.','t.\n
'))
diff --git a/src/calibre/gui2/convert/single.py b/src/calibre/gui2/convert/single.py
index 945ed42594..fa42801b54 100644
--- a/src/calibre/gui2/convert/single.py
+++ b/src/calibre/gui2/convert/single.py
@@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en'
import cPickle, shutil
-from PyQt4.Qt import QString, SIGNAL, QAbstractListModel, Qt, QVariant, QFont
+from PyQt4.Qt import QString, QAbstractListModel, Qt, QVariant, QFont, QModelIndex
from calibre.gui2 import ResizableDialog, NONE, gprefs
from calibre.ebooks.conversion.config import (GuiRecommendations, save_specifics,
@@ -150,19 +150,14 @@ class Config(ResizableDialog, Ui_Dialog):
preferred_output_format)
self.setup_pipeline()
- self.connect(self.input_formats, SIGNAL('currentIndexChanged(QString)'),
- self.setup_pipeline)
- self.connect(self.output_formats, SIGNAL('currentIndexChanged(QString)'),
- self.setup_pipeline)
- self.connect(self.groups, SIGNAL('activated(QModelIndex)'),
- self.show_pane)
- self.connect(self.groups, SIGNAL('clicked(QModelIndex)'),
- self.show_pane)
- self.connect(self.groups, SIGNAL('entered(QModelIndex)'),
- self.show_group_help)
+ self.input_formats.currentIndexChanged[str].connect(self.setup_pipeline)
+ self.output_formats.currentIndexChanged[str].connect(self.setup_pipeline)
+ self.groups.activated[(QModelIndex)].connect(self.show_pane)
+ self.groups.clicked[(QModelIndex)].connect(self.show_pane)
+ self.groups.entered[(QModelIndex)].connect(self.show_group_help)
rb = self.buttonBox.button(self.buttonBox.RestoreDefaults)
rb.setText(_('Restore &Defaults'))
- self.connect(rb, SIGNAL('clicked()'), self.restore_defaults)
+ rb.clicked[()].connect(self.restore_defaults)
self.groups.setMouseTracking(True)
geom = gprefs.get('convert_single_dialog_geom', None)
if geom:
@@ -235,8 +230,7 @@ class Config(ResizableDialog, Ui_Dialog):
widgets.append(debug)
for w in widgets:
self.stack.addWidget(w)
- self.connect(w, SIGNAL('set_help(PyQt_PyObject)'),
- self.help.setPlainText)
+ w.set_help_signal.connect(self.help.setPlainText)
self._groups_model = GroupModel(widgets)
self.groups.setModel(self._groups_model)
diff --git a/src/calibre/gui2/convert/xpath_wizard.py b/src/calibre/gui2/convert/xpath_wizard.py
index e34453e5db..0a0a371e41 100644
--- a/src/calibre/gui2/convert/xpath_wizard.py
+++ b/src/calibre/gui2/convert/xpath_wizard.py
@@ -6,7 +6,7 @@ __license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal '
__docformat__ = 'restructuredtext en'
-from PyQt4.Qt import QDialog, QWidget, SIGNAL, Qt, QDialogButtonBox, QVBoxLayout
+from PyQt4.Qt import QDialog, QWidget, Qt, QDialogButtonBox, QVBoxLayout
from calibre.gui2.convert.xpath_wizard_ui import Ui_Form
from calibre.gui2.convert.xexp_edit_ui import Ui_Form as Ui_Edit
@@ -49,8 +49,8 @@ class Wizard(QDialog):
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok)
self.verticalLayout.addWidget(self.buttonBox)
- self.connect(self.buttonBox, SIGNAL("accepted()"), self.accept)
- self.connect(self.buttonBox, SIGNAL("rejected()"), self.reject)
+ self.buttonBox.accepted.connect(self.accept)
+ self.buttonBox.rejected.connect(self.reject)
self.setModal(Qt.WindowModal)
@property
@@ -63,7 +63,7 @@ class XPathEdit(QWidget, Ui_Edit):
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.setupUi(self)
- self.connect(self.button, SIGNAL('clicked()'), self.wizard)
+ self.button.clicked[()].connect(self.wizard)
def wizard(self):
wiz = Wizard(self)
@@ -75,7 +75,6 @@ class XPathEdit(QWidget, Ui_Edit):
if hasattr(self, 'edit'):
self.edit.initialize('xpath_edit_'+unicode(self.objectName()))
-
def set_msg(self, msg):
self.msg.setText(msg)
diff --git a/src/calibre/gui2/custom_column_widgets.py b/src/calibre/gui2/custom_column_widgets.py
index 5cbd318ee9..5d52379896 100644
--- a/src/calibre/gui2/custom_column_widgets.py
+++ b/src/calibre/gui2/custom_column_widgets.py
@@ -9,7 +9,7 @@ from functools import partial
from PyQt4.Qt import (QComboBox, QLabel, QSpinBox, QDoubleSpinBox, QDateTimeEdit,
QDateTime, QGroupBox, QVBoxLayout, QSizePolicy, QGridLayout,
- QSpacerItem, QIcon, QCheckBox, QWidget, QHBoxLayout, SIGNAL,
+ QSpacerItem, QIcon, QCheckBox, QWidget, QHBoxLayout,
QPushButton, QMessageBox, QToolButton, Qt)
from calibre.utils.date import qt_to_dt, now, as_local_time, as_utc
@@ -975,7 +975,7 @@ class RemoveTags(QWidget):
layout.addWidget(self.checkbox)
layout.addStretch(1)
self.setLayout(layout)
- self.connect(self.checkbox, SIGNAL('stateChanged(int)'), self.box_touched)
+ self.checkbox.stateChanged[int].connect(self.box_touched)
def box_touched(self, state):
if state:
diff --git a/src/calibre/gui2/device.py b/src/calibre/gui2/device.py
index 530540e07c..0b0c1b3fd3 100644
--- a/src/calibre/gui2/device.py
+++ b/src/calibre/gui2/device.py
@@ -7,7 +7,7 @@ import os, traceback, Queue, time, cStringIO, re, sys, weakref
from threading import Thread, Event
from PyQt4.Qt import (
- QMenu, QAction, QActionGroup, QIcon, SIGNAL, Qt, pyqtSignal, QDialog,
+ QMenu, QAction, QActionGroup, QIcon, Qt, pyqtSignal, QDialog,
QObject, QVBoxLayout, QDialogButtonBox, QCursor, QCoreApplication,
QApplication, QEventLoop)
@@ -695,6 +695,7 @@ class DeviceMenu(QMenu): # {{{
fetch_annotations = pyqtSignal()
disconnect_mounted_device = pyqtSignal()
+ sync = pyqtSignal(object, object, object)
def __init__(self, parent=None):
QMenu.__init__(self, parent)
@@ -805,8 +806,7 @@ class DeviceMenu(QMenu): # {{{
action.setChecked(True)
def action_triggered(self, action):
- self.emit(SIGNAL('sync(PyQt_PyObject, PyQt_PyObject, PyQt_PyObject)'),
- action.dest, action.delete, action.specific)
+ self.sync.emit(action.dest, action.delete, action.specific)
def trigger_default(self, *args):
r = config['default_send_to_device_action']
@@ -973,9 +973,7 @@ class DeviceMixin(object): # {{{
self._sync_menu = DeviceMenu(self)
self.iactions['Send To Device'].qaction.setMenu(self._sync_menu)
self.iactions['Connect Share'].build_email_entries()
- self.connect(self._sync_menu,
- SIGNAL('sync(PyQt_PyObject, PyQt_PyObject, PyQt_PyObject)'),
- self.dispatch_sync_event)
+ self._sync_menu.sync.connect(self.dispatch_sync_event)
self._sync_menu.fetch_annotations.connect(
self.iactions['Fetch Annotations'].fetch_annotations)
self._sync_menu.disconnect_mounted_device.connect(self.disconnect_mounted_device)
diff --git a/src/calibre/gui2/dialogs/choose_format.py b/src/calibre/gui2/dialogs/choose_format.py
index e1f32e3d26..9319131e6e 100644
--- a/src/calibre/gui2/dialogs/choose_format.py
+++ b/src/calibre/gui2/dialogs/choose_format.py
@@ -1,7 +1,7 @@
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal '
-from PyQt4.Qt import QDialog, QListWidgetItem, SIGNAL
+from PyQt4.Qt import QDialog, QListWidgetItem, QModelIndex
from calibre.gui2 import file_icon_provider
from calibre.gui2.dialogs.choose_format_ui import Ui_ChooseFormatDialog
@@ -12,8 +12,7 @@ class ChooseFormatDialog(QDialog, Ui_ChooseFormatDialog):
QDialog.__init__(self, window)
Ui_ChooseFormatDialog.__init__(self)
self.setupUi(self)
- self.connect(self.formats, SIGNAL('activated(QModelIndex)'),
- self.activated_slot)
+ self.formats.activated[QModelIndex].connect(self.activated_slot)
self.msg.setText(msg)
for format in formats:
diff --git a/src/calibre/gui2/dialogs/choose_format_device.py b/src/calibre/gui2/dialogs/choose_format_device.py
index f5e0761e4f..48c5afff5f 100644
--- a/src/calibre/gui2/dialogs/choose_format_device.py
+++ b/src/calibre/gui2/dialogs/choose_format_device.py
@@ -1,7 +1,7 @@
__license__ = 'GPL v3'
__copyright__ = '2011, John Schember '
-from PyQt4.Qt import QDialog, QTreeWidgetItem, QIcon, SIGNAL
+from PyQt4.Qt import QDialog, QTreeWidgetItem, QIcon, QModelIndex
from calibre.gui2 import file_icon_provider
from calibre.gui2.dialogs.choose_format_device_ui import Ui_ChooseFormatDeviceDialog
@@ -20,8 +20,7 @@ class ChooseFormatDeviceDialog(QDialog, Ui_ChooseFormatDeviceDialog):
QDialog.__init__(self, window)
Ui_ChooseFormatDeviceDialog.__init__(self)
self.setupUi(self)
- self.connect(self.formats, SIGNAL('activated(QModelIndex)'),
- self.activated_slot)
+ self.formats.activated[QModelIndex].connect(self.activated_slot)
self.msg.setText(msg)
for i, (format, exists, convertible) in enumerate(formats):
diff --git a/src/calibre/gui2/dialogs/password.py b/src/calibre/gui2/dialogs/password.py
index 0e58caf2d8..90d8a86153 100644
--- a/src/calibre/gui2/dialogs/password.py
+++ b/src/calibre/gui2/dialogs/password.py
@@ -2,7 +2,7 @@ __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal '
import re
from PyQt4.QtGui import QDialog, QLineEdit
-from PyQt4.QtCore import SIGNAL, Qt
+from PyQt4.QtCore import Qt
from calibre.gui2.dialogs.password_ui import Ui_Dialog
from calibre.gui2 import dynamic
@@ -17,13 +17,15 @@ class PasswordDialog(QDialog, Ui_Dialog):
un = dynamic[self.cfg_key+'__un']
pw = dynamic[self.cfg_key+'__pw']
- if not un: un = ''
- if not pw: pw = ''
+ if not un:
+ un = ''
+ if not pw:
+ pw = ''
self.gui_username.setText(un)
self.gui_password.setText(pw)
self.sname = name
self.msg.setText(msg)
- self.connect(self.show_password, SIGNAL('stateChanged(int)'), self.toggle_password)
+ self.show_password.stateChanged[(int)].connect(self.toggle_password)
def toggle_password(self, state):
if state == Qt.Unchecked:
@@ -41,3 +43,4 @@ class PasswordDialog(QDialog, Ui_Dialog):
dynamic.set(self.cfg_key+'__un', unicode(self.gui_username.text()))
dynamic.set(self.cfg_key+'__pw', unicode(self.gui_password.text()))
QDialog.accept(self)
+
diff --git a/src/calibre/gui2/dialogs/saved_search_editor.py b/src/calibre/gui2/dialogs/saved_search_editor.py
index 40cd16c41d..ade21244e9 100644
--- a/src/calibre/gui2/dialogs/saved_search_editor.py
+++ b/src/calibre/gui2/dialogs/saved_search_editor.py
@@ -3,7 +3,6 @@ __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal '
-from PyQt4.QtCore import SIGNAL
from PyQt4.QtGui import QDialog
from calibre.gui2.dialogs.saved_search_editor_ui import Ui_SavedSearchEditor
@@ -20,10 +19,9 @@ class SavedSearchEditor(QDialog, Ui_SavedSearchEditor):
Ui_SavedSearchEditor.__init__(self)
self.setupUi(self)
- self.connect(self.add_search_button, SIGNAL('clicked()'), self.add_search)
- self.connect(self.search_name_box, SIGNAL('currentIndexChanged(int)'),
- self.current_index_changed)
- self.connect(self.delete_search_button, SIGNAL('clicked()'), self.del_search)
+ self.add_search_button.clicked[()].connect(self.add_search)
+ self.search_name_box.currentIndexChanged[(int)].connect(self.current_index_changed)
+ self.delete_search_button.clicked[()].connect(self.del_search)
self.rename_button.clicked.connect(self.rename_search)
self.current_search_name = None
diff --git a/src/calibre/gui2/dialogs/tag_categories.py b/src/calibre/gui2/dialogs/tag_categories.py
index 22f1587766..6b20392aff 100644
--- a/src/calibre/gui2/dialogs/tag_categories.py
+++ b/src/calibre/gui2/dialogs/tag_categories.py
@@ -2,7 +2,7 @@ __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal '
-from PyQt4.QtCore import SIGNAL, Qt
+from PyQt4.QtCore import Qt
from PyQt4.QtGui import QDialog, QIcon, QListWidgetItem
from calibre.gui2.dialogs.tag_categories_ui import Ui_TagCategories
@@ -12,6 +12,7 @@ from calibre.constants import islinux
from calibre.utils.icu import sort_key, strcmp
class Item:
+
def __init__(self, name, label, index, icon, exists):
self.name = name
self.label = label
@@ -22,6 +23,7 @@ class Item:
return 'name=%s, label=%s, index=%s, exists='%(self.name, self.label, self.index, self.exists)
class TagCategories(QDialog, Ui_TagCategories):
+
'''
The structure of user_categories stored in preferences is
{cat_name: [ [name, category, v], [], []}, cat_name [ [name, cat, v] ...}
@@ -125,10 +127,8 @@ class TagCategories(QDialog, Ui_TagCategories):
if islinux:
self.available_items_box.itemDoubleClicked.connect(self.apply_tags)
else:
- self.connect(self.available_items_box,
- SIGNAL('itemActivated(QListWidgetItem*)'), self.apply_tags)
- self.connect(self.applied_items_box,
- SIGNAL('itemActivated(QListWidgetItem*)'), self.unapply_tags)
+ self.available_items_box.itemActivated.connect(self.apply_tags)
+ self.applied_items_box.itemActivated.connect(self.unapply_tags)
self.populate_category_list()
if on_category is not None:
@@ -195,7 +195,7 @@ class TagCategories(QDialog, Ui_TagCategories):
return False
for c in sorted(self.categories.keys(), key=sort_key):
if strcmp(c, cat_name) == 0 or \
- (icu_lower(cat_name).startswith(icu_lower(c) + '.') and\
+ (icu_lower(cat_name).startswith(icu_lower(c) + '.') and
not cat_name.startswith(c + '.')):
error_dialog(self, _('Name already used'),
_('That name is already used, perhaps with different case.')).exec_()
diff --git a/src/calibre/gui2/dialogs/tag_editor.py b/src/calibre/gui2/dialogs/tag_editor.py
index ef16dc4704..5299949449 100644
--- a/src/calibre/gui2/dialogs/tag_editor.py
+++ b/src/calibre/gui2/dialogs/tag_editor.py
@@ -3,7 +3,7 @@ __copyright__ = '2008, Kovid Goyal '
from functools import partial
-from PyQt4.QtCore import SIGNAL, Qt
+from PyQt4.QtCore import Qt
from PyQt4.QtGui import QDialog
from calibre.gui2.dialogs.tag_editor_ui import Ui_TagEditor
@@ -51,11 +51,11 @@ class TagEditor(QDialog, Ui_TagEditor):
if tag not in tags:
self.available_tags.addItem(tag)
- self.connect(self.apply_button, SIGNAL('clicked()'), self.apply_tags)
- self.connect(self.unapply_button, SIGNAL('clicked()'), self.unapply_tags)
- self.connect(self.add_tag_button, SIGNAL('clicked()'), self.add_tag)
- self.connect(self.delete_button, SIGNAL('clicked()'), self.delete_tags)
- self.connect(self.add_tag_input, SIGNAL('returnPressed()'), self.add_tag)
+ self.apply_button.clicked[()].connect(self.apply_tags)
+ self.unapply_button.clicked[()].connect(self.unapply_tags)
+ self.add_tag_button.clicked[()].connect(self.add_tag)
+ self.delete_button.clicked[()].connect(self.delete_tags)
+ self.add_tag_input.returnPressed[()].connect(self.add_tag)
# add the handlers for the filter input clear buttons
for x in ('available', 'applied'):
getattr(self, '%s_filter_input_clear_btn' % x).clicked.connect(getattr(self, '%s_filter_input' % x).clear)
@@ -66,8 +66,8 @@ class TagEditor(QDialog, Ui_TagEditor):
if islinux:
self.available_tags.itemDoubleClicked.connect(self.apply_tags)
else:
- self.connect(self.available_tags, SIGNAL('itemActivated(QListWidgetItem*)'), self.apply_tags)
- self.connect(self.applied_tags, SIGNAL('itemActivated(QListWidgetItem*)'), self.unapply_tags)
+ self.available_tags.itemActivated.connect(self.apply_tags)
+ self.applied_tags.itemActivated.connect(self.unapply_tags)
geom = gprefs.get('tag_editor_geometry', None)
if geom is not None:
diff --git a/src/calibre/gui2/dialogs/user_profiles.py b/src/calibre/gui2/dialogs/user_profiles.py
index 50bf4f47a0..48404f5c03 100644
--- a/src/calibre/gui2/dialogs/user_profiles.py
+++ b/src/calibre/gui2/dialogs/user_profiles.py
@@ -3,8 +3,7 @@ __copyright__ = '2008, Kovid Goyal '
import time, os
-from PyQt4.Qt import SIGNAL, QUrl, QAbstractListModel, Qt, \
- QVariant, QFont
+from PyQt4.Qt import (QUrl, QAbstractListModel, Qt, QVariant, QFont)
from calibre.web.feeds.recipes import compile_recipe, custom_recipes
from calibre.web.feeds.news import AutomaticNewsRecipe
@@ -87,23 +86,19 @@ class UserProfiles(ResizableDialog, Ui_Dialog):
f.setStyleHint(f.Monospace)
self.source_code.setFont(f)
- self.connect(self.remove_feed_button, SIGNAL('clicked(bool)'),
- self.added_feeds.remove_selected_items)
- self.connect(self.remove_profile_button, SIGNAL('clicked(bool)'),
- self.remove_selected_items)
- self.connect(self.add_feed_button, SIGNAL('clicked(bool)'),
- self.add_feed)
- self.connect(self.load_button, SIGNAL('clicked()'), self.load)
- self.connect(self.builtin_recipe_button, SIGNAL('clicked()'), self.add_builtin_recipe)
- self.connect(self.share_button, SIGNAL('clicked()'), self.share)
+ self.remove_feed_button.clicked[(bool)].connect(self.added_feeds.remove_selected_items)
+ self.remove_profile_button.clicked[(bool)].connect(self.remove_selected_items)
+ self.add_feed_button.clicked[(bool)].connect(self.add_feed)
+ self.load_button.clicked[()].connect(self.load)
+ self.builtin_recipe_button.clicked[()].connect(self.add_builtin_recipe)
+ self.share_button.clicked[()].connect(self.share)
self.show_recipe_files_button.clicked.connect(self.show_recipe_files)
- self.connect(self.down_button, SIGNAL('clicked()'), self.down)
- self.connect(self.up_button, SIGNAL('clicked()'), self.up)
- self.connect(self.add_profile_button, SIGNAL('clicked(bool)'),
- self.add_profile)
- self.connect(self.feed_url, SIGNAL('returnPressed()'), self.add_feed)
- self.connect(self.feed_title, SIGNAL('returnPressed()'), self.add_feed)
- self.connect(self.toggle_mode_button, SIGNAL('clicked(bool)'), self.toggle_mode)
+ self.down_button.clicked[()].connect(self.down)
+ self.up_button.clicked[()].connect(self.up)
+ self.add_profile_button.clicked[(bool)].connect(self.add_profile)
+ self.feed_url.returnPressed[()].connect(self.add_feed)
+ self.feed_title.returnPressed[()].connect(self.add_feed)
+ self.toggle_mode_button.clicked[(bool)].connect(self.toggle_mode)
self.clear()
def show_recipe_files(self, *args):
@@ -156,9 +151,9 @@ class UserProfiles(ResizableDialog, Ui_Dialog):
url.addQueryItem('attachment', pt.name)
open_url(url)
-
def current_changed(self, current, previous):
- if not current.isValid(): return
+ if not current.isValid():
+ return
src = self._model.script(current)
if src is None:
return
@@ -186,7 +181,6 @@ class UserProfiles(ResizableDialog, Ui_Dialog):
self.source_code.setPlainText(src.replace('BasicUserRecipe', 'AdvancedUserRecipe'))
self.highlighter = PythonHighlighter(self.source_code.document())
-
def add_feed(self, *args):
title = unicode(self.feed_title.text()).strip()
if not title:
@@ -231,7 +225,6 @@ class %(classname)s(%(base_class)s):
base_class='AutomaticNewsRecipe')
return src, title
-
def populate_source_code(self):
src = self.options_to_profile().replace('BasicUserRecipe', 'AdvancedUserRecipe')
self.source_code.setPlainText(src)
@@ -328,7 +321,6 @@ class %(classname)s(%(base_class)s):
self.clear()
-
def load(self):
files = choose_files(self, 'recipe loader dialog',
_('Choose a recipe file'),
@@ -365,7 +357,6 @@ class %(classname)s(%(base_class)s):
self.feed_title.setText('')
self.feed_url.setText('')
-
def clear(self):
self.populate_options(AutomaticNewsRecipe)
self.source_code.setText('')
diff --git a/src/calibre/gui2/lrf_renderer/document.py b/src/calibre/gui2/lrf_renderer/document.py
index f0c53b12f9..970823beee 100644
--- a/src/calibre/gui2/lrf_renderer/document.py
+++ b/src/calibre/gui2/lrf_renderer/document.py
@@ -2,7 +2,7 @@ __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal '
import collections, itertools, glob
-from PyQt4.QtCore import Qt, QByteArray, SIGNAL
+from PyQt4.QtCore import Qt, QByteArray, pyqtSignal
from PyQt4.QtGui import QGraphicsRectItem, QGraphicsScene, QPen, \
QBrush, QColor, QFontDatabase, \
QGraphicsItem, QGraphicsLineItem
@@ -15,10 +15,12 @@ from calibre.ebooks.lrf.objects import Canvas as __Canvas
class Color(QColor):
+
def __init__(self, color):
QColor.__init__(self, color.r, color.g, color.b, 0xff-color.a)
class Pen(QPen):
+
def __init__(self, color, width):
QPen.__init__(self, QBrush(Color(color)), width,
(Qt.SolidLine if width > 0 else Qt.NoPen))
@@ -104,13 +106,13 @@ class _Canvas(QGraphicsRectItem):
def layout_text_block(self, block, x, y):
textwidth = block.bs.blockwidth - block.bs.sidemargin
- if block.max_y == 0 or not block.lines: # Empty block skipping
+ if block.max_y == 0 or not block.lines: # Empty block skipping
self.is_full = False
return
line = block.peek()
y += block.bs.topskip
block_consumed = False
- line.height = min(line.height, self.max_y-block.bs.topskip) # LRF files from TOR have Plot elements with their height set to 800
+ line.height = min(line.height, self.max_y-block.bs.topskip) # LRF files from TOR have Plot elements with their height set to 800
while y + line.height <= self.max_y:
block.commit()
if isinstance(line, QGraphicsItem):
@@ -122,7 +124,7 @@ class _Canvas(QGraphicsRectItem):
if not block.has_content:
try:
y += block.bs.footskip
- except AttributeError: # makelrf generates BlockStyles without footskip
+ except AttributeError: # makelrf generates BlockStyles without footskip
pass
block_consumed = True
break
@@ -178,7 +180,6 @@ class _Canvas(QGraphicsRectItem):
return matches
-
class Canvas(_Canvas, ContentObject):
def __init__(self, font_loader, canvas, logger, opts, ruby_tags, link_activated, width=0, height=0):
@@ -210,6 +211,7 @@ class Canvas(_Canvas, ContentObject):
_Canvas.layout_block(self, block, x, y)
class Header(Canvas):
+
def __init__(self, font_loader, header, page_style, logger, opts, ruby_tags, link_activated):
Canvas.__init__(self, font_loader, header, logger, opts, ruby_tags, link_activated,
page_style.textwidth, page_style.headheight)
@@ -217,6 +219,7 @@ class Header(Canvas):
self.setPen(QPen(Qt.blue, 1, Qt.DashLine))
class Footer(Canvas):
+
def __init__(self, font_loader, footer, page_style, logger, opts, ruby_tags, link_activated):
Canvas.__init__(self, font_loader, footer, logger, opts, ruby_tags, link_activated,
page_style.textwidth, page_style.footheight)
@@ -291,7 +294,6 @@ class Page(_Canvas):
self.layout_block(block, 0, self.current_y)
-
class Chapter(object):
num_of_pages = property(fget=lambda self: len(self.pages))
@@ -325,12 +327,14 @@ class History(collections.deque):
self.pos = 0
def back(self):
- if self.pos - 1 < 0: return None
+ if self.pos - 1 < 0:
+ return None
self.pos -= 1
return self[self.pos]
def forward(self):
- if self.pos + 1 >= len(self): return None
+ if self.pos + 1 >= len(self):
+ return None
self.pos += 1
return self[self.pos]
@@ -341,10 +345,11 @@ class History(collections.deque):
self.pos += 1
-
class Document(QGraphicsScene):
num_of_pages = property(fget=lambda self: sum(self.chapter_layout))
+ chapter_rendered = pyqtSignal(object)
+ page_changed = pyqtSignal(object)
def __init__(self, logger, opts):
QGraphicsScene.__init__(self)
@@ -364,7 +369,7 @@ class Document(QGraphicsScene):
def page_of(self, oid):
for chapter in self.chapters:
if oid in chapter.object_to_page_map:
- return chapter.object_to_page_map[oid]
+ return chapter.object_to_page_map[oid]
def get_page_num(self, chapterid, objid):
cnum = self.chapter_map[chapterid]
@@ -388,7 +393,6 @@ class Document(QGraphicsScene):
jb = self.objects[objid]
self.link_map[objid] = (jb.refpage, jb.refobj)
-
def back(self):
oid = self.history.back()
if oid is not None:
@@ -401,7 +405,6 @@ class Document(QGraphicsScene):
page = self.page_of(oid)
self.show_page(page)
-
def load_fonts(self, lrf, load_substitutions=True):
font_map = {}
@@ -418,7 +421,6 @@ class Document(QGraphicsScene):
self.font_loader = FontLoader(font_map, self.dpi)
-
def render_chapter(self, chapter, lrf):
oddscreen, evenscreen = Screen(self.font_loader, chapter, True, self.logger, self.opts, self.ruby_tags, self.link_activated), \
Screen(self.font_loader, chapter, False, self.logger, self.opts, self.ruby_tags, self.link_activated)
@@ -442,7 +444,6 @@ class Document(QGraphicsScene):
self.chapters.append(Chapter(oddscreen, evenscreen, pages, object_to_page_map))
self.chapter_map[chapter.id] = len(self.chapters)-1
-
def render(self, lrf, load_substitutions=True):
self.dpi = lrf.device_info.dpi/10.
self.ruby_tags = dict(**lrf.ruby_tags)
@@ -453,13 +454,12 @@ class Document(QGraphicsScene):
for pt in lrf.page_trees:
for chapter in pt:
num_chaps += 1
- self.emit(SIGNAL('chapter_rendered(int)'), num_chaps)
+ self.chapter_rendered.emit(num_chaps)
for pt in lrf.page_trees:
for chapter in pt:
self.render_chapter(chapter, lrf)
-
- self.emit(SIGNAL('chapter_rendered(int)'), -1)
+ self.chapter_rendered.emit(-1)
self.chapter_layout = [i.num_of_pages for i in self.chapters]
self.objects = None
@@ -485,8 +485,7 @@ class Document(QGraphicsScene):
self.addItem(self.current_screen)
self.current_screen.set_page(page)
- self.emit(SIGNAL('page_changed(PyQt_PyObject)'), self.current_page)
-
+ self.page_changed.emit(self.current_page)
def next(self):
self.next_by(1)
diff --git a/src/calibre/gui2/lrf_renderer/main.py b/src/calibre/gui2/lrf_renderer/main.py
index 741f6a620d..d4cab382f8 100644
--- a/src/calibre/gui2/lrf_renderer/main.py
+++ b/src/calibre/gui2/lrf_renderer/main.py
@@ -3,7 +3,7 @@ __copyright__ = '2008, Kovid Goyal '
import sys, logging, os, traceback, time
from PyQt4.QtGui import QKeySequence, QPainter, QDialog, QSpinBox, QSlider, QIcon
-from PyQt4.QtCore import Qt, QObject, SIGNAL, QCoreApplication, QThread
+from PyQt4.QtCore import Qt, QCoreApplication, QThread
from calibre import __appname__, setup_cli_handlers, islinux, isbsd
from calibre.ebooks.lrf.lrfparser import LRFDocument
@@ -58,9 +58,8 @@ class Main(MainWindow, Ui_MainWindow):
def create_document(self):
self.document = Document(self.logger, self.opts)
- QObject.connect(self.document, SIGNAL('chapter_rendered(int)'), self.chapter_rendered)
- QObject.connect(self.document, SIGNAL('page_changed(PyQt_PyObject)'), self.page_changed)
-
+ self.document.chapter_rendered.connect(self.chapter_rendered)
+ self.document.page_changed.connect(self.page_changed)
def __init__(self, logger, opts, parent=None):
MainWindow.__init__(self, opts, parent)
@@ -87,16 +86,15 @@ class Main(MainWindow, Ui_MainWindow):
self.action_previous_page.setShortcuts([QKeySequence.MoveToPreviousPage, QKeySequence(Qt.Key_Backspace)])
self.action_next_match.setShortcuts(QKeySequence.FindNext)
self.addAction(self.action_next_match)
- QObject.connect(self.action_next_page, SIGNAL('triggered(bool)'), self.next)
- QObject.connect(self.action_previous_page, SIGNAL('triggered(bool)'), self.previous)
- QObject.connect(self.action_back, SIGNAL('triggered(bool)'), self.back)
- QObject.connect(self.action_forward, SIGNAL('triggered(bool)'), self.forward)
- QObject.connect(self.action_next_match, SIGNAL('triggered(bool)'), self.next_match)
- QObject.connect(self.action_open_ebook, SIGNAL('triggered(bool)'), self.open_ebook)
- QObject.connect(self.action_configure, SIGNAL('triggered(bool)'), self.configure)
- QObject.connect(self.spin_box, SIGNAL('valueChanged(int)'), self.go_to_page)
- QObject.connect(self.slider, SIGNAL('valueChanged(int)'), self.go_to_page)
-
+ self.action_next_page.triggered[(bool)].connect(self.next)
+ self.action_previous_page.triggered[(bool)].connect(self.previous)
+ self.action_back.triggered[(bool)].connect(self.back)
+ self.action_forward.triggered[(bool)].connect(self.forward)
+ self.action_next_match.triggered[(bool)].connect(self.next_match)
+ self.action_open_ebook.triggered[(bool)].connect(self.open_ebook)
+ self.action_configure.triggered[(bool)].connect(self.configure)
+ self.spin_box.valueChanged[(int)].connect(self.go_to_page)
+ self.slider.valueChanged[(int)].connect(self.go_to_page)
self.graphics_view.setRenderHint(QPainter.Antialiasing, True)
self.graphics_view.setRenderHint(QPainter.TextAntialiasing, True)
@@ -104,7 +102,6 @@ class Main(MainWindow, Ui_MainWindow):
self.closed = False
-
def configure(self, triggered):
opts = config['LRF_ebook_viewer_options']
if not opts:
@@ -126,7 +123,7 @@ class Main(MainWindow, Ui_MainWindow):
self.file_name = os.path.basename(stream.name) if hasattr(stream, 'name') else ''
self.progress_label.setText('Parsing '+ self.file_name)
self.renderer = RenderWorker(self, stream, self.logger, self.opts)
- QObject.connect(self.renderer, SIGNAL('finished()'), self.parsed, Qt.QueuedConnection)
+ self.renderer.finished.connect(self.parsed, type=Qt.QueuedConnection)
self.search.clear()
self.last_search = None
else:
@@ -142,7 +139,6 @@ class Main(MainWindow, Ui_MainWindow):
self.set_ebook(open(file, 'rb'))
self.render()
-
def page_changed(self, num):
self.slider.setValue(num)
self.spin_box.setValue(num)
@@ -249,7 +245,6 @@ class Main(MainWindow, Ui_MainWindow):
if self.renderer is not None and self.renderer.isRunning():
self.renderer.abort()
self.renderer.wait()
- self.emit(SIGNAL('viewer_closed(PyQt_PyObject)'), self)
event.accept()
@@ -259,7 +254,7 @@ def file_renderer(stream, opts, parent=None, logger=None):
logger = logging.getLogger('lrfviewer')
setup_cli_handlers(logger, level)
if islinux or isbsd:
- try: # Set lrfviewer as the default for LRF files for this user
+ try: # Set lrfviewer as the default for LRF files for this user
from subprocess import call
call('xdg-mime default calibre-lrfviewer.desktop application/lrf', shell=True)
except:
diff --git a/src/calibre/gui2/ui.py b/src/calibre/gui2/ui.py
index ede0dc8deb..4206264450 100644
--- a/src/calibre/gui2/ui.py
+++ b/src/calibre/gui2/ui.py
@@ -15,7 +15,7 @@ from threading import Thread
from collections import OrderedDict
import apsw
-from PyQt4.Qt import (Qt, SIGNAL, QTimer, QHelpEvent, QAction,
+from PyQt4.Qt import (Qt, QTimer, QHelpEvent, QAction,
QMenu, QIcon, pyqtSignal, QUrl, QFont,
QDialog, QSystemTrayIcon, QApplication)
@@ -197,8 +197,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
self.must_restart_before_config = False
self.listener = Listener(listener)
self.check_messages_timer = QTimer()
- self.connect(self.check_messages_timer, SIGNAL('timeout()'),
- self.another_instance_wants_to_talk)
+ self.check_messages_timer.timeout.connect(self.another_instance_wants_to_talk)
self.check_messages_timer.start(1000)
for ac in self.iactions.values():
@@ -259,10 +258,9 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
self.keyboard.register_shortcut('quit calibre', _('Quit calibre'),
default_keys=('Ctrl+Q',), action=self.quit_action)
self.system_tray_icon.setContextMenu(self.system_tray_menu)
- self.connect(self.quit_action, SIGNAL('triggered(bool)'), self.quit)
- self.connect(self.donate_action, SIGNAL('triggered(bool)'), self.donate)
- self.connect(self.restore_action, SIGNAL('triggered()'),
- self.show_windows)
+ self.quit_action.triggered[bool].connect(self.quit)
+ self.donate_action.triggered[bool].connect(self.donate)
+ self.restore_action.triggered.connect(self.show_windows)
self.system_tray_icon.activated.connect(
self.system_tray_icon_activated)
@@ -508,7 +506,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
window.hide()
setattr(window, '__systray_minimized', True)
- def show_windows(self):
+ def show_windows(self, *args):
for window in QApplication.topLevelWidgets():
if getattr(window, '__systray_minimized', False):
window.show()
diff --git a/src/calibre/gui2/viewer/documentview.py b/src/calibre/gui2/viewer/documentview.py
index 130af04424..ca45455b1a 100644
--- a/src/calibre/gui2/viewer/documentview.py
+++ b/src/calibre/gui2/viewer/documentview.py
@@ -8,7 +8,7 @@ import os, math, json
from base64 import b64encode
from functools import partial
-from PyQt4.Qt import (QSize, QSizePolicy, QUrl, SIGNAL, Qt, pyqtProperty,
+from PyQt4.Qt import (QSize, QSizePolicy, QUrl, Qt, pyqtProperty,
QPainter, QPalette, QBrush, QDialog, QColor, QPoint, QImage, QRegion,
QIcon, pyqtSignature, QAction, QMenu, QString, pyqtSignal,
QApplication, pyqtSlot)
@@ -48,6 +48,7 @@ class Document(QWebPage): # {{{
page_turn = pyqtSignal(object)
mark_element = pyqtSignal(QWebElement)
settings_changed = pyqtSignal()
+ animated_scroll_done_signal = pyqtSignal()
def set_font_settings(self, opts):
settings = self.settings()
@@ -206,7 +207,7 @@ class Document(QWebPage): # {{{
@pyqtSignature("")
def animated_scroll_done(self):
- self.emit(SIGNAL('animated_scroll_done()'))
+ self.animated_scroll_done_signal.emit()
@property
def hyphenatable(self):
@@ -513,11 +514,10 @@ class DocumentView(QWebView): # {{{
self._ignore_scrollbar_signals = False
self.loading_url = None
self.loadFinished.connect(self.load_finished)
- self.connect(self.document, SIGNAL('linkClicked(QUrl)'), self.link_clicked)
- self.connect(self.document, SIGNAL('linkHovered(QString,QString,QString)'), self.link_hovered)
- self.connect(self.document, SIGNAL('selectionChanged()'), self.selection_changed)
- self.connect(self.document, SIGNAL('animated_scroll_done()'),
- self.animated_scroll_done, Qt.QueuedConnection)
+ self.document.linkClicked.connect(self.link_clicked)
+ self.document.linkHovered.connect(self.link_hovered)
+ self.document.selectionChanged[()].connect(self.selection_changed)
+ self.document.animated_scroll_done_signal.connect(self.animated_scroll_done, type=Qt.QueuedConnection)
self.document.page_turn.connect(self.page_turn_requested)
copy_action = self.pageAction(self.document.Copy)
copy_action.setIcon(QIcon(I('convert.png')))
@@ -755,7 +755,7 @@ class DocumentView(QWebView): # {{{
def set_manager(self, manager):
self.manager = manager
self.scrollbar = manager.horizontal_scrollbar
- self.connect(self.scrollbar, SIGNAL('valueChanged(int)'), self.scroll_horizontally)
+ self.scrollbar.valueChanged[(int)].connect(self.scroll_horizontally)
def scroll_horizontally(self, amount):
self.document.scroll_to(y=self.document.ypos, x=amount)
diff --git a/src/calibre/gui2/widgets.py b/src/calibre/gui2/widgets.py
index ad51090556..3d6ff36f10 100644
--- a/src/calibre/gui2/widgets.py
+++ b/src/calibre/gui2/widgets.py
@@ -8,7 +8,7 @@ import re, os
from PyQt4.Qt import (QIcon, QFont, QLabel, QListWidget, QAction,
QListWidgetItem, QTextCharFormat, QApplication, QSyntaxHighlighter,
QCursor, QColor, QWidget, QPixmap, QSplitterHandle, QToolButton,
- QVariant, Qt, SIGNAL, pyqtSignal, QRegExp, QSize, QSplitter, QPainter,
+ QVariant, Qt, pyqtSignal, QRegExp, QSize, QSplitter, QPainter,
QLineEdit, QComboBox, QPen, QGraphicsScene, QMenu, QStringListModel,
QCompleter, QStringList, QTimer, QRect, QGraphicsView, QByteArray)
@@ -65,8 +65,9 @@ class FilenamePattern(QWidget, Ui_Form): # {{{
QWidget.__init__(self, parent)
self.setupUi(self)
- self.connect(self.test_button, SIGNAL('clicked()'), self.do_test)
- self.connect(self.re.lineEdit(), SIGNAL('returnPressed()'), self.do_test)
+ self.test_button.clicked[()].connect(self.do_test)
+ self.re.lineEdit().returnPressed[()].connect(self.do_test)
+ self.filename.returnPressed[()].connect(self.do_test)
self.re.lineEdit().textChanged.connect(lambda x: self.changed_signal.emit())
def initialize(self, defaults=False):
@@ -428,11 +429,11 @@ class LineEditECM(object): # {{{
action_title_case = case_menu.addAction(_('Title Case'))
action_capitalize = case_menu.addAction(_('Capitalize'))
- self.connect(action_upper_case, SIGNAL('triggered()'), self.upper_case)
- self.connect(action_lower_case, SIGNAL('triggered()'), self.lower_case)
- self.connect(action_swap_case, SIGNAL('triggered()'), self.swap_case)
- self.connect(action_title_case, SIGNAL('triggered()'), self.title_case)
- self.connect(action_capitalize, SIGNAL('triggered()'), self.capitalize)
+ action_upper_case.triggered[()].connect(self.upper_case)
+ action_lower_case.triggered[()].connect(self.lower_case)
+ action_swap_case.triggered[()].connect(self.swap_case)
+ action_title_case.triggered[()].connect(self.title_case)
+ action_capitalize.triggered[()].connect(self.capitalize)
menu.addMenu(case_menu)
menu.exec_(event.globalPos())
@@ -506,16 +507,12 @@ class CompleteLineEdit(EnLineEdit): # {{{
self.separator = sep
self.space_before_sep = space_before_sep
- self.connect(self, SIGNAL('textChanged(QString)'), self.text_changed)
+ self.textChanged.connect(self.text_changed)
self.completer = ItemsCompleter(self, complete_items)
self.completer.setCaseSensitivity(Qt.CaseInsensitive)
- self.connect(self,
- SIGNAL('text_changed(PyQt_PyObject, PyQt_PyObject)'),
- self.completer.update)
- self.connect(self.completer, SIGNAL('activated(QString)'),
- self.complete_text)
+ self.completer.activated[str].connect(self.complete_text)
self.completer.setWidget(self)
@@ -539,9 +536,7 @@ class CompleteLineEdit(EnLineEdit): # {{{
if t1 != '':
text_items.append(t)
text_items = list(set(text_items))
-
- self.emit(SIGNAL('text_changed(PyQt_PyObject, PyQt_PyObject)'),
- text_items, prefix)
+ self.completer.update(text_items, prefix)
def complete_text(self, text):
cursor_pos = self.cursorPosition()
diff --git a/src/calibre/gui2/wizard/__init__.py b/src/calibre/gui2/wizard/__init__.py
index 5220d99316..14503ad15d 100644
--- a/src/calibre/gui2/wizard/__init__.py
+++ b/src/calibre/gui2/wizard/__init__.py
@@ -12,7 +12,7 @@ from contextlib import closing
from PyQt4.Qt import (QWizard, QWizardPage, QPixmap, Qt, QAbstractListModel,
- QVariant, QItemSelectionModel, SIGNAL, QObject, QTimer, pyqtSignal)
+ QVariant, QItemSelectionModel, QObject, QTimer, pyqtSignal, QItemSelection)
from calibre import __appname__, patheq
from calibre.library.move import MoveLibrary
from calibre.constants import (filesystem_encoding, iswindows, plugins,
@@ -479,7 +479,7 @@ class StanzaPage(QWizardPage, StanzaUI):
def __init__(self):
QWizardPage.__init__(self)
self.setupUi(self)
- self.connect(self.content_server, SIGNAL('stateChanged(int)'), self.set_port)
+ self.content_server.stateChanged[(int)].connect(self.set_port)
def initializePage(self):
from calibre.gui2 import config
@@ -548,9 +548,7 @@ class DevicePage(QWizardPage, DeviceUI):
self.device_view.setModel(self.dev_model)
self.device_view.selectionModel().select(idx,
QItemSelectionModel.Select)
- self.connect(self.manufacturer_view.selectionModel(),
- SIGNAL('selectionChanged(QItemSelection,QItemSelection)'),
- self.manufacturer_changed)
+ self.manufacturer_view.selectionModel().selectionChanged[(QItemSelection, QItemSelection)].connect(self.manufacturer_changed)
def manufacturer_changed(self, current, previous):
new = list(current.indexes())[0]
@@ -591,7 +589,7 @@ class MoveMonitor(QObject):
self.dialog.setModal(True)
self.dialog.show()
self.timer = QTimer(self)
- self.connect(self.timer, SIGNAL('timeout()'), self.check)
+ self.timer.timeout.connect(self.check)
self.timer.start(200)
def check(self):
@@ -682,14 +680,13 @@ class LibraryPage(QWizardPage, LibraryUI):
QWizardPage.__init__(self)
self.setupUi(self)
self.registerField('library_location', self.location)
- self.connect(self.button_change, SIGNAL('clicked()'), self.change)
+ self.button_change.clicked[()].connect(self.change)
self.init_languages()
self.language.currentIndexChanged[int].connect(self.change_language)
- self.connect(self.location, SIGNAL('textChanged(QString)'),
- self.location_text_changed)
+ self.location.textChanged.connect(self.location_text_changed)
def location_text_changed(self, newtext):
- self.emit(SIGNAL('completeChanged()'))
+ self.completeChanged.emit()
def init_languages(self):
self.language.blockSignals(True)