Bug 179586 - Kopete doesn't apply custom font colour and format in the panel where you write
Summary: Kopete doesn't apply custom font colour and format in the panel where you write
Status: RESOLVED FIXED
Alias: None
Product: kopete
Classification: Unmaintained
Component: Chat Window (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Kopete Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-04 12:09 UTC by Raul Moratalla
Modified: 2009-05-15 19:03 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Screenshot (43.36 KB, image/png)
2009-01-04 12:10 UTC, Raul Moratalla
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Raul Moratalla 2009-01-04 12:09:57 UTC
Version:            (using Devel)
OS:                Linux
Installed from:    Compiled sources

Hi' I have a custom font color and format (bold) for my outcoming messages. If the message that I write starts with an special character like 'á' kopete doesn't apply the font color to that letter in the panel where you write. Take a look at the screenshot and you will see it :)
Comment 1 Raul Moratalla 2009-01-04 12:10:30 UTC
Created attachment 29887 [details]
Screenshot
Comment 2 Volatore 2009-01-04 15:13:27 UTC
Let the status CONFIRMED, please... the problem is going on for a long time!!

Should this be fixed?

I just want to set a font like Trebuchet, I want it bold, and I want it coloured.
If I try to set it in the chat window from the Format Toolbar I have to set the font one thing at time.
So first I set the *bold* setting, then I write in the chat window, then I set the color, the settings remain the same for a while, then come back to regular sans serif with custom settings.
 
I'm using MSN protocol with latest Kopete on kde4 from openSuSE repository, please solve this. THANKS
Comment 3 Roman Jarosz 2009-05-09 00:08:26 UTC
This should be already fixed in kdelibs
Comment 4 Raul Moratalla 2009-05-12 23:57:41 UTC
Hi, should be possible to know in which version will be included this fix? KDE 4.2x or KDE 4.3?

Thank you
Comment 5 Roman Jarosz 2009-05-13 09:42:17 UTC
It should be fixed since commit 873146. So it is in whole KDE 4.2 and 4.3 series.
Comment 6 Roman Jarosz 2009-05-13 09:46:08 UTC
Sorry this is different bug :( but this one is also fixed (commit 965446) :) but only in trunk so it will be in KDE 4.3 beta2 (not in KDE 4.3 beta1)
Comment 7 Roman Jarosz 2009-05-13 09:47:02 UTC
And the fix is in Kopete
Comment 8 Valerio Pilo 2009-05-15 17:01:41 UTC
Hi, I'm sorry but in KMess we use a normal KTextEdit and we still experience the same issue; how is it be possible for it to have been a Kopete bug?
Comment 9 Roman Jarosz 2009-05-15 19:03:29 UTC
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 &)));