当前位置: 首页>>代码示例>>C++>>正文


C++ texteditor::FontSettings类代码示例

本文整理汇总了C++中texteditor::FontSettings的典型用法代码示例。如果您正苦于以下问题:C++ FontSettings类的具体用法?C++ FontSettings怎么用?C++ FontSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FontSettings类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QDialog

ConfigurationDialog::ConfigurationDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ConfigurationDialog),
    m_settings(0)
{
    ui->setupUi(this);

    // Filter out characters which are not allowed in a file name
    QRegExpValidator *fileNameValidator = new QRegExpValidator(ui->name);
    fileNameValidator->setRegExp(QRegExp(QLatin1String("^[^\\/\\\\\\?\\>\\<\\*\\%\\:\\\"\\']*$")));
    ui->name->setValidator(fileNameValidator);

    updateDocumentation();
    connect(ui->name, SIGNAL(textChanged(QString)), this, SLOT(updateOkButton()));
    updateOkButton(); // force initial test.
    connect(ui->editor, SIGNAL(documentationChanged(QString,QString)),
            this, SLOT(updateDocumentation(QString,QString)));

    // Set palette and font according to settings
    const TextEditor::FontSettings fs = TextEditor::TextEditorSettings::instance()->fontSettings();
    const QTextCharFormat tf = fs.toTextCharFormat(TextEditor::C_TEXT);
    const QTextCharFormat selectionFormat = fs.toTextCharFormat(TextEditor::C_SELECTION);

    QPalette pal;
    pal.setColor(QPalette::Base, tf.background().color());
    pal.setColor(QPalette::Text, tf.foreground().color());
    pal.setColor(QPalette::Foreground, tf.foreground().color());
    if (selectionFormat.background().style() != Qt::NoBrush)
        pal.setColor(QPalette::Highlight, selectionFormat.background().color());
    pal.setBrush(QPalette::HighlightedText, selectionFormat.foreground());
    ui->documentation->setPalette(pal);
    ui->editor->setPalette(pal);

    ui->documentation->setFont(tf.font());
    ui->editor->setFont(tf.font());

    // Set style sheet for documentation browser
    const QTextCharFormat tfOption = fs.toTextCharFormat(TextEditor::C_FIELD);
    const QTextCharFormat tfParam = fs.toTextCharFormat(TextEditor::C_STRING);

    const QString css =  QString::fromLatin1("span.param {color: %1; background-color: %2;} "
                                             "span.option {color: %3; background-color: %4;} "
                                             "p { text-align: justify; } ")
            .arg(tfParam.foreground().color().name())
            .arg(tfParam.background().style() == Qt::NoBrush
                 ? QString() : tfParam.background().color().name())
            .arg(tfOption.foreground().color().name())
            .arg(tfOption.background().style() == Qt::NoBrush
                 ? QString() : tfOption.background().color().name())
            ;
    ui->documentation->document()->setDefaultStyleSheet(css);
}
开发者ID:FlavioFalcao,项目名称:qt-creator,代码行数:52,代码来源:configurationdialog.cpp

示例2: setFontSettings

void JuliaEditorWidget::setFontSettings(const TextEditor::FontSettings &fs)
{
  using namespace TextEditor;
  using namespace TextEditor::Internal;

  BaseTextEditorWidget::setFontSettings(fs);

  if (baseTextDocument()->syntaxHighlighter()) {
      Highlighter *highlighter = static_cast<Highlighter *>(baseTextDocument()->syntaxHighlighter());

      highlighter->configureFormat(Highlighter::VisualWhitespace, fs.toTextCharFormat(C_VISUAL_WHITESPACE));
      highlighter->configureFormat(Highlighter::Keyword, fs.toTextCharFormat(C_KEYWORD));
      highlighter->configureFormat(Highlighter::DataType, fs.toTextCharFormat(C_TYPE));
      highlighter->configureFormat(Highlighter::Comment, fs.toTextCharFormat(C_COMMENT));
      // Using C_NUMBER for all kinds of numbers.
      highlighter->configureFormat(Highlighter::Decimal, fs.toTextCharFormat(C_NUMBER));
      highlighter->configureFormat(Highlighter::BaseN, fs.toTextCharFormat(C_NUMBER));
      highlighter->configureFormat(Highlighter::Float, fs.toTextCharFormat(C_NUMBER));
      // Using C_STRING for strings and chars.
      highlighter->configureFormat(Highlighter::Char, fs.toTextCharFormat(C_STRING));
      highlighter->configureFormat(Highlighter::String, fs.toTextCharFormat(C_STRING));

      highlighter->rehighlight();
  }
}
开发者ID:bangele,项目名称:julia-studio,代码行数:25,代码来源:juliaeditor.cpp

示例3: setFontSettings

void GLSLTextEditorWidget::setFontSettings(const TextEditor::FontSettings &fs)
{
    TextEditor::BaseTextEditorWidget::setFontSettings(fs);
    Highlighter *highlighter = qobject_cast<Highlighter*>(baseTextDocument()->syntaxHighlighter());
    if (!highlighter)
        return;

    /*
        NumberFormat,
        StringFormat,
        TypeFormat,
        KeywordFormat,
        LabelFormat,
        CommentFormat,
        VisualWhitespace,
     */
    static QVector<TextEditor::TextStyle> categories;
    if (categories.isEmpty()) {
        categories << TextEditor::C_NUMBER
                   << TextEditor::C_STRING
                   << TextEditor::C_TYPE
                   << TextEditor::C_KEYWORD
                   << TextEditor::C_OPERATOR
                   << TextEditor::C_PREPROCESSOR
                   << TextEditor::C_LABEL
                   << TextEditor::C_COMMENT
                   << TextEditor::C_DOXYGEN_COMMENT
                   << TextEditor::C_DOXYGEN_TAG
                   << TextEditor::C_VISUAL_WHITESPACE
                   << TextEditor::C_REMOVED_LINE;
    }

    highlighter->setFormats(fs.toTextCharFormats(categories));
    highlighter->rehighlight();
}
开发者ID:KDE,项目名称:android-qt-creator,代码行数:35,代码来源:glsleditor.cpp

