def __init__(self, parent=None): QWidget.__init__(self, parent) self.l = l = QGridLayout(self) self.toc_title = None self.setLayout(l) l.setContentsMargins(0, 0, 0, 0) self.view = make_view_use_window_background(QTreeWidget(self)) self.delegate = Delegate(self.view) self.view.setItemDelegate(self.delegate) self.view.setHeaderHidden(True) self.view.setAnimated(True) self.view.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.view.customContextMenuRequested.connect( self.show_context_menu, type=Qt.ConnectionType.QueuedConnection) self.view.itemActivated.connect(self.emit_navigate) self.view.itemPressed.connect(self.item_pressed) set_no_activate_on_click(self.view) self.view.itemDoubleClicked.connect(self.emit_navigate) l.addWidget(self.view) self.refresh_action = QAction(QIcon(I('view-refresh.png')), _('&Refresh'), self) self.refresh_action.triggered.connect(self.refresh) self.refresh_timer = t = QTimer(self) t.setInterval(1000), t.setSingleShot(True) t.timeout.connect(self.auto_refresh) self.toc_name = None self.currently_editing = None
def __init__(self, plugin, parent): QWidget.__init__(self, parent) self.plugin = plugin self.l = l = QVBoxLayout() self.setLayout(l) self.c = c = QLabel( _('<b>Configure %(name)s</b><br>%(desc)s') % dict(name=plugin.name, desc=plugin.description)) c.setAlignment(Qt.AlignmentFlag.AlignHCenter) l.addWidget(c) self.config_widget = plugin.config_widget() self.sa = sa = QScrollArea(self) sa.setWidgetResizable(True) sa.setWidget(self.config_widget) l.addWidget(sa) self.bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Save | QDialogButtonBox.StandardButton.Cancel, parent=self) self.bb.accepted.connect(self.finished) self.bb.rejected.connect(self.finished) self.bb.accepted.connect(self.commit) l.addWidget(self.bb) self.f = QFrame(self) self.f.setFrameShape(QFrame.Shape.HLine) l.addWidget(self.f)
def __init__(self, parent): QWidget.__init__(self, parent) self.layout = QTextLayout() self.layout.setFont(self.font()) self.layout.setCacheEnabled(True) self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Preferred) self.last_layout_rect = None
def __init__(self, parent=None): self.loaded_ruleset = None QWidget.__init__(self, parent) self.PREFS_OBJECT = JSONConfig('style-transform-rules') l = QVBoxLayout(self) self.rules_widget = w = Rules(self) w.changed.connect(self.changed.emit) l.addWidget(w) self.h = h = QHBoxLayout() l.addLayout(h) self.export_button = b = QPushButton(_('E&xport'), self) b.setToolTip(_('Export these rules to a file')) b.clicked.connect(self.export_rules) h.addWidget(b) self.import_button = b = QPushButton(_('&Import'), self) b.setToolTip(_('Import previously exported rules')) b.clicked.connect(self.import_rules) h.addWidget(b) self.test_button = b = QPushButton(_('&Test rules'), self) b.clicked.connect(self.test_rules) h.addWidget(b) h.addStretch(10) self.save_button = b = QPushButton(_('&Save'), self) b.setToolTip(_('Save this ruleset for later re-use')) b.clicked.connect(self.save_ruleset) h.addWidget(b) self.export_button = b = QPushButton(_('&Load'), self) self.load_menu = QMenu(self) b.setMenu(self.load_menu) b.setToolTip(_('Load a previously saved ruleset')) b.clicked.connect(self.load_ruleset) h.addWidget(b) self.build_load_menu()
def __init__(self, parent=None): QWidget.__init__(self, parent) self.setAcceptDrops(True) self.setMouseTracking(True) self.setFocusPolicy(Qt.FocusPolicy.ClickFocus) self.selection_state = SelectionState() self.undo_stack = u = QUndoStack() u.setUndoLimit(10) u.canUndoChanged.connect(self.emit_undo_redo_state) u.canRedoChanged.connect(self.emit_undo_redo_state) self.original_image_data = None self.is_valid = False self.original_image_format = None self.current_image = None self.current_scaled_pixmap = None self.last_canvas_size = None self.target = QRectF(0, 0, 0, 0) self.undo_action = a = self.undo_stack.createUndoAction( self, _('Undo') + ' ') a.setIcon(QIcon(I('edit-undo.png'))) self.redo_action = a = self.undo_stack.createRedoAction( self, _('Redo') + ' ') a.setIcon(QIcon(I('edit-redo.png')))
def __init__(self, gui): QWidget.__init__(self, gui) self.setObjectName('jobs_pointer') self.setVisible(False) self.resize(100, 80) self.animation = QPropertyAnimation(self, b"geometry", self) self.animation.setDuration(750) self.animation.setLoopCount(2) self.animation.setEasingCurve(QEasingCurve.Type.Linear) self.animation.finished.connect(self.hide) taily, heady = 0, 55 self.arrow_path = QPainterPath(QPointF(40, taily)) self.arrow_path.lineTo(40, heady) self.arrow_path.lineTo(20, heady) self.arrow_path.lineTo(50, self.height()) self.arrow_path.lineTo(80, heady) self.arrow_path.lineTo(60, heady) self.arrow_path.lineTo(60, taily) self.arrow_path.closeSubpath() c = self.palette().color(QPalette.ColorGroup.Active, QPalette.ColorRole.WindowText) self.color = QColor(c) self.color.setAlpha(100) self.brush = QBrush(self.color, Qt.BrushStyle.SolidPattern)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) self.l = l = QFormLayout(self) l.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.AllNonFixedFieldsGrow) self.username_label = la = QLabel('') l.addWidget(la) self.ro_text = _('Allow {} to make &changes (i.e. grant write access)') self.rw = rw = QCheckBox(self) rw.setToolTip( _( 'If enabled, allows the user to make changes to the library.' ' Adding books/deleting books/editing metadata, etc.' ) ) rw.stateChanged.connect(self.readonly_changed) l.addWidget(rw) self.access_label = la = QLabel(self) l.addWidget(la), la.setWordWrap(True) self.cpb = b = QPushButton(_('Change &password')) l.addWidget(b) b.clicked.connect(self.change_password) self.restrict_button = b = QPushButton(self) b.clicked.connect(self.change_restriction) l.addWidget(b) self.show_user()
def __init__(self, parent=None, show_open_in_editor=False): QWidget.__init__(self, parent) self.changes = [[], [], []] self.delta = 0 self.l = l = QHBoxLayout(self) self.setLayout(l) self.syncpos = 0 l.setContentsMargins(0, 0, 0, 0), l.setSpacing(0) self.view = DiffSplit(self, show_open_in_editor=show_open_in_editor) l.addWidget(self.view) self.add_diff = self.view.add_diff self.scrollbar = QScrollBar(self) l.addWidget(self.scrollbar) self.syncing = False self.bars = [] self.resize_timer = QTimer(self) self.resize_timer.setSingleShot(True) self.resize_timer.timeout.connect(self.resize_debounced) for bar in (self.scrollbar, self.view.left.verticalScrollBar(), self.view.right.verticalScrollBar()): self.bars.append(bar) bar.scroll_idx = len(self.bars) - 1 connect_lambda(bar.valueChanged[int], self, lambda self: self.scrolled(self.sender().scroll_idx)) self.view.left.resized.connect(self.resized) for v in (self.view.left, self.view.right, self.view.handle(1)): v.wheel_event.connect(self.scrollbar.wheelEvent) if v is self.view.left or v is self.view.right: v.next_change.connect(self.next_change) v.line_activated.connect(self.line_activated) connect_lambda(v.scrolled, self, lambda self: self.scrolled(1 if self.sender() is self.view.left else 2))
def __init__(self, parent=None): QWidget.__init__(self, parent) self.l = l = QFormLayout(self) l.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.AllNonFixedFieldsGrow) self.widgets = [] self.widget_map = {} self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed) for name in sorted(options, key=lambda n: options[n].shortdoc.lower()): if name in ('auth', 'port', 'allow_socket_preallocation', 'userdb'): continue opt = options[name] if opt.choices: w = Choices elif isinstance(opt.default, bool): w = Bool elif isinstance(opt.default, numbers.Integral): w = Int elif isinstance(opt.default, numbers.Real): w = Float else: w = Text if name in ('ssl_certfile', 'ssl_keyfile'): w = Path w = w(name, l) setattr(self, 'opt_' + name, w) self.widgets.append(w) self.widget_map[name] = w
def __init__(self, name, is_checked=False, path='', restriction='', parent=None, is_first=False, enable_on_checked=True): QWidget.__init__(self, parent) self.name = name self.enable_on_checked = enable_on_checked self.l = l = QVBoxLayout(self) l.setSizeConstraint(QLayout.SizeConstraint.SetMinAndMaxSize) if not is_first: self.border = b = QFrame(self) b.setFrameStyle(QFrame.Shape.HLine) l.addWidget(b) self.cw = cw = QCheckBox(name.replace('&', '&&')) cw.setStyleSheet('QCheckBox { font-weight: bold }') cw.setChecked(is_checked) cw.stateChanged.connect(self.state_changed) if path: cw.setToolTip(path) l.addWidget(cw) self.la = la = QLabel(_('Further &restrict access to books in this library that match:')) l.addWidget(la) self.rw = rw = QLineEdit(self) rw.setPlaceholderText(_('A search expression')) rw.setToolTip(textwrap.fill(_( 'A search expression. If specified, access will be further restricted' ' to only those books that match this expression. For example:' ' tags:"=Share"'))) rw.setText(restriction or '') rw.textChanged.connect(self.on_rchange) la.setBuddy(rw) l.addWidget(rw) self.state_changed()
def __init__(self, parent): QWidget.__init__(self, parent) self.sa = QScrollArea(self) self.lw = QWidget(self) self.l = QVBoxLayout(self.lw) self.sa.setWidget(self.lw), self.sa.setWidgetResizable(True) self.gl = gl = QVBoxLayout(self) self.la = QLabel(_( 'Add new locations to search for books or authors using the "Search the internet" feature' ' of the Content server. The URLs should contain {author} which will be' ' replaced by the author name and, for book URLs, {title} which will' ' be replaced by the book title.')) self.la.setWordWrap(True) gl.addWidget(self.la) self.h = QHBoxLayout() gl.addLayout(self.h) self.add_url_button = b = QPushButton(QIcon(I('plus.png')), _('&Add URL')) b.clicked.connect(self.add_url) self.h.addWidget(b) self.export_button = b = QPushButton(_('Export URLs')) b.clicked.connect(self.export_urls) self.h.addWidget(b) self.import_button = b = QPushButton(_('Import URLs')) b.clicked.connect(self.import_urls) self.h.addWidget(b) self.clear_button = b = QPushButton(_('Clear')) b.clicked.connect(self.clear) self.h.addWidget(b) self.h.addStretch(10) gl.addWidget(self.sa, stretch=10) self.items = []
def __init__(self, parent, max_height=1000): QWidget.__init__(self, parent) self.setFocusPolicy(Qt.FocusPolicy.NoFocus) self.setFocusProxy(parent) self.setVisible(False) self.setMouseTracking(True) self.setCursor(Qt.CursorShape.PointingHandCursor) self.current_results = self.current_size_hint = None self.max_text_length = 0 self.current_index = -1 self.current_top_index = 0 self.max_height = max_height self.text_option = to = QTextOption() to.setWrapMode(QTextOption.WrapMode.NoWrap) to.setAlignment(Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter) self.rendered_text_cache = {} parent.installEventFilter(self) self.relayout_timer = t = QTimer(self) t.setSingleShot(True), t.setInterval(25), t.timeout.connect( self.layout)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.l = l = QVBoxLayout(self) self.pi = ProgressIndicator(self, 96) self.setVisible(False) self.label = QLabel(self) self.label.setText( '<i>testing with some long and wrap worthy message that should hopefully still render well' ) self.label.setTextFormat(Qt.TextFormat.RichText) self.label.setAlignment(Qt.AlignmentFlag.AlignTop | Qt.AlignmentFlag.AlignHCenter) self.label.setWordWrap(True) if parent is None: self.resize(300, 300) else: self.resize(parent.size()) self.setAutoFillBackground(True) pal = self.palette() col = pal.color(QPalette.ColorRole.Window) col.setAlphaF(0.8) pal.setColor(QPalette.ColorRole.Window, col) self.setPalette(pal) self.move(0, 0) f = self.font() f.setBold(True) fm = QFontInfo(f) f.setPixelSize(int(fm.pixelSize() * 1.5)) self.label.setFont(f) l.addStretch(10) l.addWidget(self.pi) l.addWidget(self.label) l.addStretch(10)
def __init__(self, all_formats, format_map): QWidget.__init__(self) self.l = l = QGridLayout() self.setLayout(l) self.f = f = QListWidget(self) l.addWidget(f, 0, 0, 3, 1) unchecked_formats = sorted(all_formats - set(format_map)) for fmt in format_map + unchecked_formats: item = QListWidgetItem(fmt, f) item.setData(Qt.ItemDataRole.UserRole, fmt) item.setFlags(Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsUserCheckable | Qt.ItemFlag.ItemIsSelectable) item.setCheckState(Qt.CheckState.Checked if fmt in format_map else Qt.CheckState.Unchecked) self.button_up = b = QToolButton(self) b.setIcon(QIcon(I('arrow-up.png'))) l.addWidget(b, 0, 1) b.clicked.connect(self.up) self.button_down = b = QToolButton(self) b.setIcon(QIcon(I('arrow-down.png'))) l.addWidget(b, 2, 1) b.clicked.connect(self.down)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.l = l = QHBoxLayout(self) self.lp = lp = QVBoxLayout() l.addLayout(lp) self.h = h = QHBoxLayout() lp.addLayout(h) self.add_button = b = QPushButton(QIcon(I('plus.png')), _('&Add user'), self) b.clicked.connect(self.add_user) h.addWidget(b) self.remove_button = b = QPushButton( QIcon(I('minus.png')), _('&Remove user'), self ) b.clicked.connect(self.remove_user) h.addStretch(2), h.addWidget(b) self.user_list = w = QListWidget(self) w.setSpacing(1) w.doubleClicked.connect(self.current_user_activated) w.setSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Expanding) lp.addWidget(w) self.user_display = u = User(self) u.changed_signal.connect(self.changed_signal.emit) l.addWidget(u)
def __init__(self, preview, parent=None): QWidget.__init__(self, parent) self.preview = preview preview.live_css_data.connect(self.got_live_css_data) self.preview_is_refreshing = False self.refresh_needed = False preview.refresh_starting.connect(self.preview_refresh_starting) preview.refreshed.connect(self.preview_refreshed) self.apply_theme() self.setAutoFillBackground(True) self.update_timer = QTimer(self) self.update_timer.timeout.connect(self.update_data) self.update_timer.setSingleShot(True) self.update_timer.setInterval(500) self.now_showing = (None, None, None) self.stack = s = QStackedLayout(self) self.setLayout(s) self.clear_label = la = QLabel( '<h3>' + _('No style information found') + '</h3><p>' + _('Move the cursor inside a HTML tag to see what styles' ' apply to that tag.')) la.setWordWrap(True) la.setAlignment(Qt.AlignmentFlag.AlignTop | Qt.AlignmentFlag.AlignLeft) s.addWidget(la) self.box = box = Box(self) box.hyperlink_activated.connect( self.goto_declaration, type=Qt.ConnectionType.QueuedConnection) self.scroll = sc = QScrollArea(self) sc.setWidget(box) sc.setWidgetResizable(True) s.addWidget(sc)
def __init__(self, config=None): QWidget.__init__(self) self.setupUi(self) self.config = JSONConfig('store/search') if not config else config # These default values should be the same as in # calibre.gui2.store.search.search:SearchDialog.load_settings # Seconds self.opt_timeout.setValue(self.config.get('timeout', 75)) self.opt_hang_time.setValue(self.config.get('hang_time', 75)) self.opt_max_results.setValue(self.config.get('max_results', 10)) self.opt_open_external.setChecked( self.config.get('open_external', True)) # Number of threads to run for each type of operation self.opt_search_thread_count.setValue( self.config.get('search_thread_count', 4)) self.opt_cache_thread_count.setValue( self.config.get('cache_thread_count', 2)) self.opt_cover_thread_count.setValue( self.config.get('cover_thread_count', 2)) self.opt_details_thread_count.setValue( self.config.get('details_thread_count', 4))
def __init__(self, plugin): QWidget.__init__(self) self.plugin = plugin self.overl = l = QVBoxLayout(self) self.gb = QGroupBox(_('Metadata fields to download'), self) if plugin.config_help_message: self.pchm = QLabel(plugin.config_help_message) self.pchm.setWordWrap(True) self.pchm.setOpenExternalLinks(True) l.addWidget(self.pchm, 10) l.addWidget(self.gb) self.gb.l = g = QVBoxLayout(self.gb) g.setContentsMargins(0, 0, 0, 0) self.fields_view = v = FieldsList(self) g.addWidget(v) v.setFlow(QListView.Flow.LeftToRight) v.setWrapping(True) v.setResizeMode(QListView.ResizeMode.Adjust) self.fields_model = FieldsModel(self.plugin) self.fields_model.initialize() v.setModel(self.fields_model) self.memory = [] self.widgets = [] self.l = QGridLayout() self.l.setContentsMargins(0, 0, 0, 0) l.addLayout(self.l, 100) for opt in plugin.options: self.create_widgets(opt)
def __init__(self, parent=None, object_name='', show_msg=True): QWidget.__init__(self, parent) self.h = h = QHBoxLayout(self) h.setContentsMargins(0, 0, 0, 0) self.l = l = QVBoxLayout() h.addLayout(l) self.button = b = QToolButton(self) b.setIcon(QIcon(I('wizard.png'))) b.setToolTip(_('Use a wizard to generate the XPath expression')) b.clicked.connect(self.wizard) h.addWidget(b) self.edit = e = HistoryLineEdit(self) e.setMinimumWidth(350) e.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon) e.setMinimumContentsLength(30) self.msg = QLabel('') l.addWidget(self.msg) l.addWidget(self.edit) if object_name: self.setObjectName(object_name) if show_msg: b.setIconSize(QSize(40, 40)) self.msg.setBuddy(self.edit) else: self.msg.setVisible(False) l.setContentsMargins(0, 0, 0, 0)
def __init__(self, store): QWidget.__init__(self) self.setupUi(self) self.store = store self.load_setings()
def __init__(self, parent=None): QWidget.__init__(self, parent) self._layout = l = QVBoxLayout(self) self.header = QLabel( _('Double click on any entry to change the' ' keyboard shortcuts associated with it')) l.addWidget(self.header) self.view = QTreeView(self) self.view.setAlternatingRowColors(True) self.view.setHeaderHidden(True) self.view.setAnimated(True) self.view.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.view.customContextMenuRequested.connect(self.show_context_menu) l.addWidget(self.view) self.delegate = Delegate() self.view.setItemDelegate(self.delegate) self.delegate.sizeHintChanged.connect( self.editor_opened, type=Qt.ConnectionType.QueuedConnection) self.delegate.changed_signal.connect(self.changed_signal) self.search = SearchBox2(self) self.search.initialize('shortcuts_search_history', help_text=_('Search for a shortcut by name')) self.search.search.connect(self.find) self._h = h = QHBoxLayout() l.addLayout(h) h.addWidget(self.search) self.nb = QPushButton(QIcon(I('arrow-down.png')), _('&Next'), self) self.pb = QPushButton(QIcon(I('arrow-up.png')), _('&Previous'), self) self.nb.clicked.connect(self.find_next) self.pb.clicked.connect(self.find_previous) h.addWidget(self.nb), h.addWidget(self.pb) h.setStretch(0, 100)
def __init__(self, model, parent=None): QWidget.__init__(self, parent) self.l = l = QGridLayout(self) self.setLayout(l) self.setContentsMargins(0, 0, 0, 0) self.view = v = QListView(self) self.d = SpacedDelegate(v) v.doubleClicked.connect(self.double_clicked) v.setItemDelegate(self.d) v.setModel(model) l.addWidget(v, 0, 0, 1, -1) model.dataChanged.connect(self.data_changed) self.rb = b = QPushButton(QIcon(I('edit-undo.png')), _('&Revert to'), self) b.setToolTip(_('Revert the book to the selected checkpoint')) b.clicked.connect(self.revert_clicked) l.addWidget(b, 1, 1) self.cb = b = QPushButton(QIcon(I('diff.png')), _('&Compare'), self) b.setToolTip( _('Compare the state of the book at the selected checkpoint with the current state' )) b.clicked.connect(self.compare_clicked) l.addWidget(b, 1, 0)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.num_jobs = 0 self.mouse_over = False self.pi = ProgressIndicator(self, self.style().pixelMetric(QStyle.PixelMetric.PM_ToolBarIconSize)) self.pi.setVisible(False) self._jobs = QLabel('') self._jobs.mouseReleaseEvent = self.mouseReleaseEvent self.update_label() self.shortcut = 'Alt+Shift+J' self.l = l = QHBoxLayout(self) l.setSpacing(3) l.addWidget(self.pi) l.addWidget(self._jobs) m = self.style().pixelMetric(QStyle.PixelMetric.PM_DefaultFrameWidth) self.layout().setContentsMargins(m, m, m, m) self._jobs.setSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Minimum) self.setCursor(Qt.CursorShape.PointingHandCursor) b = _('Click to see list of jobs') self.setToolTip(b + _(' [Alt+Shift+J]')) self.action_toggle = QAction(b, parent) parent.addAction(self.action_toggle) self.action_toggle.triggered.connect(self.toggle) if hasattr(parent, 'keyboard'): parent.keyboard.register_shortcut('toggle jobs list', _('Show/hide the Jobs List'), default_keys=(self.shortcut,), action=self.action_toggle)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.discovery_counter = 0 self.last_hidden_text_warning = None self.current_search = None self.anchor_cfi = None self.l = l = QVBoxLayout(self) l.setContentsMargins(0, 0, 0, 0) self.search_input = si = SearchInput(self) self.searcher = None self.search_tasks = Queue() self.results_found.connect(self.on_result_found, type=Qt.ConnectionType.QueuedConnection) si.do_search.connect(self.search_requested) si.cleared.connect(self.search_cleared) si.go_back.connect(self.go_back) l.addWidget(si) self.results = r = Results(self) r.count_changed.connect(self.count_changed) r.show_search_result.connect(self.do_show_search_result, type=Qt.ConnectionType.QueuedConnection) r.current_result_changed.connect(self.update_hidden_message) l.addWidget(r, 100) self.spinner = s = BusySpinner(self) s.setVisible(False) l.addWidget(s) self.hidden_message = la = QLabel( _('This text is hidden in the book and cannot be displayed')) la.setStyleSheet('QLabel { margin-left: 1ex }') la.setWordWrap(True) la.setVisible(False) l.addWidget(la)
def __init__(self, parent): QWidget.__init__(self, parent) l = QVBoxLayout(parent) l.addWidget(self) l.setContentsMargins(0, 0, 0, 0) l = QFormLayout(self) l.setContentsMargins(0, 0, 0, 0) l.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.AllNonFixedFieldsGrow) self.choices = c = QComboBox() c.setMinimumContentsLength(30) for text, data in [ (_('Search for the author on Goodreads'), 'search-goodreads'), (_('Search for the author on Amazon'), 'search-amzn'), (_('Search for the author in your calibre library'), 'search-calibre'), (_('Search for the author on Wikipedia'), 'search-wikipedia'), (_('Search for the author on Google Books'), 'search-google'), (_('Search for the book on Goodreads'), 'search-goodreads-book'), (_('Search for the book on Amazon'), 'search-amzn-book'), (_('Search for the book on Google Books'), 'search-google-book'), (_('Use a custom search URL'), 'url'), ]: c.addItem(text, data) l.addRow(_('Clicking on &author names should:'), c) self.custom_url = u = QLineEdit(self) u.setToolTip(_( 'Enter the URL to search. It should contain the string {0}' '\nwhich will be replaced by the author name. For example,' '\n{1}').format('{author}', 'https://en.wikipedia.org/w/index.php?search={author}')) u.textChanged.connect(self.changed_signal) u.setPlaceholderText(_('Enter the URL')) c.currentIndexChanged.connect(self.current_changed) l.addRow(u) self.current_changed() c.currentIndexChanged.connect(self.changed_signal)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.l = l = QVBoxLayout(self) self.view = v = QWebEngineView(self) v.loadStarted.connect(self.load_started) v.loadProgress.connect(self.load_progress) v.loadFinished.connect(self.load_finished) l.addWidget(v) self.h = h = QHBoxLayout() l.addLayout(h) self.download_progress = d = DownloadProgress(self) h.addWidget(d) self.home_button = b = QPushButton(_('Home')) b.clicked.connect(self.home) h.addWidget(b) self.back_button = b = QPushButton(_('Back')) b.clicked.connect(v.back) h.addWidget(b) self.forward_button = b = QPushButton(_('Forward')) b.clicked.connect(v.forward) h.addWidget(b) self.progress_bar = b = QProgressBar(self) h.addWidget(b) self.reload_button = b = QPushButton(_('Reload')) b.clicked.connect(v.reload) h.addWidget(b)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.l = l = QGridLayout(self) def add_row(*args): r = l.rowCount() if len(args) == 1: l.addWidget(args[0], r, 0, 1, 2) else: la = QLabel(args[0]) l.addWidget(la, r, 0, Qt.AlignmentFlag.AlignRight), l.addWidget(args[1], r, 1) la.setBuddy(args[1]) self.heading = la = QLabel('<h2>\xa0') add_row(la) self.helpl = la = QLabel(_('For help with snippets, see the <a href="%s">User Manual</a>') % localize_user_manual_link('https://manual.calibre-ebook.com/snippets.html')) la.setOpenExternalLinks(True) add_row(la) self.name = n = QLineEdit(self) n.setPlaceholderText(_('The name of this snippet')) add_row(_('&Name:'), n) self.trig = t = QLineEdit(self) t.setPlaceholderText(_('The text used to trigger this snippet')) add_row(_('Tri&gger:'), t) self.template = t = PlainTextEdit(self) la.setBuddy(t) add_row(_('&Template:'), t) self.types = t = QListWidget(self) t.setFlow(QListView.Flow.LeftToRight) t.setWrapping(True), t.setResizeMode(QListView.ResizeMode.Adjust), t.setSpacing(5) fm = t.fontMetrics() t.setMaximumHeight(2*(fm.ascent() + fm.descent()) + 25) add_row(_('&File types:'), t) t.setToolTip(_('Which file types this snippet should be active in')) self.frame = f = QFrame(self) f.setFrameShape(QFrame.Shape.HLine) add_row(f) self.test = d = SnippetTextEdit('', self) d.snippet_manager.snip_func = self.snip_func d.setToolTip(_('You can test your snippet here')) d.setMaximumHeight(t.maximumHeight() + 15) add_row(_('T&est:'), d) i = QListWidgetItem(_('All'), t) i.setData(Qt.ItemDataRole.UserRole, '*') i.setCheckState(Qt.CheckState.Checked) i.setFlags(i.flags() | Qt.ItemFlag.ItemIsUserCheckable) for ftype in sorted(all_text_syntaxes): i = QListWidgetItem(ftype, t) i.setData(Qt.ItemDataRole.UserRole, ftype) i.setCheckState(Qt.CheckState.Checked) i.setFlags(i.flags() | Qt.ItemFlag.ItemIsUserCheckable) self.creating_snippet = False
def __init__(self, vertical, parent=None): QWidget.__init__(self, parent) self.last_data = {} self.setAcceptDrops(True) self._layout = DetailsLayout(vertical, self) self.setLayout(self._layout) self.current_path = '' self.cover_view = CoverView(vertical, self) self.cover_view.search_internet.connect(self.search_internet) self.cover_view.cover_changed.connect(self.cover_changed.emit) self.cover_view.open_cover_with.connect(self.open_cover_with.emit) self.cover_view.cover_removed.connect(self.cover_removed.emit) self._layout.addWidget(self.cover_view) self.book_info = BookInfo(vertical, self) self.book_info.show_book_info = self.show_book_info self.book_info.search_internet = self.search_internet self.book_info.search_requested = self.search_requested.emit self._layout.addWidget(self.book_info) self.book_info.link_clicked.connect(self.handle_click) self.book_info.remove_format.connect(self.remove_specific_format) self.book_info.remove_item.connect(self.remove_metadata_item) self.book_info.open_fmt_with.connect(self.open_fmt_with) self.book_info.edit_book.connect(self.edit_book) self.book_info.save_format.connect(self.save_specific_format) self.book_info.restore_format.connect(self.restore_specific_format) self.book_info.set_cover_format.connect(self.set_cover_from_format) self.book_info.compare_format.connect(self.compare_specific_format) self.book_info.copy_link.connect(self.copy_link) self.book_info.manage_category.connect(self.manage_category) self.book_info.find_in_tag_browser.connect(self.find_in_tag_browser) self.book_info.edit_identifiers.connect(self.edit_identifiers) self.setCursor(Qt.CursorShape.PointingHandCursor)
def __init__(self, parent): QWidget.__init__(self, parent) self.bcol = QColor(*gprefs['cover_grid_color']) self.btex = gprefs['cover_grid_texture'] self.update_brush() self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.l = l = QVBoxLayout(self) self.la = la = QLabel(_('Choose the external resources to download')) la.setWordWrap(True) l.addWidget(la) self.items = i = QListWidget(self) l.addWidget(i)