Пример #1
0
SettingsStore::CodeViewAppearance AppearanceWidget::readSettings()
{
    SettingsStore settings;
    SettingsStore::BookViewAppearance bookViewAppearance = settings.bookViewAppearance();
    SettingsStore::CodeViewAppearance codeViewAppearance = settings.codeViewAppearance();
    SettingsStore::SpecialCharacterAppearance specialCharacterAppearance = settings.specialCharacterAppearance();
    loadComboValueOrDefault(ui.cbBookViewFontStandard,  bookViewAppearance.font_family_standard,    "Arial");
    loadComboValueOrDefault(ui.cbBookViewFontSerif,     bookViewAppearance.font_family_serif,       "Times New Roman");
    loadComboValueOrDefault(ui.cbBookViewFontSansSerif, bookViewAppearance.font_family_sans_serif,  "Arial");
    loadComboValueOrDefault(ui.cbCodeViewFont,          codeViewAppearance.font_family,             "Consolas");
    loadComboValueOrDefault(ui.cbSpecialCharacterFont,  specialCharacterAppearance.font_family,     "Helvetica");
    ui.bookViewFontSizeSpin->setValue(bookViewAppearance.font_size);
    ui.codeViewFontSizeSpin->setValue(codeViewAppearance.font_size);
    ui.specialCharacterFontSizeSpin->setValue(specialCharacterAppearance.font_size);
    codeViewAppearance.font_family = ui.cbCodeViewFont->currentText();
    return codeViewAppearance;
}
Пример #2
0
// Constructor
XHTMLHighlighter::XHTMLHighlighter(bool checkSpelling, QObject *parent)
    : QSyntaxHighlighter(parent),
      m_checkSpelling(checkSpelling)

{
    SettingsStore settings;
    m_codeViewAppearance = settings.codeViewAppearance();
    QTextCharFormat html_format;
    QTextCharFormat doctype_format;
    QTextCharFormat html_comment_format;
    QTextCharFormat css_format;
    QTextCharFormat css_comment_format;
    QTextCharFormat attribute_name_format;
    QTextCharFormat attribute_value_format;
    QTextCharFormat entity_format;
    doctype_format        .setForeground(m_codeViewAppearance.xhtml_doctype_color);
    html_format           .setForeground(m_codeViewAppearance.xhtml_html_color);
    html_comment_format   .setForeground(m_codeViewAppearance.xhtml_html_comment_color);
    css_format            .setForeground(m_codeViewAppearance.xhtml_css_color);
    css_comment_format    .setForeground(m_codeViewAppearance.xhtml_css_comment_color);
    attribute_name_format .setForeground(m_codeViewAppearance.xhtml_attribute_name_color);
    attribute_value_format.setForeground(m_codeViewAppearance.xhtml_attribute_value_color);
    entity_format         .setForeground(m_codeViewAppearance.xhtml_entity_color);
    HighlightingRule rule;
    rule.pattern = QRegularExpression(DOCTYPE_BEGIN);
    rule.format  = doctype_format;
    m_Rules[ "DOCTYPE_BEGIN" ] = rule;
    rule.pattern = QRegularExpression(HTML_ELEMENT_BEGIN);
    rule.format  = html_format;
    m_Rules[ "HTML_ELEMENT_BEGIN" ] = rule;
    rule.pattern = QRegularExpression(HTML_ELEMENT_END);
    rule.format  = html_format;
    m_Rules[ "HTML_ELEMENT_END" ] = rule;
    rule.pattern = QRegularExpression(HTML_COMMENT_BEGIN);
    rule.format  = html_comment_format;
    m_Rules[ "HTML_COMMENT_BEGIN" ] = rule;
    rule.pattern = QRegularExpression(HTML_COMMENT_END);
    rule.format  = html_comment_format;
    m_Rules[ "HTML_COMMENT_END" ] = rule;
    rule.pattern = QRegularExpression(CSS_BEGIN);
    rule.format  = css_format;
    m_Rules[ "CSS_BEGIN" ] = rule;
    rule.pattern = QRegularExpression(CSS_END);
    rule.format  = css_format;
    m_Rules[ "CSS_END" ] = rule;
    rule.pattern = QRegularExpression(CSS_COMMENT_BEGIN);
    rule.format  = css_comment_format;
    m_Rules[ "CSS_COMMENT_BEGIN" ] = rule;
    rule.pattern = QRegularExpression(CSS_COMMENT_END);
    rule.format  = css_comment_format;
    m_Rules[ "CSS_COMMENT_END" ] = rule;
    rule.pattern = QRegularExpression(ATTRIBUTE_NAME);
    rule.format  = attribute_name_format;
    m_Rules[ "ATTRIBUTE_NAME" ] = rule;
    rule.pattern = QRegularExpression(ATTRIBUTE_VALUE);
    rule.format  = attribute_value_format;
    m_Rules[ "ATTRIBUTE_VALUE" ] = rule;
    rule.pattern = QRegularExpression(ENTITY_BEGIN);
    rule.format  = entity_format;
    m_Rules[ "ENTITY_BEGIN" ] = rule;
    rule.pattern = QRegularExpression(ENTITY_END);
    rule.format  = entity_format;
    m_Rules[ "ENTITY_END" ] = rule;
}
Пример #3
0
// Constructor
XHTMLHighlighter::XHTMLHighlighter(bool checkSpelling, QObject *parent)
    : QSyntaxHighlighter(parent),
      m_checkSpelling(checkSpelling)

