Refactor out use of SIGNAL macro

This commit is contained in:
Kovid Goyal 2014-03-31 10:03:50 +05:30
parent 45a9c57e0a
commit 2a9643793a
27 changed files with 164 additions and 214 deletions

View File

@ -8,7 +8,7 @@ Render HTML tables as images.
'''
import os, tempfile, atexit, shutil
from PyQt4.Qt import QUrl, QApplication, QSize, QEventLoop, \
SIGNAL, QPainter, QImage, QObject, Qt
QPainter, QImage, QObject, Qt
from PyQt4.QtWebKit import QWebPage
class HTMLTableRenderer(QObject):
@ -27,12 +27,11 @@ class HTMLTableRenderer(QObject):
self.tdir = tempfile.mkdtemp(prefix='calibre_render_table')
self.loop = QEventLoop()
self.page = QWebPage()
self.connect(self.page, SIGNAL('loadFinished(bool)'), self.render_html)
self.page.loadFinished.connect(self.render_html)
self.page.mainFrame().setTextSizeMultiplier(factor)
self.page.mainFrame().setHtml(html,
QUrl('file:'+os.path.abspath(self.base_dir)))
def render_html(self, ok):
try:
if not ok:

View File

@ -4,7 +4,7 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
import os, sys, Queue, threading, glob
from threading import RLock
from urllib import unquote
from PyQt4.Qt import (QVariant, QFileInfo, QObject, SIGNAL, QBuffer, Qt,
from PyQt4.Qt import (QVariant, QFileInfo, QObject, QBuffer, Qt,
QByteArray, QTranslator, QCoreApplication, QThread,
QEvent, QTimer, pyqtSignal, QDateTime, QDesktopServices,
QFileDialog, QFileIconProvider, QSettings, QColor,
@ -442,20 +442,21 @@ class GetMetadata(QObject):
GUI thread. Must be instantiated in the GUI thread.
'''
edispatch = pyqtSignal(object, object, object)
idispatch = pyqtSignal(object, object, object)
metadataf = pyqtSignal(object, object)
metadata = pyqtSignal(object, object)
def __init__(self):
QObject.__init__(self)
self.connect(self, SIGNAL('edispatch(PyQt_PyObject, PyQt_PyObject, PyQt_PyObject)'),
self._get_metadata, Qt.QueuedConnection)
self.connect(self, SIGNAL('idispatch(PyQt_PyObject, PyQt_PyObject, PyQt_PyObject)'),
self._from_formats, Qt.QueuedConnection)
self.edispatch.connect(self._get_metadata, type=Qt.QueuedConnection)
self.idispatch.connect(self._from_formats, type=Qt.QueuedConnection)
def __call__(self, id, *args, **kwargs):
self.emit(SIGNAL('edispatch(PyQt_PyObject, PyQt_PyObject, PyQt_PyObject)'),
id, args, kwargs)
self.edispatch.emit(id, args, kwargs)
def from_formats(self, id, *args, **kwargs):
self.emit(SIGNAL('idispatch(PyQt_PyObject, PyQt_PyObject, PyQt_PyObject)'),
id, args, kwargs)
self.idispatch.emit(id, args, kwargs)
def _from_formats(self, id, args, kwargs):
from calibre.ebooks.metadata.meta import metadata_from_formats
@ -463,7 +464,7 @@ class GetMetadata(QObject):
mi = metadata_from_formats(*args, **kwargs)
except:
mi = MetaInformation('', [_('Unknown')])
self.emit(SIGNAL('metadataf(PyQt_PyObject, PyQt_PyObject)'), id, mi)
self.metadataf.emit(id, mi)
def _get_metadata(self, id, args, kwargs):
from calibre.ebooks.metadata.meta import get_metadata
@ -471,7 +472,7 @@ class GetMetadata(QObject):
mi = get_metadata(*args, **kwargs)
except:
mi = MetaInformation('', [_('Unknown')])
self.emit(SIGNAL('metadata(PyQt_PyObject, PyQt_PyObject)'), id, mi)
self.metadata.emit(id, mi)
class FileIconProvider(QFileIconProvider):

View File

@ -17,10 +17,9 @@ from calibre.utils.icu import sort_key
from catalog_epub_mobi_ui import Ui_Form
from PyQt4.Qt import (Qt, QAbstractItemView, QCheckBox, QComboBox,
QDoubleSpinBox, QIcon, QInputDialog, QLineEdit, QObject, QRadioButton,
QDoubleSpinBox, QIcon, QInputDialog, QLineEdit, QRadioButton,
QSize, QSizePolicy, QTableWidget, QTableWidgetItem, QTextEdit, QToolButton,
QUrl, QVBoxLayout, QWidget,
SIGNAL)
QUrl, QVBoxLayout, QWidget)
class PluginWidget(QWidget,Ui_Form):
@ -906,7 +905,7 @@ class GenericRulesTable(QTableWidget):
self._init_controls()
# Hook check_box changes
QObject.connect(self, SIGNAL('cellChanged(int,int)'), self.enabled_state_changed)
self.cellChanged.connect(self.enabled_state_changed)
def _init_controls(self):
# Add the control set

View File

