Esempio n. 1
0
void Theme::fillDefault()
{
    addToTheme(mFormats, "text", QColor(Qt::black), QColor(Qt::white));

    QPalette appPlt(QApplication::palette());
    QColor bkg = appPlt.color(QPalette::Base);
    int value = bkg.value();
    if (value > 40)
        bkg.setHsv(bkg.hue(), bkg.saturation(), value - 11);
    else
        bkg.setHsv(bkg.hue(), bkg.saturation(), value + 20);
    addToTheme(mFormats, "currentLine", QColor(Qt::black), bkg.toRgb());
    addToTheme(mFormats, "searchResult",
               appPlt.color(QPalette::HighlightedText).darker(200),
               appPlt.color(QPalette::Highlight).darker(200));
    addToTheme(mFormats, "matchingBrackets", QColor("#2bc93d"), Qt::yellow, true);
    addToTheme(mFormats, "mismatchedBrackets", Qt::white, QColor(150,0,0));
    addToTheme(mFormats, "evaluatedCode", Qt::black, QColor("#F8A200"));

    QPalette plt(QApplication::palette());
    QColor base = plt.color(QPalette::Base);
    QColor text = plt.color(QPalette::Text);
    int shade = (base.red() + base.green() + base.blue() < 380) ? 160 : 100;

    QColor whitespace_color((base.red() + text.red()) / 2,
                            (base.green() + text.green()) / 2,
                            (base.blue() + text.blue()) / 2);

    addToTheme(mFormats, "whitespace", whitespace_color);
    addToTheme(mFormats, "keyword", QColor(0,0,230).lighter(shade),
                                    QColor(Qt::transparent), true);
    addToTheme(mFormats, "built-in", QColor(51,51,191).lighter(shade));
    addToTheme(mFormats, "env-var", QColor(140,70,20).lighter(shade));
    addToTheme(mFormats, "class", QColor(0,0,210).lighter(shade));
    addToTheme(mFormats, "number", QColor(152,0,153).lighter(shade));
    addToTheme(mFormats, "symbol", QColor(0,115,0).lighter(shade));
    addToTheme(mFormats, "string", QColor(95,95,95).lighter(shade));
    addToTheme(mFormats, "char", QColor(0,115,0).lighter(shade));
    addToTheme(mFormats, "comment", QColor(191,0,0).lighter(shade));
    addToTheme(mFormats, "primitive", QColor(51,51,191).lighter(shade));
    addToTheme(mFormats, "lineNumbers", plt.color(QPalette::ButtonText), 
                                        plt.color(QPalette::Mid));
    addToTheme(mFormats, "selection", plt.color(QPalette::HighlightedText),
                                      plt.color(QPalette::Highlight));
    addToTheme(mFormats, "postwindowtext", plt.color(QPalette::ButtonText));
    addToTheme(mFormats, "postwindowerror", QColor(209, 28, 36));
    addToTheme(mFormats, "postwindowwarning", QColor(165, 119, 6));
    addToTheme(mFormats, "postwindowsuccess", QColor(115, 138, 5));
    addToTheme(mFormats, "postwindowemphasis", Qt::black, Qt::transparent, true);
}
Esempio n. 2
0
void Manager::initDefaults()
{
    QPalette appPlt( QApplication::palette() );

    beginGroup("IDE");

    setDefault("startWithSession", "last");

    beginGroup("interpreter");
    setDefault("autoStart", true);
    endGroup();

    setDefault("postWindow/scrollback", 1000);

    beginGroup("editor");

    setDefault("spaceIndent", false);
    setDefault("indentWidth", 4);
    setDefault("stepForwardEvaluation", false);
    setDefault("lineWrap", true);
    setDefault("disableBlinkingCursor", false);
    setDefault("highlightBracketContents", true);
    setDefault("inactiveEditorFadeAlpha", 64);
    setDefault("insertMatchingTokens", false);

    setDefault("blinkDuration", 600);

    setDefault("font/family", "monospace");
    setDefault("font/antialias", true);

    beginGroup("colors");

    QTextCharFormat matchingBracketsFormat;
    matchingBracketsFormat.setForeground(Qt::red);
    matchingBracketsFormat.setBackground(QColor("#ffff7f"));
    matchingBracketsFormat.setFontWeight(QFont::Bold);
    setDefault("matchingBrackets", QVariant::fromValue(matchingBracketsFormat));

    QTextCharFormat bracketMismatchFormat;
    bracketMismatchFormat.setBackground(QColor(150,0,0));
    bracketMismatchFormat.setForeground(Qt::white);
    setDefault("mismatchedBrackets", QVariant::fromValue(bracketMismatchFormat));

    QTextCharFormat evaluatedCodeFormat;
    evaluatedCodeFormat.setBackground(QColor("#F8A200"));
    evaluatedCodeFormat.setForeground(Qt::black);
    setDefault("evaluatedCode", QVariant::fromValue(evaluatedCodeFormat));

    QTextCharFormat currentLineFormat;
    {
        QColor bkg = appPlt.color(QPalette::Base);
        int value = bkg.value();
        if (value > 40)
            bkg.setHsv( bkg.hue(), bkg.saturation(), value - 11);
        else
            bkg.setHsv( bkg.hue(), bkg.saturation(), value + 20 );
        currentLineFormat.setBackground(bkg.toRgb());
    }
    setDefault("currentLine", QVariant::fromValue(currentLineFormat));

    QTextCharFormat searchResultFormat;
    searchResultFormat.setBackground(appPlt.color(QPalette::Highlight).darker(200));
    searchResultFormat.setForeground(appPlt.color(QPalette::HighlightedText).darker(200));
    setDefault("searchResult", QVariant::fromValue(searchResultFormat));

    endGroup(); // colors

    beginGroup("highlighting");
    initHighlightingDefaults();
    endGroup(); // highlighting

    endGroup(); // editor

    endGroup(); // IDE
}