Esempio n. 1
0
    def restore_defaults(self):
        opts = config("").parse()
        self.load_options(opts)
        from calibre.gui2.viewer.main import dprefs, vprefs

        self.word_lookups = dprefs.defaults["word_lookups"]
        self.opt_singleinstance.setChecked(vprefs.defaults["singleinstance"])
Esempio n. 2
0
def option_parser():
    c = config()
    parser = c.option_parser(usage=_('''\
%prog [options] file

View an ebook.
'''))
    setup_gui_option_parser(parser)
    return parser
Esempio n. 3
0
def option_parser():
    c = config()
    parser = c.option_parser(usage=_('''\
%prog [options] file

View an ebook.
'''))
    setup_gui_option_parser(parser)
    return parser
Esempio n. 4
0
    def __init__(self, shortcuts, parent=None):
        QDialog.__init__(self, parent)
        self.setupUi(self)

        for x in ('text', 'background'):
            getattr(self, 'change_%s_color_button' % x).clicked.connect(
                partial(self.change_color, x, reset=False))
            getattr(self, 'reset_%s_color_button' % x).clicked.connect(
                partial(self.change_color, x, reset=True))
        self.css.setToolTip(
            _('Set the user CSS stylesheet. This can be used to customize the look of all books.'
              ))

        self.shortcuts = shortcuts
        self.shortcut_config = ShortcutConfig(shortcuts, parent=self)
        bb = self.buttonBox
        bb.button(bb.RestoreDefaults).clicked.connect(self.restore_defaults)

        with zipfile.ZipFile(
                P('viewer/hyphenate/patterns.zip', allow_user_override=False),
                'r') as zf:
            pats = [x.split('.')[0].replace('-', '_') for x in zf.namelist()]
        names = list(map(get_language, pats))
        pmap = {}
        for i in range(len(pats)):
            pmap[names[i]] = pats[i]
        for x in sorted(names):
            self.hyphenate_default_lang.addItem(x, QVariant(pmap[x]))
        self.hyphenate_pats = pats
        self.hyphenate_names = names
        p = self.tabs.widget(1)
        p.layout().addWidget(self.shortcut_config)

        if isxp:
            self.hyphenate.setVisible(False)
            self.hyphenate_default_lang.setVisible(False)
            self.hyphenate_label.setVisible(False)

        self.themes = load_themes()
        self.save_theme_button.clicked.connect(self.save_theme)
        self.load_theme_button.m = m = QMenu()
        self.load_theme_button.setMenu(m)
        m.triggered.connect(self.load_theme)
        self.delete_theme_button.m = m = QMenu()
        self.delete_theme_button.setMenu(m)
        m.triggered.connect(self.delete_theme)

        opts = config().parse()
        self.load_options(opts)
        self.init_load_themes()

        self.clear_search_history_button.clicked.connect(
            self.clear_search_history)
        self.resize(self.width(),
                    min(self.height(), max(575,
                                           min_available_height() - 25)))
Esempio n. 5
0
 def accept(self, *args):
     if self.shortcut_config.is_editing:
         from calibre.gui2 import info_dialog
         info_dialog(self, _('Still editing'),
                 _('You are in the middle of editing a keyboard shortcut'
                     ' first complete that, by clicking outside the '
                     ' shortcut editing box.'), show=True)
         return
     self.save_options(config())
     return QDialog.accept(self, *args)
