Пример #1
0
 def set_type(self):
     try:
         ext = self.file_name.split(".")[-1]
         print(ext)
     except:
         ext = ""
         self.text_edit_field.setLexer(Qsci.QsciLexerCPP(self))
         pass
     if ext == "py":
         self.text_edit_field.setLexer(Qsci.QsciLexerPython(self))
         self.hide_web()
         print("type python")
     elif ext == "cpp" or ext == "c":
         self.text_edit_field.setLexer(Qsci.QsciLexerCPP(self))
         self.hide_web()
         print("type cpp")
     elif ext == "html":
         self.text_edit_field.setLexer(Qsci.QsciLexerHTML(self))
         self.terminal.setHidden(True)
         self.browser = QWebView(self)
         self.browser.load(QUrl(self.file_name))
         self.browser.move(self.x_y[0] * 66, 30)
         self.browser.setFixedSize(self.x_y[0] * 0.33, self.x_y[1] - 20)
         self.browser.show()
         #self.browser.move(500,0)
         #self.setGeometry((self.screen.width()-self.wd+200)/2,0,self.wd,self.ht-50)
         #self.setFixedSize(self.wd+200,self.ht-50)
         print("type html")
Пример #2
0
 def setScintillaProperties(self, scintillaWidget, contentType='html'):
     scintillaWidget.setFont(self.framework.get_font())
     scintillaWidget.setWrapMode(1)
     scintillaWidget.zoomTo(self.framework.get_zoom_size())
     # TOOD: set based on line numbers (size is in pixels)
     scintillaWidget.setMarginWidth(1, '1000')
     lexerInstance = Qsci.QsciLexerHTML(scintillaWidget)
     lexerInstance.setFont(self.framework.get_font())
     scintillaWidget.setLexer(lexerInstance)
     self.scintillaWidgets.add(scintillaWidget)
Пример #3
0
    def populate_response_content(self, url, req_headers, req_body, res_headers, res_body, res_content_type = ''):
            
        self.request_url = url
        self.request_headers = req_headers
        self.request_body = req_body
        self.response_headers = res_headers
        self.response_body = res_body
        self.response_content_type = res_content_type

        if self.showRequest:
            self.reqReqEdit.setText(ContentHelper.getCombinedText(self.request_headers, self.request_body, ''))

        # TODO: should support different lexers based on content type
        lexerInstance = Qsci.QsciLexerHTML(self.reqResEdit)
        lexerInstance.setFont(self.framework.get_font())
        self.reqResEdit.setLexer(lexerInstance)
        # TODO: should verify trailing newlines?
        self.reqResEdit.setText(ContentHelper.getCombinedText(self.response_headers, self.response_body, self.response_content_type))

        self.do_render_apply(self.tabWidget.currentIndex())
Пример #4
0
def SetScintillaProperties(framework, scintillaWidget, contentType='html'):
    lexerInstance = None
    font = framework.get_font()
    if 'html' == contentType:
        lexerInstance = Qsci.QsciLexerHTML(scintillaWidget)
    elif 'javascript' == contentType:
        lexerInstance = Qsci.QsciLexerJavaScript(scintillaWidget)
    elif 'python' == contentType:
        lexerInstance = Qsci.QsciLexerPython(scintillaWidget)
        font = framework.get_python_code_font()
    elif contentType in ('hex', 'monospace'):
        font = framework.get_monospace_font()
    else:
        pass

    scintillaWidget.setFont(font)
    scintillaWidget.setWrapMode(1)
    scintillaWidget.zoomTo(framework.get_zoom_size())
    # TOOD: set based on line numbers (size is in pixels)
    scintillaWidget.setMarginWidth(1, '1000')
    if lexerInstance is not None:
        lexerInstance.setFont(font)
        scintillaWidget.setLexer(lexerInstance)
    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 = QtGui.QLabel("<b>%s</b>" % message)

        self.list_model = ListModel()

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

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

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

        left_frame = QtGui.QFrame()
        layout = QtGui.QGridLayout(left_frame)
        layout.setMargin(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 = QtGui.QFrame()
        layout = QtGui.QFormLayout(right_frame)
        layout.setMargin(0)
        self.description_line_edit = QtGui.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 = QtGui.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)