def setup_ui(self): from calibre.gui2.convert.look_and_feel_ui import Ui_Form f, w = Ui_Form(), QWidget() f.setupUi(w) self.l = l = QFormLayout(self) self.setLayout(l) l.addRow(QLabel(_('Select what style information you want completely removed:'))) self.h = h = QHBoxLayout() for name, text in ( ('fonts', _('&Fonts')), ('margins', _('&Margins')), ('padding', _('&Padding')), ('floats', _('Flo&ats')), ('colors', _('&Colors')), ): c = QCheckBox(text) setattr(self, 'opt_' + name, c) h.addWidget(c) c.setToolTip(getattr(f, 'filter_css_' + name).toolTip()) l.addRow(h) self.others = o = QLineEdit(self) l.addRow(_('&Other CSS properties:'), o) o.setToolTip(f.filter_css_others.toolTip()) if self.current_name is not None: self.filter_current = c = QCheckBox(_('Only filter CSS in the current file (%s)') % self.current_name) l.addRow(c) l.addRow(self.bb)
def setupUi(self, *a): self.l = l = QFormLayout(self) self.opt_docx_page_size = QComboBox(self) l.addRow(_('Paper si&ze:'), self.opt_docx_page_size) self.opt_docx_custom_page_size = w = QLineEdit(self) w.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed) l.addRow(_('&Custom size:'), w) for i, text in enumerate( (_('Page &left margin'), _('Page &top margin'), _('Page &right margin'), _('Page &bottom margin'))): m = 'left top right bottom'.split()[i] w = QDoubleSpinBox(self) w.setRange(-100, 500), w.setSuffix(' pt'), w.setDecimals(1) setattr(self, 'opt_docx_page_margin_' + m, w) l.addRow(text + ':', w) self.opt_docx_no_toc = QCheckBox( _('Do not insert the &Table of Contents as a page at the start of the document' )) l.addRow(self.opt_docx_no_toc) self.opt_docx_no_cover = QCheckBox( _('Do not insert &cover as image at start of document')) l.addRow(self.opt_docx_no_cover) self.opt_preserve_cover_aspect_ratio = QCheckBox( _('Preserve the aspect ratio of the image inserted as cover')) l.addRow(self.opt_preserve_cover_aspect_ratio)
def __init__(self, width, height, parent=None): QDialog.__init__(self, parent) self.l = l = QFormLayout(self) self.setLayout(l) self.aspect_ratio = width / float(height) l.addRow(QLabel(_('Choose the new width and height'))) self._width = w = QSpinBox(self) w.setMinimum(1) w.setMaximum(10 * width) w.setValue(width) w.setSuffix(' px') l.addRow(_('&Width:'), w) self._height = h = QSpinBox(self) h.setMinimum(1) h.setMaximum(10 * height) h.setValue(height) h.setSuffix(' px') l.addRow(_('&Height:'), h) connect_lambda(w.valueChanged, self, lambda self: self.keep_ar('width')) connect_lambda(h.valueChanged, self, lambda self: self.keep_ar('height')) self.ar = ar = QCheckBox(_('Keep &aspect ratio')) ar.setChecked(True) l.addRow(ar) self.resize(self.sizeHint()) self.bb = bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) l.addRow(bb)
def setup_ui(self): self.l = l = QFormLayout(self) self.setLayout(l) self.title = t = QLineEdit(self) l.addRow(_('&Title:'), t) t.setFocus(Qt.FocusReason.OtherFocusReason) self.authors = a = QLineEdit(self) l.addRow(_('&Authors:'), a) a.setText(tprefs.get('previous_new_book_authors', '')) self.languages = la = LanguagesEdit(self) l.addRow(_('&Language:'), la) la.lang_codes = (tprefs.get('previous_new_book_lang', canonicalize_lang(get_lang())), ) bb = self.bb l.addRow(bb) bb.clear() bb.addButton(QDialogButtonBox.StandardButton.Cancel) b = bb.addButton('&EPUB', QDialogButtonBox.ButtonRole.AcceptRole) connect_lambda(b.clicked, self, lambda self: self.set_fmt('epub')) b = bb.addButton('&AZW3', QDialogButtonBox.ButtonRole.AcceptRole) connect_lambda(b.clicked, self, lambda self: self.set_fmt('azw3'))
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, user_data, parent=None, username=None): QDialog.__init__(self, parent) self.user_data = user_data self.setWindowTitle( _('Change password for {}').format(username) if username else _('Add new user') ) self.l = l = QFormLayout(self) l.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.AllNonFixedFieldsGrow) self.uw = u = QLineEdit(self) l.addRow(_('&Username:'******'Set the password for this user'))) self.p1, self.p2 = p1, p2 = QLineEdit(self), QLineEdit(self) l.addRow(_('&Password:'******'&Repeat password:'******'pw']) self.showp = sp = QCheckBox(_('&Show password')) sp.stateChanged.connect(self.show_password) l.addRow(sp) self.bb = bb = QDialogButtonBox( QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel ) l.addRow(bb) bb.accepted.connect(self.accept), bb.rejected.connect(self.reject) (self.uw if not username else self.p1).setFocus(Qt.FocusReason.OtherFocusReason)
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, 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, scheme_name, scheme, existing_names, edit_scheme=False, parent=None): QDialog.__init__(self, parent) self.existing_names, self.is_editing, self.scheme_name = existing_names, edit_scheme, scheme_name self.l = l = QFormLayout(self) self.setLayout(l) self.setWindowTitle(scheme_name) self.name = n = QLineEdit(self) n.setText(scheme_name if edit_scheme else '#' + ('My Color Scheme')) l.addRow(_('&Name:'), self.name) for x in 'color1 color2 contrast_color1 contrast_color2'.split(): setattr(self, x, ColorButton(scheme[x], self)) l.addRow(_('Color &1:'), self.color1) l.addRow(_('Color &2:'), self.color2) l.addRow(_('Contrast color &1 (mainly for text):'), self.contrast_color1) l.addRow(_('Contrast color &2 (mainly for text):'), self.contrast_color2) self.bb = bb = QDialogButtonBox( QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) l.addRow(bb)
def setup_ui(self): self.l = l = QFormLayout(self) l.setFieldGrowthPolicy( QFormLayout.FieldGrowthPolicy.AllNonFixedFieldsGrow) l.addRow( QLabel( _('The key of the identifier, for example, in isbn:XXX, the key is "isbn"' ))) self.key = k = QLineEdit(self) l.addRow(_('&Key:'), k) l.addRow( QLabel(_('The name that will appear in the Book details panel'))) self.nw = n = QLineEdit(self) l.addRow(_('&Name:'), n) la = QLabel( _('The template used to create the link.' ' The placeholder {0} in the template will be replaced' ' with the actual identifier value. Use {1} to avoid the value' ' being quoted.').format('{id}', '{id_unquoted}')) la.setWordWrap(True) l.addRow(la) self.template = t = QLineEdit(self) l.addRow(_('&Template:'), t) t.selectAll() t.setFocus(Qt.FocusReason.OtherFocusReason) l.addWidget(self.bb)
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 __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): BasicSettings.__init__(self, parent) self.l = l = QFormLayout(self) self.setLayout(l) nd = self('nestable_dock_widgets') nd.setText( _('Allow dockable &windows to be nested inside the dock areas')) nd.setToolTip('<p>' + _( 'By default, you can have only a single row or column of windows in the dock' ' areas (the areas around the central editors). This option allows' ' for more flexible window layout, but is a little more complex to use.' )) l.addRow(nd) l.addRow( QLabel( _('Choose which windows will occupy the corners of the dockable areas' ))) for v, h in product(('top', 'bottom'), ('left', 'right')): choices = { 'vertical': { 'left': _('Left'), 'right': _('Right') }[h], 'horizontal': { 'top': _('Top'), 'bottom': _('Bottom') }[v] } name = f'dock_{v}_{h}' w = self.choices_widget(name, choices, 'horizontal', 'horizontal') cn = { ('top', 'left'): _('The &top-left corner'), ('top', 'right'): _('The top-&right corner'), ('bottom', 'left'): _('The &bottom-left corner'), ('bottom', 'right'): _('The bottom-ri&ght corner') }[(v, h)] l.addRow(cn + ':', w) nd = self('restore_book_state') nd.setText( _('Restore &state of previously edited book when opening it again') ) nd.setToolTip('<p>' + _( 'When opening a previously edited book again, restore its state. That means all open' ' files are automatically re-opened and the cursor is positioned at its previous location.' )) l.addRow(nd) nd = self('file_list_shows_full_pathname') nd.setText(_('Show full &file paths in the File browser')) nd.setToolTip('<p>' + _( 'Showing the full file paths is useful when editing books that contain' ' multiple files with the same file name.')) l.addRow(nd)
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 setupUi(self, *a): Ui_Form.setupUi(self, *a) v = self.page_margins_box.v = QVBoxLayout(self.page_margins_box) self.opt_pdf_use_document_margins = c = QCheckBox(_('Use page margins from the &document being converted')) v.addWidget(c) h = self.page_margins_box.h = QHBoxLayout() l = self.page_margins_box.l = QFormLayout() r = self.page_margins_box.r = QFormLayout() h.addLayout(l), h.addLayout(r) v.addLayout(h) def margin(which): w = QDoubleSpinBox(self) w.setRange(-100, 500), w.setSuffix(' pt'), w.setDecimals(1) setattr(self, 'opt_pdf_page_margin_' + which, w) return w l.addRow(_('&Left:'), margin('left')) l.addRow(_('&Right:'), margin('right')) r.addRow(_('&Top:'), margin('top')) r.addRow(_('&Bottom:'), margin('bottom')) self.opt_use_profile_size.toggled.connect(self.profile_size_toggled)
def setup_ui(self): self.vl = vl = QVBoxLayout(self) self.l = l = QFormLayout() vl.addLayout(l) l.setContentsMargins(0, 0, 0, 0) l.addRow(QLabel(_('Print %s to a PDF file') % elided_text(self.book_title))) self.h = h = QHBoxLayout() self.file_name = f = QLineEdit(self) val = dynamic.get(self.OUTPUT_NAME, None) if not val: val = expanduser('~') else: val = os.path.dirname(val) f.setText(os.path.abspath(os.path.join(val, self.default_file_name))) self.browse_button = b = QToolButton(self) b.setIcon(QIcon(I('document_open.png'))), b.setToolTip(_('Choose location for PDF file')) b.clicked.connect(self.choose_file) h.addWidget(f), h.addWidget(b) f.setMinimumWidth(350) w = QLabel(_('&File:')) l.addRow(w, h), w.setBuddy(f) self.paper_size = ps = PaperSizes(self) ps.initialize() ps.set_value_for_config = vprefs.get('print-to-pdf-page-size', None) l.addRow(_('Paper &size:'), ps) tmap = { 'left':_('&Left margin:'), 'top':_('&Top margin:'), 'right':_('&Right margin:'), 'bottom':_('&Bottom margin:'), } for edge in 'left top right bottom'.split(): m = QDoubleSpinBox(self) m.setSuffix(' ' + _('inches')) m.setMinimum(0), m.setMaximum(3), m.setSingleStep(0.1) val = vprefs.get('print-to-pdf-%s-margin' % edge, 1) m.setValue(val) setattr(self, '%s_margin' % edge, m) l.addRow(tmap[edge], m) self.pnum = pnum = QCheckBox(_('Add page &number to printed pages'), self) pnum.setChecked(vprefs.get('print-to-pdf-page-numbers', True)) l.addRow(pnum) self.show_file = sf = QCheckBox(_('&Open PDF file after printing'), self) sf.setChecked(vprefs.get('print-to-pdf-show-file', True)) l.addRow(sf) vl.addStretch(10) vl.addWidget(self.bb)
def setup_ui(self): self.l = l = QFormLayout(self) self.setLayout(l) self.err_label = QLabel('') self.name_edit = QLineEdit(self) self.name_edit.textChanged.connect(self.verify) self.name_edit.setText(self.candidate) pos = self.candidate.rfind('.') if pos > -1: self.name_edit.setSelection(0, pos) l.addRow(_('File &name:'), self.name_edit) l.addRow(self.err_label) l.addRow(self.bb)
def setup_ui(self): self.l = l = QFormLayout(self) self.setLayout(l) self.la = la = QLabel(ngettext( 'Change the font %s to:', 'Change the fonts %s to:', self.old_family.count(',')+1) % self.old_family) la.setWordWrap(True) l.addRow(la) self._family = f = QLineEdit(self) l.addRow(_('&New font:'), f) f.textChanged.connect(self.updated_family) self.embed_status = e = QLabel('\xa0') l.addRow(e) l.addRow(self.bb)
def __init__(self, parent): QWidget.__init__(self, parent) self.default_template = default_custom_list_template() self.l = l = QFormLayout(self) l.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.AllNonFixedFieldsGrow) self.la = la = QLabel('<p>' + _( 'Here you can create a template to control what data is shown when' ' using the <i>Custom list</i> mode for the book list')) la.setWordWrap(True) l.addRow(la) self.thumbnail = t = QCheckBox(_('Show a cover &thumbnail')) self.thumbnail_height = th = QSpinBox(self) th.setSuffix(' px'), th.setRange(60, 600) self.entry_height = eh = QLineEdit(self) l.addRow(t), l.addRow(_('Thumbnail &height:'), th) l.addRow(_('Entry &height:'), eh) t.stateChanged.connect(self.changed_signal) th.valueChanged.connect(self.changed_signal) eh.textChanged.connect(self.changed_signal) eh.setToolTip(textwrap.fill(_( 'The height for each entry. The special value "auto" causes a height to be calculated' ' based on the number of lines in the template. Otherwise, use a CSS length, such as' ' 100px or 15ex'))) t.stateChanged.connect(self.thumbnail_state_changed) th.setVisible(False) self.comments_fields = cf = QLineEdit(self) l.addRow(_('&Long text fields:'), cf) cf.setToolTip(textwrap.fill(_( 'A comma separated list of fields that will be added at the bottom of every entry.' ' These fields are interpreted as containing HTML, not plain text.'))) cf.textChanged.connect(self.changed_signal) self.la1 = la = QLabel('<p>' + _( 'The template below will be interpreted as HTML and all {{fields}} will be replaced' ' by the actual metadata, if available. For custom columns use the column lookup' ' name, for example: #mytags. You can use {0} as a separator' ' to split a line into multiple columns.').format('|||')) la.setWordWrap(True) l.addRow(la) self.template = t = QPlainTextEdit(self) l.addRow(t) t.textChanged.connect(self.changed_signal) self.imex = bb = QDialogButtonBox(self) b = bb.addButton(_('&Import template'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.import_template) b = bb.addButton(_('E&xport template'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.export_template) l.addRow(bb)
def setup_ui(self): self.l = l = QFormLayout(self) self.setLayout(l) self._name = n = QLineEdit(self) l.addRow(_('&Name of custom theme:'), n) self.base = b = QComboBox(self) b.addItems(sorted(builtin_theme_names())) l.addRow(_('&Builtin theme to base on:'), b) idx = b.findText(tprefs['editor_theme'] or default_theme()) if idx == -1: idx = b.findText(default_theme()) b.setCurrentIndex(idx) l.addRow(self.bb)
def __init__(self, parent=None): BasicSettings.__init__(self, parent) self.l = l = QFormLayout(self) self.setLayout(l) def default_font(which): from qt.webengine import QWebEngineSettings s = QWebEngineSettings.defaultSettings() which = getattr(s, {'serif': 'SerifFont', 'sans': 'SansSerifFont', 'mono': 'FixedFont'}[which]) return s.fontFamily(which) def family_getter(which, w): ans = unicode_type(w.currentFont().family()) if ans == default_font(which): ans = None return ans def family_setter(which, w, val): w.setCurrentFont(QFont(val or default_font(which))) families = {'serif':_('Serif text'), 'sans':_('Sans-serif text'), 'mono':_('Monospaced text')} for fam in sorted(families): text = families[fam] w = QFontComboBox(self) self('engine_preview_%s_family' % fam, widget=w, getter=partial(family_getter, fam), setter=partial(family_setter, fam)) l.addRow(_('Font family for &%s:') % text, w) w = self.choices_widget('preview_standard_font_family', families, 'serif', 'serif') l.addRow(_('Style for standard &text:'), w) w = self('preview_base_font_size') w.setMinimum(8), w.setMaximum(100), w.setSuffix(' px') l.addRow(_('&Default font size:'), w) w = self('preview_mono_font_size') w.setMinimum(8), w.setMaximum(100), w.setSuffix(' px') l.addRow(_('&Monospace font size:'), w) w = self('preview_minimum_font_size') w.setMinimum(4), w.setMaximum(100), w.setSuffix(' px') l.addRow(_('Mi&nimum font size:'), w) w = self('preview_sync_context') w.setMinimum(0), w.setMaximum(10), w.setSuffix(' ' + _('lines')) w.setToolTip('<p>' + _( 'Number of lines that are shown above the current line when syncing the text shown in the preview panel to the cursor position in the code view')) l.addRow(_('Visible lines above s&ync point:'), w) l.addRow(_('Background color:'), self.color_override('preview_background')) l.addRow(_('Foreground color:'), self.color_override('preview_foreground')) l.addRow(_('Link color:'), self.color_override('preview_link_color'))
def __init__(self, tts_client, initial_backend_settings=None, parent=None): QWidget.__init__(self, parent) self.l = l = QFormLayout(self) self.tts_client = tts_client with BusyCursor(): self.voice_data = self.tts_client.get_voice_data() self.default_system_rate = self.tts_client.default_system_rate self.all_sound_outputs = self.tts_client.get_sound_outputs() self.speed = s = QSlider(Qt.Orientation.Horizontal, self) s.setMinimumWidth(200) l.addRow(_('&Speed of speech (words per minute):'), s) s.setRange(self.tts_client.min_rate, self.tts_client.max_rate) s.setSingleStep(1) s.setPageStep(2) self.voices = v = QTableView(self) self.voices_model = VoicesModel(self.voice_data, parent=v) self.proxy_model = p = QSortFilterProxyModel(self) p.setFilterCaseSensitivity(Qt.CaseSensitivity.CaseInsensitive) p.setSourceModel(self.voices_model) v.setModel(p) v.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows) v.setSortingEnabled(True) v.horizontalHeader().resizeSection( 0, QFontMetrics(self.font()).averageCharWidth() * 25) v.horizontalHeader().resizeSection( 1, QFontMetrics(self.font()).averageCharWidth() * 30) v.verticalHeader().close() v.verticalHeader().close() v.setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection) v.sortByColumn(0, Qt.SortOrder.AscendingOrder) l.addRow(v) self.sound_outputs = so = QComboBox(self) so.addItem(_('System default'), '') for x in self.all_sound_outputs: so.addItem(x.get('description') or x['id'], x['id']) l.addRow(_('Sound output:'), so) self.backend_settings = initial_backend_settings or {}
def get_bulk_rename_settings(parent, number, msg=None, sanitize=sanitize_file_name, leading_zeros=True, prefix=None, category='text', allow_spine_order=False): # {{{ d = QDialog(parent) d.setWindowTitle(_('Bulk rename items')) d.l = l = QFormLayout(d) d.setLayout(l) d.prefix = p = QLineEdit(d) default_prefix = {k:v for k, __, v in CATEGORIES}.get(category, _('Chapter-')) previous = tprefs.get('file-list-bulk-rename-prefix', {}) prefix = prefix or previous.get(category, default_prefix) p.setText(prefix) p.selectAll() d.la = la = QLabel(msg or _( 'All selected files will be renamed to the form prefix-number')) l.addRow(la) l.addRow(_('&Prefix:'), p) d.num = num = QSpinBox(d) num.setMinimum(0), num.setValue(1), num.setMaximum(1000) l.addRow(_('Starting &number:'), num) if allow_spine_order: d.spine_order = QCheckBox(_('Rename files according to their book order')) d.spine_order.setToolTip(textwrap.fill(_( 'Rename the selected files according to the order they appear in the book, instead of the order they were selected in.'))) l.addRow(d.spine_order) d.bb = bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel) bb.accepted.connect(d.accept), bb.rejected.connect(d.reject) l.addRow(bb) ans = {'prefix': None, 'start': None} if d.exec() == QDialog.DialogCode.Accepted: prefix = sanitize(str(d.prefix.text())) previous[category] = prefix tprefs.set('file-list-bulk-rename-prefix', previous) num = d.num.value() fmt = '%d' if leading_zeros: largest = num + number - 1 fmt = f'%0{len(str(largest))}d' ans['prefix'] = prefix + fmt ans['start'] = num if allow_spine_order: ans['spine_order'] = d.spine_order.isChecked() return ans
def __init__(self, parent=None): BasicSettings.__init__(self, parent) self.l = l = QFormLayout(self) self.setLayout(l) um = self('update_metadata_from_calibre') um.setText(_('Update &metadata embedded in the book when opening')) um.setToolTip('<p>' + _( 'When the file is opened, update the metadata embedded in the book file to the current metadata' ' in the calibre library.')) l.addRow(um) ask = self('choose_tweak_fmt') ask.setText(_('Ask which &format to edit if more than one format is available for the book')) l.addRow(ask) order = self.order_widget('tweak_fmt_order') order.setToolTip(_('When auto-selecting the format to edit for a book with' ' multiple formats, this is the preference order.')) l.addRow(_('Preferred format order (drag and drop to change)'), order)
def setup_ui(self): self.l = l = QFormLayout(self) self.export_format = ef = QComboBox(self) ef.addItem(_('Plain text'), 'txt') ef.addItem(_('Markdown'), 'md') ef.addItem(*self.file_type_data()) idx = ef.findData(self.prefs[self.pref_name]) if idx > -1: ef.setCurrentIndex(idx) ef.currentIndexChanged.connect(self.save_format_pref) l.addRow(_('Format to export in:'), ef) l.addRow(self.bb) self.bb.clear() self.bb.addButton(QDialogButtonBox.StandardButton.Cancel) b = self.bb.addButton(_('Copy to clipboard'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.copy_to_clipboard) b.setIcon(QIcon(I('edit-copy.png'))) b = self.bb.addButton(_('Save to file'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.save_to_file) b.setIcon(QIcon(I('save.png')))
def __init__(self, username, restriction, parent=None): QDialog.__init__(self, parent) self.setWindowTitle(_('Change library access permissions for {}').format(username)) self.username = username self._items = [] self.l = l = QFormLayout(self) l.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.AllNonFixedFieldsGrow) self.libraries = t = QWidget(self) t.setObjectName('libraries') t.l = QVBoxLayout(self.libraries) self.atype = a = QComboBox(self) a.addItems([_('All libraries'), _('Only the specified libraries'), _('All except the specified libraries')]) self.library_restrictions = restriction['library_restrictions'].copy() if restriction['allowed_library_names']: a.setCurrentIndex(1) self.items = restriction['allowed_library_names'] elif restriction['blocked_library_names']: a.setCurrentIndex(2) self.items = restriction['blocked_library_names'] else: a.setCurrentIndex(0) a.currentIndexChanged.connect(self.atype_changed) l.addRow(_('Allow access to:'), a) self.msg = la = QLabel(self) la.setWordWrap(True) l.addRow(la) self.la = la = QLabel(_('Specify the libraries below:')) la.setWordWrap(True) self.sa = sa = QScrollArea(self) sa.setWidget(t), sa.setWidgetResizable(True) l.addRow(la), l.addRow(sa) self.atype_changed() self.bb = bb = QDialogButtonBox( QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel ) bb.accepted.connect(self.accept), bb.rejected.connect(self.reject) l.addWidget(bb) self.items = self.items
def __init__(self, tts_client, initial_backend_settings=None, parent=None): QWidget.__init__(self, parent) self.l = l = QFormLayout(self) self.tts_client = tts_client self.speed = s = QSlider(Qt.Orientation.Horizontal, self) s.setTickPosition(QSlider.TickPosition.TicksAbove) s.setMinimumWidth(200) l.addRow(_('&Speed of speech:'), s) s.setRange(self.tts_client.min_rate, self.tts_client.max_rate) s.setSingleStep(10) s.setTickInterval((s.maximum() - s.minimum()) // 2) self.output_modules = om = QComboBox(self) with BusyCursor(): self.voice_data = self.tts_client.get_voice_data() self.system_default_output_module = self.tts_client.system_default_output_module om.addItem(_('System default'), self.system_default_output_module) for x in self.voice_data: om.addItem(x, x) l.addRow(_('Speech s&ynthesizer:'), om) self.voices = v = QTableView(self) self.voices_model = VoicesModel(self.voice_data, self.system_default_output_module, parent=v) self.proxy_model = p = QSortFilterProxyModel(self) p.setFilterCaseSensitivity(Qt.CaseSensitivity.CaseInsensitive) p.setSourceModel(self.voices_model) v.setModel(p) v.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows) v.setSortingEnabled(True) h = v.horizontalHeader() h.resizeSection(0, QFontMetrics(self.font()).averageCharWidth() * 30) v.verticalHeader().close() v.setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection) v.sortByColumn(0, Qt.SortOrder.AscendingOrder) om.currentIndexChanged.connect(self.output_module_changed) l.addRow(v) self.backend_settings = initial_backend_settings or {}
def __init__(self, as_dict, parent=None): QWidget.__init__(self, parent) self.changed_signal.connect(parent.changed_signal) self.l = l = QFormLayout(self) self.type_widget = t = QComboBox(self) l.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.ExpandingFieldsGrow) t.addItems([_('Book'), _('Author')]) l.addRow(_('URL type:'), t) self.name_widget = n = QLineEdit(self) n.setClearButtonEnabled(True) l.addRow(_('Name:'), n) self.url_widget = w = QLineEdit(self) w.setClearButtonEnabled(True) l.addRow(_('URL:'), w) if as_dict: self.name = as_dict['name'] self.url = as_dict['url'] self.url_type = as_dict['type'] self.type_widget.currentIndexChanged.connect(self.changed_signal) self.name_widget.textChanged.connect(self.changed_signal) self.url_widget.textChanged.connect(self.changed_signal)
def setup_ui(self): self.splitter = QSplitter(self) self.l = l = QVBoxLayout(self) l.addWidget(self.splitter) l.addWidget(self.bb) self.w = w = QGroupBox(_('Theme Metadata'), self) self.splitter.addWidget(w) l = w.l = QFormLayout(w) l.setFieldGrowthPolicy( QFormLayout.FieldGrowthPolicy.ExpandingFieldsGrow) self.missing_icons_group = mg = QGroupBox(self) self.mising_icons = mi = QListWidget(mg) mi.setSelectionMode(QAbstractItemView.SelectionMode.NoSelection) mg.l = QVBoxLayout(mg) mg.l.addWidget(mi) self.splitter.addWidget(mg) self.title = QLineEdit(self) l.addRow(_('&Title:'), self.title) self.author = QLineEdit(self) l.addRow(_('&Author:'), self.author) self.version = v = QSpinBox(self) v.setMinimum(1), v.setMaximum(1000000) l.addRow(_('&Version:'), v) self.license = lc = QLineEdit(self) l.addRow(_('&License:'), lc) self.url = QLineEdit(self) l.addRow(_('&URL:'), self.url) lc.setText( _('The license for the icons in this theme. Common choices are' ' Creative Commons or Public Domain.')) self.description = QTextEdit(self) l.addRow(self.description) self.refresh_button = rb = self.bb.addButton( _('&Refresh'), QDialogButtonBox.ButtonRole.ActionRole) rb.setIcon(QIcon(I('view-refresh.png'))) rb.clicked.connect(self.refresh) self.apply_report()
def setup_ui(self): self.l = l = QFormLayout(self) l.setFieldGrowthPolicy( QFormLayout.FieldGrowthPolicy.AllNonFixedFieldsGrow) self.setLayout(l) la = self.la = QLabel( _('You can import an HTML or DOCX file directly as an EPUB and edit it. The EPUB' ' will be generated with minimal changes from the source, unlike doing a full' ' conversion in calibre.')) la.setWordWrap(True) l.addRow(la) self.h1 = h1 = QHBoxLayout() self.src = src = QLineEdit(self) src.setPlaceholderText(_('Choose the file to import')) h1.addWidget(src) self.b1 = b = QToolButton(self) b.setIcon(QIcon(I('document_open.png'))) b.setText(_('Choose file')) h1.addWidget(b) l.addRow(_('Source file:'), h1) b.clicked.connect(self.choose_source) b.setFocus(Qt.FocusReason.OtherFocusReason) self.h2 = h1 = QHBoxLayout() self.dest = src = QLineEdit(self) src.setPlaceholderText( _('Choose the location for the newly created EPUB')) h1.addWidget(src) self.b2 = b = QToolButton(self) b.setIcon(QIcon(I('document_open.png'))) b.setText(_('Choose file')) h1.addWidget(b) l.addRow(_('Destination file:'), h1) b.clicked.connect(self.choose_destination) l.addRow(self.bb)