From bcb704366cb5e333a626c18c308c7e0448a8e69f Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kopete/plugins/texteffect/texteffectplugin.cpp | 198 +++++++++++++++++++++++++ 1 file changed, 198 insertions(+) create mode 100644 kopete/plugins/texteffect/texteffectplugin.cpp (limited to 'kopete/plugins/texteffect/texteffectplugin.cpp') diff --git a/kopete/plugins/texteffect/texteffectplugin.cpp b/kopete/plugins/texteffect/texteffectplugin.cpp new file mode 100644 index 00000000..5374b2ca --- /dev/null +++ b/kopete/plugins/texteffect/texteffectplugin.cpp @@ -0,0 +1,198 @@ +/*************************************************************************** + texteffectplugin.cpp - description + ------------------- + begin : jeu nov 14 2002 + copyright : (C) 2002 by Olivier Goffart + email : ogoffart @ kde.org + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include + +#include +#include + +#include "kopetechatsessionmanager.h" + +#include "texteffectplugin.h" +#include "texteffectconfig.h" + +typedef KGenericFactory TextEffectPluginFactory; +K_EXPORT_COMPONENT_FACTORY( kopete_texteffect, TextEffectPluginFactory( "kopete_texteffect" ) ) + +TextEffectPlugin::TextEffectPlugin( QObject *parent, const char *name, const QStringList &/*args*/ ) +: Kopete::Plugin( TextEffectPluginFactory::instance(), parent, name ) +{ + if( !pluginStatic_ ) + pluginStatic_=this; + + m_config = new TextEffectConfig; + + connect ( this , SIGNAL( settingsChanged() ) , this , SLOT( slotSettingsChanged() ) ); + + connect( Kopete::ChatSessionManager::self(), + SIGNAL( aboutToSend( Kopete::Message & ) ), + SLOT( slotOutgoingMessage( Kopete::Message & ) ) ); + + last_color=0; +} + +TextEffectPlugin::~TextEffectPlugin() +{ + delete m_config; + pluginStatic_ = 0L; +} + +TextEffectPlugin* TextEffectPlugin::plugin() +{ + return pluginStatic_ ; +} + +TextEffectPlugin* TextEffectPlugin::pluginStatic_ = 0L; + + +void TextEffectPlugin::slotOutgoingMessage( Kopete::Message& msg ) +{ + if(msg.direction() != Kopete::Message::Outbound) + return; + + QStringList colors=m_config->colors(); + + if(m_config->colorChar() || m_config->colorWords() || m_config->lamer() || m_config->waves() ) + { + QString original=msg.plainBody(); + QString resultat; + + unsigned int c=0; + bool wavein=false; + + for(unsigned int f=0;fcolorChar() || (m_config->colorWords() && x==' ' )) + { + if(f!=0) + resultat+=""; + resultat+="colorRandom()) + c=rand()%colors.count(); + else + { + c++; + if(c >= colors.count()) + c=0; + } + resultat+="\">"; + } + switch (x.latin1()) + { + case '>': + resultat+=">"; + break; + case '<': + resultat+="<"; + break; + case '&': + resultat+="&"; + break; + case '\n': + resultat+="
"; + case 'a': + case 'A': + if(m_config->lamer()) + { + resultat+="4"; + break; + } //else, go to the default, all other case have this check + case 'e': + case 'E': + if(m_config->lamer()) + { + resultat+="3"; + break; + }//else, go to the default, all other case have this check + case 'i': + case 'I': + if(m_config->lamer()) + { + resultat+="1"; + break; + }//else, go to the default, all other case have this check + case 'l': + case 'L': + if(m_config->lamer()) + { + resultat+="|"; + break; + }//else, go to the default, all other case have this check + case 't': + case 'T': + if(m_config->lamer()) + { + resultat+="7"; + break; + }//else, go to the default, all other case have this check + case 's': + case 'S': + if(m_config->lamer()) + { + resultat+="5"; + break; + }//else, go to the default, all other case have this check + case 'o': + case 'O': + if(m_config->lamer()) + { + resultat+="0"; + break; + }//else, go to the default, all other case have this check + default: + if(m_config->waves()) + { + resultat+= wavein ? x.lower() : x.upper(); + wavein=!wavein; + } + else + resultat+=x; + break; + } + } + if( m_config->colorChar() || m_config->colorWords() ) + resultat+="
"; + msg.setBody(resultat,Kopete::Message::RichText); + } + + if(m_config->colorLines()) + { + if(m_config->colorRandom()) + { + last_color=rand()%colors.count(); + } + else + { + last_color++; + if(last_color >= colors.count()) + last_color=0; + } + + msg.setFg(QColor (colors[last_color])); + } +} + +void TextEffectPlugin::slotSettingsChanged() +{ + m_config->load(); +} + + +#include "texteffectplugin.moc" + -- cgit v1.2.1