Esempio n. 6
0
    def __init__(self, shortcuts, parent=None):
        QDialog.__init__(self, parent)
        self.setupUi(self)

        for x in ('text', 'background'):
            getattr(self, 'change_%s_color_button'%x).clicked.connect(
                            partial(self.change_color, x, reset=False))
            getattr(self, 'reset_%s_color_button'%x).clicked.connect(
                    partial(self.change_color, x, reset=True))
        self.css.setToolTip(_('Set the user CSS stylesheet. This can be used to customize the look of all books.'))

        self.shortcuts = shortcuts
        self.shortcut_config = ShortcutConfig(shortcuts, parent=self)
        bb = self.buttonBox
        bb.button(bb.RestoreDefaults).clicked.connect(self.restore_defaults)

        with zipfile.ZipFile(P('viewer/hyphenate/patterns.zip',
            allow_user_override=False), 'r') as zf:
            pats = [x.split('.')[0].replace('-', '_') for x in zf.namelist()]
        names = list(map(get_language, pats))
        pmap = {}
        for i in range(len(pats)):
            pmap[names[i]] = pats[i]
        for x in sorted(names):
            self.hyphenate_default_lang.addItem(x, pmap[x])
        self.hyphenate_pats = pats
        self.hyphenate_names = names
        p = self.tabs.widget(1)
        p.layout().addWidget(self.shortcut_config)

        if isxp:
            self.hyphenate.setVisible(False)
            self.hyphenate_default_lang.setVisible(False)
            self.hyphenate_label.setVisible(False)

        self.themes = load_themes()
        self.save_theme_button.clicked.connect(self.save_theme)
        self.load_theme_button.m = m = QMenu()
        self.load_theme_button.setMenu(m)
        m.triggered.connect(self.load_theme)
        self.delete_theme_button.m = m = QMenu()
        self.delete_theme_button.setMenu(m)
        m.triggered.connect(self.delete_theme)

        opts = config().parse()
        self.load_options(opts)
        self.init_load_themes()
        self.init_dictionaries()

        self.clear_search_history_button.clicked.connect(self.clear_search_history)
        self.resize(self.width(), min(self.height(), max(575, min_available_height()-25)))

        for x in 'add remove change'.split():
            getattr(self, x + '_dictionary_website_button').clicked.connect(getattr(self, x + '_dictionary_website'))
Esempio n. 7
0
 def read_settings(self):
     c = config().parse()
     if c.remember_window_size:
         wg = vprefs.get('viewer_window_geometry', None)
         if wg is not None:
             self.restoreGeometry(wg)
     self.show_toc_on_open = vprefs.get('viewer_toc_isvisible', False)
     desktop  = QApplication.instance().desktop()
     av = desktop.availableGeometry(self).height() - 30
     if self.height() > av:
         self.resize(self.width(), av)
Esempio n. 8
0
 def read_settings(self):
     c = config().parse()
     if c.remember_window_size:
         wg = vprefs.get('viewer_window_geometry', None)
         if wg is not None:
             self.restoreGeometry(wg)
     self.show_toc_on_open = vprefs.get('viewer_toc_isvisible', False)
     desktop  = QApplication.instance().desktop()
     av = desktop.availableGeometry(self).height() - 30
     if self.height() > av:
         self.resize(self.width(), av)
Esempio n. 9
0
 def save_theme(self):
     themename, ok = QInputDialog.getText(self, _("Theme name"), _("Choose a name for this theme"))
     if not ok:
         return
     themename = unicode(themename).strip()
     if not themename:
         return
     c = config("")
     c.add_opt("theme_name_xxx", default=themename)
     self.save_options(c)
     self.themes["theme_" + themename] = c.src
     self.init_load_themes()
     self.theming_message.setText(_("Saved settings as the theme named: %s") % themename)
Esempio n. 10
0
 def save_theme(self):
     themename, ok = QInputDialog.getText(self, _('Theme name'),
             _('Choose a name for this theme'))
     if not ok:
         return
     themename = unicode(themename).strip()
     if not themename:
         return
     c = config('')
     c.add_opt('theme_name_xxx', default=themename)
     self.save_options(c)
     self.themes['theme_'+themename] = c.src
     self.init_load_themes()
     self.theming_message.setText(_('Saved settings as the theme named: %s')%
         themename)
Esempio n. 11
0
    def restore_defaults(self):
        opts = config("").parse()
        self.load_options(opts)
        from calibre.gui2.viewer.main import dprefs

        self.word_lookups = dprefs.defaults["word_lookups"]