{
    SettingsStore settings;
    m_codeViewAppearance = settings.codeViewAppearance();
    QTextCharFormat html_format;
    QTextCharFormat doctype_format;
    QTextCharFormat html_comment_format;
    QTextCharFormat css_format;
    QTextCharFormat css_comment_format;
    QTextCharFormat attribute_name_format;
    QTextCharFormat attribute_value_format;
    QTextCharFormat entity_format;
    QTextCharFormat special_space_format;

    doctype_format        .setForeground(m_codeViewAppearance.xhtml_doctype_color);
    html_format           .setForeground(m_codeViewAppearance.xhtml_html_color);
    html_comment_format   .setForeground(m_codeViewAppearance.xhtml_html_comment_color);
    css_format            .setForeground(m_codeViewAppearance.xhtml_css_color);
    css_comment_format    .setForeground(m_codeViewAppearance.xhtml_css_comment_color);
    attribute_name_format .setForeground(m_codeViewAppearance.xhtml_attribute_name_color);
    attribute_value_format.setForeground(m_codeViewAppearance.xhtml_attribute_value_color);
    entity_format         .setForeground(m_codeViewAppearance.xhtml_entity_color);
    // use the same color as for entities but as an underline since they are "spaces"
    special_space_format  .setUnderlineColor(m_codeViewAppearance.xhtml_entity_color);
    special_space_format  .setUnderlineStyle(QTextCharFormat::DashUnderline);
    HighlightingRule rule;
    rule.pattern = QRegularExpression(DOCTYPE_BEGIN);
    rule.format  = doctype_format;
    m_Rules[ "DOCTYPE_BEGIN" ] = rule;
    rule.pattern = QRegularExpression(HTML_ELEMENT_BEGIN);
    rule.format  = html_format;
    m_Rules[ "HTML_ELEMENT_BEGIN" ] = rule;
    rule.pattern = QRegularExpression(HTML_ELEMENT_END);
    rule.format  = html_format;
    m_Rules[ "HTML_ELEMENT_END" ] = rule;
    rule.pattern = QRegularExpression(HTML_COMMENT_BEGIN);
    rule.format  = html_comment_format;
    m_Rules[ "HTML_COMMENT_BEGIN" ] = rule;
    rule.pattern = QRegularExpression(HTML_COMMENT_END);
    rule.format  = html_comment_format;
    m_Rules[ "HTML_COMMENT_END" ] = rule;
    rule.pattern = QRegularExpression(CSS_BEGIN);
    rule.format  = css_format;
    m_Rules[ "CSS_BEGIN" ] = rule;
    rule.pattern = QRegularExpression(CSS_END);
    rule.format  = css_format;
    m_Rules[ "CSS_END" ] = rule;
    rule.pattern = QRegularExpression(CSS_COMMENT_BEGIN);
    rule.format  = css_comment_format;
    m_Rules[ "CSS_COMMENT_BEGIN" ] = rule;
    rule.pattern = QRegularExpression(CSS_COMMENT_END);
    rule.format  = css_comment_format;
    m_Rules[ "CSS_COMMENT_END" ] = rule;
    rule.pattern = QRegularExpression(ATTRIBUTE_NAME);
    rule.format  = attribute_name_format;
    m_Rules[ "ATTRIBUTE_NAME" ] = rule;
    rule.pattern = QRegularExpression(ATTRIBUTE_VALUE);
    rule.format  = attribute_value_format;
    m_Rules[ "ATTRIBUTE_VALUE" ] = rule;
    rule.pattern = QRegularExpression(ENTITY_BEGIN);
    rule.format  = entity_format;
    m_Rules[ "ENTITY_BEGIN" ] = rule;
    rule.pattern = QRegularExpression(ENTITY_END);
    rule.format  = entity_format;
    m_Rules[ "ENTITY_END" ] = rule;
    rule.pattern = QRegularExpression(SPECIAL_SPACE_BEGIN);
    rule.format  = special_space_format;
    m_Rules[ "SPECIAL_SPACE_BEGIN" ] = rule;
}