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.
Created attachment 13459 [details] patch Now auto replace on incoming and on outcoming work, still trying to figure out about dots and capitalizing options
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>&Text:</string> + <string>Te&xt:</string> </property> <property name="buddy" stdset="0"> <cstring>m_key</cstring>
nice for fixing this bug, i totaly forgot it.