@ -48,7 +48,7 @@ class Widget(QWidget):
STRIP_TEXT_FIELDS = True
changed_signal = pyqtSignal()
set_help = pyqtSignal(object)
set_help_signal = pyqtSignal(object)
def __init__(self, parent, options):
QWidget.__init__(self, parent)
@ -238,7 +238,7 @@ class Widget(QWidget):
def set_help(self, msg):
if msg and getattr(msg, 'strip', lambda:True)():
try:
self.set_help.emit(msg)
self.set_help_signal.emit(msg)
except:
pass

View File

@ -6,7 +6,7 @@ __docformat__ = 'restructuredtext en'
import shutil
from PyQt4.Qt import QString, SIGNAL
from PyQt4.Qt import QString, QModelIndex
from calibre.gui2.convert.single import (Config, sort_formats_by_preference,
GroupModel, gprefs, get_output_formats)
@ -42,14 +42,10 @@ class BulkConfig(Config):
'values saved in a previous conversion (if they exist) instead '
'of using the defaults specified in the Preferences'))
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.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.setVisible(False)
self.groups.setMouseTracking(True)
@ -103,8 +99,7 @@ class BulkConfig(Config):
widgets.append(output_widget)
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)

View File

@ -8,8 +8,6 @@ __docformat__ = 'restructuredtext en'
import os
from PyQt4.Qt import SIGNAL
from calibre.gui2.convert.debug_ui import Ui_Form
from calibre.gui2.convert import Widget
from calibre.gui2 import error_dialog, choose_dir
@ -27,10 +25,8 @@ class DebugWidget(Widget, Ui_Form):
)
self.db, self.book_id = db, book_id
self.initialize_options(get_option, get_help, db, book_id)
self.connect(self.button_debug_dir, SIGNAL('clicked()'),
self.set_debug_dir)
self.connect(self.button_clear, SIGNAL('clicked()'),
self.clear_debug_dir)
self.button_debug_dir.clicked[()].connect(self.set_debug_dir)
self.button_clear.clicked[()].connect(self.clear_debug_dir)
def clear_debug_dir(self):
self.opt_debug_pipeline.setText('')

View File

@ -6,7 +6,7 @@ __license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from PyQt4.Qt import QDialog, SIGNAL
from PyQt4.Qt import QDialog
from calibre.gui2.convert.font_key_ui import Ui_Dialog
@ -18,17 +18,13 @@ class FontKeyChooser(QDialog, Ui_Dialog):
self.default_font_key = font_key
self.default_base_font_size = base_font_size
self.connect(self.buttonBox, SIGNAL('clicked(QAbstractButton*)'),
self.button_clicked)
self.connect(self.button_use_default, SIGNAL('clicked()'),
self.use_default)
self.buttonBox.clicked.connect(self.button_clicked)
self.button_use_default.clicked[()].connect(self.use_default)
for x in ('input_base_font_size', 'input_font_size',
'output_base_font_size'):
self.connect(getattr(self, x), SIGNAL('valueChanged(double)'),
self.calculate)
self.connect(self.font_size_key, SIGNAL('textChanged(QString)'),
self.calculate)
getattr(self, x).valueChanged.connect(self.calculate)
self.font_size_key.textChanged.connect(self.calculate)
self.initialize()

View File

@ -6,7 +6,7 @@ __license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from PyQt4.Qt import SIGNAL, QVariant, Qt
from PyQt4.Qt import QVariant, Qt
from calibre.gui2.convert.look_and_feel_ui import Ui_Form
from calibre.gui2.convert import Widget
@ -52,8 +52,7 @@ class LookAndFeelWidget(Widget, Ui_Form):
self.initialize_options(get_option, get_help, db, book_id)
self.opt_disable_font_rescaling.toggle()
self.opt_disable_font_rescaling.toggle()
self.connect(self.button_font_key, SIGNAL('clicked()'),
self.font_key_wizard)
self.button_font_key.clicked[()].connect(self.font_key_wizard)
self.opt_remove_paragraph_spacing.toggle()
self.opt_remove_paragraph_spacing.toggle()
self.opt_smarten_punctuation.stateChanged.connect(

View File

@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en'
import os, re
from PyQt4.Qt import QPixmap, SIGNAL
from PyQt4.Qt import QPixmap
from calibre.gui2 import choose_images, error_dialog
from calibre.gui2.convert.metadata_ui import Ui_Form
@ -59,7 +59,7 @@ class MetadataWidget(Widget, Ui_Form):
if self.db is not None:
self.initialize_metadata_options()
self.initialize_options(get_option, get_help, db, book_id)
self.connect(self.cover_button, SIGNAL("clicked()"), self.select_cover)
self.cover_button.clicked[()].connect(self.select_cover)
self.comment.hide_toolbars()
self.cover.cover_changed.connect(self.change_cover)

View File

@ -6,7 +6,7 @@ __license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__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('<p>'+it.replace('t.','t.\n<br>'))

View File

@ -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)

View File

@ -6,7 +6,7 @@ __license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__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)

View File

@ -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:

View File

@ -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)

View File

@ -1,7 +1,7 @@
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
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:

View File

@ -1,7 +1,7 @@
__license__ = 'GPL v3'
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
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):

View File

@ -2,7 +2,7 @@ __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
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)

View File

@ -3,7 +3,6 @@ __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
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

View File

@ -2,7 +2,7 @@ __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
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_()

View File

@ -3,7 +3,7 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
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:

View File

@ -3,8 +3,7 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
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('')

View File

@ -2,7 +2,7 @@ __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
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)

View File

@ -3,7 +3,7 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
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:

View File

@ -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()

View File

@ -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)

View File

@ -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()

View File

@ -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)