Bug 116381 - [Kopete] Sentence Options, Not Working
Summary: [Kopete] Sentence Options, Not Working
Status: RESOLVED FIXED
Alias: None
Product: kopete
Classification: Applications
Component: Autoreplace plugin (show other bugs)
Version: 0.10.3
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Kopete Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-14 23:37 UTC by ian
Modified: 2006-11-13 05:15 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
patch (686 bytes, patch)
2005-11-15 03:17 UTC, Haris Kouzinopoulos
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ian 2005-11-14 23:37:26 UTC
Version:           0.10.3 (using KDE 3.4.2 Level "b" , SUSE 10.0)
Compiler:          Target: i586-suse-linux
OS:                Linux (i686) release 2.6.13-15-default

The Sentence Options part in the auto replace plugin is not working. I check the check box, hit ok, and test it. Does not add a dot (period) at the end of each line, nor does it capitalise the first letter in each line. When I check back, it is unchecked so I check it, and the same problem happens.
Comment 1 Haris Kouzinopoulos 2005-11-15 03:17:52 UTC
Created attachment 13459 [details]
patch

Now auto replace on incoming and on outcoming work, still trying to figure out
about dots and capitalizing options
Comment 2 Will Stephenson 2006-11-05 16:57:04 UTC
SVN commit 602278 by wstephens:

Make sentence options (Capitalize and full stop.) work, and handle
inbound messages as advertised.

NB Hariz Kouzinopoulos:  I did not use your patch, because while it is
technically correct, the job of saving the widgets' values is performed
automatically by KCAutoConfigModule, if it knows about the widgets.  A
previous author neglected to change the widgets passed to
KCAutoConfigModule when adding the sentence options, so that is why
these were not read/written.  Thank you for submitting a patch though,
it was the impetus to solve the bug properly.

BUG:116381


 M  +29 -22    autoreplaceplugin.cpp  
 M  +8 -3      autoreplaceplugin.h  
 M  +7 -2      autoreplacepreferences.cpp  
 M  +6 -3      autoreplaceprefs.ui  


--- branches/KDE/3.5/kdenetwork/kopete/plugins/autoreplace/autoreplaceplugin.cpp #602277:602278
@@ -20,6 +20,7 @@
 #include <kopetecontact.h>
 
 #include "kopetechatsessionmanager.h"
+#include "kopetesimplemessagehandler.h"
 
 #include "autoreplaceplugin.h"
 #include "autoreplaceconfig.h"
@@ -39,13 +40,19 @@
 	connect( Kopete::ChatSessionManager::self(), SIGNAL( aboutToSend( Kopete::Message & ) ),
 		this, SLOT( slotAboutToSend( Kopete::Message & ) ) );
 
+	// nb this connection causes the slot to be called on in- and outbound
+	// messages which suggests something is broken in the message handler
+	// system!
+	m_inboundHandler = new Kopete::SimpleMessageHandlerFactory( Kopete::Message::Inbound,
+		Kopete::MessageHandlerFactory::InStageToSent, this, SLOT( slotAboutToSend( Kopete::Message& ) ) );
+
 	connect( this, SIGNAL( settingsChanged() ), this, SLOT( slotSettingsChanged() ) );
 }
 
 AutoReplacePlugin::~AutoReplacePlugin()
 {
 	pluginStatic_ = 0L;
-
+	delete m_inboundHandler;
 	delete m_prefs;
 }
 
@@ -87,30 +94,30 @@
 		// the message is now the one with replaced words
 		if(isReplaced)
 			msg.setBody( replaced_message, Kopete::Message::PlainText );
-	}
 
