def __init__(self, old_family, embedded_families, parent=None): self.old_family = old_family self.local_families = {icu_lower(f) for f in font_scanner.find_font_families()} | { icu_lower(f) for f in embedded_families} Dialog.__init__(self, _('Change font'), 'change-font-family', parent=parent) self.setMinimumWidth(300) self.resize(self.sizeHint())
def accept(self): searches = tprefs['saved_searches'] all_names = {x['name'] for x in searches} - {self.original_name} n = unicode(self.search_name.text()).strip() search = self.search if not n: return error_dialog(self, _('Must specify name'), _( 'You must specify a search name'), show=True) if n in all_names: return error_dialog(self, _('Name exists'), _( 'Another search with the name %s already exists') % n, show=True) search['name'] = n f = unicode(self.find.text()) if not f: return error_dialog(self, _('Must specify find'), _( 'You must specify a find expression'), show=True) search['find'] = f r = unicode(self.replace.text()) search['replace'] = r search['dot_all'] = bool(self.dot_all.isChecked()) search['case_sensitive'] = bool(self.case_sensitive.isChecked()) search['mode'] = self.mode_box.mode if self.search_index == -1: searches.append(search) else: searches[self.search_index] = search tprefs.set('saved_searches', searches) Dialog.accept(self)
def __init__(self, revert_button_msg=None, parent=None, show_open_in_editor=False): self.context = 3 self.beautify = False self.apply_diff_calls = [] self.show_open_in_editor = show_open_in_editor self.revert_button_msg = revert_button_msg Dialog.__init__(self, _('Differences between books'), 'diff-dialog', parent=parent) self.view.line_activated.connect(self.line_activated)
def __init__(self, parent=None): self.resources_replaced = False self.show_diff = False Dialog.__init__(self, _('Download external resources'), 'download-external-resources', parent) self.state = 0 self.get_done.connect(self._get_done) self.download_done.connect(self._download_done) self.replace_done.connect(self._replace_done) self.progress.connect(self.download_status.progress, type=Qt.QueuedConnection)
def __init__(self, names=None, jpeg_quality=None, parent=None): self.names, self.jpeg_quality = names, jpeg_quality self.keep_going = True self.result = (None, '') Dialog.__init__(self, _('Compressing Images...'), 'compress-images-progress', parent=parent) self.gui_loop.connect(self.update_progress, type=Qt.QueuedConnection) self.cidone.connect(self.accept, type=Qt.QueuedConnection) t = Thread(name='RunCompressImages', target=self.run_compress) t.daemon = True t.start()
def __init__(self, search=None, search_index=-1, parent=None, state=None): self.search = search or {} self.original_name = self.search.get('name', None) self.search_index = search_index Dialog.__init__(self, _('Edit search'), 'edit-saved-search', parent=parent) if state is not None: self.find.setText(state['find']) self.replace.setText(state['replace']) self.case_sensitive.setChecked(state['case_sensitive']) self.dot_all.setChecked(state['dot_all'])
def __init__(self, parent=None, for_browsing=False): self.for_browsing = for_browsing Dialog.__init__( self, _("Images in book") if for_browsing else _("Choose an image"), "browse-image-dialog" if for_browsing else "insert-image-dialog", parent, ) self.chosen_image = None self.chosen_image_is_external = False
def __init__(self, revert_button_msg=None, parent=None, show_open_in_editor=False, show_as_window=False): self.context = 3 self.beautify = False self.apply_diff_calls = [] self.show_open_in_editor = show_open_in_editor self.revert_button_msg = revert_button_msg Dialog.__init__(self, _('Differences between books'), 'diff-dialog', parent=parent) self.setWindowFlags(self.windowFlags() | Qt.WindowMinMaxButtonsHint) if show_as_window: self.setWindowFlags(Qt.Window) self.view.line_activated.connect(self.line_activated)
def __init__(self, parent=None): self.__current_word = None self.thread = None self.cancel = False dictionaries.initialize() self.current_word_changed_timer = t = QTimer() t.timeout.connect(self.do_current_word_changed) t.setSingleShot(True), t.setInterval(100) Dialog.__init__(self, _('Check spelling'), 'spell-check', parent) self.work_finished.connect(self.work_done, type=Qt.QueuedConnection) self.setAttribute(Qt.WA_DeleteOnClose, False)
def accept(self): if self.state == 0: return self.reject() if self.state == 1: resources = self.choose_resources.resources self.download_status(resources) self.wait.setCurrentIndex(2) self.bb.setVisible(False) t = Thread(name='DownloadResources', target=self.download_resources, args=(resources,)) t.daemon = True t.start() return if self.state == 2: return self.wait.stop() Dialog.accept(self)
def accept(self): if not self.theme_name: return error_dialog(self, _('No name specified'), _( 'You must specify a name for your theme'), show=True) if '*' + self.theme_name in custom_theme_names(): return error_dialog(self, _('Name already used'), _( 'A custom theme with the name %s already exists') % self.theme_name, show=True) return Dialog.accept(self)
def _replace_done(self, ret, tb): if tb is not None: error_dialog(self, _('Replace failed'), _( 'Failed to replace external resources, click "Show Details" for more information.'), det_msg=tb, show=True) Dialog.reject(self) else: self.wait.setCurrentIndex(3) self.state = 3 self.bb.clear() self.resources_replaced = True self.bb.setStandardButtons(self.bb.Ok | self.bb.Close) b = self.bb.button(self.bb.Ok) b.setText(_('See what &changed')) b.setIcon(QIcon(I('diff.png'))) b.clicked.connect(lambda : setattr(self, 'show_diff', True)) self.bb.setVisible(True)
def accept(self): if not self.func_name: return error_dialog(self, _('Must specify name'), _( 'You must specify a name for this function.'), show=True) source = self.source try: mod = compile_code(source, self.func_name) except Exception as err: return error_dialog(self, _('Invalid python code'), _( 'The code you created is not valid python code, with error: %s') % err, show=True) if not callable(mod.get('replace')): return error_dialog(self, _('No replace function'), _( 'You must create a python function named replace in your code'), show=True) user_functions[self.func_name] = source functions(refresh=True) refresh_boxes() Dialog.accept(self)
def accept(self): if not self.theme_name: return error_dialog(self, _("No name specified"), _("You must specify a name for your theme"), show=True) if "*" + self.theme_name in custom_theme_names(): return error_dialog( self, _("Name already used"), _("A custom theme with the name %s already exists") % self.theme_name, show=True, ) return Dialog.accept(self)
def keyPressEvent(self, ev): if not self.view.handle_key(ev): if ev.key() in (Qt.Key_Enter, Qt.Key_Return): return # The enter key is used by the search box, so prevent it closing the dialog if ev.key() == Qt.Key_Slash: return self.search.setFocus(Qt.OtherFocusReason) if ev.matches(QKeySequence.Copy): text = self.view.view.left.selected_text + self.view.view.right.selected_text if text: QApplication.clipboard().setText(text) return if ev.matches(QKeySequence.FindNext): self.sbn.click() return if ev.matches(QKeySequence.FindPrevious): self.sbp.click() return return Dialog.keyPressEvent(self, ev)
def accept(self): if self.stack.currentIndex() > 0: err = self.edit_snip.validate() if err is None: self.stack.setCurrentIndex(0) if self.edit_snip.creating_snippet: item = self.snip_to_item(self.edit_snip.snip) else: item = self.snip_list.currentItem() snip = self.edit_snip.snip item.setText(self.snip_to_text(snip)) item.setData(Qt.ItemDataRole.UserRole, snip) self.snip_list.setCurrentItem(item) self.snip_list.scrollToItem(item) else: error_dialog(self, _('Invalid snippet'), err, show=True) return user_snippets['snippets'] = [self.snip_list.item(i).data(Qt.ItemDataRole.UserRole) for i in range(self.snip_list.count())] snippets(refresh=True) return Dialog.accept(self)
def accept(self): if self.stack.currentIndex() > 0: err = self.edit_snip.validate() if err is None: self.stack.setCurrentIndex(0) if self.edit_snip.creating_snippet: item = self.snip_to_item(self.edit_snip.snip) else: item = self.snip_list.currentItem() snip = self.edit_snip.snip item.setText(self.snip_to_text(snip)) item.setData(Qt.UserRole, snip) self.snip_list.setCurrentItem(item) self.snip_list.scrollToItem(item) else: error_dialog(self, _('Invalid snippet'), err, show=True) return user_snippets['snippets'] = [self.snip_list.item(i).data(Qt.UserRole) for i in range(self.snip_list.count())] snippets(refresh=True) return Dialog.accept(self)
def __init__(self, parent=None): Dialog.__init__(self, _('Check external links'), 'check-external-links-dialog', parent) self.progress_made.connect(self.on_progress_made, type=Qt.ConnectionType.QueuedConnection)
def sizeHint(self): ans = Dialog.sizeHint(self) ans.setWidth(600) return ans
def reject(self): if self.stack.currentIndex() > 0: self.stack.setCurrentIndex(0) return return Dialog.reject(self)
def __init__(self, parent=None): Dialog.__init__(self, _('Create/edit custom theme'), 'custom-theme-editor', parent=parent)
def __init__(self, parent=None): Dialog.__init__(self, _('Saved Searches'), 'saved-searches', parent=parent)
def show(self): self.initialize() Dialog.show(self) self.raise_()
def __init__(self, parent=None): Dialog.__init__(self, _('Compress images'), 'compress-images', parent=parent)
def sizeHint(self): return Dialog.sizeHint(self) + QSize(100, 50)
def __init__(self, parent=None): self.initialized = False Dialog.__init__(self, _('Insert character'), 'charmap_dialog', parent) self.setWindowIcon(QIcon(I('character-set.png'))) self.focus_widget = None
def __init__(self, parent=None): self.ignore_changes = False Dialog.__init__(self, _('Customize templates'), 'customize-templates', parent=parent)
def __init__(self, gui): self.gui = gui self.qlinedit_widgets = {} Dialog.__init__(self, _('Edit Spans & Divs Customization'), '{}plugin:spandiv_config'.format(PLUGIN_SAFE_NAME), gui)
def __init__(self, parent, files): self.files = files Dialog.__init__(self, _('Changed Files'), 'toolbag_show_results_dialog', parent)
def reject(self): self.keep_going = False self.bb.button(QDialogButtonBox.StandardButton.Cancel).setEnabled(False) Dialog.reject(self)
def __init__(self, parent=None): Dialog.__init__(self, _('Manage Fonts'), 'manage-fonts', parent=parent)
def __init__(self, parent=None): Dialog.__init__(self, 'Debug output', 'sr-function-debug-output') self.setAttribute(Qt.WA_DeleteOnClose, False)
def sizeHint(self): ans = Dialog.sizeHint(self) ans.setHeight(600) ans.setWidth(max(ans.width(), 800)) return ans
def show(self): if self.rb.isEnabled(): self.refresh() return Dialog.show(self)
def __init__(self, parent=None): Dialog.__init__(self, _('Create custom theme'), 'custom-theme-create', parent=parent)
def __init__(self, parent=None): Dialog.__init__(self, _('Create/edit snippets'), 'snippet-editor', parent=parent) self.setWindowIcon(QIcon(I('snippets.png')))
def reject(self): if self.state == 2: return self.wait.stop() return Dialog.reject(self)
def reject(self): self.keep_going = False self.bb.button(self.bb.Cancel).setEnabled(False) Dialog.reject(self)
def __init__(self, family, faces, parent=None): Dialog.__init__(self, _('Font faces for %s') % family, 'editor-embedding-data', parent) self.family, self.faces = family, faces self.populate_text()
def __init__(self, parent=None, for_browsing=False): self.for_browsing = for_browsing Dialog.__init__(self, _('Images in book') if for_browsing else _('Choose an image'), 'browse-image-dialog' if for_browsing else 'insert-image-dialog', parent) self.chosen_image = None self.chosen_image_is_external = False
def __init__(self, candidate, parent=None): self.candidate = candidate self.filename = None Dialog.__init__(self, _('Choose file name'), 'choose-file-name', parent=parent)
def __init__(self, msg=None, parent=None): self.msg = msg Dialog.__init__(self, _('Choose folder'), 'choose-folder', parent=parent)
def __init__(self, parent=None): self.fmt = 'epub' Dialog.__init__(self, _('Create new book'), 'create-new-book', parent=parent)
def __init__(self, parent, force_entire_book=False): self.prefs = self.prefsPrep() self.parent = parent self.force_entire_book = force_entire_book self.criteria = None Dialog.__init__(self, _('Chinese Conversion'), 'chinese_conversion_dialog', parent)
def show(self): Dialog.show(self), self.raise_(), self.activateWindow()
def __init__(self, func_name='', parent=None): self._func_name = func_name Dialog.__init__(self, _('Create/edit a function'), 'edit-sr-func', parent=parent)