[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kopete-devel
Subject:    [kopete-devel] [PATCH] fixing krichtexteditor in chatwindow
From:       Cyrill Helg <phlogsmailinglists () gmail ! com>
Date:       2008-08-25 16:46:25
Message-ID: 200808251846.25908.phlogsmailinglists () gmail ! com
[Download RAW message or body]

Hello

I fixed bug 168994, that I reported myself earlier. While playing around in 
the inputbox I found another problem: As soon as you remove all your typed 
text the textbox resets its style. So to adress this the font settings are 
hold in variables as well.

There are other bugs existing relating to this that I try to fix.

Cyrill Helg

["chatwidow.richtext.patch" (text/x-patch)]

Index: kopete/kopete/chatwindow/krichtexteditpart.cpp
===================================================================
--- kopete/kopete/chatwindow/krichtexteditpart.cpp	(Revision 851192)
+++ kopete/kopete/chatwindow/krichtexteditpart.cpp	(Arbeitskopie)
@@ -87,7 +87,7 @@
 public:
     Private()
      : editor(0), richTextEnabled(false), \
                richTextSupport(KRichTextEditPart::DisableRichText),
-       configWriteLock(false)
+       configWriteLock(true) //setting this to true fixes bug: 168994
     {}
 
     KopeteTextEdit *editor;
@@ -100,6 +100,10 @@
 
     KAction *actionTextColor;
 
+    QColor desiredTextColor;
+    QFont desiredFont;
+    int desiredFontSize;
+
     KToggleAction *action_bold;
     KToggleAction *action_italic;
     KToggleAction *action_underline;
@@ -269,7 +273,7 @@
     connect( d->action_underline, SIGNAL(toggled(bool)),
         this, SLOT(setFontUnderline(bool)) );
 
-    // TODO: Port to new Qt4 signals
+    // TODO: Port to new Qt4 signals. These are qt4 signals no?
     connect( d->editor, SIGNAL(currentCharFormatChanged(QTextCharFormat)),
         this, SLOT( updateCharFormat() ) );
     updateCharFormat();
@@ -337,6 +341,13 @@
     d->action_bold->setChecked(  d->editor->fontWeight() >= QFont::Bold );
     d->action_italic->setChecked( d->editor->fontItalic() );
     d->action_underline->setChecked( d->editor->fontUnderline() );
+
+    //this "workarounds" KTextEdit edit, to keep the font even when you delete all \
typed chars +    setTextColor(d->desiredTextColor);
+    if( useRichText() )
+    {
+        d->editor->setCurrentFont( d->desiredFont );
+    }
 }
 
 void KRichTextEditPart::updateAligment()
@@ -376,18 +387,17 @@
     KConfigGroup config(KGlobal::config(), "RichTextEditor");
 
     QColor standardColor = KColorScheme(QPalette::Active, \
                KColorScheme::View).foreground().color();
-    QColor tmpColor;
-    tmpColor = config.readEntry("TextColor", standardColor );
-    kDebug() << "Text color: " << tmpColor.name();
 
-    setTextColor( tmpColor );
+    d->desiredTextColor = config.readEntry("TextColor", standardColor );
+    setTextColor( d->desiredTextColor );
 
-    QFont tmpFont = KGlobalSettings::generalFont();
-    setFont( config.readEntry("Font", tmpFont ) );
 
-    int tmp = KGlobalSettings::generalFont().pixelSize();
-    setFontSize( config.readEntry( "FontSize", tmp ) );
+    d->desiredFont = config.readEntry("Font", KGlobalSettings::generalFont() );
+    setFont( d->desiredFont );
 
+    d->desiredFontSize = config.readEntry( "FontSize", \
KGlobalSettings::generalFont().pixelSize() ); +    setFontSize( d->desiredFontSize );
+
     d->action_bold->setChecked( config.readEntry( "FontBold", false ) );
     d->action_italic->setChecked( config.readEntry( "FontItalic", false ) );
     d->action_underline->setChecked( config.readEntry( "FontUnderline", false ) );
@@ -424,6 +434,7 @@
     config.writeEntry("FontBold", currentFont.bold() );
     config.writeEntry("FontItalic", currentFont.italic() );
     config.writeEntry("FontUnderline", currentFont.underline() );
+
     config.writeEntry("TextColor", d->editor->textColor() );
     config.writeEntry("EditAlignment", int(d->editor->alignment()) );
     config.sync();
@@ -431,7 +442,7 @@
 
 void KRichTextEditPart::setTextColor()
 {
-    QColor currentTextColor = d->editor->textColor();
+    QColor currentTextColor = d->desiredTextColor;
 
     int result = KColorDialog::getColor( currentTextColor, \
KColorScheme(QPalette::Active, KColorScheme::View).foreground().color() , d->editor \
);  if(!currentTextColor.isValid())
@@ -439,6 +450,7 @@
     if ( result != QDialog::Accepted  )
         return;
 
+    d->desiredTextColor = currentTextColor;
     setTextColor( currentTextColor );
 
     writeConfig();
@@ -474,9 +486,9 @@
 
 void KRichTextEditPart::setFont()
 {
-    QFont currentFont = d->editor->currentFont();
+    QFont currentFont = d->desiredFont;
     KFontDialog::getFont( currentFont, false, d->editor );
-
+    d->desiredFont = currentFont;
     setFont( currentFont );
     writeConfig();
 }



_______________________________________________
kopete-devel mailing list
kopete-devel@kde.org
https://mail.kde.org/mailman/listinfo/kopete-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic