[kopete-bugs] [Bug 179586] Kopete doesn't apply custom font colour and format in the panel where you write

Roman Jarosz kedgedev at gmail.com
Fri May 15 19:03:31 CEST 2009


https://bugs.kde.org/show_bug.cgi?id=179586





--- Comment #9 from Roman Jarosz <kedgedev gmail com>  2009-05-15 19:03:29 ---
It's more a Qt bug/feature, the QTextEdit removes format when text is cleared.
So in Kopete I've hacked it by remembering the last valid QTextCharFormat
format and setting it back right after it's cleared.
The fix is in commit 965446. To be precise it's the part below (the
updateCharFormat is called every time currentCharFormatChanged is emitted)
Opaque part is there only so we don't store non opaque formats (can happen
during html paste) as a text because when we would load it from string the
background would be back.

void KopeteRichTextWidget::updateCharFormat(const QTextCharFormat & f)
{
    // TODO: This should go to KRichTextWidget or KRichTextEdit
    if (d->resettingCharFormat)
        return;

    if (f != QTextCharFormat() || !document()->isEmpty())
    {
        d->lastCharFormat = f;
        bool bOpaque = d->lastCharFormat.foreground().isOpaque();
        bool fOpaque = d->lastCharFormat.background().isOpaque();

        if (!fOpaque)
            d->lastCharFormat.setForeground(palette().color(QPalette::Active,
QPalette::Text));
        if (!bOpaque)
            d->lastCharFormat.setBackground(palette().color(QPalette::Active,
QPalette::Base));

        if (!fOpaque || !bOpaque)
        {
            d->resettingCharFormat = true;
            KRichTextWidget::setCurrentCharFormat(d->lastCharFormat);
            d->resettingCharFormat = false;
        }

    }
    else
    {
        d->resettingCharFormat = true;
        KRichTextWidget::setCurrentCharFormat(d->lastCharFormat);
        d->resettingCharFormat = false;
    }
    updateActionStates();
}

plus in virtual function createActions has to be

    // FIXME: Really ugly hack, but we reset format in updateCharFormat and if
we don't disconnect this
    //        then actions will have old values and not the resetted.
    disconnect(this, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)),
               this, SLOT(_k_updateCharFormatActions(const QTextCharFormat
&)));

-- 
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the kopete-bugs mailing list