Example #1
0
    def setup_ui(self):
        from calibre.gui2.tweak_book.templates import DEFAULT_TEMPLATES
        from calibre.gui2.tweak_book.editor.text import TextEdit
        self.l = l = QFormLayout(self)
        self.setLayout(l)

        self.syntaxes = s = QComboBox(self)
        s.addItems(sorted(DEFAULT_TEMPLATES.iterkeys()))
        s.setCurrentIndex(s.findText('html'))
        l.addRow(_('Choose the &type of template to edit:'), s)
        s.currentIndexChanged.connect(self.show_template)

        self.helpl = la = QLabel(_(
            'The variables {0} and {1} will be replaced with the title and author of the book. {2}'
            ' is where the cursor will be positioned. If you want to include braces in your template,'
            ' for example for CSS rules, you have to escape them, like this: {3}').format(*['<code>%s</code>'%x for x in
                ['{TITLE}', '{AUTHOR}', '%CURSOR%', 'body {{ color: red }}']]))
        la.setWordWrap(True)
        l.addRow(la)

        self.save_timer = t = QTimer(self)
        t.setSingleShot(True), t.setInterval(100)
        t.timeout.connect(self._save_syntax)

        self.editor = e = TextEdit(self)
        l.addRow(e)
        e.textChanged.connect(self.save_syntax)

        self.show_template()

        self.bb.clear()
        self.bb.addButton(self.bb.Close)
        self.rd = b = self.bb.addButton(self.bb.RestoreDefaults)
        b.clicked.connect(self.restore_defaults)
        l.addRow(self.bb)
Example #2
0
    def setup_ui(self):
        from calibre.gui2.tweak_book.templates import DEFAULT_TEMPLATES
        from calibre.gui2.tweak_book.editor.text import TextEdit
        self.l = l = QFormLayout(self)
        self.setLayout(l)

        self.syntaxes = s = QComboBox(self)
        s.addItems(sorted(DEFAULT_TEMPLATES.iterkeys()))
        s.setCurrentIndex(s.findText('html'))
        l.addRow(_('Choose the &type of template to edit:'), s)
        s.currentIndexChanged.connect(self.show_template)

        self.helpl = la = QLabel(
            _('The variables {0} and {1} will be replaced with the title and author of the book. {2}'
              ' is where the cursor will be positioned.').format(
                  '{TITLE}', '{AUTHOR}', '%CURSOR%'))
        la.setWordWrap(True)
        l.addRow(la)

        self.save_timer = t = QTimer(self)
        t.setSingleShot(True), t.setInterval(100)
        t.timeout.connect(self._save_syntax)

        self.editor = e = TextEdit(self)
        l.addRow(e)
        e.textChanged.connect(self.save_syntax)

        self.show_template()

        self.bb.clear()
        self.bb.addButton(self.bb.Close)
        self.rd = b = self.bb.addButton(self.bb.RestoreDefaults)
        b.clicked.connect(self.restore_defaults)
        l.addRow(self.bb)
Example #3
0
    def setup_ui(self):
        from calibre.gui2.tweak_book.templates import DEFAULT_TEMPLATES
        from calibre.gui2.tweak_book.editor.text import TextEdit
        # Cannot use QFormLayout as it does not play nice with TextEdit on windows
        self.l = l = QVBoxLayout(self)

        self.syntaxes = s = QComboBox(self)
        s.addItems(sorted(DEFAULT_TEMPLATES.iterkeys()))
        s.setCurrentIndex(s.findText('html'))
        h = QHBoxLayout()
        l.addLayout(h)
        la = QLabel(_('Choose the &type of template to edit:'))
        la.setBuddy(s)
        h.addWidget(la), h.addWidget(s), h.addStretch(10)
        s.currentIndexChanged.connect(self.show_template)

        self.helpl = la = QLabel(
            _('The variables {0} and {1} will be replaced with the title and author of the book. {2}'
              ' is where the cursor will be positioned. If you want to include braces in your template,'
              ' for example for CSS rules, you have to escape them, like this: {3}'
              ).format(*[
                  '<code>%s</code>' % x for x in
                  ['{TITLE}', '{AUTHOR}', '%CURSOR%', 'body {{ color: red }}']
              ]))
        la.setWordWrap(True)
        l.addWidget(la)

        self.save_timer = t = QTimer(self)
        t.setSingleShot(True), t.setInterval(100)
        t.timeout.connect(self._save_syntax)

        self.editor = e = TextEdit(self)
        l.addWidget(e)
        e.textChanged.connect(self.save_syntax)

        self.show_template()

        self.bb.clear()
        self.bb.addButton(self.bb.Close)
        self.rd = b = self.bb.addButton(self.bb.RestoreDefaults)
        b.clicked.connect(self.restore_defaults)
        l.addWidget(self.bb)
Example #4
0
    def setup_ui(self):
        from calibre.gui2.tweak_book.templates import DEFAULT_TEMPLATES
        from calibre.gui2.tweak_book.editor.text import TextEdit

        # Cannot use QFormLayout as it does not play nice with TextEdit on windows
        self.l = l = QVBoxLayout(self)

        self.syntaxes = s = QComboBox(self)
        s.addItems(sorted(DEFAULT_TEMPLATES.iterkeys()))
        s.setCurrentIndex(s.findText("html"))
        h = QHBoxLayout()
        l.addLayout(h)
        la = QLabel(_("Choose the &type of template to edit:"))
        la.setBuddy(s)
        h.addWidget(la), h.addWidget(s), h.addStretch(10)
        s.currentIndexChanged.connect(self.show_template)

        self.helpl = la = QLabel(
            _(
                "The variables {0} and {1} will be replaced with the title and author of the book. {2}"
                " is where the cursor will be positioned. If you want to include braces in your template,"
                " for example for CSS rules, you have to escape them, like this: {3}"
            ).format(*["<code>%s</code>" % x for x in ["{TITLE}", "{AUTHOR}", "%CURSOR%", "body {{ color: red }}"]])
        )
        la.setWordWrap(True)
        l.addWidget(la)

        self.save_timer = t = QTimer(self)
        t.setSingleShot(True), t.setInterval(100)
        t.timeout.connect(self._save_syntax)

        self.editor = e = TextEdit(self)
        l.addWidget(e)
        e.textChanged.connect(self.save_syntax)

        self.show_template()

        self.bb.clear()
        self.bb.addButton(self.bb.Close)
        self.rd = b = self.bb.addButton(self.bb.RestoreDefaults)
        b.clicked.connect(self.restore_defaults)
        l.addWidget(self.bb)