-	if( msg.direction() == Kopete::Message::Outbound )
-	{
-		if ( m_prefs->dotEndSentence() )
+		if( msg.direction() == Kopete::Message::Outbound )
 		{
-			QString replaced_message = msg.plainBody();
-			// eventually add . at the end of the lines, sent lines only
-			replaced_message.replace( QRegExp( "([a-z])$" ), "\\1." );
-			// replaced_message.replace(QRegExp( "([\\w])$" ), "\\1." );
-			
-			// the message is now the one with replaced words
-			msg.setBody( replaced_message, Kopete::Message::PlainText );
-		}
+			if ( m_prefs->dotEndSentence() )
+			{
+				QString replaced_message = msg.plainBody();
+				// eventually add . at the end of the lines, sent lines only
+				replaced_message.replace( QRegExp( "([a-z])$" ), "\\1." );
+				// replaced_message.replace(QRegExp( "([\\w])$" ), "\\1." );
 
-		if( m_prefs->capitalizeBeginningSentence() )
-		{
-			QString replaced_message = msg.plainBody();
-			// eventually start each sent line with capital letter
-			// TODO 	". "	 "? "	 "! " 
-			replaced_message[ 0 ] = replaced_message.at( 0 ).upper();
-			
-			// the message is now the one with replaced words
-			msg.setBody( replaced_message, Kopete::Message::PlainText );
+				// the message is now the one with replaced words
+				msg.setBody( replaced_message, Kopete::Message::PlainText );
+			}
+
+			if( m_prefs->capitalizeBeginningSentence() )
+			{
+				QString replaced_message = msg.plainBody();
+				// eventually start each sent line with capital letter
+				// TODO 	". "	 "? "	 "! "
+				replaced_message[ 0 ] = replaced_message.at( 0 ).upper();
+
+				// the message is now the one with replaced words
+				msg.setBody( replaced_message, Kopete::Message::PlainText );
+			}
 		}
 	}
 }
--- branches/KDE/3.5/kdenetwork/kopete/plugins/autoreplace/autoreplaceplugin.h #602277:602278
@@ -26,9 +26,13 @@
 #include "kopetemessage.h"
 #include "kopeteplugin.h"
 
-namespace Kopete { class Message; }
-namespace Kopete { class MetaContact; }
-namespace Kopete { class ChatSession; }
+namespace Kopete {
+	class Message;
+	class MetaContact;
+	class ChatSession;
+	class SimpleMessageHandlerFactory;
+}
+
 class AutoReplaceConfig;
 
 class AutoReplacePlugin : public Kopete::Plugin
@@ -48,6 +52,7 @@
 
 private:
 	static AutoReplacePlugin * pluginStatic_;
+	Kopete::SimpleMessageHandlerFactory *m_inboundHandler;
 
 	AutoReplaceConfig *m_prefs;
 };
--- branches/KDE/3.5/kdenetwork/kopete/plugins/autoreplace/autoreplacepreferences.cpp #602277:602278
@@ -15,6 +15,7 @@
  *                                                                         *
  ***************************************************************************/
 
+#include <qcheckbox.h>
 #include <qlayout.h>
 #include <qpushbutton.h>
 #include <qgroupbox.h>
@@ -60,8 +61,12 @@
 
 	m_wordListChanged = false;
 
-	setMainWidget( preferencesDialog->gb_options, "AutoReplace Plugin" );
-
+	// Sentence options and which messages to apply autoreplace to
+	// are managed by KCMAutoConfigModule.  The list of replacements
+	// itself is manually read/written as KCMAutoConfigModule doesn't support it.
+	autoConfig()->ignoreSubWidget( preferencesDialog->replacementsGroup );
+	setMainWidget( preferencesDialog, "AutoReplace Plugin" );
+	
 	m_config = new AutoReplaceConfig;
 	load();
 }
--- branches/KDE/3.5/kdenetwork/kopete/plugins/autoreplace/autoreplaceprefs.ui #602277:602278
@@ -13,13 +13,16 @@
             <height>378</height>
         </rect>
     </property>
+    <property name="caption">
+        <string>AutoReplacePrefsUI</string>
+    </property>
     <grid>
         <property name="name">
             <cstring>unnamed</cstring>
         </property>
         <widget class="QGroupBox" row="0" column="0">
             <property name="name">
-                <cstring>groupBox3</cstring>
+                <cstring>gb_sentences</cstring>
             </property>
             <property name="title">
                 <string>Sentence Options</string>
@@ -80,7 +83,7 @@
         </widget>
         <widget class="QGroupBox" row="1" column="0">
             <property name="name">
-                <cstring>groupBox4</cstring>
+                <cstring>replacementsGroup</cstring>
             </property>
             <property name="title">
                 <string>Replacements List</string>
@@ -168,7 +171,7 @@
                                 <cstring>textLabel1</cstring>
                             </property>
                             <property name="text">
-                                <string>&amp;Text:</string>
+                                <string>Te&amp;xt:</string>
                             </property>
                             <property name="buddy" stdset="0">
                                 <cstring>m_key</cstring>
Comment 3 Haris Kouzinopoulos 2006-11-13 05:15:57 UTC
nice for fixing this bug, i totaly forgot it.