View Single Post
Old 01-06-2019, 08:40 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,910
Karma: 22669818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
First for language, you want:

Code:
if language[0] in ("pt_BR", "pt_PT", "pt")
more generally speaking you can eventually setup proper translations for the plugin, via Transifex.

Now for the config dialog , you have to link up the config menu item to some code to actually open the dialog, like this, in main.py:

Code:
    def do_config(self):
        from calibre.gui2.widgets2 import Dialog
        from calibre.gui2.tweak_book import tprefs
        from PyQt5.Qt import QVBoxLayout
        from calibre_plugins.ACE.config import ConfigWidget
        tool = self

        class ConfigDialog(Dialog):

            def __init__(self):
                Dialog.__init__(self, 'Configure ACE', 'plugin-ace-config-dialog', parent=tool.gui, prefs=tprefs)

            def setup_ui(self):
                self.l = QVBoxLayout(self)
                self.w = ConfigWidget()
                self.l.addWidget(self.w)

            def accept(self):
                if self.w.validate():
                    self.w.save_settings()
                    Dialog.accept(self)

        d = ConfigDialog()
        d.exec_()
link it up to you action like this:

Code:
            config_menu_item.triggered.connect(self.do_config)
kovidgoyal is offline   Reply With Quote