Example #1
0
void GenericCodeEditor::onCursorPositionChanged()
{
    if (mHighlightCurrentLine)
        updateCurrentLineHighlighting();
    mLastCursorBlock = textCursor().blockNumber();
    updateDocLastSelection();
}
Example #2
0
void GenericCodeEditor::applySettings( Settings::Manager *settings )
{
    settings->beginGroup("IDE/editor");

    bool lineWrap = settings->value("lineWrap").toBool();
    bool showWhitespace = settings->value("showWhitespace").toBool();
    mInactiveFadeAlpha = settings->value("inactiveEditorFadeAlpha").toInt();

    QPalette palette;

    settings->beginGroup("colors");

    if (settings->contains("text")) {
        QTextCharFormat format = settings->value("text").value<QTextCharFormat>();
        QBrush bg = format.background();
        QBrush fg = format.foreground();
        if (bg.style() != Qt::NoBrush)
            palette.setBrush(QPalette::Base, bg);
        if (fg.style() != Qt::NoBrush)
            palette.setBrush(QPalette::Text, fg);
    }

    if (settings->contains("lineNumbers")) {
        // NOTE: the line number widget will inherit the palette from the editor
        QTextCharFormat format = settings->value("lineNumbers").value<QTextCharFormat>();
        QBrush bg = format.background();
        QBrush fg = format.foreground();
        if (bg.style() != Qt::NoBrush)
            palette.setBrush(QPalette::Mid, bg);
        if (fg.style() != Qt::NoBrush)
            palette.setBrush(QPalette::ButtonText, fg);
    }

    if (settings->contains("selection")) {
        QTextCharFormat format = settings->value("selection").value<QTextCharFormat>();
        QBrush bg = format.background();
        QBrush fg = format.foreground();
        if (bg.style() != Qt::NoBrush)
            palette.setBrush(QPalette::Highlight, bg);
        if (fg.style() != Qt::NoBrush)
            palette.setBrush(QPalette::HighlightedText, fg);
    }

    mCurrentLineTextFormat = settings->value("currentLine").value<QTextCharFormat>();
    mSearchResultTextFormat = settings->value("searchResult").value<QTextCharFormat>();

    settings->endGroup(); // colors

    mHighlightCurrentLine = settings->value("highlightCurrentLine").toBool();
    updateCurrentLineHighlighting();

    settings->endGroup(); // IDE/editor

    setLineWrapMode( lineWrap ? QPlainTextEdit::WidgetWidth : QPlainTextEdit::NoWrap );
    setShowWhitespace( showWhitespace );
    setPalette(palette);
    
    setActiveAppearance(hasFocus());
}
Example #3
0
void GenericCodeEditor::applySettings( Settings::Manager *settings )
{
    settings->beginGroup("IDE/editor");

    bool lineWrap = settings->value("lineWrap").toBool();
    bool showWhitespace = settings->value("showWhitespace").toBool();
    bool showLinenumber = settings->value("showLinenumber").toBool();
    mInactiveFadeAlpha = settings->value("inactiveEditorFadeAlpha").toInt();

    QPalette palette;

    const QTextCharFormat *format = &settings->getThemeVal("text");
    QBrush bg = format->background();
    QBrush fg = format->foreground();
    if (bg.style() != Qt::NoBrush)
        palette.setBrush(QPalette::Base, bg);
    if (fg.style() != Qt::NoBrush)
        palette.setBrush(QPalette::Text, fg);

    // NOTE: the line number widget will inherit the palette from the editor
    format = &settings->getThemeVal("lineNumbers");
    mLineIndicator->setFont(format->font());
    bg = format->background();
    fg = format->foreground();
    palette.setBrush(QPalette::Mid,
                            bg.style() != Qt::NoBrush ? bg : palette.base());
    palette.setBrush(QPalette::ButtonText,
                            fg.style() != Qt::NoBrush ? fg : palette.base());

    format = &settings->getThemeVal("selection");
    bg = format->background();
    fg = format->foreground();
    if (bg.style() != Qt::NoBrush)
        palette.setBrush(QPalette::Highlight, bg);
    if (fg.style() != Qt::NoBrush)
        palette.setBrush(QPalette::HighlightedText, fg);

    mCurrentLineTextFormat = settings->getThemeVal("currentLine");
    mSearchResultTextFormat = settings->getThemeVal("searchResult");

    mHighlightCurrentLine = settings->value("highlightCurrentLine").toBool();
    updateCurrentLineHighlighting();

    settings->endGroup(); // IDE/editor

    setLineWrapMode( lineWrap ? QPlainTextEdit::WidgetWidth : QPlainTextEdit::NoWrap );
    setShowWhitespace( showWhitespace );
    setShowLinenumber( showLinenumber );
    mLineIndicator->setLineCount(blockCount());
    setPalette(palette);
    
    setActiveAppearance(hasFocus());
}