| Summary: | [Kopete] Sentence Options, Not Working | ||
|---|---|---|---|
| Product: | [Unmaintained] kopete | Reporter: | ian <ian-school> |
| Component: | Autoreplace plugin | Assignee: | Kopete Developers <kopete-bugs-null> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | NOR | ||
| Version First Reported In: | 0.10.3 | ||
| Target Milestone: | --- | ||
| Platform: | unspecified | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
| Attachments: | patch | ||
|
Description
ian
2005-11-14 23:37:26 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
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. |