mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Remove use of global connect_lambda()
This commit is contained in:
parent
6014aec7ae
commit
36ff53ca30
@ -26,6 +26,7 @@ from calibre.gui2 import (
|
||||
)
|
||||
from calibre.gui2.actions import InterfaceAction
|
||||
from calibre.library import current_library_name
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.config import prefs, tweaks
|
||||
from calibre.utils.icu import sort_key
|
||||
from calibre.utils.localization import ngettext
|
||||
|
@ -26,6 +26,7 @@ from calibre.gui2.actions import InterfaceAction
|
||||
from calibre.gui2.actions.choose_library import library_qicon
|
||||
from calibre.gui2.dialogs.progress import ProgressDialog
|
||||
from calibre.gui2.widgets2 import Dialog
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.config import prefs
|
||||
from calibre.utils.icu import numeric_sort_key, sort_key
|
||||
from calibre.utils.localization import ngettext
|
||||
|
@ -5,11 +5,12 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
from qt.core import QIcon, QMenu, QTimer, QToolButton, pyqtSignal, QUrl
|
||||
from qt.core import QIcon, QMenu, QTimer, QToolButton, QUrl, pyqtSignal
|
||||
|
||||
from calibre.gui2 import info_dialog, question_dialog, open_url
|
||||
from calibre.gui2 import info_dialog, open_url, question_dialog
|
||||
from calibre.gui2.actions import InterfaceAction
|
||||
from calibre.gui2.dialogs.smartdevice import SmartdeviceDialog
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.icu import primary_sort_key
|
||||
from calibre.utils.smtp import config as email_config
|
||||
|
||||
|
@ -5,13 +5,15 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
from functools import partial
|
||||
|
||||
from qt.core import (QTimer, QApplication, Qt, QEvent, QDialog, QMenu, QIcon,
|
||||
QDialogButtonBox, QPushButton, QLabel, QGridLayout)
|
||||
from qt.core import (
|
||||
QApplication, QDialog, QDialogButtonBox, QEvent, QGridLayout, QIcon, QLabel, QMenu,
|
||||
QPushButton, Qt, QTimer,
|
||||
)
|
||||
|
||||
from calibre.gui2 import error_dialog
|
||||
from calibre.gui2.actions import InterfaceAction
|
||||
from calibre.gui2.widgets2 import HistoryComboBox
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.icu import sort_key
|
||||
|
||||
|
||||
|
@ -22,6 +22,7 @@ from calibre.gui2.actions import InterfaceAction
|
||||
from calibre.gui2.convert.metadata import create_opf_file
|
||||
from calibre.gui2.dialogs.progress import ProgressDialog
|
||||
from calibre.ptempfile import PersistentTemporaryDirectory
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.config_base import tweaks
|
||||
from calibre.utils.localization import ngettext
|
||||
from polyglot.builtins import iteritems, itervalues
|
||||
|
@ -9,6 +9,7 @@ __docformat__ = 'restructuredtext en'
|
||||
from qt.core import QToolButton
|
||||
|
||||
from calibre.gui2.actions import InterfaceAction
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.icu import lower as icu_lower
|
||||
from polyglot.builtins import string_or_bytes
|
||||
|
||||
|
@ -6,14 +6,15 @@ __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import os
|
||||
from itertools import count
|
||||
from collections import OrderedDict
|
||||
from itertools import count
|
||||
from qt.core import (
|
||||
QCheckBox, QDialog, QDialogButtonBox, QGridLayout, QIcon, QLabel, QTimer
|
||||
QCheckBox, QDialog, QDialogButtonBox, QGridLayout, QIcon, QLabel, QTimer,
|
||||
)
|
||||
|
||||
from calibre.gui2 import error_dialog, gprefs, question_dialog
|
||||
from calibre.gui2.actions import InterfaceAction
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.monotonic import monotonic
|
||||
from polyglot.builtins import iteritems
|
||||
|
||||
@ -148,7 +149,10 @@ class ToCEditAction(InterfaceAction):
|
||||
self.do_one(book_id, fmt)
|
||||
|
||||
def do_one(self, book_id, fmt):
|
||||
import struct, json, atexit
|
||||
import atexit
|
||||
import json
|
||||
import struct
|
||||
|
||||
from calibre.utils.shm import SharedMemory
|
||||
db = self.gui.current_db
|
||||
path = db.format(book_id, fmt, index_is_id=True, as_path=True)
|
||||
|
@ -6,11 +6,13 @@ __copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import time
|
||||
|
||||
from qt.core import QTimer, QDialog, QDialogButtonBox, QCheckBox, QVBoxLayout, QLabel, Qt
|
||||
from qt.core import (
|
||||
QCheckBox, QDialog, QDialogButtonBox, QLabel, Qt, QTimer, QVBoxLayout,
|
||||
)
|
||||
|
||||
from calibre.gui2 import error_dialog, question_dialog
|
||||
from calibre.gui2.actions import InterfaceAction
|
||||
from calibre.startup import connect_lambda
|
||||
|
||||
|
||||
class Choose(QDialog):
|
||||
|
@ -30,6 +30,7 @@ from calibre.gui2.dnd import (
|
||||
dnd_get_files, dnd_get_image, dnd_has_extension, dnd_has_image, image_extensions,
|
||||
)
|
||||
from calibre.gui2.widgets2 import HTMLDisplay
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.config import tweaks
|
||||
from calibre.utils.img import blend_image, image_from_x
|
||||
from calibre.utils.localization import is_rtl, langnames_to_langcodes
|
||||
|
@ -10,23 +10,24 @@ from contextlib import contextmanager
|
||||
from html5_parser import parse
|
||||
from lxml import html
|
||||
from qt.core import (
|
||||
QAction, QApplication, QBrush, QByteArray, QCheckBox, QColor, QColorDialog,
|
||||
QDialog, QDialogButtonBox, QFont, QFontInfo, QFontMetrics, QFormLayout, QIcon,
|
||||
QKeySequence, QLabel, QLineEdit, QMenu, QPalette, QPlainTextEdit, QPushButton,
|
||||
QSize, QSyntaxHighlighter, Qt, QTabWidget, QTextBlockFormat, QTextCharFormat,
|
||||
QTextCursor, QTextEdit, QTextFormat, QTextListFormat, QTimer, QToolButton, QUrl,
|
||||
QVBoxLayout, QWidget, pyqtSignal, pyqtSlot
|
||||
QAction, QApplication, QBrush, QByteArray, QCheckBox, QColor, QColorDialog, QDialog,
|
||||
QDialogButtonBox, QFont, QFontInfo, QFontMetrics, QFormLayout, QIcon, QKeySequence,
|
||||
QLabel, QLineEdit, QMenu, QPalette, QPlainTextEdit, QPushButton, QSize,
|
||||
QSyntaxHighlighter, Qt, QTabWidget, QTextBlockFormat, QTextCharFormat, QTextCursor,
|
||||
QTextEdit, QTextFormat, QTextListFormat, QTimer, QToolButton, QUrl, QVBoxLayout,
|
||||
QWidget, pyqtSignal, pyqtSlot,
|
||||
)
|
||||
|
||||
from calibre import xml_replace_entities
|
||||
from calibre.ebooks.chardet import xml_to_unicode
|
||||
from calibre.gui2 import (
|
||||
NO_URL_FORMATTING, choose_files, error_dialog, gprefs, is_dark_theme
|
||||
NO_URL_FORMATTING, choose_files, error_dialog, gprefs, is_dark_theme,
|
||||
)
|
||||
from calibre.gui2.book_details import css
|
||||
from calibre.gui2.flow_toolbar import create_flow_toolbar
|
||||
from calibre.gui2.widgets import LineEditECM
|
||||
from calibre.gui2.widgets2 import to_plain_text
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.cleantext import clean_xml_chars
|
||||
from calibre.utils.config import tweaks
|
||||
from calibre.utils.imghdr import what
|
||||
|
@ -6,12 +6,12 @@ __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import json
|
||||
from qt.core import QDialog, Qt
|
||||
|
||||
from qt.core import Qt, QDialog
|
||||
|
||||
from calibre.gui2.convert.look_and_feel_ui import Ui_Form
|
||||
from calibre.gui2.convert import Widget
|
||||
from calibre.ebooks.conversion.config import OPTIONS
|
||||
from calibre.gui2.convert import Widget
|
||||
from calibre.gui2.convert.look_and_feel_ui import Ui_Form
|
||||
from calibre.startup import connect_lambda
|
||||
from polyglot.builtins import iteritems
|
||||
|
||||
|
||||
|
@ -6,19 +6,19 @@ from collections import OrderedDict
|
||||
from contextlib import suppress
|
||||
from copy import deepcopy
|
||||
from qt.core import (
|
||||
QCheckBox, QColor, QColorDialog, QDialog, QDialogButtonBox,
|
||||
QFormLayout, QFrame, QGridLayout, QHBoxLayout, QIcon, QInputDialog, QLabel,
|
||||
QLineEdit, QListWidget, QListWidgetItem, QMenu, QPixmap, QPushButton, QSize,
|
||||
QSizePolicy, QSpinBox, Qt, QTabWidget, QTimer, QToolButton, QVBoxLayout, QWidget,
|
||||
pyqtSignal
|
||||
QCheckBox, QColor, QColorDialog, QDialog, QDialogButtonBox, QFormLayout, QFrame,
|
||||
QGridLayout, QHBoxLayout, QIcon, QInputDialog, QLabel, QLineEdit, QListWidget,
|
||||
QListWidgetItem, QMenu, QPixmap, QPushButton, QSize, QSizePolicy, QSpinBox, Qt,
|
||||
QTabWidget, QTimer, QToolButton, QVBoxLayout, QWidget, pyqtSignal,
|
||||
)
|
||||
|
||||
from calibre.constants import config_dir
|
||||
from calibre.ebooks.covers import (
|
||||
all_styles, cprefs, default_color_themes, generate_cover, override_prefs
|
||||
all_styles, cprefs, default_color_themes, generate_cover, override_prefs,
|
||||
)
|
||||
from calibre.gui2 import error_dialog, gprefs
|
||||
from calibre.gui2.font_family_chooser import FontFamilyChooser
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.date import now
|
||||
from calibre.utils.filenames import make_long_path_useable
|
||||
from calibre.utils.icu import primary_sort_key, sort_key
|
||||
|
@ -43,6 +43,7 @@ from calibre.library.save_to_disk import find_plugboard
|
||||
from calibre.ptempfile import (
|
||||
PersistentTemporaryFile, force_unicode as filename_to_unicode,
|
||||
)
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.config import device_prefs, tweaks
|
||||
from calibre.utils.filenames import ascii_filename
|
||||
from calibre.utils.img import scale_image
|
||||
|
@ -4,21 +4,21 @@
|
||||
|
||||
import textwrap
|
||||
from qt.core import (
|
||||
QAction, QApplication, QBrush, QCheckBox, QDialog, QGridLayout,
|
||||
QHBoxLayout, QIcon, QKeySequence, QLabel, QListView, QModelIndex, QPalette,
|
||||
QPixmap, QPushButton, QShortcut, QSize, Qt, QTimer, QToolButton,
|
||||
QVBoxLayout, QWidget, pyqtSignal, QDialogButtonBox, QSplitter
|
||||
QAction, QApplication, QBrush, QCheckBox, QDialog, QDialogButtonBox, QGridLayout,
|
||||
QHBoxLayout, QIcon, QKeySequence, QLabel, QListView, QModelIndex, QPalette, QPixmap,
|
||||
QPushButton, QShortcut, QSize, QSplitter, Qt, QTimer, QToolButton, QVBoxLayout,
|
||||
QWidget, pyqtSignal,
|
||||
)
|
||||
|
||||
from calibre import fit_image
|
||||
from calibre.gui2 import NO_URL_FORMATTING, gprefs
|
||||
from calibre.gui2.book_details import (
|
||||
create_open_cover_with_menu, css, details_context_menu_event, render_html,
|
||||
set_html
|
||||
create_open_cover_with_menu, css, details_context_menu_event, render_html, set_html,
|
||||
)
|
||||
from calibre.gui2.ui import get_gui
|
||||
from calibre.gui2.widgets import CoverView
|
||||
from calibre.gui2.widgets2 import Dialog, HTMLDisplay
|
||||
from calibre.startup import connect_lambda
|
||||
|
||||
|
||||
class Cover(CoverView):
|
||||
@ -60,7 +60,7 @@ class Configure(Dialog):
|
||||
|
||||
def setup_ui(self):
|
||||
from calibre.gui2.preferences.look_feel import (
|
||||
DisplayedFields, move_field_down, move_field_up
|
||||
DisplayedFields, move_field_down, move_field_up,
|
||||
)
|
||||
self.l = QVBoxLayout(self)
|
||||
self.field_display_order = fdo = QListView(self)
|
||||
|
@ -2,12 +2,13 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
from functools import partial
|
||||
|
||||
from qt.core import (
|
||||
QDialog, QListWidgetItem, QModelIndex, QIcon, QLabel, QVBoxLayout, QSize,
|
||||
QDialogButtonBox, QListWidget, QHBoxLayout, QPushButton, QMenu)
|
||||
QDialog, QDialogButtonBox, QHBoxLayout, QIcon, QLabel, QListWidget, QListWidgetItem,
|
||||
QMenu, QModelIndex, QPushButton, QSize, QVBoxLayout,
|
||||
)
|
||||
|
||||
from calibre.gui2 import file_icon_provider
|
||||
from calibre.startup import connect_lambda
|
||||
|
||||
|
||||
class ChooseFormatDialog(QDialog):
|
||||
@ -51,7 +52,7 @@ class ChooseFormatDialog(QDialog):
|
||||
self.update_open_with_button()
|
||||
|
||||
def populate_open_with(self):
|
||||
from calibre.gui2.open_with import populate_menu, edit_programs
|
||||
from calibre.gui2.open_with import edit_programs, populate_menu
|
||||
menu = self.own
|
||||
menu.clear()
|
||||
fmt = self._formats[self.formats.currentRow()]
|
||||
|
@ -6,7 +6,7 @@ __copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
from qt.core import (
|
||||
QDialog, Qt, QIcon, QVBoxLayout, QHBoxLayout, QLabel, QCheckBox, QDialogButtonBox
|
||||
QCheckBox, QDialog, QDialogButtonBox, QHBoxLayout, QIcon, QLabel, Qt, QVBoxLayout,
|
||||
)
|
||||
|
||||
from calibre import confirm_config_name
|
||||
|
@ -6,8 +6,10 @@ __copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net' \
|
||||
'2010, John Schember <john@nachtimwald.com>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
from qt.core import QDialog, QIcon, Qt
|
||||
|
||||
from calibre.gui2.dialogs.confirm_delete_location_ui import Ui_Dialog
|
||||
from qt.core import QDialog, Qt, QIcon
|
||||
from calibre.startup import connect_lambda
|
||||
|
||||
|
||||
class Dialog(QDialog, Ui_Dialog):
|
||||
|
@ -5,14 +5,16 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
from qt.core import (
|
||||
QVBoxLayout, QSplitter, QWidget, QLabel, QCheckBox, QTextBrowser, Qt, QDialog, QDialogButtonBox
|
||||
QCheckBox, QDialog, QDialogButtonBox, QLabel, QSplitter, Qt, QTextBrowser,
|
||||
QVBoxLayout, QWidget,
|
||||
)
|
||||
|
||||
from calibre.ebooks.metadata import authors_to_string
|
||||
from calibre.ebooks.metadata.book.base import field_metadata
|
||||
from calibre.gui2 import dynamic, gprefs
|
||||
from calibre.gui2.widgets2 import Dialog
|
||||
from calibre.gui2.dialogs.confirm_delete import confirm_config_name
|
||||
from calibre.gui2.widgets2 import Dialog
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.config import tweaks
|
||||
from calibre.utils.date import format_date
|
||||
|
||||
|
@ -2,22 +2,23 @@
|
||||
# License: GPLv3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
|
||||
import os
|
||||
import stat
|
||||
from functools import partial
|
||||
from threading import Thread, Event
|
||||
import os, stat
|
||||
|
||||
from qt.core import (
|
||||
QSize, QStackedLayout, QWidget, QVBoxLayout, QLabel, QPushButton,
|
||||
QListWidget, QListWidgetItem, QIcon, Qt, pyqtSignal, QGridLayout,
|
||||
QProgressBar, QDialog, QDialogButtonBox, QScrollArea, QLineEdit, QFrame, QAbstractItemView
|
||||
QAbstractItemView, QDialog, QDialogButtonBox, QFrame, QGridLayout, QIcon, QLabel,
|
||||
QLineEdit, QListWidget, QListWidgetItem, QProgressBar, QPushButton, QScrollArea,
|
||||
QSize, QStackedLayout, Qt, QVBoxLayout, QWidget, pyqtSignal,
|
||||
)
|
||||
from threading import Event, Thread
|
||||
|
||||
from calibre import human_readable, as_unicode
|
||||
from calibre import as_unicode, human_readable
|
||||
from calibre.constants import iswindows
|
||||
from calibre.db.legacy import LibraryDatabase
|
||||
from calibre.gui2 import choose_dir, error_dialog, question_dialog
|
||||
from calibre.gui2.widgets2 import Dialog
|
||||
from calibre.utils.exim import all_known_libraries, export, Importer, import_data
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.exim import Importer, all_known_libraries, export, import_data
|
||||
from calibre.utils.icu import numeric_sort_key
|
||||
|
||||
|
||||
|
@ -28,6 +28,7 @@ from calibre.gui2.dialogs.metadata_bulk_ui import Ui_MetadataBulkDialog
|
||||
from calibre.gui2.dialogs.tag_editor import TagEditor
|
||||
from calibre.gui2.dialogs.template_line_editor import TemplateLineEditor
|
||||
from calibre.gui2.widgets import LineEditECM
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.config import JSONConfig, dynamic, prefs, tweaks
|
||||
from calibre.utils.date import internal_iso_format_string, qt_to_dt
|
||||
from calibre.utils.icu import (
|
||||
|
@ -1,22 +1,23 @@
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import re, copy
|
||||
import copy
|
||||
import re
|
||||
from datetime import date
|
||||
|
||||
from qt.core import (
|
||||
QDialog, QDialogButtonBox, QFrame, QLabel, QComboBox, QIcon, QVBoxLayout, Qt,
|
||||
QSize, QHBoxLayout, QTabWidget, QLineEdit, QWidget, QGroupBox, QFormLayout,
|
||||
QSpinBox, QRadioButton, QPushButton, QToolButton
|
||||
QComboBox, QDialog, QDialogButtonBox, QFormLayout, QFrame, QGroupBox, QHBoxLayout,
|
||||
QIcon, QLabel, QLineEdit, QPushButton, QRadioButton, QSize, QSpinBox, Qt,
|
||||
QTabWidget, QToolButton, QVBoxLayout, QWidget,
|
||||
)
|
||||
|
||||
from calibre import strftime
|
||||
from calibre.library.caches import CONTAINS_MATCH, EQUALS_MATCH, REGEXP_MATCH
|
||||
from calibre.gui2 import gprefs
|
||||
from calibre.gui2.complete2 import EditWithComplete
|
||||
from calibre.utils.icu import sort_key
|
||||
from calibre.library.caches import CONTAINS_MATCH, EQUALS_MATCH, REGEXP_MATCH
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.config import tweaks
|
||||
from calibre.utils.date import now
|
||||
from calibre.utils.icu import sort_key
|
||||
from calibre.utils.localization import localize_user_manual_link
|
||||
|
||||
box_values = {}
|
||||
|
@ -9,6 +9,7 @@ from calibre.constants import islinux
|
||||
from calibre.gui2 import error_dialog, gprefs, question_dialog
|
||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||
from calibre.gui2.dialogs.tag_editor_ui import Ui_TagEditor
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.icu import sort_key
|
||||
|
||||
|
||||
|
@ -6,9 +6,10 @@ import os
|
||||
from functools import lru_cache
|
||||
from qt.core import (
|
||||
QApplication, QEvent, QInputDevice, QMouseEvent, QObject, QPointF, QScroller, Qt,
|
||||
pyqtSignal
|
||||
pyqtSignal,
|
||||
)
|
||||
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.monotonic import monotonic
|
||||
from polyglot.builtins import itervalues
|
||||
|
||||
|
@ -27,6 +27,7 @@ from calibre.gui2.dialogs.jobs_ui import Ui_JobsDialog
|
||||
from calibre.gui2.progress_indicator import ProgressIndicator
|
||||
from calibre.gui2.threaded_jobs import ThreadedJob, ThreadedJobServer
|
||||
from calibre.gui2.widgets2 import Dialog
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.icu import lower
|
||||
from calibre.utils.ipc.job import ParallelJob
|
||||
from calibre.utils.ipc.server import Server
|
||||
|
@ -29,6 +29,7 @@ from calibre.gui2.dialogs.confirm_delete import confirm
|
||||
from calibre.gui2.viewer.widgets import ResultsDelegate, SearchBox
|
||||
from calibre.gui2.widgets import BusyCursor
|
||||
from calibre.gui2.widgets2 import Dialog, RightClickButton
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.localization import ngettext
|
||||
|
||||
|
||||
|
@ -14,6 +14,7 @@ from threading import Thread
|
||||
from calibre.ebooks.metadata.opf2 import metadata_to_opf
|
||||
from calibre.gui2.threaded_jobs import ThreadedJob
|
||||
from calibre.ptempfile import PersistentTemporaryDirectory, PersistentTemporaryFile
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.ipc.simple_worker import WorkerError, fork_job
|
||||
from calibre.utils.localization import ngettext
|
||||
from polyglot.builtins import iteritems
|
||||
|
@ -25,6 +25,7 @@ from calibre.gui2.languages import LanguagesEdit as LE
|
||||
from calibre.gui2.metadata.basic_widgets import PubdateEdit, RatingEdit
|
||||
from calibre.gui2.widgets2 import RightClickButton
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.date import UNDEFINED_DATE
|
||||
from calibre.utils.icu import lower as icu_lower
|
||||
from calibre.utils.localization import ngettext
|
||||
|
@ -4,12 +4,12 @@
|
||||
|
||||
import re
|
||||
import textwrap
|
||||
|
||||
from qt.core import QAbstractTableModel, QFont, Qt, QAbstractItemView
|
||||
from qt.core import QAbstractItemView, QAbstractTableModel, QFont, Qt
|
||||
|
||||
from calibre.gui2 import gprefs
|
||||
from calibre.gui2.preferences import AbortCommit, ConfigWidgetBase, test_widget
|
||||
from calibre.gui2.preferences.email_ui import Ui_Form
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.config import ConfigProxy
|
||||
from calibre.utils.icu import numeric_sort_key
|
||||
from calibre.utils.smtp import config as smtp_prefs
|
||||
|
@ -37,6 +37,7 @@ from calibre.gui2.preferences.coloring import EditRules
|
||||
from calibre.gui2.preferences.look_feel_ui import Ui_Form
|
||||
from calibre.gui2.widgets import BusyCursor
|
||||
from calibre.gui2.widgets2 import Dialog
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.config import prefs
|
||||
from calibre.utils.icu import sort_key
|
||||
from calibre.utils.localization import available_translations, get_lang, get_language
|
||||
|
@ -5,12 +5,13 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
from qt.core import QAbstractListModel, Qt, QIcon, QItemSelectionModel
|
||||
from qt.core import QAbstractListModel, QIcon, QItemSelectionModel, Qt
|
||||
|
||||
from calibre import force_unicode
|
||||
from calibre.gui2 import error_dialog, gprefs, warning_dialog
|
||||
from calibre.gui2.preferences import AbortCommit, ConfigWidgetBase, test_widget
|
||||
from calibre.gui2.preferences.toolbar_ui import Ui_Form
|
||||
from calibre.gui2 import gprefs, warning_dialog, error_dialog
|
||||
from calibre.gui2.preferences import ConfigWidgetBase, test_widget, AbortCommit
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.icu import primary_sort_key
|
||||
|
||||
|
||||
|
@ -7,22 +7,23 @@ import os
|
||||
import shutil
|
||||
from qt.core import (
|
||||
QApplication, QHBoxLayout, QIcon, QLabel, QProgressBar, QPushButton, QSize, QUrl,
|
||||
QVBoxLayout, QWidget, pyqtSignal
|
||||
QVBoxLayout, QWidget, pyqtSignal,
|
||||
)
|
||||
from qt.webengine import (
|
||||
QWebEngineDownloadRequest, QWebEnginePage, QWebEngineProfile, QWebEngineView
|
||||
QWebEngineDownloadRequest, QWebEnginePage, QWebEngineProfile, QWebEngineView,
|
||||
)
|
||||
|
||||
from calibre import random_user_agent, url_slash_cleaner
|
||||
from calibre.constants import STORE_DIALOG_APP_UID, islinux, iswindows
|
||||
from calibre.ebooks import BOOK_EXTENSIONS
|
||||
from calibre.gui2 import (
|
||||
Application, choose_save_file, error_dialog, gprefs, info_dialog, set_app_uid
|
||||
Application, choose_save_file, error_dialog, gprefs, info_dialog, set_app_uid,
|
||||
)
|
||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||
from calibre.gui2.listener import send_message_in_process
|
||||
from calibre.gui2.main_window import MainWindow
|
||||
from calibre.ptempfile import PersistentTemporaryDirectory, reset_base_dir
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.webengine import setup_profile
|
||||
from polyglot.binary import as_base64_bytes, from_base64_bytes
|
||||
from polyglot.builtins import string_or_bytes
|
||||
|
@ -22,6 +22,7 @@ from calibre.gui2.dialogs.tag_list_editor import TagListEditor
|
||||
from calibre.gui2.tag_browser.view import TagsView
|
||||
from calibre.gui2.widgets import HistoryLineEdit
|
||||
from calibre.library.field_metadata import category_icon_map
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.icu import sort_key
|
||||
from calibre.utils.localization import ngettext
|
||||
from polyglot.builtins import iteritems
|
||||
|
@ -16,6 +16,7 @@ from calibre.gui2 import Application, error_dialog, question_dialog
|
||||
from calibre.gui2.complete2 import EditWithComplete
|
||||
from calibre.gui2.ui import get_gui
|
||||
from calibre.gui2.widgets2 import Dialog
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.config import JSONConfig
|
||||
from calibre.utils.localization import localize_user_manual_link
|
||||
from polyglot.builtins import iteritems
|
||||
|
@ -26,6 +26,7 @@ from calibre.gui2.convert.xpath_wizard import XPathEdit
|
||||
from calibre.gui2.progress_indicator import ProgressIndicator
|
||||
from calibre.gui2.toc.location import ItemEdit
|
||||
from calibre.ptempfile import reset_base_dir
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.config import JSONConfig
|
||||
from calibre.utils.filenames import atomic_rename
|
||||
from calibre.utils.icu import lower as icu_lower, upper as icu_upper
|
||||
|
@ -61,6 +61,7 @@ from calibre.gui2.tweak_book.widgets import (
|
||||
)
|
||||
from calibre.gui2.widgets import BusyCursor
|
||||
from calibre.ptempfile import PersistentTemporaryDirectory, TemporaryDirectory
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.config import JSONConfig
|
||||
from calibre.utils.icu import numeric_sort_key
|
||||
from calibre.utils.imghdr import identify
|
||||
|
@ -9,16 +9,17 @@ import textwrap
|
||||
from bisect import bisect
|
||||
from functools import partial
|
||||
from qt.core import (
|
||||
QAbstractItemModel, QAbstractListModel, QApplication, QCheckBox, QGridLayout,
|
||||
QHBoxLayout, QIcon, QInputMethodEvent, QLabel, QListView, QMenu, QMimeData,
|
||||
QModelIndex, QPen, QPushButton, QSize, QSizePolicy, QSplitter,
|
||||
QStyledItemDelegate, Qt, QToolButton, QTreeView, pyqtSignal, QAbstractItemView, QDialogButtonBox
|
||||
QAbstractItemModel, QAbstractItemView, QAbstractListModel, QApplication, QCheckBox,
|
||||
QDialogButtonBox, QGridLayout, QHBoxLayout, QIcon, QInputMethodEvent, QLabel,
|
||||
QListView, QMenu, QMimeData, QModelIndex, QPen, QPushButton, QSize, QSizePolicy,
|
||||
QSplitter, QStyledItemDelegate, Qt, QToolButton, QTreeView, pyqtSignal,
|
||||
)
|
||||
|
||||
from calibre.gui2.tweak_book import tprefs
|
||||
from calibre.gui2.tweak_book.widgets import Dialog
|
||||
from calibre.gui2.widgets import BusyCursor
|
||||
from calibre.gui2.widgets2 import HistoryLineEdit2
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.icu import safe_chr as codepoint_to_chr
|
||||
from calibre.utils.unicode_names import character_name_from_code, points_for_word
|
||||
from calibre_extensions.progress_indicator import set_no_activate_on_click
|
||||
|
@ -4,22 +4,26 @@
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import sys, os, re, textwrap
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import textwrap
|
||||
from functools import partial
|
||||
|
||||
from qt.core import (
|
||||
QGridLayout, QToolButton, QIcon, QRadioButton, QMenu, QApplication, Qt,
|
||||
QSize, QWidget, QLabel, QStackedLayout, QPainter, QRect, QVBoxLayout,
|
||||
QCursor, QEventLoop, QKeySequence, pyqtSignal, QTimer, QHBoxLayout, QDialogButtonBox)
|
||||
QApplication, QCursor, QDialogButtonBox, QEventLoop, QGridLayout, QHBoxLayout,
|
||||
QIcon, QKeySequence, QLabel, QMenu, QPainter, QRadioButton, QRect, QSize,
|
||||
QStackedLayout, Qt, QTimer, QToolButton, QVBoxLayout, QWidget, pyqtSignal,
|
||||
)
|
||||
|
||||
from calibre.ebooks.oeb.polish.container import Container
|
||||
from calibre.ebooks.oeb.polish.utils import guess_type
|
||||
from calibre.gui2 import info_dialog
|
||||
from calibre.gui2.progress_indicator import ProgressIndicator
|
||||
from calibre.gui2.tweak_book.editor import syntax_from_mime
|
||||
from calibre.gui2.tweak_book.diff.view import DiffView
|
||||
from calibre.gui2.tweak_book.editor import syntax_from_mime
|
||||
from calibre.gui2.tweak_book.widgets import Dialog
|
||||
from calibre.gui2.widgets2 import HistoryLineEdit2
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.filenames import samefile
|
||||
from calibre.utils.icu import numeric_sort_key
|
||||
from polyglot.builtins import iteritems
|
||||
@ -97,7 +101,7 @@ def changed_files(list_of_names1, list_of_names2, get_data1, get_data2):
|
||||
|
||||
|
||||
def get_decoded_raw(name):
|
||||
from calibre.ebooks.chardet import xml_to_unicode, force_encoding
|
||||
from calibre.ebooks.chardet import force_encoding, xml_to_unicode
|
||||
with open(name, 'rb') as f:
|
||||
raw = f.read()
|
||||
syntax = syntax_from_mime(name, guess_type(name))
|
||||
|
@ -10,10 +10,10 @@ from functools import partial
|
||||
from itertools import chain
|
||||
from math import ceil
|
||||
from qt.core import (
|
||||
QApplication, QBrush, QColor, QEvent, QEventLoop, QFont, QHBoxLayout,
|
||||
QIcon, QImage, QKeySequence, QMenu, QPainter, QPainterPath, QPalette, QPen,
|
||||
QPixmap, QPlainTextEdit, QRect, QScrollBar, QSplitter, QSplitterHandle, Qt,
|
||||
QTextCharFormat, QTextCursor, QTextLayout, QTimer, QWidget, pyqtSignal
|
||||
QApplication, QBrush, QColor, QEvent, QEventLoop, QFont, QHBoxLayout, QIcon, QImage,
|
||||
QKeySequence, QMenu, QPainter, QPainterPath, QPalette, QPen, QPixmap,
|
||||
QPlainTextEdit, QRect, QScrollBar, QSplitter, QSplitterHandle, Qt, QTextCharFormat,
|
||||
QTextCursor, QTextLayout, QTimer, QWidget, pyqtSignal,
|
||||
)
|
||||
|
||||
from calibre import fit_image, human_readable
|
||||
@ -22,10 +22,11 @@ from calibre.gui2.tweak_book import tprefs
|
||||
from calibre.gui2.tweak_book.diff import get_sequence_matcher
|
||||
from calibre.gui2.tweak_book.diff.highlight import get_highlighter
|
||||
from calibre.gui2.tweak_book.editor.text import (
|
||||
LineNumbers, PlainTextEdit, default_font_family
|
||||
LineNumbers, PlainTextEdit, default_font_family,
|
||||
)
|
||||
from calibre.gui2.tweak_book.editor.themes import get_theme, theme_color
|
||||
from calibre.gui2.widgets import BusyCursor
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.icu import utf16_length
|
||||
from calibre.utils.xml_parse import safe_xml_fromstring
|
||||
from polyglot.builtins import as_bytes, iteritems
|
||||
|
@ -15,6 +15,7 @@ from calibre.gui2 import error_dialog, info_dialog, warning_dialog
|
||||
from calibre.gui2.progress_indicator import WaitStack
|
||||
from calibre.gui2.tweak_book import current_container
|
||||
from calibre.gui2.tweak_book.widgets import Dialog
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.localization import ngettext
|
||||
from polyglot.builtins import iteritems
|
||||
|
||||
|
@ -5,14 +5,16 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import sys
|
||||
|
||||
from qt.core import (
|
||||
QMainWindow, Qt, QApplication, pyqtSignal, QLabel, QIcon, QFormLayout, QSize,
|
||||
QDialog, QSpinBox, QCheckBox, QDialogButtonBox, QToolButton, QMenu, QInputDialog)
|
||||
QApplication, QCheckBox, QDialog, QDialogButtonBox, QFormLayout, QIcon,
|
||||
QInputDialog, QLabel, QMainWindow, QMenu, QSize, QSpinBox, Qt, QToolButton,
|
||||
pyqtSignal,
|
||||
)
|
||||
|
||||
from calibre.gui2 import error_dialog
|
||||
from calibre.gui2.tweak_book import actions, tprefs, editors
|
||||
from calibre.gui2.tweak_book import actions, editors, tprefs
|
||||
from calibre.gui2.tweak_book.editor.canvas import Canvas
|
||||
from calibre.startup import connect_lambda
|
||||
from polyglot.builtins import itervalues
|
||||
|
||||
|
||||
|
@ -8,10 +8,11 @@ import os
|
||||
import sys
|
||||
from functools import partial
|
||||
from qt.core import (
|
||||
QAbstractListModel, QApplication, QCheckBox, QFormLayout, QGridLayout, QClipboard,
|
||||
QHBoxLayout, QIcon, QInputDialog, QLabel, QLineEdit, QListView, QMenu, QPainter,
|
||||
QPixmap, QRect, QSize, QSizePolicy, QSortFilterProxyModel, QStyledItemDelegate,
|
||||
Qt, QToolButton, QTreeWidget, QTreeWidgetItem, QVBoxLayout, pyqtSignal, QDialog, QDialogButtonBox
|
||||
QAbstractListModel, QApplication, QCheckBox, QClipboard, QDialog, QDialogButtonBox,
|
||||
QFormLayout, QGridLayout, QHBoxLayout, QIcon, QInputDialog, QLabel, QLineEdit,
|
||||
QListView, QMenu, QPainter, QPixmap, QRect, QSize, QSizePolicy,
|
||||
QSortFilterProxyModel, QStyledItemDelegate, Qt, QToolButton, QTreeWidget,
|
||||
QTreeWidgetItem, QVBoxLayout, pyqtSignal,
|
||||
)
|
||||
|
||||
from calibre import fit_image
|
||||
@ -23,6 +24,7 @@ from calibre.gui2.tweak_book import current_container, tprefs
|
||||
from calibre.gui2.tweak_book.file_list import name_is_ok
|
||||
from calibre.gui2.tweak_book.widgets import Dialog
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.icu import numeric_sort_key
|
||||
from calibre.utils.localization import canonicalize_lang, get_lang
|
||||
from calibre_extensions.progress_indicator import set_no_activate_on_click
|
||||
|
@ -35,6 +35,7 @@ from calibre.gui2.tweak_book import (
|
||||
)
|
||||
from calibre.gui2.tweak_book.editor import syntax_from_mime
|
||||
from calibre.gui2.tweak_book.templates import template_for
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.fonts.utils import get_font_names
|
||||
from calibre.utils.icu import numeric_sort_key
|
||||
from calibre.utils.localization import ngettext, pgettext
|
||||
|
@ -5,20 +5,20 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import re
|
||||
from qt.core import (
|
||||
QAbstractItemView, QApplication, QCheckBox, QDialog, QDialogButtonBox, QHBoxLayout,
|
||||
QIcon, QLabel, QListWidget, QListWidgetItem, QPalette, QPen, QPixmap, QProgressBar,
|
||||
QSize, QSpinBox, QStyle, QStyledItemDelegate, Qt, QTextBrowser, QVBoxLayout,
|
||||
pyqtSignal,
|
||||
)
|
||||
from threading import Thread
|
||||
|
||||
from qt.core import (
|
||||
QTextBrowser, QVBoxLayout, QDialog, QDialogButtonBox, QIcon, QLabel,
|
||||
QCheckBox, Qt, QListWidgetItem, QHBoxLayout, QListWidget, QPixmap,
|
||||
QSpinBox, QStyledItemDelegate, QSize, QStyle, QPen, QPalette,
|
||||
QProgressBar, pyqtSignal, QApplication, QAbstractItemView
|
||||
)
|
||||
|
||||
from calibre import human_readable, fit_image, force_unicode
|
||||
from calibre import fit_image, force_unicode, human_readable
|
||||
from calibre.ebooks.oeb.polish.main import CUSTOMIZATION
|
||||
from calibre.gui2 import empty_index, question_dialog
|
||||
from calibre.gui2.tweak_book import tprefs, current_container, set_current_container
|
||||
from calibre.gui2.tweak_book import current_container, set_current_container, tprefs
|
||||
from calibre.gui2.tweak_book.widgets import Dialog
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.icu import numeric_sort_key
|
||||
|
||||
|
||||
@ -254,8 +254,8 @@ class CompressImagesProgress(Dialog):
|
||||
t.start()
|
||||
|
||||
def run_compress(self):
|
||||
from calibre.gui2.tweak_book import current_container
|
||||
from calibre.ebooks.oeb.polish.images import compress_images
|
||||
from calibre.gui2.tweak_book import current_container
|
||||
report = []
|
||||
try:
|
||||
self.result = (compress_images(
|
||||
@ -304,7 +304,9 @@ class CompressImagesProgress(Dialog):
|
||||
if __name__ == '__main__':
|
||||
from calibre.gui2 import Application
|
||||
app = Application([])
|
||||
import sys, sip
|
||||
import sip
|
||||
import sys
|
||||
|
||||
from calibre.ebooks.oeb.polish.container import get_container
|
||||
c = get_container(sys.argv[-1], tweak_mode=True)
|
||||
set_current_container(c)
|
||||
|
@ -31,6 +31,7 @@ from calibre.gui2.tweak_book.editor.themes import (
|
||||
from calibre.gui2.tweak_book.spell import ManageDictionaries
|
||||
from calibre.gui2.tweak_book.widgets import Dialog
|
||||
from calibre.gui2.widgets2 import ColorButton
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.localization import get_lang, ngettext
|
||||
from polyglot.builtins import iteritems, itervalues
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
# License: GPLv3 Copyright: 2013, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
|
||||
import copy
|
||||
import json
|
||||
import regex
|
||||
@ -9,32 +8,33 @@ import time
|
||||
from collections import Counter, OrderedDict
|
||||
from functools import partial
|
||||
from qt.core import (
|
||||
QAbstractListModel, QAction, QApplication, QCheckBox, QComboBox, QFont, QFrame,
|
||||
QGridLayout, QHBoxLayout, QIcon, QItemSelection, QKeySequence, QLabel, QLineEdit,
|
||||
QListView, QMenu, QMimeData, QModelIndex, QPushButton, QScrollArea, QSize, QItemSelectionModel,
|
||||
QSizePolicy, QStackedLayout, QStyledItemDelegate, Qt, QTimer, QToolBar, QDialog,
|
||||
QToolButton, QVBoxLayout, QWidget, pyqtSignal, QAbstractItemView, QEvent, QDialogButtonBox
|
||||
QAbstractItemView, QAbstractListModel, QAction, QApplication, QCheckBox, QComboBox,
|
||||
QDialog, QDialogButtonBox, QEvent, QFont, QFrame, QGridLayout, QHBoxLayout, QIcon,
|
||||
QItemSelection, QItemSelectionModel, QKeySequence, QLabel, QLineEdit, QListView,
|
||||
QMenu, QMimeData, QModelIndex, QPushButton, QScrollArea, QSize, QSizePolicy,
|
||||
QStackedLayout, QStyledItemDelegate, Qt, QTimer, QToolBar, QToolButton, QVBoxLayout,
|
||||
QWidget, pyqtSignal,
|
||||
)
|
||||
|
||||
from calibre import prepare_string_for_xml
|
||||
from calibre.constants import iswindows
|
||||
from calibre.ebooks.conversion.search_replace import (
|
||||
REGEX_FLAGS, compile_regular_expression
|
||||
REGEX_FLAGS, compile_regular_expression,
|
||||
)
|
||||
from calibre.gui2 import choose_files, choose_save_file, error_dialog, info_dialog
|
||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||
from calibre.gui2.dialogs.message_box import MessageBox
|
||||
from calibre.gui2.tweak_book import current_container, editors, tprefs
|
||||
from calibre.gui2.tweak_book.editor.snippets import (
|
||||
KEY, MODIFIER, SnippetTextEdit, find_matching_snip, parse_template,
|
||||
string_length
|
||||
KEY, MODIFIER, SnippetTextEdit, find_matching_snip, parse_template, string_length,
|
||||
)
|
||||
from calibre.gui2.tweak_book.function_replace import (
|
||||
Function, FunctionBox, FunctionEditor, functions as replace_functions,
|
||||
remove_function
|
||||
remove_function,
|
||||
)
|
||||
from calibre.gui2.widgets import BusyCursor
|
||||
from calibre.gui2.widgets2 import FlowLayout, HistoryComboBox
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.icu import primary_contains
|
||||
from polyglot.builtins import error_message, iteritems
|
||||
|
||||
|
@ -41,6 +41,7 @@ from calibre.spell.dictionary import (
|
||||
get_dictionary, remove_dictionary, rename_dictionary,
|
||||
)
|
||||
from calibre.spell.import_from import import_from_oxt
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.icu import contains, primary_contains, primary_sort_key, sort_key
|
||||
from calibre.utils.localization import (
|
||||
calibre_langcode_to_name, canonicalize_lang, get_lang, get_language,
|
||||
|
@ -2,19 +2,22 @@
|
||||
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
|
||||
from qt.core import (
|
||||
QWidget, QHBoxLayout, QVBoxLayout, QLabel, QComboBox, QPushButton, QIcon,
|
||||
pyqtSignal, QFont, QCheckBox, QSizePolicy
|
||||
)
|
||||
from lxml.etree import tostring
|
||||
from qt.core import (
|
||||
QCheckBox, QComboBox, QFont, QHBoxLayout, QIcon, QLabel, QPushButton, QSizePolicy,
|
||||
QVBoxLayout, QWidget, pyqtSignal,
|
||||
)
|
||||
|
||||
from calibre import prepare_string_for_xml
|
||||
from calibre.gui2 import error_dialog
|
||||
from calibre.gui2.tweak_book import tprefs, editors, current_container
|
||||
from calibre.gui2.tweak_book.search import get_search_regex, InvalidRegex, initialize_search_request
|
||||
from calibre.gui2.tweak_book import current_container, editors, tprefs
|
||||
from calibre.gui2.tweak_book.search import (
|
||||
InvalidRegex, get_search_regex, initialize_search_request,
|
||||
)
|
||||
from calibre.gui2.widgets import BusyCursor
|
||||
from calibre.gui2.widgets2 import HistoryComboBox
|
||||
from polyglot.builtins import iteritems, error_message
|
||||
from calibre.startup import connect_lambda
|
||||
from polyglot.builtins import error_message, iteritems
|
||||
|
||||
# UI {{{
|
||||
|
||||
|
@ -10,35 +10,36 @@ import unicodedata
|
||||
from collections import OrderedDict
|
||||
from math import ceil
|
||||
from qt.core import (
|
||||
QAbstractListModel, QApplication, QCheckBox, QComboBox, QDialog,
|
||||
QDialogButtonBox, QEvent, QFormLayout, QFrame, QGridLayout, QGroupBox,
|
||||
QHBoxLayout, QIcon, QItemSelectionModel, QLabel, QLineEdit, QListView, QMimeData,
|
||||
QModelIndex, QPainter, QPalette, QPixmap, QPlainTextEdit, QPoint, QRect, QSize,
|
||||
QSizePolicy, QSplitter, QStaticText, QStyle, QStyledItemDelegate, Qt, QTextCursor,
|
||||
QTextDocument, QTextOption, QToolButton, QVBoxLayout, QWidget, pyqtSignal
|
||||
QAbstractListModel, QApplication, QCheckBox, QComboBox, QDialog, QDialogButtonBox,
|
||||
QEvent, QFormLayout, QFrame, QGridLayout, QGroupBox, QHBoxLayout, QIcon,
|
||||
QItemSelectionModel, QLabel, QLineEdit, QListView, QMimeData, QModelIndex, QPainter,
|
||||
QPalette, QPixmap, QPlainTextEdit, QPoint, QRect, QSize, QSizePolicy, QSplitter,
|
||||
QStaticText, QStyle, QStyledItemDelegate, Qt, QTextCursor, QTextDocument,
|
||||
QTextOption, QToolButton, QVBoxLayout, QWidget, pyqtSignal,
|
||||
)
|
||||
|
||||
from calibre import human_readable, prepare_string_for_xml
|
||||
from calibre.constants import iswindows
|
||||
from calibre.ebooks.oeb.polish.cover import get_raster_cover_name
|
||||
from calibre.ebooks.oeb.polish.toc import (
|
||||
ensure_container_has_nav, get_guide_landmarks, get_nav_landmarks, set_landmarks
|
||||
ensure_container_has_nav, get_guide_landmarks, get_nav_landmarks, set_landmarks,
|
||||
)
|
||||
from calibre.ebooks.oeb.polish.upgrade import guide_epubtype_map
|
||||
from calibre.ebooks.oeb.polish.utils import guess_type, lead_text
|
||||
from calibre.gui2 import (
|
||||
choose_files, choose_images, choose_save_file, error_dialog, info_dialog
|
||||
choose_files, choose_images, choose_save_file, error_dialog, info_dialog,
|
||||
)
|
||||
from calibre.gui2.complete2 import EditWithComplete
|
||||
from calibre.gui2.tweak_book import current_container, tprefs
|
||||
from calibre.gui2.widgets2 import (
|
||||
PARAGRAPH_SEPARATOR, Dialog as BaseDialog, HistoryComboBox, to_plain_text
|
||||
PARAGRAPH_SEPARATOR, Dialog as BaseDialog, HistoryComboBox, to_plain_text,
|
||||
)
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.icu import (
|
||||
numeric_sort_key, primary_contains, primary_sort_key, sort_key
|
||||
numeric_sort_key, primary_contains, primary_sort_key, sort_key,
|
||||
)
|
||||
from calibre.utils.matcher import (
|
||||
DEFAULT_LEVEL1, DEFAULT_LEVEL2, DEFAULT_LEVEL3, Matcher, get_char
|
||||
DEFAULT_LEVEL1, DEFAULT_LEVEL2, DEFAULT_LEVEL3, Matcher, get_char,
|
||||
)
|
||||
from polyglot.builtins import iteritems
|
||||
|
||||
|
@ -4,11 +4,10 @@
|
||||
|
||||
import os
|
||||
from functools import partial
|
||||
|
||||
from qt.core import (
|
||||
QAction, QGroupBox, QHBoxLayout, QIcon, QKeySequence, QLabel, QListWidget,
|
||||
QListWidgetItem, QMenu, Qt, QToolBar, QToolButton, QVBoxLayout, pyqtSignal, QDialog,
|
||||
QAbstractItemView, QDialogButtonBox
|
||||
QAbstractItemView, QAction, QDialog, QDialogButtonBox, QGroupBox, QHBoxLayout,
|
||||
QIcon, QKeySequence, QLabel, QListWidget, QListWidgetItem, QMenu, Qt, QToolBar,
|
||||
QToolButton, QVBoxLayout, pyqtSignal,
|
||||
)
|
||||
from qt.webengine import QWebEnginePage
|
||||
|
||||
@ -18,6 +17,7 @@ from calibre.gui2.viewer.config import get_session_pref
|
||||
from calibre.gui2.viewer.shortcuts import index_to_key_sequence
|
||||
from calibre.gui2.viewer.web_view import set_book_path, vprefs
|
||||
from calibre.gui2.widgets2 import Dialog
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.icu import primary_sort_key
|
||||
|
||||
|
||||
@ -236,7 +236,7 @@ class ActionsToolBar(ToolBar):
|
||||
a.setToolTip(_('Switch to paged mode -- where the text is broken into pages'))
|
||||
|
||||
def change_sleep_permission(self, disallow_sleep=True):
|
||||
from .control_sleep import prevent_sleep, allow_sleep
|
||||
from .control_sleep import allow_sleep, prevent_sleep
|
||||
if disallow_sleep:
|
||||
if self.prevent_sleep_cookie is None:
|
||||
try:
|
||||
|
@ -10,8 +10,8 @@ from collections import defaultdict, namedtuple
|
||||
from hashlib import sha256
|
||||
from qt.core import (
|
||||
QApplication, QCursor, QDockWidget, QEvent, QMainWindow, QMenu, QMimeData,
|
||||
QModelIndex, QPixmap, Qt, QTimer, QToolBar, QUrl, QVBoxLayout, QWidget,
|
||||
pyqtSignal, sip
|
||||
QModelIndex, QPixmap, Qt, QTimer, QToolBar, QUrl, QVBoxLayout, QWidget, pyqtSignal,
|
||||
sip,
|
||||
)
|
||||
from threading import Thread
|
||||
|
||||
@ -20,23 +20,23 @@ from calibre.constants import ismacos, iswindows
|
||||
from calibre.customize.ui import available_input_formats
|
||||
from calibre.db.annotations import merge_annotations
|
||||
from calibre.gui2 import (
|
||||
add_to_recent_docs, choose_files, error_dialog, sanitize_env_vars
|
||||
add_to_recent_docs, choose_files, error_dialog, sanitize_env_vars,
|
||||
)
|
||||
from calibre.gui2.dialogs.drm_error import DRMErrorMessage
|
||||
from calibre.gui2.image_popup import ImagePopup
|
||||
from calibre.gui2.main_window import MainWindow
|
||||
from calibre.gui2.viewer import get_current_book_data, performance_monitor
|
||||
from calibre.gui2.viewer.annotations import (
|
||||
AnnotationsSaveWorker, annotations_dir, parse_annotations
|
||||
AnnotationsSaveWorker, annotations_dir, parse_annotations,
|
||||
)
|
||||
from calibre.gui2.viewer.bookmarks import BookmarkManager
|
||||
from calibre.gui2.viewer.config import (
|
||||
get_session_pref, load_reading_rates, save_reading_rates, vprefs
|
||||
get_session_pref, load_reading_rates, save_reading_rates, vprefs,
|
||||
)
|
||||
from calibre.gui2.viewer.convert_book import clean_running_workers, prepare_book
|
||||
from calibre.gui2.viewer.highlights import HighlightsPanel
|
||||
from calibre.gui2.viewer.integration import (
|
||||
get_book_library_details, load_annotations_map_from_library
|
||||
get_book_library_details, load_annotations_map_from_library,
|
||||
)
|
||||
from calibre.gui2.viewer.lookup import Lookup
|
||||
from calibre.gui2.viewer.overlay import LoadingOverlay
|
||||
@ -44,6 +44,7 @@ from calibre.gui2.viewer.search import SearchPanel
|
||||
from calibre.gui2.viewer.toc import TOC, TOCSearch, TOCView
|
||||
from calibre.gui2.viewer.toolbars import ActionsToolBar
|
||||
from calibre.gui2.viewer.web_view import WebView, get_path_for_name, set_book_path
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.date import utcnow
|
||||
from calibre.utils.img import image_from_path
|
||||
from calibre.utils.ipc.simple_worker import WorkerError
|
||||
|
@ -3,25 +3,28 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
'''
|
||||
Miscellaneous widgets used in the GUI
|
||||
'''
|
||||
import re, os
|
||||
import os
|
||||
import re
|
||||
from qt.core import (
|
||||
QAction, QApplication, QClipboard, QColor, QComboBox, QCompleter, QCursor, QEvent,
|
||||
QFont, QGraphicsScene, QGraphicsView, QIcon, QKeySequence, QLabel, QLineEdit,
|
||||
QListWidget, QListWidgetItem, QMenu, QPageSize, QPainter, QPalette, QPen, QPixmap,
|
||||
QPrinter, QRect, QSize, QSplitter, QSplitterHandle, QStringListModel,
|
||||
QSyntaxHighlighter, Qt, QTextCharFormat, QTimer, QToolButton, QWidget, pyqtSignal,
|
||||
)
|
||||
|
||||
from qt.core import (QIcon, QFont, QLabel, QListWidget, QAction, QEvent,
|
||||
QListWidgetItem, QTextCharFormat, QApplication, QSyntaxHighlighter,
|
||||
QCursor, QColor, QWidget, QPixmap, QSplitterHandle, QToolButton,
|
||||
Qt, pyqtSignal, QSize, QSplitter, QPainter, QPageSize, QPrinter,
|
||||
QLineEdit, QComboBox, QPen, QGraphicsScene, QMenu, QStringListModel, QKeySequence,
|
||||
QCompleter, QTimer, QRect, QGraphicsView, QPalette, QClipboard)
|
||||
|
||||
from calibre.constants import iswindows, ismacos
|
||||
from calibre.gui2 import (error_dialog, pixmap_to_data, gprefs,
|
||||
warning_dialog)
|
||||
from calibre.gui2.filename_pattern_ui import Ui_Form
|
||||
from calibre import fit_image, strftime, force_unicode
|
||||
from calibre import fit_image, force_unicode, strftime
|
||||
from calibre.constants import ismacos, iswindows
|
||||
from calibre.ebooks import BOOK_EXTENSIONS
|
||||
from calibre.utils.config import prefs, XMLConfig
|
||||
from calibre.gui2 import error_dialog, gprefs, pixmap_to_data, warning_dialog
|
||||
from calibre.gui2.dnd import (
|
||||
DownloadDialog, dnd_get_files, dnd_get_image, dnd_get_local_image_and_pixmap,
|
||||
dnd_has_extension, dnd_has_image, image_extensions,
|
||||
)
|
||||
from calibre.gui2.filename_pattern_ui import Ui_Form
|
||||
from calibre.gui2.progress_indicator import ProgressIndicator as _ProgressIndicator
|
||||
from calibre.gui2.dnd import (dnd_has_image, dnd_get_image, dnd_get_files,
|
||||
image_extensions, dnd_has_extension, dnd_get_local_image_and_pixmap, DownloadDialog)
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.config import XMLConfig, prefs
|
||||
from calibre.utils.localization import localize_user_manual_link
|
||||
from polyglot.builtins import native_string_type
|
||||
|
||||
|
@ -42,6 +42,24 @@ def get_debug_executable():
|
||||
return [exe_name]
|
||||
|
||||
|
||||
def connect_lambda(bound_signal, self, func, **kw):
|
||||
import weakref
|
||||
r = weakref.ref(self)
|
||||
del self
|
||||
num_args = func.__code__.co_argcount - 1
|
||||
if num_args < 0:
|
||||
raise TypeError('lambda must take at least one argument')
|
||||
|
||||
def slot(*args):
|
||||
ctx = r()
|
||||
if ctx is not None:
|
||||
if len(args) != num_args:
|
||||
args = args[:num_args]
|
||||
func(ctx, *args)
|
||||
|
||||
bound_signal.connect(slot, **kw)
|
||||
|
||||
|
||||
def initialize_calibre():
|
||||
if hasattr(initialize_calibre, 'initialized'):
|
||||
return
|
||||
@ -126,22 +144,6 @@ def initialize_calibre():
|
||||
builtins.__dict__['icu_upper'] = icu_upper
|
||||
builtins.__dict__['icu_title'] = title_case
|
||||
|
||||
def connect_lambda(bound_signal, self, func, **kw):
|
||||
import weakref
|
||||
r = weakref.ref(self)
|
||||
del self
|
||||
num_args = func.__code__.co_argcount - 1
|
||||
if num_args < 0:
|
||||
raise TypeError('lambda must take at least one argument')
|
||||
|
||||
def slot(*args):
|
||||
ctx = r()
|
||||
if ctx is not None:
|
||||
if len(args) != num_args:
|
||||
args = args[:num_args]
|
||||
func(ctx, *args)
|
||||
|
||||
bound_signal.connect(slot, **kw)
|
||||
builtins.__dict__['connect_lambda'] = connect_lambda
|
||||
|
||||
if islinux or ismacos or isfreebsd:
|
||||
|
Loading…
x
Reference in New Issue
Block a user