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 setupUi(self, x): self.resize(720, 603) self.l = l = QHBoxLayout(self) self.list = lv = ListView(self) l.addWidget(lv) self.stack = s = QStackedWidget(self) l.addWidget(s, stretch=10)
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, dock_action, parent=None): QWidget.__init__(self, parent=parent) self.view_to_debug = parent self.view = None self.layout = QHBoxLayout(self) self.layout.setContentsMargins(0, 0, 0, 0) self.dock_action = dock_action QTimer.singleShot(0, self.connect_to_dock)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.l = l = QVBoxLayout(self) self.h = h = QHBoxLayout() self.la = la = QLabel(self.MSG) la.setWordWrap(True) l.addWidget(la) l.addLayout(h) self.action = a = QComboBox(self) h.addWidget(a) for action, text in iteritems(self.ACTION_MAP): a.addItem(text, action) a.currentIndexChanged.connect(self.update_state) self.la1 = la = QLabel('\xa0' + self.SUBJECT + '\xa0') h.addWidget(la) self.match_type = q = QComboBox(self) h.addWidget(q) for action, text in iteritems(self.MATCH_TYPE_MAP): q.addItem(text, action) q.currentIndexChanged.connect(self.update_state) self.la2 = la = QLabel(':\xa0') h.addWidget(la) self.query = q = QueryEdit(self) h.addWidget(q) self.tag_editor_button = b = QToolButton(self) b.setIcon(QIcon(I('chapters.png'))) b.setToolTip(_('Edit the list of tags with the Tag editor')) h.addWidget(b), b.clicked.connect(self.edit_tags) b.setVisible(self.can_use_tag_editor) self.h2 = h = QHBoxLayout() l.addLayout(h) self.la3 = la = QLabel(self.REPLACE_TEXT + '\xa0') h.addWidget(la) self.replace = r = QLineEdit(self) h.addWidget(r) self.regex_help = la = QLabel( '<p>' + self.REGEXP_HELP_TEXT % localize_user_manual_link( 'https://manual.calibre-ebook.com/regexp.html')) la.setOpenExternalLinks(True) la.setWordWrap(True) l.addWidget(la) la.setVisible(False) l.addStretch(10) self.la3.setVisible(False), self.replace.setVisible(False) self.update_state()
def setup_ui(self): self.use_stemmer = us = QCheckBox(_('&Match on related words')) us.setChecked(gprefs['browse_annots_use_stemmer']) us.setToolTip('<p>' + _( 'With this option searching for words will also match on any related words (supported in several languages). For' ' example, in the English language: <i>correction</i> matches <i>correcting</i> and <i>corrected</i> as well' )) us.stateChanged.connect(lambda state: gprefs.set( 'browse_annots_use_stemmer', state != Qt.CheckState.Unchecked)) l = QVBoxLayout(self) self.splitter = s = QSplitter(self) l.addWidget(s) s.setChildrenCollapsible(False) self.browse_panel = bp = BrowsePanel(self) bp.open_annotation.connect(self.do_open_annotation) bp.show_book.connect(self.show_book) bp.delete_requested.connect(self.delete_selected) bp.export_requested.connect(self.export_selected) bp.edit_annotation.connect(self.edit_annotation) s.addWidget(bp) self.details_panel = dp = DetailsPanel(self) s.addWidget(dp) dp.open_annotation.connect(self.do_open_annotation) dp.show_book.connect(self.show_book) dp.delete_annotation.connect(self.delete_annotation) dp.edit_annotation.connect(self.edit_annotation) bp.current_result_changed.connect(dp.show_result) h = QHBoxLayout() l.addLayout(h) h.addWidget(us), h.addStretch(10), h.addWidget(self.bb) self.delete_button = b = self.bb.addButton( _('&Delete all selected'), QDialogButtonBox.ButtonRole.ActionRole) b.setToolTip(_('Delete the selected annotations')) b.setIcon(QIcon(I('trash.png'))) b.clicked.connect(self.delete_selected) self.export_button = b = self.bb.addButton( _('&Export all selected'), QDialogButtonBox.ButtonRole.ActionRole) b.setToolTip(_('Export the selected annotations')) b.setIcon(QIcon(I('save.png'))) b.clicked.connect(self.export_selected) self.refresh_button = b = RightClickButton(self.bb) self.bb.addButton(b, QDialogButtonBox.ButtonRole.ActionRole) b.setText(_('&Refresh')) b.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon) self.refresh_menu = m = QMenu(self) m.addAction(_('Rebuild search index')).triggered.connect(self.rebuild) b.setMenu(m) b.setToolTip( _('Refresh annotations in case they have been changed since this window was opened' )) b.setIcon(QIcon(I('restart.png'))) b.setPopupMode(QToolButton.ToolButtonPopupMode.DelayedPopup) b.clicked.connect(self.refresh)
def setup_ui(self): self.block_show = False self.properties = [] self.l = l = QVBoxLayout(self) self.setLayout(l) h = QHBoxLayout() l.addLayout(h) self.la = la = QLabel(_('&Edit theme:')) h.addWidget(la) self.theme = t = QComboBox(self) la.setBuddy(t) t.addItems(sorted(custom_theme_names())) t.setMinimumWidth(200) if t.count() > 0: t.setCurrentIndex(0) t.currentIndexChanged[int].connect(self.show_theme) h.addWidget(t) self.add_button = b = QPushButton(QIcon(I('plus.png')), _('Add &new theme'), self) b.clicked.connect(self.create_new_theme) h.addWidget(b) self.remove_button = b = QPushButton(QIcon(I('minus.png')), _('&Remove theme'), self) b.clicked.connect(self.remove_theme) h.addWidget(b) h.addStretch(1) self.scroll = s = QScrollArea(self) self.w = w = QWidget(self) s.setWidget(w), s.setWidgetResizable(True) self.cl = cl = QVBoxLayout() w.setLayout(cl) from calibre.gui2.tweak_book.editor.text import TextEdit self.preview = p = TextEdit(self, expected_geometry=(73, 50)) p.load_text( HELP_TEXT.format(*[ '<b>%s</b>' % x for x in ('Normal', 'Visual', 'CursorLine', 'LineNr', 'MatchParen', 'Function', 'Type', 'Statement', 'Constant', 'SpecialCharacter', 'Error', 'SpellError', 'Comment') ])) p.setMaximumWidth(p.size_hint.width() + 5) s.setMinimumWidth(600) self.splitter = sp = QSplitter(self) l.addWidget(sp) sp.addWidget(s), sp.addWidget(p) self.bb.clear() self.bb.addButton(QDialogButtonBox.StandardButton.Close) l.addWidget(self.bb) if self.theme.count() > 0: self.show_theme()
def setup_ui(self): self.l = l = QVBoxLayout(self) self._text = PlainTextEdit(self) self._text.ctrl_enter_pushed.connect(self.ctrl_enter_pushed) l.addWidget(self._text) hl = QHBoxLayout() hl.addWidget(QLabel(_('Press Ctrl+Enter to accept or Esc to cancel'))) hl.addWidget(self.bb) l.addLayout(hl)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.l = l = QVBoxLayout(self) self.msg_label = la = QLabel( '<p>' + self.MSG + '<p>' + _('You can <b>change an existing rule</b> by double clicking it')) la.setWordWrap(True) l.addWidget(la) self.h = h = QHBoxLayout() l.addLayout(h) self.add_button = b = QPushButton(QIcon(I('plus.png')), _('&Add rule'), self) b.clicked.connect(self.add_rule) h.addWidget(b) self.remove_button = b = QPushButton(QIcon(I('minus.png')), _('&Remove rule(s)'), self) b.clicked.connect(self.remove_rules) h.addWidget(b) self.h3 = h = QHBoxLayout() l.addLayout(h) self.rule_list = r = QListWidget(self) self.delegate = Delegate(self) r.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection) r.setItemDelegate(self.delegate) r.doubleClicked.connect(self.edit_rule) h.addWidget(r) r.setDragEnabled(True) r.viewport().setAcceptDrops(True) r.setDropIndicatorShown(True) r.setDragDropMode(QAbstractItemView.DragDropMode.InternalMove) r.setDefaultDropAction(Qt.DropAction.MoveAction) self.l2 = l = QVBoxLayout() h.addLayout(l) self.up_button = b = QToolButton(self) b.setIcon(QIcon(I('arrow-up.png'))), b.setToolTip( _('Move current rule up')) b.clicked.connect(self.move_up) l.addWidget(b) self.down_button = b = QToolButton(self) b.setIcon(QIcon(I('arrow-down.png'))), b.setToolTip( _('Move current rule down')) b.clicked.connect(self.move_down) l.addStretch(10), l.addWidget(b)
def __init__(self, parent): self.restrict_to_book_ids = frozenset() QWidget.__init__(self, parent) v = QVBoxLayout(self) v.setContentsMargins(0, 0, 0, 0) h = QHBoxLayout() h.setContentsMargins(0, 0, 0, 0) v.addLayout(h) self.rla = QLabel(_('Restrict to') + ': ') h.addWidget(self.rla) la = QLabel(_('Type:')) h.addWidget(la) self.types_box = tb = QComboBox(self) tb.la = la tb.currentIndexChanged.connect(self.restrictions_changed) connect_lambda( tb.currentIndexChanged, tb, lambda tb: gprefs.set( 'browse_annots_restrict_to_type', tb.currentData())) la.setBuddy(tb) tb.setToolTip(_('Show only annotations of the specified type')) h.addWidget(tb) la = QLabel(_('User:'******'browse_annots_restrict_to_user', ub.currentData())) la.setBuddy(ub) ub.setToolTip(_('Show only annotations created by the specified user')) h.addWidget(ub) h.addStretch(10) h = QHBoxLayout() self.restrict_to_books_cb = cb = QCheckBox('') self.update_book_restrictions_text() cb.setToolTip( _('Only show annotations from books that have been selected in the calibre library' )) cb.setChecked( bool(gprefs.get('show_annots_from_selected_books_only', False))) cb.stateChanged.connect(self.show_only_selected_changed) h.addWidget(cb) v.addLayout(h)
def __init__(self, parent, current_img, current_url, geom_name='viewer_image_popup_geometry'): QDialog.__init__(self) self.current_image_name = '' self.maximized_at_last_fullscreen = False self.setWindowFlag(Qt.WindowType.WindowMinimizeButtonHint) self.setWindowFlag(Qt.WindowType.WindowMaximizeButtonHint) dw = QApplication.instance().desktop() self.avail_geom = dw.availableGeometry(parent if parent is not None else self) self.current_img = current_img self.current_url = current_url self.factor = 1.0 self.geom_name = geom_name self.scrollarea = sa = ScrollArea() sa.setAlignment(Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignVCenter) sa.setBackgroundRole(QPalette.ColorRole.Dark) self.label = l = Label(sa) sa.toggle_fit.connect(self.toggle_fit) sa.setWidget(l) self.bb = bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Close) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) self.zi_button = zi = bb.addButton(_('Zoom &in'), QDialogButtonBox.ButtonRole.ActionRole) self.zo_button = zo = bb.addButton(_('Zoom &out'), QDialogButtonBox.ButtonRole.ActionRole) self.save_button = so = bb.addButton(_('&Save as'), QDialogButtonBox.ButtonRole.ActionRole) self.rotate_button = ro = bb.addButton(_('&Rotate'), QDialogButtonBox.ButtonRole.ActionRole) self.fullscreen_button = fo = bb.addButton(_('&Full screen'), QDialogButtonBox.ButtonRole.ActionRole) zi.setIcon(QIcon(I('plus.png'))) zo.setIcon(QIcon(I('minus.png'))) so.setIcon(QIcon(I('save.png'))) ro.setIcon(QIcon(I('rotate-right.png'))) fo.setIcon(QIcon(I('page.png'))) zi.clicked.connect(self.zoom_in) zo.clicked.connect(self.zoom_out) so.clicked.connect(self.save_image) ro.clicked.connect(self.rotate_image) fo.setCheckable(True) self.l = l = QVBoxLayout(self) l.addWidget(sa) self.h = h = QHBoxLayout() h.setContentsMargins(0, 0, 0, 0) l.addLayout(h) self.fit_image = i = QCheckBox(_('&Fit image')) i.setToolTip(_('Fit image inside the available space')) i.setChecked(bool(gprefs.get('image_popup_fit_image'))) i.stateChanged.connect(self.fit_changed) h.addWidget(i), h.addStretch(), h.addWidget(bb) if self.fit_image.isChecked(): self.set_to_viewport_size() geom = gprefs.get(self.geom_name) if geom is not None: self.restoreGeometry(geom) fo.setChecked(self.isFullScreen()) fo.toggled.connect(self.toggle_fullscreen)
def __init__(self, parent, model): QWidget.__init__(self, parent) self.l = l = QHBoxLayout(self) self.view = v = QListView(self) v.doubleClicked.connect(self.item_activated) v.setModel(CustomRecipeModel(model)) l.addWidget(v) self.stacks = s = QStackedWidget(self) l.addWidget(s, stretch=10, alignment=Qt.AlignmentFlag.AlignTop) self.first_msg = la = QLabel( _('Create a new news source by clicking one of the buttons below')) la.setWordWrap(True) s.addWidget(la) self.w = w = QWidget(self) w.l = l = QVBoxLayout(w) l.setContentsMargins(0, 0, 0, 0) s.addWidget(w) self.title = la = QLabel(w) la.setAlignment(Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignTop) l.addWidget(la) l.setSpacing(20) self.edit_button = b = QPushButton(QIcon(I('modified.png')), _('&Edit this recipe'), w) b.setSizePolicy( QSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)) b.clicked.connect(self.edit_requested) l.addWidget(b) self.remove_button = b = QPushButton(QIcon(I('list_remove.png')), _('&Remove this recipe'), w) b.clicked.connect(self.remove) b.setSizePolicy( QSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)) l.addWidget(b) self.export_button = b = QPushButton(QIcon(I('save.png')), _('S&ave recipe as file'), w) b.setSizePolicy( QSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)) b.clicked.connect(self.save_recipe) l.addWidget(b) self.download_button = b = QPushButton( QIcon(I('download-metadata.png')), _('&Download this recipe'), w) b.clicked.connect(self.download) b.setSizePolicy( QSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)) l.addWidget(b) self.select_row() v.selectionModel().currentRowChanged.connect(self.recipe_selected)
def setup_ui(self): self.l = l = QVBoxLayout(self) self.setLayout(l) self.h = h = QHBoxLayout() l.addLayout(h) names = [n for n, linear in self.container.spine_names] fn, f = create_filterable_names_list(names, filter_text=_('Filter files'), parent=self) self.file_names, self.file_names_filter = fn, f fn.selectionModel().selectionChanged.connect(self.selected_file_changed) self.fnl = fnl = QVBoxLayout() self.la1 = la = QLabel(_('Choose a &file to link to:')) la.setBuddy(fn) fnl.addWidget(la), fnl.addWidget(f), fnl.addWidget(fn) h.addLayout(fnl), h.setStretch(0, 2) fn, f = create_filterable_names_list([], filter_text=_('Filter locations'), parent=self, model=AnchorsModel) fn.setSpacing(5) self.anchor_names, self.anchor_names_filter = fn, f fn.selectionModel().selectionChanged.connect(self.update_target) fn.doubleClicked.connect(self.accept, type=Qt.ConnectionType.QueuedConnection) self.anl = fnl = QVBoxLayout() self.la2 = la = QLabel(_('Choose a &location (anchor) in the file:')) la.setBuddy(fn) fnl.addWidget(la), fnl.addWidget(f), fnl.addWidget(fn) h.addLayout(fnl), h.setStretch(1, 1) self.tl = tl = QFormLayout() tl.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.AllNonFixedFieldsGrow) self.target = t = QLineEdit(self) t.setPlaceholderText(_('The destination (href) for the link')) tl.addRow(_('&Target:'), t) l.addLayout(tl) self.text_edit = t = QLineEdit(self) la.setBuddy(t) tl.addRow(_('Te&xt:'), t) t.setText(self.initial_text or '') t.setPlaceholderText(_('The (optional) text for the link')) self.template_edit = t = HistoryComboBox(self) t.lineEdit().setClearButtonEnabled(True) t.initialize('edit_book_insert_link_template_history') tl.addRow(_('Tem&plate:'), t) from calibre.gui2.tweak_book.editor.smarts.html import DEFAULT_LINK_TEMPLATE t.setText(tprefs.get('insert-hyperlink-template', None) or DEFAULT_LINK_TEMPLATE) t.setToolTip('<p>' + _(''' The template to use for generating the link. In addition to {0} and {1} you can also use {2}, {3} and {4} variables in the template, they will be replaced by the source filename, the destination filename and the anchor, respectively. ''').format( '_TEXT_', '_TARGET_', '_SOURCE_FILENAME_', '_DEST_FILENAME_', '_ANCHOR_')) l.addWidget(self.bb)
def setup_ui(self): self.l = l = QVBoxLayout(self) self.setLayout(l) self.gb = gb = QGroupBox(_('&Images in book'), self) self.v = v = QVBoxLayout(gb) gb.setLayout(v), gb.setFlat(True) self.names, self.names_filter = create_filterable_names_list( sorted(self.image_names, key=sort_key), filter_text=_('Filter the list of images'), parent=self) self.names.doubleClicked.connect( self.double_clicked, type=Qt.ConnectionType.QueuedConnection) self.cover_view = CoverView(self) l.addWidget(self.names_filter) v.addWidget(self.names) self.splitter = s = QSplitter(self) l.addWidget(s) s.addWidget(gb) s.addWidget(self.cover_view) self.h = h = QHBoxLayout() self.preserve = p = QCheckBox(_('Preserve aspect ratio')) p.setToolTip( textwrap.fill( _('If enabled the cover image you select will be embedded' ' into the book in such a way that when viewed, its aspect' ' ratio (ratio of width to height) will be preserved.' ' This will mean blank spaces around the image if the screen' ' the book is being viewed on has an aspect ratio different' ' to the image.'))) p.setChecked(tprefs['add_cover_preserve_aspect_ratio']) p.setVisible(self.container.book_type != 'azw3') def on_state_change(s): tprefs.set('add_cover_preserve_aspect_ratio', s == Qt.CheckState.Checked) p.stateChanged.connect(on_state_change) self.info_label = il = QLabel('\xa0') h.addWidget(p), h.addStretch(1), h.addWidget(il) l.addLayout(h) l.addWidget(self.bb) b = self.bb.addButton(_('Import &image'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.import_image) b.setIcon(QIcon(I('document_open.png'))) self.names.setFocus(Qt.FocusReason.OtherFocusReason) self.names.selectionModel().currentChanged.connect( self.current_image_changed) cname = get_raster_cover_name(self.container) if cname: row = self.names.model().find_name(cname) if row > -1: self.names.setCurrentIndex(self.names.model().index(row))
def __init__(self, parent): QWidget.__init__(self, parent) self.l = QHBoxLayout(self) self.setLayout(self.l) self.la = QLabel('') self.l.addWidget(self.la) self.l.setContentsMargins(0, 0, 0, 0) f = self.la.font() f.setBold(False) self.la.setFont(f)
def __init__(self, ui): QWidget.__init__(self, ui) self.l = l = QVBoxLayout(self) self.la = la = QLabel(_('&Find:')) self.find = ft = HistoryComboBox(self) ft.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed) ft.initialize('tweak_book_text_search_history') la.setBuddy(ft) self.h = h = QHBoxLayout() h.addWidget(la), h.addWidget(ft), l.addLayout(h) self.h2 = h = QHBoxLayout() l.addLayout(h) self.mode = m = ModeBox(self) h.addWidget(m) self.where_box = wb = WhereBox(self) h.addWidget(wb) self.cs = cs = QCheckBox(_('&Case sensitive')) h.addWidget(cs) self.da = da = QCheckBox(_('&Dot all')) da.setToolTip('<p>' + _( "Make the '.' special character match any character at all, including a newline" )) h.addWidget(da) self.h3 = h = QHBoxLayout() l.addLayout(h) h.addStretch(10) self.next_button = b = QPushButton(QIcon(I('arrow-down.png')), _('&Next'), self) b.setToolTip(_('Find next match')) h.addWidget(b) connect_lambda(b.clicked, self, lambda self: self.do_search('down')) self.prev_button = b = QPushButton(QIcon(I('arrow-up.png')), _('&Previous'), self) b.setToolTip(_('Find previous match')) h.addWidget(b) connect_lambda(b.clicked, self, lambda self: self.do_search('up')) state = tprefs.get('text_search_widget_state') self.state = state or {}
def create_color_button(key, text): b = ColorButton(data, key, text, self) b.changed.connect(self.changed), l.addWidget(b) bc = QToolButton(self) bc.setIcon(QIcon(I('clear_left.png'))) bc.setToolTip(_('Remove color')) bc.clicked.connect(b.clear) h = QHBoxLayout() h.addWidget(b), h.addWidget(bc) return h
def __init__(self, parent=None): QWidget.__init__(self, parent) self.l = l = QHBoxLayout(self) l.setContentsMargins(0, 0, 0, 0) self.pi = ProgressIndicator(self, 24) l.addWidget(self.pi) self.la = la = QLabel(_('Searching...')) l.addWidget(la) l.addStretch(10) self.is_running = False
def __init__(self, msg, name, parent, config_set=dynamic, icon='dialog_warning.png', title=None, confirm_msg=None, show_cancel_button=True, extra_button=None): QDialog.__init__(self, parent) self.setWindowTitle(title or _("Are you sure?")) self.setWindowIcon(QIcon(I(icon))) self.l = l = QVBoxLayout(self) self.h = h = QHBoxLayout() l.addLayout(h) self.icon_widget = Icon(self) self.icon_widget.set_icon(QIcon(I(icon))) self.msg = m = QLabel(self) m.setOpenExternalLinks(True) m.setMinimumWidth(350), m.setWordWrap(True), m.setObjectName("msg") m.setText(msg) h.addWidget(self.icon_widget), h.addSpacing(10), h.addWidget(m) self.again = a = QCheckBox( (confirm_msg or _("&Show this warning again")), self) a.setChecked(True), a.setObjectName("again") a.stateChanged.connect(self.toggle) l.addWidget(a) if show_cancel_button: buttons = QDialogButtonBox.StandardButton.Yes | QDialogButtonBox.StandardButton.No standard_button = QDialogButtonBox.StandardButton.Yes else: buttons = QDialogButtonBox.StandardButton.Ok standard_button = QDialogButtonBox.StandardButton.Ok self.buttonBox = bb = QDialogButtonBox(buttons, self) bb.setObjectName("buttonBox") bb.setFocus(Qt.FocusReason.OtherFocusReason) bb.accepted.connect(self.accept), bb.rejected.connect(self.reject) self.extra_button_clicked = False if extra_button: b = bb.addButton(extra_button, QDialogButtonBox.ButtonRole.AcceptRole) b.clicked.connect(self.on_extra_button_click) l.addWidget(bb) self.name = name self.config_set = config_set self.resize(self.sizeHint()) bb.button(standard_button).setFocus(Qt.FocusReason.OtherFocusReason)
def __init__(self, title, msg='\u00a0', min=0, max=99, parent=None, cancelable=True, icon=None): QDialog.__init__(self, parent) if icon is None: self.l = l = QVBoxLayout(self) else: self.h = h = QHBoxLayout(self) self.icon = i = QLabel(self) if not isinstance(icon, QIcon): icon = QIcon(I(icon)) i.setPixmap(icon.pixmap(64)) h.addWidget(i, alignment=Qt.AlignmentFlag.AlignTop | Qt.AlignmentFlag.AlignHCenter) self.l = l = QVBoxLayout() h.addLayout(l) self.setWindowIcon(icon) self.title_label = t = QLabel(title) self.setWindowTitle(title) t.setStyleSheet('QLabel { font-weight: bold }'), t.setAlignment( Qt.AlignmentFlag.AlignCenter), t.setTextFormat( Qt.TextFormat.PlainText) l.addWidget(t) self.bar = b = QProgressBar(self) b.setMinimum(min), b.setMaximum(max), b.setValue(min) l.addWidget(b) self.message = m = QLabel(self) fm = QFontMetrics(self.font()) m.setAlignment(Qt.AlignmentFlag.AlignCenter), m.setMinimumWidth( fm.averageCharWidth() * 80), m.setTextFormat( Qt.TextFormat.PlainText) l.addWidget(m) self.msg = msg self.button_box = bb = QDialogButtonBox( QDialogButtonBox.StandardButton.Abort, self) bb.rejected.connect(self._canceled) l.addWidget(bb) self.setWindowModality(Qt.WindowModality.ApplicationModal) self.canceled = False if not cancelable: bb.setVisible(False) self.cancelable = cancelable self.resize(self.sizeHint())
def __init__(self, parent=None): QDialog.__init__(self, parent=parent) self.l = l = QFormLayout(self) self.setLayout(l) self.setWindowTitle(_('Import OPML file')) self.setWindowIcon(QIcon(I('opml.png'))) self.h = h = QHBoxLayout() self.path = p = QLineEdit(self) p.setMinimumWidth(300) p.setPlaceholderText(_('Path to OPML file')) h.addWidget(p) self.cfb = b = QToolButton(self) b.setIcon(QIcon(I('document_open.png'))) b.setToolTip(_('Browse for OPML file')) b.clicked.connect(self.choose_file) h.addWidget(b) l.addRow(_('&OPML file:'), h) l.labelForField(h).setBuddy(p) b.setFocus(Qt.FocusReason.OtherFocusReason) self._articles_per_feed = a = QSpinBox(self) a.setMinimum(1), a.setMaximum(1000), a.setValue(100) a.setToolTip(_('Maximum number of articles to download per RSS feed')) l.addRow(_('&Maximum articles per feed:'), a) self._oldest_article = o = QSpinBox(self) o.setMinimum(1), o.setMaximum(3650), o.setValue(7) o.setSuffix(_(' days')) o.setToolTip( _('Articles in the RSS feeds older than this will be ignored')) l.addRow(_('&Oldest article:'), o) self.preserve_groups = g = QCheckBox( _('Preserve groups in the OPML file')) g.setToolTip('<p>' + _( 'If enabled, every group of feeds in the OPML file will be converted into a single recipe. Otherwise every feed becomes its own recipe' )) g.setChecked(True) l.addRow(g) self._replace_existing = r = QCheckBox(_('Replace existing recipes')) r.setToolTip('<p>' + _( 'If enabled, any existing recipes with the same titles as entries in the OPML file will be replaced.' ' Otherwise, new entries with modified titles will be created')) r.setChecked(True) l.addRow(r) self.bb = bb = QDialogButtonBox( QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel) bb.accepted.connect(self.accept), bb.rejected.connect(self.reject) l.addRow(bb) self.recipes = ()
def __init__(self, parent=None): QWidget.__init__(self, parent) self.l = l = QHBoxLayout(self) self.setLayout(l) self.label = QLabel('') self.pi = ProgressIndicator(self, 24) l.addWidget(self.label) l.addWidget(self.pi) l.setContentsMargins(0, 0, 0, 0) self.pi.setVisible(False) self.stop()
def __init__(self, parent=None): super().__init__(parent) l = QHBoxLayout(self) l.setContentsMargins(0, 0, 0, 0) self.edit = le = GenericEdit(self) l.addWidget(le) l.addSpacing(5) self.la = la = QLabel(_('<a href="{}">CSS selector help</a>').format('https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors')) la.setOpenExternalLinks(True) l.addWidget(la) self.setPlaceholderText = self.edit.setPlaceholderText
def setup_ui(self): self.l = l = QVBoxLayout(self) self.setLayout(l) self.tl = tl = QFormLayout() self.semantic_type = QComboBox(self) for key, val in iteritems(self.all_types): self.semantic_type.addItem(val, key) tl.addRow(_('Type of &semantics:'), self.semantic_type) self.target = t = QLineEdit(self) t.setPlaceholderText(_('The destination (href) for the link')) tl.addRow(_('&Target:'), t) l.addLayout(tl) self.hline = hl = QFrame(self) hl.setFrameStyle(QFrame.Shape.HLine) l.addWidget(hl) self.h = h = QHBoxLayout() l.addLayout(h) names = [n for n, linear in self.container.spine_names] fn, f = create_filterable_names_list(names, filter_text=_('Filter files'), parent=self) self.file_names, self.file_names_filter = fn, f fn.selectionModel().selectionChanged.connect( self.selected_file_changed) self.fnl = fnl = QVBoxLayout() self.la1 = la = QLabel(_('Choose a &file:')) la.setBuddy(fn) fnl.addWidget(la), fnl.addWidget(f), fnl.addWidget(fn) h.addLayout(fnl), h.setStretch(0, 2) fn, f = create_filterable_names_list([], filter_text=_('Filter locations'), parent=self) self.anchor_names, self.anchor_names_filter = fn, f fn.selectionModel().selectionChanged.connect(self.update_target) fn.doubleClicked.connect(self.accept, type=Qt.ConnectionType.QueuedConnection) self.anl = fnl = QVBoxLayout() self.la2 = la = QLabel(_('Choose a &location (anchor) in the file:')) la.setBuddy(fn) fnl.addWidget(la), fnl.addWidget(f), fnl.addWidget(fn) h.addLayout(fnl), h.setStretch(1, 1) self.bb.addButton(QDialogButtonBox.StandardButton.Help) self.bb.helpRequested.connect(self.help_requested) l.addWidget(self.bb) self.semantic_type_changed() self.semantic_type.currentIndexChanged.connect( self.semantic_type_changed) self.target.textChanged.connect(self.target_text_changed)
def __init__(self, model, parent=None): QWidget.__init__(self, parent) self._layout = QHBoxLayout() self.setLayout(self._layout) self.view = QListView(self) self._layout.addWidget(self.view) self.view.setModel(model) self.delegate = Delegate() self.view.setItemDelegate(self.delegate) self.delegate.sizeHintChanged.connect( self.scrollTo, type=Qt.ConnectionType.QueuedConnection)
def __init__(self, name, data, parent=None): QWidget.__init__(self, parent) self.l = l = QHBoxLayout(self) self.setLayout(l) self.label = QLabel(name) l.addWidget(self.label) self.data = data def create_color_button(key, text): b = ColorButton(data, key, text, self) b.changed.connect(self.changed), l.addWidget(b) bc = QToolButton(self) bc.setIcon(QIcon(I('clear_left.png'))) bc.setToolTip(_('Remove color')) bc.clicked.connect(b.clear) h = QHBoxLayout() h.addWidget(b), h.addWidget(bc) return h for k, text in (('fg', _('&Foreground')), ('bg', _('&Background'))): h = create_color_button(k, text) l.addLayout(h) for k, text in (('bold', _('B&old')), ('italic', _('&Italic'))): w = Bool(data, k, text, self) w.changed.connect(self.changed) l.addWidget(w) self.underline = us = QComboBox(self) us.addItems(sorted(tuple(underline_styles) + ('', ))) idx = us.findText(data.get('underline', '') or '') us.setCurrentIndex(max(idx, 0)) us.currentIndexChanged.connect(self.us_changed) self.la = la = QLabel(_('&Underline:')) la.setBuddy(us) h = QHBoxLayout() h.addWidget(la), h.addWidget(us), l.addLayout(h) h = create_color_button('underline_color', _('Color')) l.addLayout(h) l.addStretch(1)
def setup_ui(self): from calibre.ebooks.oeb.polish.images import get_compressible_images self.setWindowIcon(QIcon(I('compress-image.png'))) self.h = h = QHBoxLayout(self) self.images = i = QListWidget(self) h.addWidget(i) self.l = l = QVBoxLayout() h.addLayout(l) c = current_container() for name in sorted(get_compressible_images(c), key=numeric_sort_key): x = QListWidgetItem(name, i) x.setData(Qt.ItemDataRole.UserRole, c.filesize(name)) i.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection) i.setMinimumHeight(350), i.setMinimumWidth(350) i.selectAll(), i.setSpacing(5) self.delegate = ImageItemDelegate(self) i.setItemDelegate(self.delegate) self.la = la = QLabel(_( 'You can compress the images in this book losslessly, reducing the file size of the book,' ' without affecting image quality. Typically image size is reduced by 5 - 15%.')) la.setWordWrap(True) la.setMinimumWidth(250) l.addWidget(la), l.addSpacing(30) self.enable_lossy = el = QCheckBox(_('Enable &lossy compression of JPEG images')) el.setToolTip(_('This allows you to change the quality factor used for JPEG images.\nBy lowering' ' the quality you can greatly reduce file size, at the expense of the image looking blurred.')) l.addWidget(el) self.h2 = h = QHBoxLayout() l.addLayout(h) self.jq = jq = QSpinBox(self) jq.setMinimum(0), jq.setMaximum(100), jq.setValue(tprefs.get('jpeg_compression_quality_for_lossless_compression', 80)), jq.setEnabled(False) jq.setToolTip(_('The compression quality, 1 is high compression, 100 is low compression.\nImage' ' quality is inversely correlated with compression quality.')) jq.valueChanged.connect(self.save_compression_quality) el.toggled.connect(jq.setEnabled) self.jql = la = QLabel(_('Compression &quality:')) la.setBuddy(jq) h.addWidget(la), h.addWidget(jq) l.addStretch(10) l.addWidget(self.bb)
def __init__(self, download_id, filename, parent=None): QWidget.__init__(self, parent) self.l = l = QHBoxLayout(self) self.la = la = QLabel('{}:\xa0'.format(filename)) la.setMaximumWidth(400) l.addWidget(la) self.pb = pb = QProgressBar(self) pb.setRange(0, 0) l.addWidget(pb) self.download_id = download_id
def __init__(self): QWidget.__init__(self) self.l = QHBoxLayout() self.setLayout(self.l) self.label = QLabel('Hello world &message:') self.l.addWidget(self.label) self.msg = QLineEdit(self) self.msg.setText(prefs['hello_world_msg']) self.l.addWidget(self.msg) self.label.setBuddy(self.msg)
def __init__(self, parent): QWidget.__init__(self, parent) self.l = l = QVBoxLayout(self) self.cover = ZoomedCover(self) l.addWidget(self.cover) self.h = QHBoxLayout() l.addLayout(self.h) self.bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Close, self) self.size_label = QLabel(self) self.h.addWidget(self.size_label) self.h.addStretch(10) self.h.addWidget(self.bb)