Example #1
0
 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())
Example #2
0
    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)
Example #3
0
 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)
Example #4
0
 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)
Example #5
0
 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()
Example #6
0
 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'])
Example #7
0
 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
Example #8
0
 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)
Example #9
0
 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)
Example #10
0
 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)
Example #11
0
 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)
Example #12
0
 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)
Example #13
0
    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)
Example #14
0
 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)
Example #15
0
 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)
Example #16
0
 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)
Example #17
0
 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)
Example #18
0
 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)
Example #20
0
 def sizeHint(self):
     ans = Dialog.sizeHint(self)
     ans.setWidth(600)
     return ans
Example #21
0
 def reject(self):
     if self.stack.currentIndex() > 0:
         self.stack.setCurrentIndex(0)
         return
     return Dialog.reject(self)
Example #22
0
 def __init__(self, parent=None):
     Dialog.__init__(self,
                     _('Create/edit custom theme'),
                     'custom-theme-editor',
                     parent=parent)
Example #23
0
 def reject(self):
     if self.stack.currentIndex() > 0:
         self.stack.setCurrentIndex(0)
         return
     return Dialog.reject(self)
Example #24
0
 def sizeHint(self):
     ans = Dialog.sizeHint(self)
     ans.setWidth(600)
     return ans
Example #25
0
 def __init__(self, parent=None):
     Dialog.__init__(self, _('Saved Searches'), 'saved-searches', parent=parent)
Example #26
0
 def show(self):
     self.initialize()
     Dialog.show(self)
     self.raise_()
Example #27
0
 def __init__(self, parent=None):
     Dialog.__init__(self, _('Compress images'), 'compress-images', parent=parent)
 def sizeHint(self):
     return Dialog.sizeHint(self) + QSize(100, 50)
Example #29
0
 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
Example #30
0
 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)
Example #32
0
 def __init__(self, parent=None):
     Dialog.__init__(self,
                     _('Saved Searches'),
                     'saved-searches',
                     parent=parent)
 def __init__(self, parent, files):
     self.files = files
     Dialog.__init__(self, _('Changed Files'), 'toolbag_show_results_dialog', parent)
Example #34
0
 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)
Example #36
0
 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)
Example #39
0
 def __init__(self, parent=None):
     Dialog.__init__(self,
                     _('Create custom theme'),
                     'custom-theme-create',
                     parent=parent)
Example #40
0
 def sizeHint(self):
     return Dialog.sizeHint(self) + QSize(100, 50)
Example #41
0
 def __init__(self, parent=None):
     Dialog.__init__(self, _('Create/edit snippets'), 'snippet-editor', parent=parent)
     self.setWindowIcon(QIcon(I('snippets.png')))
Example #42
0
 def reject(self):
     if self.state == 2:
         return
     self.wait.stop()
     return Dialog.reject(self)
Example #43
0
 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()
Example #45
0
 def __init__(self, parent=None):
     Dialog.__init__(self, _('Manage Fonts'), 'manage-fonts', parent=parent)
Example #46
0
 def reject(self):
     self.keep_going = False
     self.bb.button(self.bb.Cancel).setEnabled(False)
     Dialog.reject(self)
Example #47
0
 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()
Example #48
0
 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
Example #49
0
 def __init__(self, parent=None):
     Dialog.__init__(self, _('Create/edit snippets'), 'snippet-editor', parent=parent)
     self.setWindowIcon(QIcon(I('snippets.png')))
Example #50
0
 def __init__(self, candidate, parent=None):
     self.candidate = candidate
     self.filename = None
     Dialog.__init__(self, _('Choose file name'), 'choose-file-name', parent=parent)
Example #51
0
 def __init__(self, msg=None, parent=None):
     self.msg = msg
     Dialog.__init__(self, _('Choose folder'), 'choose-folder', parent=parent)
Example #52
0
 def __init__(self, parent=None):
     self.fmt = 'epub'
     Dialog.__init__(self, _('Create new book'), 'create-new-book', parent=parent)
Example #53
0
 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)
Example #54
0
 def show(self):
     Dialog.show(self), self.raise_(), self.activateWindow()
Example #55
0
 def reject(self):
     if self.state == 2:
         return
     self.wait.stop()
     return Dialog.reject(self)
Example #56
0
 def __init__(self, func_name='', parent=None):
     self._func_name = func_name
     Dialog.__init__(self, _('Create/edit a function'), 'edit-sr-func', parent=parent)