示例4: setFontSettings

void ProFileEditorWidget::setFontSettings(const TextEditor::FontSettings &fs)
{
    TextEditor::BaseTextEditorWidget::setFontSettings(fs);
    ProFileHighlighter *highlighter = qobject_cast<ProFileHighlighter*>(baseTextDocument()->syntaxHighlighter());
    if (!highlighter)
        return;

    static QVector<TextEditor::TextStyle> categories;
    if (categories.isEmpty()) {
        categories << TextEditor::C_TYPE
                   << TextEditor::C_KEYWORD
                   << TextEditor::C_COMMENT
                   << TextEditor::C_VISUAL_WHITESPACE;
    }

    highlighter->setFormats(fs.toTextCharFormats(categories));
    highlighter->rehighlight();
}
开发者ID:aizaimenghuangu,项目名称:QtTestor,代码行数:18,代码来源:profileeditor.cpp

示例5: setFontSettings

void CMakeEditor::setFontSettings(const TextEditor::FontSettings &fs)
{
    TextEditor::BaseTextEditor::setFontSettings(fs);
    CMakeHighlighter *highlighter = qobject_cast<CMakeHighlighter*>(baseTextDocument()->syntaxHighlighter());
    if (!highlighter)
        return;

    static QVector<QString> categories;
    if (categories.isEmpty()) {
        categories << QLatin1String(TextEditor::Constants::C_LABEL)  // variables
                << QLatin1String(TextEditor::Constants::C_LINK)   // functions
                << QLatin1String(TextEditor::Constants::C_COMMENT)
                << QLatin1String(TextEditor::Constants::C_STRING);
    }

    const QVector<QTextCharFormat> formats = fs.toTextCharFormats(categories);
    highlighter->setFormats(formats.constBegin(), formats.constEnd());
    highlighter->rehighlight();
}
开发者ID:TheProjecter,项目名称:project-qtcreator,代码行数:19,代码来源:cmakeeditor.cpp

示例6: updateFontSettings

void SemanticHighlighter::updateFontSettings(const TextEditor::FontSettings &fontSettings)
{
    m_formats[LocalIdType] = fontSettings.toTextCharFormat(TextEditor::C_QML_LOCAL_ID);
    m_formats[ExternalIdType] = fontSettings.toTextCharFormat(TextEditor::C_QML_EXTERNAL_ID);
    m_formats[QmlTypeType] = fontSettings.toTextCharFormat(TextEditor::C_QML_TYPE_ID);
    m_formats[RootObjectPropertyType] = fontSettings.toTextCharFormat(TextEditor::C_QML_ROOT_OBJECT_PROPERTY);
    m_formats[ScopeObjectPropertyType] = fontSettings.toTextCharFormat(TextEditor::C_QML_SCOPE_OBJECT_PROPERTY);
    m_formats[ExternalObjectPropertyType] = fontSettings.toTextCharFormat(TextEditor::C_QML_EXTERNAL_OBJECT_PROPERTY);
    m_formats[JsScopeType] = fontSettings.toTextCharFormat(TextEditor::C_JS_SCOPE_VAR);
    m_formats[JsImportType] = fontSettings.toTextCharFormat(TextEditor::C_JS_IMPORT_VAR);
    m_formats[JsGlobalType] = fontSettings.toTextCharFormat(TextEditor::C_JS_GLOBAL_VAR);
    m_formats[LocalStateNameType] = fontSettings.toTextCharFormat(TextEditor::C_QML_STATE_NAME);
    m_formats[BindingNameType] = fontSettings.toTextCharFormat(TextEditor::C_BINDING);
    m_formats[FieldType] = fontSettings.toTextCharFormat(TextEditor::C_FIELD);
}
开发者ID:CNOT,项目名称:julia-studio,代码行数:15,代码来源:qmljssemantichighlighter.cpp

示例7: commentFormat

// Retrieve the comment char format from the text editor.
static QTextCharFormat commentFormat()
{
    const TextEditor::FontSettings settings = TextEditor::TextEditorSettings::instance()->fontSettings();
    return settings.toTextCharFormat(TextEditor::C_COMMENT);
}
开发者ID:CNOT,项目名称:julia-studio,代码行数:6,代码来源:gitsubmiteditorwidget.cpp

示例8: setFontSettings

/**
  QtCreator has own fonts&color settings. Highlighter wants get access to
  this settings before highlightBlock() called first time.
  Settings provided by PyEditor::EditorWidget class.
  */
void Highlighter::setFontSettings(const TextEditor::FontSettings &fs)
{
    _formats = fs.toTextCharFormats(FORMAT_CATEGORIES);
    rehighlight();
}
开发者ID:sergey-shambir,项目名称:sergey-shambir-sandbox,代码行数:10,代码来源:highlighter.cpp


注:本文中的texteditor::FontSettings类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。