Пример #1
0
 def __init__(self, *args, **kwargs):
     QAction.__init__(self, *args)
     WinterObject.__init__(self)
     self.title = self.text()
     self.api = API()
     if 'icon' in kwargs:
         icon = kwargs['icon']
         self.orig_icon = QIcon(self.api.icons[icon])
         self.setIcon(QIcon.fromTheme(icon, QIcon(self.api.icons[icon])))
     if isinstance(args[0], QIcon):
         icon = args[0]
         self.orig_icon = icon
         self.setIcon(icon)
Пример #2
0
 def __init__(self, title, pattern, color, font, font_size=10, offset=0, bold=False, italic=False):
     WinterObject.__init__(self)
     self.title = title
     self.pattern = pattern
     self.color = QColor(color)
     self.offset = offset
     self.bold = bold
     self.italic = italic
     self.font_size = font_size
     self.font = QFont(font)
     self.font.setBold(self.bold)
     self.font.setItalic(self.italic)
     self.font.setPointSize(self.font_size)
Пример #3
0
 def __init__(self, *args, **kwargs):
     QAction.__init__(self, *args)
     WinterObject.__init__(self)
     self.title = self.text()
     self.api = API()
     if 'icon' in kwargs:
         icon = kwargs['icon']
         self.orig_icon = QIcon(self.api.icons[icon])
         self.setIcon(QIcon.fromTheme(icon, QIcon(self.api.icons[icon])))
     if isinstance(args[0], QIcon):
         icon = args[0]
         self.orig_icon = icon
         self.setIcon(icon)
Пример #4
0
    def __init__(self, parent, filename='', lexer='', autosave=True):
        FocusProxy.__init__(self)
        WinterObject.__init__(self)
        self.QSCI_SUPPORT = QSCI_SUPPORT
        self.parent = parent
        self.autosave = autosave
        try:
            self.api = parent.API()
        except AttributeError:
            from baseQt import API

            self.api = API()
        self.filename = filename
        lay = QVBoxLayout()
        self.tb = QToolBar(self)
        lay.addWidget(self.tb)

        self.tb_save = QToolButton()
        #        self.tb_save.setIcon(QIcon.fromTheme('document-save', QIcon(self.api.icons['filesave'])))
        #        self.connect(self.tb_save, SIGNAL("clicked()"), self.save)
        #        self.tb.addWidget(self.tb_save)

        if QSCI_SUPPORT:
            editor = QsciScintilla(self)
            editor.setUtf8(True)
            self.lexers = {'Bash': QsciLexerBash, 'Batch': QsciLexerBatch, 'CMake': QsciLexerCMake, 'CPP': QsciLexerCPP,
                           'CSS': QsciLexerCSS, 'D': QsciLexerD, 'Diff': QsciLexerDiff, 'Fortran': QsciLexerFortran77,
                           'HTML': QsciLexerHTML, 'Lua': QsciLexerLua, 'Make': QsciLexerMakefile,
                           'Pascal': QsciLexerPascal,
                           'Perl': QsciLexerPerl, 'PostScript': QsciLexerPostScript, 'POV': QsciLexerPOV,
                           'Properties': QsciLexerProperties, 'Python': QsciLexerPython, 'Ruby': QsciLexerRuby,
                           'SQL': QsciLexerSQL, 'TCL': QsciLexerTCL, 'TeX': QsciLexerTeX,
                           'VHDL': QsciLexerVHDL, 'YAML': QsciLexerYAML, 'Plain': QsciLexerPython}

            if lexer:
                lex = self.lexers[lexer]()
                lex.setPaper(QColor(self.parent.config.options.qsci.bg_color))
                #lex.setColor(QColor(self.parent.config.options.qsci.fg_color))
                editor.setLexer(lex)

            editor.resetSelectionBackgroundColor()
            editor.resetSelectionForegroundColor()
            editor.setCaretLineBackgroundColor(QColor(self.parent.config.options.qsci.caretline_color))
            editor.setMarginsBackgroundColor(QColor(self.parent.config.options.qsci.margins_bg_color))
            editor.setMarginsForegroundColor(QColor(self.parent.config.options.qsci.margins_fg_color))
            editor.setFoldMarginColors(QColor(self.parent.config.options.qsci.foldmargin_prim_color),
                QColor(self.parent.config.options.qsci.foldmargin_sec_color))
            editor.setSelectionBackgroundColor(QColor(self.parent.config.options.qsci.selection_bg_color))
            editor.setSelectionForegroundColor(QColor(self.parent.config.options.qsci.selection_fg_color))
            editor.setFolding(self.parent.config.options.qsci.folding)
            editor.setPaper(QColor(self.parent.config.options.qsci.bg_color))
            editor.setColor(QColor(self.parent.config.options.qsci.fg_color))

            font = QFont()
            font.setFamily(self.parent.config.options.qsci.font)
            font.setFixedPitch(True)
            font.setPointSize(self.parent.config.options.qsci.font_size)
            fm = QFontMetrics(font)
            editor.setFont(font)
            if self.parent.config.options.qsci.linenumbers:
                editor.setMarginsFont(font)
                editor.setMarginWidth(0, fm.width("000") + 5)
                editor.setMarginLineNumbers(0, True)
            if self.parent.config.options.qsci.folding:
                editor.setFolding(QsciScintilla.BoxedTreeFoldStyle)
            editor.setBraceMatching(QsciScintilla.SloppyBraceMatch)
            editor.setCaretLineVisible(self.parent.config.options.qsci.caretline)




        else:
            editor = QTextEdit(self)

        self.editor = editor
        self.focused = editor
        lay.addWidget(editor)
        if filename:
            self.open(filename)

        self.setLayout(lay)

        if self.autosave:
            self.editor.focusOutEvent = self.focusOutEvent