示例#1
0
CharacterGeneral::CharacterGeneral(QWidget *parent, bool uniqueFormat)
        : QWidget(parent),
        m_blockSignals(false),
        m_nameVisible(true),
        m_style(0)
{
    widget.setupUi(this);

    m_layoutTab = new FontLayoutTab(true, uniqueFormat, this);

    m_characterDecorations = new FontDecorations(uniqueFormat, this);
    connect(m_characterDecorations, SIGNAL(backgroundColorChanged(QColor)), this, SLOT(slotBackgroundColorChanged(QColor)));
    connect(m_characterDecorations, SIGNAL(textColorChanged(QColor)), this, SLOT(slotTextColorChanged(QColor)));

    m_characterHighlighting = new CharacterHighlighting(uniqueFormat, this);
    connect(m_characterHighlighting, SIGNAL(underlineChanged(KCharacterStyle::LineType, KCharacterStyle::LineStyle, QColor)), this, SLOT(slotUnderlineChanged(KCharacterStyle::LineType, KCharacterStyle::LineStyle, QColor)));
    connect(m_characterHighlighting, SIGNAL(strikethroughChanged(KCharacterStyle::LineType, KCharacterStyle::LineStyle, QColor)), this, SLOT(slotStrikethroughChanged(KCharacterStyle::LineType, KCharacterStyle::LineStyle, QColor)));
    connect(m_characterHighlighting, SIGNAL(capitalizationChanged(QFont::Capitalization)), this, SLOT(slotCapitalizationChanged(QFont::Capitalization)));

    m_fontTab = new FontTab(uniqueFormat, this);
    connect(m_fontTab, SIGNAL(fontChanged(const QFont &)), this, SLOT(slotFontSelected(const QFont &)));

    m_languageTab = new LanguageTab(uniqueFormat, this);

    widget.tabs->addTab(m_fontTab, i18n("Font"));
    widget.tabs->addTab(m_characterDecorations, i18n("Decorations"));
    widget.tabs->addTab(m_characterHighlighting, i18n("Highlighting"));
    widget.tabs->addTab(m_layoutTab, i18n("Layout"));
    //widget.tabs->addTab(m_languageTab, i18n("Language"));
    m_languageTab->setVisible(false);

    connect(widget.name, SIGNAL(textChanged(const QString &)), this, SIGNAL(nameChanged(const QString&)));
    connect(widget.name, SIGNAL(textChanged(const QString &)), this, SLOT(setName(const QString&)));
}
示例#2
0
void DocumentHandler::setUnderline(bool arg)
{
    QTextCharFormat fmt;
    fmt.setFontUnderline(arg);
    mergeFormatOnWordOrSelection(fmt);
    emit underlineChanged();
}
示例#3
0
void DocumentHandler::reset()
{
    emit fontFamilyChanged();
    emit alignmentChanged();
    emit boldChanged();
    emit italicChanged();
    emit underlineChanged();
    emit fontSizeChanged();
    emit textColorChanged();
}
示例#4
0
void Text::dispatchEvents()
{
    int old_line = m_old_line + (m_old_start_index / m_width);
    int new_line = m_line + (m_start_index / m_width);
    if (old_line != new_line) {
        m_old_line = m_line;
        emit lineChanged();
    }

    if (m_latin != m_latin_old) {
        m_latin_old = m_latin;
        emit latinChanged();
    }

    if (m_old_start_index != m_start_index
            || m_text_dirty) {
        m_text_dirty = false;
        QString old_text = m_text;
        m_text = m_text_line->mid(m_start_index, m_end_index - m_start_index + 1);
        if (m_old_start_index != m_start_index) {
            m_old_start_index = m_start_index;
            emit indexChanged();
        }
        emit textChanged();
    }

    if (m_style_dirty) {
        m_style_dirty = false;

        bool emit_foreground = m_new_style.foreground != m_style.foreground;
        bool emit_background = m_new_style.background != m_style.background;
        TextStyle::Styles new_style = m_new_style.style;
        TextStyle::Styles old_style = m_style.style;

        bool emit_bold = false;
        bool emit_blink = false;
        bool emit_underline = false;
        bool emit_inverse = false;
        if (new_style != old_style) {
            emit_bold = differentStyle(new_style, old_style, TextStyle::Bold);
            emit_blink = differentStyle(new_style, old_style, TextStyle::Blinking);
            emit_underline = differentStyle(new_style, old_style, TextStyle::Underlined);
            emit_inverse = differentStyle(new_style, old_style, TextStyle::Inverse);
        }

        m_style = m_new_style;
        if (emit_inverse) {
            setForegroundColor();
            setBackgroundColor();
        } else {
            if (emit_foreground || emit_bold) {
                setForegroundColor();
            }
            if (emit_background) {
                setBackgroundColor();
            }
        }

        if (emit_bold) {
            emit boldChanged();
        }

        if (emit_blink) {
            emit blinkingChanged();
        }

        if (emit_underline) {
            emit underlineChanged();
        }

    }


    if (m_visible_old != m_visible) {
        m_visible_old = m_visible;
        emit visibleChanged();
    }
}