def __init__(self, calibre_version, plugin_updates, parent=None): QDialog.__init__(self, parent) self.setAttribute(Qt.WidgetAttribute.WA_QuitOnClose, False) self.resize(400, 250) self.l = QGridLayout() self.setLayout(self.l) self.logo = QLabel() self.logo.setMaximumWidth(110) self.logo.setPixmap(QIcon(I('lt.png')).pixmap(100, 100)) ver = calibre_version if ver.endswith('.0'): ver = ver[:-2] self.label = QLabel( '<p>' + _('New version <b>{ver}</b> of {app} is available for download. ' 'See the <a href="{url}">new features</a>.').format( url=localize_website_link( 'https://calibre-ebook.com/whats-new'), app=__appname__, ver=ver)) self.label.setOpenExternalLinks(True) self.label.setWordWrap(True) self.setWindowTitle(_('Update available!')) self.setWindowIcon(QIcon(I('lt.png'))) self.l.addWidget(self.logo, 0, 0) self.l.addWidget(self.label, 0, 1) self.cb = QCheckBox(_('Show this notification for future updates'), self) self.l.addWidget(self.cb, 1, 0, 1, -1) self.cb.setChecked(config.get('new_version_notification')) self.cb.stateChanged.connect(self.show_future) self.bb = QDialogButtonBox(self) b = self.bb.addButton(_('&Get update'), QDialogButtonBox.ButtonRole.AcceptRole) b.setDefault(True) b.setIcon(QIcon(I('arrow-down.png'))) if plugin_updates > 0: b = self.bb.addButton(_('Update &plugins'), QDialogButtonBox.ButtonRole.ActionRole) b.setIcon(QIcon(I('plugins/plugin_updater.png'))) b.clicked.connect(self.get_plugins, type=Qt.ConnectionType.QueuedConnection) self.bb.addButton(QDialogButtonBox.StandardButton.Cancel) self.l.addWidget(self.bb, 2, 0, 1, -1) self.bb.accepted.connect(self.accept) self.bb.rejected.connect(self.reject) save_version_notified(calibre_version)
def __init__(self, current_cover=None, parent=None): QDialog.__init__(self, parent) self.current_cover = current_cover self.log = Log() self.book = self.cover_pixmap = None self.setWindowTitle(_('Downloading metadata...')) self.setWindowIcon(QIcon(I('download-metadata.png'))) self.stack = QStackedWidget() self.l = l = QVBoxLayout() self.setLayout(l) l.addWidget(self.stack) self.bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Cancel|QDialogButtonBox.StandardButton.Ok) self.h = h = QHBoxLayout() l.addLayout(h) self.bb.rejected.connect(self.reject) self.bb.accepted.connect(self.accept) self.ok_button = self.bb.button(QDialogButtonBox.StandardButton.Ok) self.ok_button.setEnabled(False) self.ok_button.clicked.connect(self.ok_clicked) self.prev_button = pb = QPushButton(QIcon(I('back.png')), _('&Back'), self) pb.clicked.connect(self.back_clicked) pb.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed) self.log_button = self.bb.addButton(_('&View log'), QDialogButtonBox.ButtonRole.ActionRole) self.log_button.clicked.connect(self.view_log) self.log_button.setIcon(QIcon(I('debug.png'))) self.prev_button.setVisible(False) h.addWidget(self.prev_button), h.addWidget(self.bb) self.identify_widget = IdentifyWidget(self.log, self) self.identify_widget.rejected.connect(self.reject) self.identify_widget.results_found.connect(self.identify_results_found) self.identify_widget.book_selected.connect(self.book_selected) self.stack.addWidget(self.identify_widget) self.covers_widget = CoversWidget(self.log, self.current_cover, parent=self) self.covers_widget.chosen.connect(self.ok_clicked) self.stack.addWidget(self.covers_widget) self.resize(850, 600) geom = gprefs.get('metadata_single_gui_geom', None) if geom is not None and geom: QApplication.instance().safe_restore_geometry(self, geom) self.finished.connect(self.cleanup)
def __init__(self, parent=None): QDialog.__init__(self, parent) self._layout = l = QGridLayout(self) self.setLayout(l) self.setWindowIcon(QIcon(I('mail.png'))) self.setWindowTitle(_('Select recipients')) self.recipients = r = QListWidget(self) l.addWidget(r, 0, 0, 1, -1) self.la = la = QLabel(_('Add a new recipient:')) la.setStyleSheet('QLabel { font-weight: bold }') l.addWidget(la, l.rowCount(), 0, 1, -1) self.labels = tuple( map(QLabel, (_('&Address'), _('A&lias'), _('&Formats'), _('&Subject')))) tooltips = ( _('The email address of the recipient'), _('The optional alias (simple name) of the recipient'), _('Formats to email. The first matching one will be sent (comma separated list)' ), _('The optional subject for email sent to this recipient')) for i, name in enumerate(('address', 'alias', 'formats', 'subject')): c = i % 2 row = l.rowCount() - c self.labels[i].setText(str(self.labels[i].text()) + ':') l.addWidget(self.labels[i], row, (2 * c)) le = QLineEdit(self) le.setToolTip(tooltips[i]) setattr(self, name, le) self.labels[i].setBuddy(le) l.addWidget(le, row, (2 * c) + 1) self.formats.setText(prefs['output_format'].upper()) self.add_button = b = QPushButton(QIcon(I('plus.png')), _('&Add recipient'), self) b.clicked.connect(self.add_recipient) l.addWidget(b, l.rowCount(), 0, 1, -1) self.bb = bb = QDialogButtonBox( QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel) l.addWidget(bb, l.rowCount(), 0, 1, -1) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) self.setMinimumWidth(500) self.setMinimumHeight(400) self.resize(self.sizeHint()) self.init_list()
def __init__(self, window, name, msg): QDialog.__init__(self, window) Ui_Dialog.__init__(self) self.setupUi(self) self.cfg_key = re.sub(r'[^0-9a-zA-Z]', '_', name) un = dynamic[self.cfg_key + '__un'] pw = dynamic[self.cfg_key + '__pw'] if not un: un = '' if not pw: pw = '' self.gui_username.setText(un) self.gui_password.setText(pw) self.sname = name self.msg.setText(msg) self.show_password.stateChanged[(int)].connect(self.toggle_password)
def __init__(self, parent): QDialog.__init__(self, parent) self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose, False) self.queue = [] self.do_pop.connect(self.pop, type=Qt.ConnectionType.QueuedConnection) self._layout = l = QGridLayout() self.setLayout(l) self.icon = QIcon(I('dialog_error.png')) self.setWindowIcon(self.icon) self.icon_widget = Icon(self) self.icon_widget.set_icon(self.icon) self.msg_label = QLabel('<p> ') self.msg_label.setStyleSheet('QLabel { margin-top: 1ex; }') self.msg_label.setWordWrap(True) self.msg_label.setTextFormat(Qt.TextFormat.RichText) self.det_msg = QPlainTextEdit(self) self.det_msg.setVisible(False) self.bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Close, parent=self) self.bb.accepted.connect(self.accept) self.bb.rejected.connect(self.reject) self.ctc_button = self.bb.addButton(_('&Copy to clipboard'), QDialogButtonBox.ButtonRole.ActionRole) self.ctc_button.clicked.connect(self.copy_to_clipboard) self.retry_button = self.bb.addButton(_('&Retry'), QDialogButtonBox.ButtonRole.ActionRole) self.retry_button.clicked.connect(self.retry) self.retry_func = None self.show_det_msg = _('Show &details') self.hide_det_msg = _('Hide &details') self.det_msg_toggle = self.bb.addButton(self.show_det_msg, QDialogButtonBox.ButtonRole.ActionRole) self.det_msg_toggle.clicked.connect(self.toggle_det_msg) self.det_msg_toggle.setToolTip( _('Show detailed information about this error')) self.suppress = QCheckBox(self) l.addWidget(self.icon_widget, 0, 0, 1, 1) l.addWidget(self.msg_label, 0, 1, 1, 1) l.addWidget(self.det_msg, 1, 0, 1, 2) l.addWidget(self.suppress, 2, 0, 1, 2, Qt.AlignmentFlag.AlignLeft|Qt.AlignmentFlag.AlignBottom) l.addWidget(self.bb, 3, 0, 1, 2, Qt.AlignmentFlag.AlignRight|Qt.AlignmentFlag.AlignBottom) l.setColumnStretch(1, 100) self.setModal(False) self.suppress.setVisible(False) self.do_resize()
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, gui, cover_flow): QDialog.__init__(self, gui) self._layout = QStackedLayout() self.setLayout(self._layout) self.setWindowTitle(_('Browse by covers')) self.layout().addWidget(cover_flow) geom = gprefs.get('cover_browser_dialog_geometry', None) if not geom or not QApplication.instance().safe_restore_geometry( self, geom): h, w = available_height() - 60, int(available_width() / 1.5) self.resize(w, h) self.action_fs_toggle = a = QAction(self) self.addAction(a) a.setShortcuts([QKeySequence(QKeySequence.StandardKey.FullScreen)]) a.triggered.connect(self.toggle_fullscreen) self.action_esc_fs = a = QAction(self) a.triggered.connect(self.show_normal) self.addAction(a) a.setShortcuts( [QKeySequence('Esc', QKeySequence.SequenceFormat.PortableText)]) self.pre_fs_geom = None cover_flow.setFocus(Qt.FocusReason.OtherFocusReason) self.view_action = a = QAction(self) iactions = gui.iactions self.addAction(a) a.setShortcuts( list(iactions['View'].menuless_qaction.shortcuts()) + [QKeySequence(Qt.Key.Key_Space)]) a.triggered.connect(iactions['View'].menuless_qaction.trigger) self.auto_scroll_action = a = QAction(self) a.setShortcuts( list(iactions['Autoscroll Books'].menuless_qaction.shortcuts())) self.addAction(a) a.triggered.connect( iactions['Autoscroll Books'].menuless_qaction.trigger) self.sd_action = a = QAction(self) self.addAction(a) a.setShortcuts( list(iactions['Send To Device'].menuless_qaction.shortcuts())) a.triggered.connect( iactions['Send To Device'].menuless_qaction.trigger)
def __init__(self, all_authors, current_authors, parent=None): QDialog.__init__(self, parent) self.l = l = QGridLayout() self.setLayout(l) self.setWindowTitle(_('Edit authors')) self.la = QLabel( _('Edit the authors for this book. You can drag and drop to re-arrange authors' )) self.la.setWordWrap(True) l.addWidget(self.la, 0, 0, 1, 3) self.al = al = List(all_authors, self) al.addItems(current_authors) l.addWidget(al, 1, 0, 1, 3) self.author = a = Edit(self) init_line_edit(a, all_authors) a.lineEdit().setPlaceholderText(_('Enter an author to add')) a.returnPressed.connect(self.add_author) l.addWidget(a, 2, 0) self.ab = b = QPushButton(_('&Add')) b.setIcon(QIcon(I('plus.png'))) l.addWidget(b, 2, 1) b.clicked.connect(self.add_author) self.db = b = QPushButton(_('&Remove selected')) l.addWidget(b, 2, 2) b.setIcon(QIcon(I('minus.png'))) b.clicked.connect(self.al.delete_selected) self.bb = bb = QDialogButtonBox( QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) l.addWidget(bb, 3, 0, 1, 3) l.setColumnStretch(0, 10) self.resize(self.sizeHint() + QSize(150, 100)) geom = gprefs.get('authors-edit-geometry', None) if geom is not None: QApplication.instance().safe_restore_geometry(self, geom) self.author.setFocus(Qt.FocusReason.OtherFocusReason)
def __init__(self, msg, parent=None, window_title=_('Working')): QDialog.__init__(self, parent) self._layout = QVBoxLayout() self.setLayout(self._layout) self.msg = QLabel(msg) # self.msg.setWordWrap(True) self.font = QFont() self.font.setPointSize(self.font.pointSize() + 8) self.msg.setFont(self.font) self.pi = ProgressIndicator(self) self.pi.setDisplaySize(QSize(100, 100)) self._layout.addWidget(self.pi, 0, Qt.AlignmentFlag.AlignHCenter) self._layout.addSpacing(15) self._layout.addWidget(self.msg, 0, Qt.AlignmentFlag.AlignHCenter) self.start() self.setWindowTitle(window_title) self.resize(self.sizeHint())
def __init__(self, gui): QDialog.__init__(self, gui) self.l = l = QVBoxLayout(self) self.msg = QLabel('') self.msg.setWordWrap(True) l.addWidget(self.msg) self.bb = bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Close) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) b = bb.addButton(_('Queue &all books for backup'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.mark_all_dirty) b.setIcon(QIcon(I('lt.png'))) l.addWidget(bb) self.db = weakref.ref(gui.current_db) self.setResult(9) self.setWindowTitle(_('Backup status')) self.update() self.resize(self.sizeHint() + QSize(50, 15))
def __init__(self, parent, db, preferred_output_format=None, has_saved_settings=True, book_ids=()): QDialog.__init__(self, parent) self.widgets = [] self.setupUi() try: self.num_of_books = len(book_ids) except Exception: self.num_of_books = 1 self.setup_output_formats(db, preferred_output_format) self.db = db self.setup_pipeline() self.input_label.hide() self.input_formats.hide() self.opt_individual_saved_settings.setVisible(True) self.opt_individual_saved_settings.setChecked(True) self.opt_individual_saved_settings.setToolTip(_('For ' 'settings that cannot be specified in this dialog, use the ' 'values saved in a previous conversion (if they exist) instead ' 'of using the defaults specified in the Preferences')) self.output_formats.currentIndexChanged[native_string_type].connect(self.setup_pipeline) self.groups.setSpacing(5) self.groups.activated[(QModelIndex)].connect(self.show_pane) self.groups.clicked[(QModelIndex)].connect(self.show_pane) self.groups.entered[(QModelIndex)].connect(self.show_group_help) rb = self.buttonBox.button(QDialogButtonBox.StandardButton.RestoreDefaults) rb.setVisible(False) self.groups.setMouseTracking(True) if not has_saved_settings: o = self.opt_individual_saved_settings o.setEnabled(False) o.setToolTip(_('None of the selected books have saved conversion ' 'settings.')) o.setChecked(False) geom = gprefs.get('convert_bulk_dialog_geom', None) if geom: QApplication.instance().safe_restore_geometry(self, geom) else: self.resize(self.sizeHint())
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 __init__(self, title, name, parent=None, prefs=gprefs): QDialog.__init__(self, parent) self.prefs_for_persistence = prefs self.setWindowTitle(title) self.name = name self.bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel) self.bb.accepted.connect(self.accept) self.bb.rejected.connect(self.reject) self.setup_ui() self.resize(self.sizeHint()) geom = self.prefs_for_persistence.get(name + '-geometry', None) if geom is not None: QApplication.instance().safe_restore_geometry(self, geom) if hasattr(self, 'splitter'): state = self.prefs_for_persistence.get(name + '-splitter-state', None) if state is not None: self.splitter.restoreState(state)
def __init__(self, parent, db): QDialog.__init__(self, parent) self.l = QVBoxLayout() self.setLayout(self.l) self.l1 = QLabel( _('Vacuuming database to improve performance.') + ' ' + _('This will take a while, please wait...')) self.setWindowTitle(_('Vacuuming...')) self.l1.setWordWrap(True) self.l.addWidget(self.l1) self.msg = QLabel('') self.update_msg.connect(self.msg.setText, type=Qt.ConnectionType.QueuedConnection) self.l.addWidget(self.msg) self.msg.setWordWrap(True) self.resize(self.sizeHint() + QSize(100, 50)) self.error = None self.db = db.new_api self.rejected = False
def __init__(self, dev, ignored_folders=None, parent=None): QDialog.__init__(self, parent) self.l = l = QVBoxLayout() self.setLayout(l) self.la = la = QLabel('<p>' + _('<b>Scanned folders:</b>') + ' ' + _('You can select which folders calibre will ' 'scan when searching this device for books.')) la.setWordWrap(True) l.addWidget(la) self.tabs = QTabWidget(self) l.addWidget(self.tabs) self.widgets = [] for storage in dev.filesystem_cache.entries: self.dev = dev w = Storage(storage, item_func=self.create_item) del self.dev self.tabs.addTab(w, storage.name) self.widgets.append(w) w.itemChanged.connect(self.item_changed) self.la2 = la = QLabel( _('If you a select a previously unselected folder, any sub-folders' ' will not be visible until you restart calibre.')) l.addWidget(la) la.setWordWrap(True) self.bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel) self.bb.accepted.connect(self.accept) self.bb.rejected.connect(self.reject) self.sab = self.bb.addButton(_('Select &all'), QDialogButtonBox.ButtonRole.ActionRole) self.sab.clicked.connect(self.select_all) self.snb = self.bb.addButton(_('Select &none'), QDialogButtonBox.ButtonRole.ActionRole) self.snb.clicked.connect(self.select_none) l.addWidget(self.bb) self.setWindowTitle(_('Choose folders to scan')) self.setWindowIcon(QIcon(I('devices/tablet.png'))) self.resize(600, 500)
def __init__(self, parent): QDialog.__init__(self, parent) self.setupUi(self) try: self.sh_label.setText(self.sh_label.text() % localize_user_manual_link( 'https://manual.calibre-ebook.com/gui.html#the-search-interface')) except TypeError: pass # link already localized self.buttonBox.accepted.connect(self.advanced_search_button_pushed) self.tab_2_button_box.accepted.connect(self.accept) self.tab_2_button_box.rejected.connect(self.reject) self.clear_button.clicked.connect(self.clear_button_pushed) self.advanced_clear_button.clicked.connect(self.clear_advanced) self.adv_search_used = False self.mc = '' self.tabWidget.setCurrentIndex(0) self.tabWidget.currentChanged[int].connect(self.tab_changed) self.tab_changed(0)
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, parent, items): QDialog.__init__(self, parent) Ui_DeleteMatchingFromDeviceDialog.__init__(self) self.setupUi(self) self.explanation.setText('<p>'+_('All checked books will be ' '<b>permanently deleted</b> from your ' 'device. Please verify the list.')+'</p>') self.buttonBox.accepted.connect(self.accepted) self.buttonBox.rejected.connect(self.rejected) self.table.cellClicked.connect(self.cell_clicked) self.table.setSelectionMode(QAbstractItemView.SelectionMode.NoSelection) self.table.setColumnCount(7) self.table.setHorizontalHeaderLabels( ['', _('Location'), _('Title'), _('Author'), _('Date'), _('Format'), _('Path')]) rows = 0 for card in items: rows += len(items[card][1]) self.table.setRowCount(rows) row = 0 for card in items: (model,books) = items[card] for (id,book) in books: item = QTableWidgetItem() item.setFlags(Qt.ItemFlag.ItemIsUserCheckable|Qt.ItemFlag.ItemIsEnabled) item.setCheckState(Qt.CheckState.Checked) item.setData(Qt.ItemDataRole.UserRole, (model, id, book.path)) self.table.setItem(row, 0, item) self.table.setItem(row, 1, tableItem(card)) self.table.setItem(row, 2, titleTableItem(book.title)) self.table.setItem(row, 3, authorTableItem(book)) self.table.setItem(row, 4, dateTableItem(book.datetime)) self.table.setItem(row, 5, centeredTableItem(book.path.rpartition('.')[2])) self.table.setItem(row, 6, tableItem(book.path)) row += 1 self.table.setCurrentCell(0, 1) self.table.resizeColumnsToContents() self.table.setSortingEnabled(True) self.table.sortByColumn(2, Qt.SortOrder.AscendingOrder) self.table.setCurrentCell(0, 1)
def __init__(self, parent, prefs): QDialog.__init__(self, parent) self.prefs = prefs self.setWindowTitle(_('Create ToC from XPath')) self.l = l = QVBoxLayout() self.setLayout(l) self.la = la = QLabel( _('Specify a series of XPath expressions for the different levels of' ' the Table of Contents. You can use the wizard buttons to help' ' you create XPath expressions.')) la.setWordWrap(True) l.addWidget(la) self.widgets = [] for i in range(5): la = _('Level %s ToC:') % ('&%d' % (i + 1)) xp = XPathEdit(self) xp.set_msg(la) self.widgets.append(xp) l.addWidget(xp) self.bb = bb = QDialogButtonBox( QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) self.ssb = b = bb.addButton(_('&Save settings'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.save_settings) self.load_button = b = bb.addButton( _('&Load settings'), QDialogButtonBox.ButtonRole.ActionRole) self.load_menu = QMenu(b) b.setMenu(self.load_menu) self.setup_load_button() self.remove_duplicates_cb = QCheckBox( _('Do not add duplicate entries at the same level')) self.remove_duplicates_cb.setChecked( self.prefs.get('xpath_toc_remove_duplicates', True)) l.addWidget(self.remove_duplicates_cb) l.addStretch() l.addWidget(bb) self.resize(self.sizeHint() + QSize(50, 75))
def __init__(self, window, msg, formats, show_open_with=False): QDialog.__init__(self, window) self.resize(507, 377) self.setWindowIcon(QIcon(I("mimetypes/unknown.png"))) self.setWindowTitle(_('Choose format')) self.l = l = QVBoxLayout(self) self.msg = QLabel(msg) l.addWidget(self.msg) self.formats = QListWidget(self) self.formats.setIconSize(QSize(64, 64)) self.formats.activated[QModelIndex].connect(self.activated_slot) l.addWidget(self.formats) self.h = h = QHBoxLayout() h.setContentsMargins(0, 0, 0, 0) l.addLayout(h) if show_open_with: self.owb = QPushButton(_('&Open with...'), self) self.formats.currentRowChanged.connect( self.update_open_with_button) h.addWidget(self.owb) self.own = QMenu(self.owb.text()) self.owb.setMenu(self.own) self.own.aboutToShow.connect(self.populate_open_with) self.buttonBox = bb = QDialogButtonBox(self) bb.setStandardButtons(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel) bb.accepted.connect(self.accept), bb.rejected.connect(self.reject) h.addStretch(10), h.addWidget(self.buttonBox) formats = list(formats) for format in formats: self.formats.addItem( QListWidgetItem( file_icon_provider().icon_from_ext(format.lower()), format.upper())) self._formats = formats self.formats.setCurrentRow(0) self._format = self.open_with_format = None if show_open_with: self.populate_open_with() self.update_open_with_button()
def __init__(self, mi=None, prefs=None, parent=None): QDialog.__init__(self, parent) self.setWindowTitle(_('Cover generation settings')) self.l = l = QVBoxLayout(self) self.setLayout(l) self.settings = CoverSettingsWidget(mi=mi, prefs=prefs, parent=self) l.addWidget(self.settings) self.save_settings = ss = QCheckBox( _('Save these settings as the &defaults for future use')) ss.setChecked( gprefs.get('cover_generation_save_settings_for_future', True)) l.addWidget(ss) self.bb = bb = QDialogButtonBox( QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel) l.addWidget(bb) bb.accepted.connect(self.accept), bb.rejected.connect(self.reject) bb.b = b = bb.addButton(_('Restore &defaults'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.restore_defaults) bb.ld = b = bb.addButton(_('&Save'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.export_settings) b.setToolTip( _('Save the current cover generation settings for later re-use')) bb.sd = b = bb.addButton(_('&Load'), QDialogButtonBox.ButtonRole.ActionRole) self.load_menu = QMenu(b) self.load_menu.aboutToShow.connect(self.populate_load_menu) b.setMenu(self.load_menu) b.setToolTip(_('Load previously saved cover generation settings')) ss.setToolTip('<p>' + _( 'Save the current settings as the settings to use always instead of just this time. Remember that' ' for styles and colors the actual style or color used is chosen at random from' ' the list of checked styles/colors.')) self.resize(self.sizeHint()) geom = gprefs.get('cover_settings_dialog_geom', None) if geom is not None: QApplication.instance().safe_restore_geometry(self, geom) self.prefs_for_rendering = None
def __init__(self, parent, text, column_name=None): QDialog.__init__(self, parent) Ui_CommentsDialog.__init__(self) self.setupUi(self) # Remove help icon on title bar icon = self.windowIcon() self.setWindowFlags(self.windowFlags()&(~Qt.WindowType.WindowContextHelpButtonHint)) self.setWindowIcon(icon) self.textbox.html = comments_to_html(text) if text else '' self.textbox.wyswyg_dirtied() # self.textbox.setTabChangesFocus(True) self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setText(_('O&K')) self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setText(_('&Cancel')) if column_name: self.setWindowTitle(_('Edit "{0}"').format(column_name)) geom = gprefs.get('comments_dialog_geom', None) if geom is not None: QApplication.instance().safe_restore_geometry(self, geom)
def __init__(self, raw, parent=None): QDialog.__init__(self, parent) self.setWindowTitle(_('Plugin tweaks')) self.edit = QPlainTextEdit(self) self.highlighter = PythonHighlighter(self.edit.document()) self.l = QVBoxLayout() self.setLayout(self.l) self.msg = QLabel( _('Add/edit tweaks for any custom plugins you have installed. ' 'Documentation for these tweaks should be available ' 'on the website from where you downloaded the plugins.')) self.msg.setWordWrap(True) self.l.addWidget(self.msg) self.l.addWidget(self.edit) self.edit.setPlainText(raw) self.bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok|QDialogButtonBox.StandardButton.Cancel, Qt.Orientation.Horizontal, self) self.bb.accepted.connect(self.accept) self.bb.rejected.connect(self.reject) self.l.addWidget(self.bb) self.resize(550, 300)
def __init__(self, pdfpath, parent=None): QDialog.__init__(self, parent) self.pdfpath = pdfpath self.stack = WaitLayout(_('Rendering PDF pages, please wait...'), parent=self) self.container = self.stack.after self.container.l = l = QVBoxLayout(self.container) self.la = la = QLabel( _('Choose a cover from the list of PDF pages below')) l.addWidget(la) self.covers = c = QListWidget(self) l.addWidget(c) self.item_delegate = CoverDelegate(self) c.setItemDelegate(self.item_delegate) c.setIconSize(QSize(120, 160)) c.setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection) c.setViewMode(QListView.ViewMode.IconMode) c.setUniformItemSizes(True) c.setResizeMode(QListView.ResizeMode.Adjust) c.itemDoubleClicked.connect(self.accept, type=Qt.ConnectionType.QueuedConnection) self.bb = bb = QDialogButtonBox( QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) self.more_pages = b = bb.addButton( _('&More pages'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.start_rendering) l.addWidget(bb) self.rendering_done.connect(self.show_pages, type=Qt.ConnectionType.QueuedConnection) self.first = 1 self.setWindowTitle(_('Choose cover from PDF')) self.setWindowIcon(file_icon_provider().icon_from_ext('pdf')) self.resize(QSize(800, 600)) self.tdir = PersistentTemporaryDirectory('_pdf_covers') self.start_rendering()
def __init__(self, fmt_count, msg, single=False, parent=None, exclude=False): QDialog.__init__(self, parent) self._l = QVBoxLayout(self) self.single_fmt = single self.setLayout(self._l) self.setWindowTitle(_('Choose formats')) self._m = QLabel(msg) self._m.setWordWrap(True) self._l.addWidget(self._m) self.formats = Formats(fmt_count) self.fview = QListView(self) self.fview.doubleClicked.connect( self.double_clicked, type=Qt.ConnectionType.QueuedConnection) if exclude: if QApplication.instance().is_dark_theme: sheet = 'background-color: #DAA520; color: black' else: sheet = 'background-color: #fae7b5' self.fview.setStyleSheet('QListView { %s }' % sheet) self._l.addWidget(self.fview) self.fview.setModel(self.formats) self.fview.setSelectionMode( QAbstractItemView.SelectionMode.SingleSelection if single else QAbstractItemView.SelectionMode.MultiSelection) self.bbox = \ QDialogButtonBox(QDialogButtonBox.StandardButton.Ok|QDialogButtonBox.StandardButton.Cancel, Qt.Orientation.Horizontal, self) self._l.addWidget(self.bbox) self.bbox.accepted.connect(self.accept) self.bbox.rejected.connect(self.reject) self.fview.setIconSize(QSize(48, 48)) self.fview.setSpacing(2) self.resize(350, 500) self.selected_formats = set()
def __init__(self, parent, plugin, locations): QDialog.__init__(self, parent) self.locations = locations self.setWindowTitle(_('Add "%s" to toolbars or menus') % plugin.name) self._layout = QVBoxLayout(self) self.setLayout(self._layout) self._header_label = QLabel( _('Select the toolbars and/or menus to add <b>%s</b> to:') % plugin.name) self._layout.addWidget(self._header_label) self._locations_list = QListWidget(self) self._locations_list.setSelectionMode( QAbstractItemView.SelectionMode.MultiSelection) sizePolicy = QSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) self._locations_list.setSizePolicy(sizePolicy) for key, text in locations: self._locations_list.addItem(text) if key in {'toolbar', 'toolbar-device'}: self._locations_list.item(self._locations_list.count() - 1).setSelected(True) self._layout.addWidget(self._locations_list) self._footer_label = QLabel( _('You can also customise the plugin locations ' 'using <b>Preferences -> Interface -> Toolbars</b>')) self._layout.addWidget(self._footer_label) button_box = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel) button_box.accepted.connect(self.accept) button_box.rejected.connect(self.reject) self._layout.addWidget(button_box) self.resize(self.sizeHint())
def __init__(self, parent, duplicates, loc): QDialog.__init__(self, parent) l = QVBoxLayout() self.setLayout(l) self.la = la = QLabel( _('Books with the same, title, author and language as the following already exist in the library %s.' ' Select which books you want copied anyway.') % os.path.basename(loc)) la.setWordWrap(True) l.addWidget(la) self.setWindowTitle(_('Duplicate books')) self.books = QListWidget(self) self.items = [] for book_id, (title, authors) in iteritems(duplicates): i = QListWidgetItem( _('{0} by {1}').format(title, ' & '.join(authors[:3])), self.books) i.setData(Qt.ItemDataRole.UserRole, book_id) i.setFlags(Qt.ItemFlag.ItemIsUserCheckable | Qt.ItemFlag.ItemIsEnabled) i.setCheckState(Qt.CheckState.Checked) self.items.append(i) l.addWidget(self.books) self.bb = bb = QDialogButtonBox( QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) self.a = b = bb.addButton(_('Select &all'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.select_all), b.setIcon(QIcon(I('plus.png'))) self.n = b = bb.addButton(_('Select &none'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.select_none), b.setIcon(QIcon(I('minus.png'))) self.ctc = b = bb.addButton(_('&Copy to clipboard'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.copy_to_clipboard), b.setIcon( QIcon(I('edit-copy.png'))) l.addWidget(bb) self.resize(600, 400)
def __init__(self, plugin, *args): QDialog.__init__(self, *args) self.setupUi(self) self.plugin = plugin self.search_query.initialize('store_mobileread_search') self.search_query.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon) self.search_query.setMinimumContentsLength(25) self.adv_search_button.setIcon(QIcon(I('search.png'))) self._model = BooksModel(self.plugin.get_book_list()) self.results_view.setModel(self._model) self.total.setText('%s' % self.results_view.model().rowCount()) self.search_button.clicked.connect(self.do_search) self.adv_search_button.clicked.connect(self.build_adv_search) self.results_view.activated.connect(self.open_store) self.results_view.model().total_changed.connect(self.update_book_total) self.finished.connect(self.dialog_closed) self.restore_state()
def __init__(self, parent=None, base_font_size=0.0, font_key=None): QDialog.__init__(self, parent) self.setupUi(self) try: self.wh_label.setText(self.wh_label.text( ) % localize_user_manual_link( 'https://manual.calibre-ebook.com/conversion.html#font-size-rescaling' )) except TypeError: pass # link already localized self.default_font_key = font_key self.default_base_font_size = base_font_size self.buttonBox.clicked.connect(self.button_clicked) self.button_use_default.clicked.connect(self.use_default) for x in ('input_base_font_size', 'input_font_size', 'output_base_font_size'): getattr(self, x).valueChanged.connect(self.calculate) self.font_size_key.textChanged.connect(self.calculate) self.initialize()
def __init__(self, parent=None): QDialog.__init__(self, parent) self._layout = QVBoxLayout(self) self.setLayout(self._layout) self.log = QPlainTextEdit(self) self._layout.addWidget(self.log) self.log.setPlainText(_('Getting device information') + '...') self.copy = QPushButton(_('Copy to &clipboard')) self.copy.setDefault(True) self.setWindowTitle(_('User-defined device information')) self.setWindowIcon(QIcon(I('debug.png'))) self.copy.clicked.connect(self.copy_to_clipboard) self.ok = QPushButton('&OK') self.ok.setAutoDefault(False) self.ok.clicked.connect(self.accept) self.bbox = QDialogButtonBox(self) self.bbox.addButton(self.copy, QDialogButtonBox.ButtonRole.ActionRole) self.bbox.addButton(self.ok, QDialogButtonBox.ButtonRole.AcceptRole) self._layout.addWidget(self.bbox) self.resize(750, 500) self.bbox.setEnabled(False) QTimer.singleShot(1000, self.device_info)