def accept(self): if not self.validate(): return self.abort_disk_usage.set() if self.run_action(): self.restart_needed = self.stack.currentIndex() == 2 Dialog.accept(self)
def accept(self): r = self.rule for i, which in enumerate([_('Key'), _('Name'), _('Template')]): if not r[i]: return error_dialog(self, _('Value needed'), _( 'The %s field cannot be empty') % which, show=True) Dialog.accept(self)
def accept(self): name = self.sname.text().strip() if not name: return error_dialog( self, _('No search name'), _('You must specify a name for the Saved search'), show=True) expression = self.search.text().strip() if not expression: return error_dialog( self, _('No search expression'), _('You must specify a search expression for the Saved search'), show=True) self.accepted_data = name, expression if self.validate is not None: err = self.validate(name, expression) if err: return error_dialog(self, _('Invalid saved search'), err, show=True) Dialog.accept(self) if self.commit_changes: if icu_lower(name) in self.search_names: self.searches.pop(self.search_names[icu_lower(name)], None) self.searches[name] = expression commit_searches(self.searches)
def accept(self): rules = defaultdict(list) for r in range(self.table.rowCount()): def item(c): return self.table.item(r, c).text() rules[item(0)].append([item(1), item(2)]) msprefs['id_link_rules'] = dict(rules) Dialog.accept(self)
def restore_defaults(self): if self.current_theme is not None: if not question_dialog(self, _('Are you sure?'), _( 'Are you sure you want to remove the <b>%s</b> icon theme' ' and return to the stock icons?') % self.current_theme): return self.commit_changes = remove_icon_theme Dialog.accept(self)
def __init__(self, file_type='jpeg', parent=None, prefs=oprefs): self.file_type = file_type self.programs = self.find_error = self.selected_entry = None self.select_manually = False Dialog.__init__(self, _('Choose a program'), 'choose-open-with-program-dialog', parent=parent, prefs=prefs) self.found.connect(self.programs_found, type=Qt.QueuedConnection) self.pi.startAnimation() t = Thread(target=self.find_programs) t.daemon = True t.start()
def __init__(self, parent=None, search=None): self.initial_search = search Dialog.__init__( self, _('Add a new Saved search'), 'add-saved-search', parent) from calibre.gui2.ui import get_gui db = get_gui().current_db self.searches = {} for name in db.saved_search_names(): self.searches[name] = db.saved_search_lookup(name) self.search_names = {icu_lower(n) for n in db.saved_search_names()}
def __init__(self, parent=None): try: self.current_theme = json.loads(I('icon-theme.json', data=True))['title'] except Exception: self.current_theme = None Dialog.__init__(self, _('Choose an icon theme'), 'choose-icon-theme-dialog', parent) self.themes_downloaded.connect(self.show_themes, type=Qt.QueuedConnection) self.cover_downloaded.connect(self.set_cover, type=Qt.QueuedConnection) self.keep_downloading = True self.commit_changes = None self.new_theme_title = None
def __init__(self, parent=None, search=None, commit_changes=True, label=None, validate=None): self.initial_search = search self.validate = validate self.label = label self.commit_changes = commit_changes Dialog.__init__( self, _('Add a new Saved search'), 'add-saved-search', parent) from calibre.gui2.ui import get_gui db = get_gui().current_db self.searches = {} for name in db.saved_search_names(): self.searches[name] = db.saved_search_lookup(name) self.search_names = {icu_lower(n):n for n in db.saved_search_names()}
def accept(self): mi = self.metadata if not mi.get('title'): return error_dialog(self, _('No title specified'), _( 'You must specify a title for this icon theme'), show=True) if not mi.get('author'): return error_dialog(self, _('No author specified'), _( 'You must specify an author for this icon theme'), show=True) return Dialog.accept(self)
def accept(self): fname = self.file_name.text().strip() if not fname: return error_dialog(self, _('No filename specified'), _( 'You must specify a filename for the PDF file to generate'), show=True) if not fname.lower().endswith('.pdf'): return error_dialog(self, _('Incorrect filename specified'), _( 'The filename for the PDF file must end with .pdf'), show=True) self.save_used_values() return Dialog.accept(self)
def accept(self): Dialog.accept(self) name = self.sname.text().strip() if not name: return error_dialog( self, _('No search name'), _('You must specify a search name'), show=True) expression = self.search.text().strip() if not expression: return error_dialog( self, _('No search expression'), _('You must specify a search expression'), show=True) if icu_lower(name) in self.searches: self.searches.pop(icu_lower(name), None) self.searches[name] = expression commit_searches(self.searches)
def accept(self): if self.theme_list.currentIndex() < 0: return error_dialog(self, _('No theme selected'), _( 'You must first select an icon theme'), show=True) theme = self.theme_list.currentItem().data(Qt.UserRole) url = BASE_URL + theme['icons-url'] size = theme['compressed-size'] theme = {k:theme.get(k, '') for k in 'name title version'.split()} self.keep_downloading = True d = DownloadProgress(self, size) d.canceled_signal.connect(lambda : setattr(self, 'keep_downloading', False)) self.downloaded_theme = None def download(): self.downloaded_theme = buf = BytesIO() try: response = get_https_resource_securely(url, get_response=True) while self.keep_downloading: raw = response.read(1024) if not raw: break buf.write(raw) d.downloaded(buf.tell()) d.queue_accept() except Exception: import traceback self.downloaded_theme = traceback.format_exc() d.queue_reject() t = Thread(name='DownloadIconTheme', target=download) t.daemon = True t.start() ret = d.exec_() if self.downloaded_theme and not isinstance(self.downloaded_theme, BytesIO): return error_dialog(self, _('Download failed'), _( 'Failed to download icon theme, click "Show Details" for more information.'), show=True, det_msg=self.downloaded_theme) if ret == d.Rejected or not self.keep_downloading or d.canceled or self.downloaded_theme is None: return dt = self.downloaded_theme def commit_changes(): dt.seek(0) f = decompress(dt) f.seek(0) remove_icon_theme() install_icon_theme(theme, f) self.commit_changes = commit_changes self.new_theme_title = theme['title'] return Dialog.accept(self)
def __init__(self, parent, text, column_name=None): title = _('Edit "{0}"').format(column_name) if column_name else _('Edit text') Dialog.__init__(self, title, 'edit-plain-text-dialog', parent=parent) self.text = text
def accept(self): if self.theme_list.currentIndex() < 0: return error_dialog(self, _('No theme selected'), _('You must first select an icon theme'), show=True) theme = self.theme_list.currentItem().data(Qt.UserRole) url = BASE_URL + theme['icons-url'] size = theme['compressed-size'] theme = {k: theme.get(k, '') for k in 'name title version'.split()} self.keep_downloading = True d = DownloadProgress(self, size) d.canceled_signal.connect( lambda: setattr(self, 'keep_downloading', False)) self.downloaded_theme = None def download(): self.downloaded_theme = buf = BytesIO() try: response = get_https_resource_securely(url, get_response=True) while self.keep_downloading: raw = response.read(1024) if not raw: break buf.write(raw) d.downloaded(buf.tell()) d.queue_accept() except Exception: import traceback self.downloaded_theme = traceback.format_exc() d.queue_reject() t = Thread(name='DownloadIconTheme', target=download) t.daemon = True t.start() ret = d.exec_() if self.downloaded_theme and not isinstance(self.downloaded_theme, BytesIO): return error_dialog( self, _('Download failed'), _('Failed to download icon theme, click "Show Details" for more information.' ), show=True, det_msg=self.downloaded_theme) if ret == d.Rejected or not self.keep_downloading or d.canceled or self.downloaded_theme is None: return dt = self.downloaded_theme def commit_changes(): dt.seek(0) f = decompress(dt) f.seek(0) remove_icon_theme() install_icon_theme(theme, f) self.commit_changes = commit_changes self.new_theme_title = theme['title'] return Dialog.accept(self)
def __init__(self, recipe_model, parent=None): self.recipe_model = recipe_model Dialog.__init__(self, _("Add custom news source"), 'add-custom-news-source', parent=parent)
def reject(self): idx = self.stack.currentIndex() if idx > 0: self.stack.setCurrentIndex(0) return Dialog.reject(self)
def __init__(self, db, parent=None): self.db = db Dialog.__init__(self, _('Configure the Book details window'), 'book-details-popup-conf', parent)
def __init__(self, rules, parent=None): self.rules = self.compile_rules(rules) Dialog.__init__(self, self.DIALOG_TITLE, self.PREFS_NAME, parent=parent)
def accept(self): self.model.commit() return Dialog.accept(self)
def __init__(self, parent): Dialog.__init__(self, _('Edit lookup sources'), 'viewer-edit-lookup-locations', parent=parent)
def __init__(self, parent=None): self.current_restriction = None Dialog.__init__(self, _('Annotations browser'), 'library-annotations-browser', parent=parent, default_buttons=QDialogButtonBox.StandardButton.Close) self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose, False) self.setWindowIcon(QIcon(I('highlight.png')))
def accept(self): ci = self.plist.currentItem() if ci is not None: self.selected_entry = ci.data(ENTRY_ROLE) return Dialog.accept(self)
def __init__(self, book_title, parent=None, prefs=vprefs): self.book_title = book_title self.default_file_name = sanitize_file_name(book_title[:75] + '.pdf') self.paper_size_map = {a:getattr(QPageSize, a.capitalize()) for a in PAPER_SIZES} Dialog.__init__(self, _('Print to PDF'), 'print-to-pdf', prefs=prefs, parent=parent)
def __init__(self, parent=None): self.loaded_ruleset = None Dialog.__init__(self, self.DIALOG_TITLE, self.PREFS_NAME, parent=parent)
def __init__(self, parent, job): self.job = job self.html_view = hasattr(job, 'html_details') and not getattr( job, 'ignore_html_details', False) Dialog.__init__(self, job.description, 'job-detail-view-dialog', parent)
def sizeHint(self): ans = Dialog.sizeHint(self) ans.setWidth(ans.width() + 150) return ans
def sizeHint(self): sh = Dialog.sizeHint(self) return QSize(max(sh.width(), 900), 600)
def accept(self): if not self.selected_recipe: return error_dialog(self, _('Choose recipe'), _( 'You must choose a recipe to customize first'), show=True) return Dialog.accept(self)
def accept(self): if self.edit_widget.validate(): Dialog.accept(self)
def accept(self): idx = self.stack.currentIndex() if idx > 0: self.editing_finished() return Dialog.accept(self)
def __init__(self, parent=None): Dialog.__init__(self, self.DIALOG_TITLE, self.PREFS_NAME, parent=None)
def sizeHint(self): ans = Dialog.sizeHint(self) ans.setWidth(max(700, ans.width())) return ans
def __init__(self, msg, name, parent, mi): self.msg, self.mi, self.conf_name = msg, mi, name Dialog.__init__(self, _('Are you sure?'), 'confirm-merge-dialog', parent)
def __init__(self, file_type='jpeg', parent=None): self.file_type = file_type.lower() Dialog.__init__(self, _('Edit the applications for %s files') % file_type.upper(), 'edit-open-with-programs', parent=parent)
def __init__(self, parent, report): self.report = report Dialog.__init__(self, _('Create an icon theme'), 'create-icon-theme', parent)
def __init__(self, parent=None): self.loaded_ruleset = None Dialog.__init__(self, _('Edit tag mapper rules'), 'edit-tag-mapper-rules', parent=parent)
def __init__(self, notes, parent=None): self.initial_notes = notes Dialog.__init__(self, name='edit-notes-highlight', title=_('Edit notes'), parent=parent)
def __init__(self, rules, parent=None): self.rules = rules Dialog.__init__(self, self.DIALOG_TITLE, self.PREFS_NAME, parent=parent)
def __init__(self, book_title, parent=None, prefs=vprefs): self.book_title = book_title self.default_file_name = book_title[:75] + '.pdf' self.paper_size_map = {a:getattr(QPageSize, a.capitalize()) for a in PAPER_SIZES} Dialog.__init__(self, _('Print to PDF'), 'print-to-pdf', prefs=prefs, parent=parent)
def __init__(self, title, name, parent=None): BaseDialog.__init__(self, title, name, parent=parent, prefs=tprefs)
def __init__(self, key='', name='', template='', parent=None): title = _('Edit rule') if key else _('Create a new rule') Dialog.__init__(self, title=title, name='id-links-rule-editor', parent=parent) self.key.setText(key), self.nw.setText(name), self.template.setText(template or 'http://example.com/{id}')
def __init__(self, parent=None): Dialog.__init__(self, _('Configure the toolbar'), 'configure-viewer-toolbar', parent=parent, prefs=vprefs)
def __init__(self, parent=None): Dialog.__init__(self, title=_('Create rules for identifiers'), name='id-links-rules-editor', parent=parent)
def __init__(self, notes, parent=None): self.initial_notes = notes Dialog.__init__(self, _('Edit notes for highlight'), 'library-annotations-browser-edit-notes', parent=parent)
def __init__(self, parent=None): Dialog.__init__(self, _('Edit rule'), 'edit-tag-mapper-rule', parent=None)
def keyPressEvent(self, ev): if ev.key() not in (Qt.Key_Enter, Qt.Key_Return): return Dialog.keyPressEvent(self, ev)
def __init__(self, rules, parent=None): self.rules = rules Dialog.__init__(self, _('Test tag mapper rules'), 'test-tag-mapper-rules', parent=parent)
def reject(self): self.abort_disk_usage.set() Dialog.reject(self)
def __init__(self, recipe_model, parent=None): self.recipe_model = recipe_model Dialog.__init__(self, _("Choose builtin recipe"), 'choose-builtin-recipe', parent=parent)