Beispiel #1
0
    def setEditorType(self, tpe: EditorType, inner=False):
        self.editType = tpe
        if not inner:
            self.editorTypeBox.setCurrentIndex(tpe.value)

        if tpe == EditorType.JSON:
            self.editor.changeLexer(Qsci.QsciLexerJSON(self.editor), 'JSON')
        elif tpe == EditorType.XML:
            self.editor.changeLexer(Qsci.QsciLexerXML(self.editor), 'XML')
        elif tpe == EditorType.HTML:
            self.editor.changeLexer(Qsci.QsciLexerHTML(self.editor), 'HTML')
        elif tpe == EditorType.Javascript:
            self.editor.changeLexer(Qsci.QsciLexerJavaScript(self.editor),
                                    'Javascript')
        else:
            self.editor.changeLexer(Qsci.QsciLexerMarkdown(self.editor),
                                    'Text<')

        self.editorTypeChanged.emit(tpe.value)
Beispiel #2
0
    def __init__(self, parent=None):
        BaseDialog.__init__(self, parent, remove_stretch=True)
        message = _("Edit Standard Letters")
        self.setWindowTitle(message)

        self._standard_letters = None
        self.deleted_letters = []

        header_label = QtWidgets.QLabel("<b>%s</b>" % message)

        self.list_model = ListModel()

        self.list_view = QtWidgets.QListView()
        self.list_view.setModel(self.list_model)

        icon = QtGui.QIcon(":/eraser.png")
        delete_but = QtWidgets.QPushButton(icon, "")
        delete_but.setToolTip(_("Delete the currently selected letter"))
        delete_but.setMaximumWidth(80)

        icon = QtGui.QIcon(":/add_user.png")
        add_but = QtWidgets.QPushButton(icon, "")
        add_but.setToolTip(_("Add a New Letter"))
        add_but.setMaximumWidth(80)

        left_frame = QtWidgets.QFrame()
        layout = QtWidgets.QGridLayout(left_frame)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self.list_view, 0, 0, 1, 3)
        layout.addWidget(delete_but, 1, 0)
        layout.addWidget(add_but, 1, 1)
        left_frame.setMaximumWidth(250)

        right_frame = QtWidgets.QFrame()
        layout = QtWidgets.QFormLayout(right_frame)
        layout.setContentsMargins(0, 0, 0, 0)
        self.description_line_edit = QtWidgets.QLineEdit()
        self.text_edit = Qsci.QsciScintilla()
        self.text_edit.setLexer(Qsci.QsciLexerHTML())
        self.footer_text_edit = Qsci.QsciScintilla()
        self.footer_text_edit.setLexer(Qsci.QsciLexerHTML())

        layout.addRow(_("Desctription"), self.description_line_edit)
        layout.addRow(_("Body Text"), self.text_edit)
        layout.addRow(_("Footer"), self.footer_text_edit)

        splitter = QtWidgets.QSplitter()
        splitter.addWidget(left_frame)
        splitter.addWidget(right_frame)
        splitter.setSizes([1, 10])
        self.insertWidget(header_label)
        self.insertWidget(splitter)

        self.list_view.pressed.connect(self.show_data)

        self.cancel_but.setText(_("Close"))
        self.apply_but.setText(_("Apply Changes"))

        self.set_check_on_cancel(True)
        self.signals()
        add_but.clicked.connect(self.add_letter)
        delete_but.clicked.connect(self.remove_letter)

        self.orig_data = []
        QtCore.QTimer.singleShot(100, self.load_existing)