Esempio n. 12
0
 def load_theme(self, ac):
     theme = ac.theme_id
     raw = self.themes[theme]
     self.load_options(config(raw).parse())
     self.theming_message.setText(_("Loaded settings from the theme %s") % theme[len("theme_") :])
Esempio n. 13
0
 def restore_defaults(self):
     opts = config('').parse()
     self.load_options(opts)
     from calibre.gui2.viewer.main import dprefs
     self.word_lookups = dprefs.defaults['word_lookups']
Esempio n. 14
0
    def __init__(self, shortcuts, parent=None):
        QDialog.__init__(self, parent)
        self.setupUi(self)

        for x in ("text", "background"):
            getattr(self, "change_%s_color_button" % x).clicked.connect(partial(self.change_color, x, reset=False))
            getattr(self, "reset_%s_color_button" % x).clicked.connect(partial(self.change_color, x, reset=True))
        self.css.setToolTip(_("Set the user CSS stylesheet. This can be used to customize the look of all books."))

        self.shortcuts = shortcuts
        self.shortcut_config = ShortcutConfig(shortcuts, parent=self)
        bb = self.buttonBox
        bb.button(bb.RestoreDefaults).clicked.connect(self.restore_defaults)

        with zipfile.ZipFile(P("viewer/hyphenate/patterns.zip", allow_user_override=False), "r") as zf:
            pats = [x.split(".")[0].replace("-", "_") for x in zf.namelist()]

        lang_pats = {
            "el_monoton": get_language("el").partition(";")[0] + _(" monotone"),
            "el_polyton": get_language("el").partition(";")[0] + _(" polytone"),
            "sr_cyrl": get_language("sr") + _(" cyrillic"),
            "sr_latn": get_language("sr") + _(" latin"),
        }

        def gl(pat):
            return lang_pats.get(pat, get_language(pat))

        names = list(map(gl, pats))
        pmap = {}
        for i in range(len(pats)):
            pmap[names[i]] = pats[i]
        for x in sorted(names):
            self.hyphenate_default_lang.addItem(x, pmap[x])
        self.hyphenate_pats = pats
        self.hyphenate_names = names
        p = self.tabs.widget(1)
        p.layout().addWidget(self.shortcut_config)

        if isxp:
            self.hyphenate.setVisible(False)
            self.hyphenate_default_lang.setVisible(False)
            self.hyphenate_label.setVisible(False)

        self.themes = load_themes()
        self.save_theme_button.clicked.connect(self.save_theme)
        self.load_theme_button.m = m = QMenu()
        self.load_theme_button.setMenu(m)
        m.triggered.connect(self.load_theme)
        self.delete_theme_button.m = m = QMenu()
        self.delete_theme_button.setMenu(m)
        m.triggered.connect(self.delete_theme)

        opts = config().parse()
        self.load_options(opts)
        self.init_load_themes()
        self.init_dictionaries()

        self.clear_search_history_button.clicked.connect(self.clear_search_history)
        self.resize(self.width(), min(self.height(), max(575, min_available_height() - 25)))

        for x in "add remove change".split():
            getattr(self, x + "_dictionary_website_button").clicked.connect(getattr(self, x + "_dictionary_website"))
Esempio n. 15
0
 def restore_defaults(self):
     opts = config('').parse()
     self.load_options(opts)
Esempio n. 16
0
 def restore_defaults(self):
     opts = config('').parse()
     self.load_options(opts)
Esempio n. 17
0
 def load_theme(self, ac):
     theme = ac.theme_id
     raw = self.themes[theme]
     self.load_options(config(raw).parse())
     self.theming_message.setText(_('Loaded settings from the theme %s')%
             theme[len('theme_'):])
Esempio n. 18
0
 def restore_defaults(self):
     opts = config('').parse()
     self.load_options(opts)
     from calibre.gui2.viewer.main import dprefs, vprefs
     self.word_lookups = dprefs.defaults['word_lookups']
     self.opt_singleinstance.setChecked(vprefs.defaults['singleinstance'])