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/highlight/Makefile.am | 21 + kopete/plugins/highlight/filter.cpp | 32 ++ kopete/plugins/highlight/filter.h | 54 +++ kopete/plugins/highlight/highlightconfig.cpp | 206 +++++++++ kopete/plugins/highlight/highlightconfig.h | 46 ++ kopete/plugins/highlight/highlightplugin.cpp | 106 +++++ kopete/plugins/highlight/highlightplugin.h | 63 +++ kopete/plugins/highlight/highlightpreferences.cpp | 269 ++++++++++++ kopete/plugins/highlight/highlightpreferences.h | 58 +++ kopete/plugins/highlight/highlightprefsbase.ui | 466 +++++++++++++++++++++ kopete/plugins/highlight/icons/Makefile.am | 3 + .../plugins/highlight/icons/cr32-app-highlight.png | Bin 0 -> 1239 bytes kopete/plugins/highlight/kopete_highlight.desktop | 129 ++++++ .../highlight/kopete_highlight_config.desktop | 125 ++++++ 14 files changed, 1578 insertions(+) create mode 100644 kopete/plugins/highlight/Makefile.am create mode 100644 kopete/plugins/highlight/filter.cpp create mode 100644 kopete/plugins/highlight/filter.h create mode 100644 kopete/plugins/highlight/highlightconfig.cpp create mode 100644 kopete/plugins/highlight/highlightconfig.h create mode 100644 kopete/plugins/highlight/highlightplugin.cpp create mode 100644 kopete/plugins/highlight/highlightplugin.h create mode 100644 kopete/plugins/highlight/highlightpreferences.cpp create mode 100644 kopete/plugins/highlight/highlightpreferences.h create mode 100644 kopete/plugins/highlight/highlightprefsbase.ui create mode 100644 kopete/plugins/highlight/icons/Makefile.am create mode 100644 kopete/plugins/highlight/icons/cr32-app-highlight.png create mode 100644 kopete/plugins/highlight/kopete_highlight.desktop create mode 100644 kopete/plugins/highlight/kopete_highlight_config.desktop (limited to 'kopete/plugins/highlight') diff --git a/kopete/plugins/highlight/Makefile.am b/kopete/plugins/highlight/Makefile.am new file mode 100644 index 00000000..d74a3886 --- /dev/null +++ b/kopete/plugins/highlight/Makefile.am @@ -0,0 +1,21 @@ +METASOURCES = AUTO + +SUBDIRS = icons + +AM_CPPFLAGS = $(KOPETE_INCLUDES) $(all_includes) + +kde_module_LTLIBRARIES = kopete_highlight.la kcm_kopete_highlight.la + +kopete_highlight_la_SOURCES = highlightplugin.cpp highlightconfig.cpp filter.cpp +kopete_highlight_la_LDFLAGS = -module -no-undefined $(KDE_PLUGIN) $(all_libraries) +kopete_highlight_la_LIBADD = ../../libkopete/libkopete.la + +kcm_kopete_highlight_la_SOURCES = highlightprefsbase.ui highlightpreferences.cpp filter.cpp highlightconfig.cpp +kcm_kopete_highlight_la_LDFLAGS = -module -no-undefined $(KDE_PLUGIN) $(all_libraries) +kcm_kopete_highlight_la_LIBADD = $(LIB_KOPETECOMPAT) $(LIB_KUTILS) + +service_DATA = kopete_highlight.desktop +servicedir = $(kde_servicesdir) + +kcm_DATA = kopete_highlight_config.desktop +kcmdir = $(kde_servicesdir)/kconfiguredialog diff --git a/kopete/plugins/highlight/filter.cpp b/kopete/plugins/highlight/filter.cpp new file mode 100644 index 00000000..814bd678 --- /dev/null +++ b/kopete/plugins/highlight/filter.cpp @@ -0,0 +1,32 @@ +/*************************************************************************** + filter.cpp - filter for the highlight plugin + ------------------- + begin : mar 14 2003 + copyright : (C) 2003 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 "filter.h" + +Filter::Filter() +{ +} + +Filter::~Filter() +{ +} + +/* + * But is this file useful? :-D + */ + + diff --git a/kopete/plugins/highlight/filter.h b/kopete/plugins/highlight/filter.h new file mode 100644 index 00000000..b2ac0794 --- /dev/null +++ b/kopete/plugins/highlight/filter.h @@ -0,0 +1,54 @@ +/*************************************************************************** + filter.h - filter for the highlight plugin + ------------------- + begin : mar 14 2003 + copyright : (C) 2003 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. * + * * + ***************************************************************************/ + +#ifndef FILTER_H +#define FILTER_H + + +#include +#include + +/** + * @author Olivier Goffart + **/ +class Filter +{ +public: + Filter(); + ~Filter(); + + QString displayName; + QString search; + bool caseSensitive; + bool isRegExp; + + bool setImportance; + unsigned int importance; + + bool setFG; + QColor FG; + + bool setBG; + QColor BG; + + bool playSound; + QString soundFN; + + bool raiseView; +}; + +#endif diff --git a/kopete/plugins/highlight/highlightconfig.cpp b/kopete/plugins/highlight/highlightconfig.cpp new file mode 100644 index 00000000..ba97e6a8 --- /dev/null +++ b/kopete/plugins/highlight/highlightconfig.cpp @@ -0,0 +1,206 @@ +/* + highlightconfig.cpp + + Copyright (c) 2003 by Olivier Goffart + Copyright (c) 2003 by Matt Rogers + + Kopete (c) 2002-2003 by the Kopete developers + + ************************************************************************* + * * + * 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 +#include + +#include +#include +#include + +#include "filter.h" +#include "highlightconfig.h" + + +HighlightConfig::HighlightConfig() +{ + load(); + m_filters.setAutoDelete(true); +} + +HighlightConfig::~HighlightConfig() +{ + m_filters.clear(); +} + +void HighlightConfig::removeFilter(Filter *f) +{ + //m_filters is "autodelete (true) so when we use remove(...) it deleted f + //so don't use (delete (f) after otherwise ot crash + m_filters.remove(f); +} + +void HighlightConfig::appendFilter(Filter *f) +{ + m_filters.append(f); +} + +QPtrList HighlightConfig::filters() const +{ + return m_filters; +} + +Filter* HighlightConfig::newFilter() +{ + Filter *filtre=new Filter(); + filtre->caseSensitive=false; + filtre->isRegExp=false; + filtre->setImportance=false; + filtre->importance=1; + filtre->setBG=false; + filtre->setFG=false; + filtre->playSound=false; + filtre->raiseView=false; + filtre->displayName=i18n("-New filter-"); + m_filters.append(filtre); + return filtre; +} + +void HighlightConfig::load() +{ + m_filters.clear(); //clear filters + + QString filename = locateLocal( "appdata", QString::fromLatin1( "highlight.xml" ) ); + if( filename.isEmpty() ) + return ; + + QDomDocument filterList( QString::fromLatin1( "highlight-plugin" ) ); + + QFile filterListFile( filename ); + filterListFile.open( IO_ReadOnly ); + filterList.setContent( &filterListFile ); + + QDomElement list = filterList.documentElement(); + + QDomNode node = list.firstChild(); + while( !node.isNull() ) + { + QDomElement element = node.toElement(); + if( !element.isNull() ) + { +// if( element.tagName() == QString::fromLatin1("filter") +// { + Filter *filtre=newFilter(); + QDomNode filterNode = node.firstChild(); + + while( !filterNode.isNull() ) + { + QDomElement filterElement = filterNode.toElement(); + if( !filterElement.isNull() ) + { + if( filterElement.tagName() == QString::fromLatin1( "display-name" ) ) + { + filtre->displayName = filterElement.text(); + } + else if( filterElement.tagName() == QString::fromLatin1( "search" ) ) + { + filtre->search = filterElement.text(); + + filtre->caseSensitive= ( filterElement.attribute( QString::fromLatin1( "caseSensitive" ), QString::fromLatin1( "1" ) ) == QString::fromLatin1( "1" ) ); + filtre->isRegExp= ( filterElement.attribute( QString::fromLatin1( "regExp" ), QString::fromLatin1( "0" ) ) == QString::fromLatin1( "1" ) ); + } + else if( filterElement.tagName() == QString::fromLatin1( "FG" ) ) + { + filtre->FG = filterElement.text(); + filtre->setFG= ( filterElement.attribute( QString::fromLatin1( "set" ), QString::fromLatin1( "0" ) ) == QString::fromLatin1( "1" ) ); + } + else if( filterElement.tagName() == QString::fromLatin1( "BG" ) ) + { + filtre->BG = filterElement.text(); + filtre->setBG= ( filterElement.attribute( QString::fromLatin1( "set" ), QString::fromLatin1( "0" ) ) == QString::fromLatin1( "1" ) ); + } + else if( filterElement.tagName() == QString::fromLatin1( "importance" ) ) + { + filtre->importance = filterElement.text().toUInt(); + filtre->setImportance= ( filterElement.attribute( QString::fromLatin1( "set" ), QString::fromLatin1( "0" ) ) == QString::fromLatin1( "1" ) ); + } + else if( filterElement.tagName() == QString::fromLatin1( "sound" ) ) + { + filtre->soundFN = filterElement.text(); + filtre->playSound = ( filterElement.attribute( QString::fromLatin1( "set" ), QString::fromLatin1( "0" ) ) == QString::fromLatin1( "1" ) ); + } + else if( filterElement.tagName() == QString::fromLatin1( "raise" ) ) + { + filtre->raiseView = ( filterElement.attribute( QString::fromLatin1( "set" ), QString::fromLatin1( "0" ) ) == QString::fromLatin1( "1" ) ); + } + } + filterNode = filterNode.nextSibling(); + } +// } + } + node = node.nextSibling(); + } + filterListFile.close(); +} + +void HighlightConfig::save() +{ + + QString fileName = locateLocal( "appdata", QString::fromLatin1( "highlight.xml" ) ); + + KSaveFile file( fileName ); + if( file.status() == 0 ) + { + QTextStream *stream = file.textStream(); + stream->setEncoding( QTextStream::UnicodeUTF8 ); + + QString xml = QString::fromLatin1( + "\n" + "\n" + "\n" ); + + // Save metafilter information. + QPtrListIterator filtreIt( m_filters ); + for( ; filtreIt.current(); ++filtreIt ) + { + Filter *filtre = *filtreIt; + xml += QString::fromLatin1( " \n " ) + + QStyleSheet::escape(filtre->displayName) + + QString::fromLatin1( "\n" ); + + xml += QString::fromLatin1(" ( filtre->caseSensitive ) ) + + QString::fromLatin1("\" regExp=\"") + QString::number( static_cast( filtre->isRegExp ) ) + + QString::fromLatin1( "\">" ) + QStyleSheet::escape( filtre->search ) + QString::fromLatin1( "\n" ); + + xml += QString::fromLatin1(" ( filtre->setBG ) ) + + QString::fromLatin1( "\">" ) + QStyleSheet::escape( filtre->BG.name() ) + QString::fromLatin1( "\n" ); + xml += QString::fromLatin1(" ( filtre->setFG ) ) + + QString::fromLatin1( "\">" ) + QStyleSheet::escape( filtre->FG.name() ) + QString::fromLatin1( "\n" ); + + xml += QString::fromLatin1(" ( filtre->setImportance ) ) + + QString::fromLatin1( "\">" ) + QString::number( filtre->importance ) + QString::fromLatin1( "\n" ); + + xml += QString::fromLatin1(" ( filtre->playSound ) ) + + QString::fromLatin1( "\">" ) + QStyleSheet::escape( filtre->soundFN ) + QString::fromLatin1( "\n" ); + + xml += QString::fromLatin1(" ( filtre->raiseView ) ) + + QString::fromLatin1( "\">\n" ); + + xml += QString::fromLatin1( " \n" ); + } + + xml += QString::fromLatin1( "\n" ); + + *stream << xml; + } +} + +// vim: set noet ts=4 sts=4 sw=4: diff --git a/kopete/plugins/highlight/highlightconfig.h b/kopete/plugins/highlight/highlightconfig.h new file mode 100644 index 00000000..35813403 --- /dev/null +++ b/kopete/plugins/highlight/highlightconfig.h @@ -0,0 +1,46 @@ +/* + highlightconfig.h + + Copyright (c) 2003 by Olivier Goffart + Copyright (c) 2003 by Matt Rogers + + Kopete (c) 2002-2003 by the Kopete developers + + ************************************************************************* + * * + * 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. * + * * + ************************************************************************* +*/ +#ifndef HIGHLIGHTCONFIG_H +#define HIGHLIGHTCONFIG_H + +#include +#include + +class Filter; + +class HighlightConfig +{ +public: + HighlightConfig(); + ~HighlightConfig(); + + void load(); + void save(); + + QPtrList filters() const; + void removeFilter (Filter *f); + void appendFilter (Filter *f); + Filter* newFilter(); + +private: + QPtrList m_filters; +}; + +#endif + +// vim: set noet ts=4 sts=4 sw=4: diff --git a/kopete/plugins/highlight/highlightplugin.cpp b/kopete/plugins/highlight/highlightplugin.cpp new file mode 100644 index 00000000..2f1cbb43 --- /dev/null +++ b/kopete/plugins/highlight/highlightplugin.cpp @@ -0,0 +1,106 @@ +/*************************************************************************** + highlightplugin.cpp - description + ------------------- + begin : mar 14 2003 + copyright : (C) 2003 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 "kopeteview.h" + +#include "filter.h" +#include "highlightplugin.h" +#include "highlightconfig.h" + +typedef KGenericFactory HighlightPluginFactory; +K_EXPORT_COMPONENT_FACTORY( kopete_highlight, HighlightPluginFactory( "kopete_highlight" ) ) + +HighlightPlugin::HighlightPlugin( QObject *parent, const char *name, const QStringList &/*args*/ ) +: Kopete::Plugin( HighlightPluginFactory::instance(), parent, name ) +{ + if( !pluginStatic_ ) + pluginStatic_=this; + + connect( Kopete::ChatSessionManager::self(), SIGNAL( aboutToDisplay( Kopete::Message & ) ), SLOT( slotIncomingMessage( Kopete::Message & ) ) ); + connect ( this , SIGNAL( settingsChanged() ) , this , SLOT( slotSettingsChanged() ) ); + + m_config = new HighlightConfig; + + m_config->load(); +} + +HighlightPlugin::~HighlightPlugin() +{ + pluginStatic_ = 0L; + delete m_config; +} + +HighlightPlugin* HighlightPlugin::plugin() +{ + return pluginStatic_ ; +} + +HighlightPlugin* HighlightPlugin::pluginStatic_ = 0L; + + +void HighlightPlugin::slotIncomingMessage( Kopete::Message& msg ) +{ + if(msg.direction() != Kopete::Message::Inbound) + return; // FIXME: highlighted internal/actions messages are not showed correctly in the chat window (bad style) + // but they should maybe be highlinghted if needed + + QPtrList filters=m_config->filters(); + QPtrListIterator it( filters ); + Filter *f; + while ((f = it.current()) != 0 ) + { + ++it; + if(f->isRegExp ? + msg.plainBody().contains(QRegExp(f->search , f->caseSensitive)) : + msg.plainBody().contains(f->search , f->caseSensitive) ) + { + if(f->setBG) + msg.setBg(f->BG); + if(f->setFG) + msg.setFg(f->FG); + if(f->setImportance) + msg.setImportance((Kopete::Message::MessageImportance)f->importance); + if(f->playSound) + KNotifyClient::userEvent (QString::null, KNotifyClient::Sound, KNotifyClient::Default, f->soundFN ); + + if (f->raiseView && + msg.manager() && msg.manager()->view()) { + KopeteView *theview = msg.manager()->view(); + theview->raise(); + } + + break; //uh? + } + } +} + +void HighlightPlugin::slotSettingsChanged() +{ + m_config->load(); +} + + + +#include "highlightplugin.moc" + +// vim: set noet ts=4 sts=4 sw=4: + diff --git a/kopete/plugins/highlight/highlightplugin.h b/kopete/plugins/highlight/highlightplugin.h new file mode 100644 index 00000000..0a421f55 --- /dev/null +++ b/kopete/plugins/highlight/highlightplugin.h @@ -0,0 +1,63 @@ +/*************************************************************************** + highlightplugin.h - description + ------------------- + begin : mar 14 2003 + copyright : (C) 2003 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. * + * * + ***************************************************************************/ + +#ifndef HighlightPLUGIN_H +#define HighlightPLUGIN_H + +#include +#include +#include + +#include "kopetemessage.h" +#include "kopeteplugin.h" + +class QStringList; +class QString; +class QTimer; + +namespace Kopete { class Message; } +namespace Kopete { class MetaContact; } +namespace Kopete { class ChatSession; } + +class HighlightConfig; +class Filter; + +/** + * @author Olivier Goffart + */ + +class HighlightPlugin : public Kopete::Plugin +{ + Q_OBJECT + +public: + static HighlightPlugin *plugin(); + + HighlightPlugin( QObject *parent, const char *name, const QStringList &args ); + ~HighlightPlugin(); + +public slots: + void slotIncomingMessage( Kopete::Message& msg ); + void slotSettingsChanged(); + + +private: + static HighlightPlugin* pluginStatic_; + HighlightConfig *m_config; +}; + +#endif diff --git a/kopete/plugins/highlight/highlightpreferences.cpp b/kopete/plugins/highlight/highlightpreferences.cpp new file mode 100644 index 00000000..9641d034 --- /dev/null +++ b/kopete/plugins/highlight/highlightpreferences.cpp @@ -0,0 +1,269 @@ +/*************************************************************************** + highlightpreferences.cpp - description + ------------------- + begin : mar 14 2003 + copyright : (C) 2003 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "filter.h" +#include "highlightplugin.h" +#include "highlightconfig.h" +#include "highlightprefsbase.h" +#include "highlightpreferences.h" + +typedef KGenericFactory HighlightPreferencesFactory; +K_EXPORT_COMPONENT_FACTORY( kcm_kopete_highlight, HighlightPreferencesFactory( "kcm_kopete_highlight" ) ) + +HighlightPreferences::HighlightPreferences(QWidget *parent, const char* /*name*/, const QStringList &args) + : KCModule(HighlightPreferencesFactory::instance(), parent, args) +{ + donttouch=true; + ( new QVBoxLayout( this ) )->setAutoAdd( true ); + preferencesDialog = new HighlightPrefsUI(this); + m_config = new HighlightConfig; + + connect(preferencesDialog->m_list , SIGNAL(selectionChanged()) , this , SLOT(slotCurrentFilterChanged())); + connect(preferencesDialog->m_list , SIGNAL(doubleClicked ( QListViewItem *, const QPoint &, int )) , this , SLOT(slotRenameFilter())); + connect(preferencesDialog->m_add , SIGNAL(pressed()) , this , SLOT(slotAddFilter())); + connect(preferencesDialog->m_remove , SIGNAL(pressed()) , this , SLOT(slotRemoveFilter())); + connect(preferencesDialog->m_rename , SIGNAL(pressed()) , this , SLOT(slotRenameFilter())); + connect(preferencesDialog->m_editregexp , SIGNAL(pressed()) , this , SLOT(slotEditRegExp())); + + //Maybe here i should use a slot per widget, but i am too lazy + connect(preferencesDialog->m_case , SIGNAL(stateChanged(int)) , this , SLOT(slotSomethingHasChanged())); + connect(preferencesDialog->m_regexp , SIGNAL(stateChanged(int)) , this , SLOT(slotSomethingHasChanged())); + connect(preferencesDialog->m_setImportance , SIGNAL(stateChanged(int)) , this , SLOT(slotSomethingHasChanged())); + connect(preferencesDialog->m_setBG , SIGNAL(stateChanged(int)) , this , SLOT(slotSomethingHasChanged())); + connect(preferencesDialog->m_setFG , SIGNAL(stateChanged(int)) , this , SLOT(slotSomethingHasChanged())); + connect(preferencesDialog->m_search , SIGNAL(textChanged(const QString&)) , this , SLOT(slotSomethingHasChanged())); + connect(preferencesDialog->m_sound , SIGNAL(stateChanged(int)) , this , SLOT(slotSomethingHasChanged())); + connect(preferencesDialog->m_soundFN , SIGNAL(textChanged(const QString&)) , this , SLOT(slotSomethingHasChanged())); + connect(preferencesDialog->m_raise , SIGNAL(stateChanged(int)) , this , SLOT(slotSomethingHasChanged())); + connect(preferencesDialog->m_search , SIGNAL(textChanged(const QString&)) , this , SLOT(slotSomethingHasChanged())); + connect(preferencesDialog->m_importance , SIGNAL(activated(int)) , this , SLOT(slotSomethingHasChanged())); + connect(preferencesDialog->m_FG , SIGNAL(changed(const QColor&)) , this , SLOT(slotSomethingHasChanged())); + connect(preferencesDialog->m_BG , SIGNAL(changed(const QColor&)) , this , SLOT(slotSomethingHasChanged())); + + load(); + donttouch=false; +} + +HighlightPreferences::~HighlightPreferences() +{ + delete m_config; +} + +void HighlightPreferences::load() +{ + m_config->load(); + donttouch=true; + preferencesDialog->m_list->clear(); + m_filterItems.clear(); + + QPtrList filters=m_config->filters(); + QPtrListIterator it( filters ); + Filter *f; + bool first=true; + while ( (f=it.current()) != 0 ) + { + ++it; + QListViewItem* lvi= new QListViewItem(preferencesDialog->m_list); + lvi->setText(0,f->displayName ); + m_filterItems.insert(lvi,f); + if(first) + preferencesDialog->m_list->setSelected(lvi, true); + first=false; + } + donttouch=false; + emit KCModule::changed(false); +} + +void HighlightPreferences::save() +{ + m_config->save(); + emit KCModule::changed(false); +} + + +void HighlightPreferences::slotCurrentFilterChanged() +{ + donttouch=true; + Filter *current; + if(!preferencesDialog->m_list->selectedItem() || !(current=m_filterItems[preferencesDialog->m_list->selectedItem()])) + { + preferencesDialog->m_search->setEnabled(false); + preferencesDialog->m_case->setEnabled(false); + preferencesDialog->m_regexp->setEnabled(false); + preferencesDialog->m_importance->setEnabled(false); + preferencesDialog->m_setImportance->setEnabled(false); + preferencesDialog->m_BG->setEnabled(false); + preferencesDialog->m_setBG->setEnabled(false); + preferencesDialog->m_FG->setEnabled(false); + preferencesDialog->m_setFG->setEnabled(false); + preferencesDialog->m_soundFN->setEnabled(false); + preferencesDialog->m_sound->setEnabled(false); + preferencesDialog->m_raise->setEnabled(false); + preferencesDialog->m_editregexp->setEnabled(false); + preferencesDialog->m_rename->setEnabled(false); + preferencesDialog->m_remove->setEnabled(false); + donttouch=false; + return; + } + + preferencesDialog->m_rename->setEnabled(true); + preferencesDialog->m_remove->setEnabled(true); + + preferencesDialog->m_search->setEnabled(true); + preferencesDialog->m_case->setEnabled(true); + preferencesDialog->m_regexp->setEnabled(true); + preferencesDialog->m_setImportance->setEnabled(true); + preferencesDialog->m_setBG->setEnabled(true); + preferencesDialog->m_setFG->setEnabled(true); + preferencesDialog->m_sound->setEnabled(true); + preferencesDialog->m_raise->setEnabled(true); + + + preferencesDialog->m_search->setText(current->search); + preferencesDialog->m_case->setChecked(current->caseSensitive); + preferencesDialog->m_regexp->setChecked(current->isRegExp); + preferencesDialog->m_editregexp->setEnabled(current->isRegExp); + preferencesDialog->m_importance->setCurrentItem(current->importance); + preferencesDialog->m_setImportance->setChecked(current->setImportance); + preferencesDialog->m_importance->setEnabled(current->setImportance); + preferencesDialog->m_BG->setColor(current->BG); + preferencesDialog->m_setBG->setChecked(current->setBG); + preferencesDialog->m_BG->setEnabled(current->setBG); + preferencesDialog->m_FG->setColor(current->FG); + preferencesDialog->m_setFG->setChecked(current->setFG); + preferencesDialog->m_FG->setEnabled(current->setFG); + preferencesDialog->m_soundFN->setURL(current->soundFN); + preferencesDialog->m_sound->setChecked(current->playSound); + preferencesDialog->m_raise->setChecked(current->raiseView); + preferencesDialog->m_soundFN->setEnabled(current->playSound); + + donttouch=false; +} + +void HighlightPreferences::slotAddFilter() +{ + Filter *filtre=m_config->newFilter(); + QListViewItem* lvi= new QListViewItem(preferencesDialog->m_list); + lvi->setText(0,filtre->displayName ); + m_filterItems.insert(lvi,filtre); + preferencesDialog->m_list->setSelected(lvi, true); +} + +void HighlightPreferences::slotRemoveFilter() +{ + QListViewItem *lvi=preferencesDialog->m_list->selectedItem(); + if(!lvi) + return; + Filter *current=m_filterItems[lvi]; + if(!current) + return; + + m_filterItems.remove(lvi); + delete lvi; + m_config->removeFilter(current); + emit KCModule::changed(true); +} + +void HighlightPreferences::slotRenameFilter() +{ + QListViewItem *lvi=preferencesDialog->m_list->selectedItem(); + if(!lvi) + return; + Filter *current=m_filterItems[lvi]; + if(!current) + return; + + bool ok; + QString newname = KInputDialog::getText( + i18n( "Rename Filter" ), i18n( "Please enter the new name for the filter:" ), current->displayName, &ok ); + if( !ok ) + return; + current->displayName=newname; + lvi->setText(0,newname); + emit KCModule::changed(true); +} + + +void HighlightPreferences::slotSomethingHasChanged() +{ + Filter *current; + if(donttouch || !preferencesDialog->m_list->selectedItem() || !(current=m_filterItems[preferencesDialog->m_list->selectedItem()])) + return; + + current->search=preferencesDialog->m_search->text(); + current->caseSensitive=preferencesDialog->m_case->isChecked(); + current->isRegExp=preferencesDialog->m_regexp->isChecked(); + preferencesDialog->m_editregexp->setEnabled(current->isRegExp); + current->importance=preferencesDialog->m_importance->currentItem(); + current->setImportance=preferencesDialog->m_setImportance->isChecked(); + preferencesDialog->m_importance->setEnabled(current->setImportance); + current->BG=preferencesDialog->m_BG->color(); + current->setBG=preferencesDialog->m_setBG->isChecked(); + preferencesDialog->m_BG->setEnabled(current->setBG); + current->FG=preferencesDialog->m_FG->color(); + current->setFG=preferencesDialog->m_setFG->isChecked(); + preferencesDialog->m_FG->setEnabled(current->setFG); + current->soundFN=preferencesDialog->m_soundFN->url(); + current->playSound=preferencesDialog->m_sound->isChecked(); + preferencesDialog->m_soundFN->setEnabled(current->playSound); + current->raiseView=preferencesDialog->m_raise->isChecked(); + + emit KCModule::changed(true); +} + +void HighlightPreferences::slotEditRegExp() +{ + QDialog *editorDialog = KParts::ComponentFactory::createInstanceFromQuery( "KRegExpEditor/KRegExpEditor" ); + if ( editorDialog ) + { + // kdeutils was installed, so the dialog was found fetch the editor interface + KRegExpEditorInterface *editor = static_cast( editorDialog->qt_cast( "KRegExpEditorInterface" ) ); + Q_ASSERT( editor ); // This should not fail! + // now use the editor. + editor->setRegExp(preferencesDialog->m_search->text()); + + // Finally exec the dialog + if(editorDialog->exec() == QDialog::Accepted ) + { + preferencesDialog->m_search->setText(editor->regExp()); + } + + } + else + { + // Don't offer the dialog. + } +} + +#include "highlightpreferences.moc" + +// vim: set noet ts=4 sts=4 sw=4: diff --git a/kopete/plugins/highlight/highlightpreferences.h b/kopete/plugins/highlight/highlightpreferences.h new file mode 100644 index 00000000..a2c7e31b --- /dev/null +++ b/kopete/plugins/highlight/highlightpreferences.h @@ -0,0 +1,58 @@ +/*************************************************************************** + highlightpreferences.h - description + ------------------- + begin : mar 14 2003 + copyright : (C) 2003 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. * + * * + ***************************************************************************/ + +#ifndef HighlightPREFERENCES_H +#define HighlightPREFERENCES_H + +#include +#include + +class HighlightPrefsUI; +class Filter; +class QListViewItem; + +/** + *@author Olivier Goffart + */ + +class HighlightPreferences : public KCModule { + Q_OBJECT +public: + + HighlightPreferences(QWidget *parent = 0, const char* name = 0, const QStringList &args = QStringList()); + ~HighlightPreferences(); + + virtual void save(); + virtual void load(); + +private: + HighlightPrefsUI *preferencesDialog; + HighlightConfig *m_config; + QMap m_filterItems; + + bool donttouch; + +private slots: + void slotCurrentFilterChanged(); + void slotAddFilter(); + void slotRemoveFilter(); + void slotRenameFilter(); + void slotSomethingHasChanged(); + void slotEditRegExp(); +}; + +#endif diff --git a/kopete/plugins/highlight/highlightprefsbase.ui b/kopete/plugins/highlight/highlightprefsbase.ui new file mode 100644 index 00000000..b8150c56 --- /dev/null +++ b/kopete/plugins/highlight/highlightprefsbase.ui @@ -0,0 +1,466 @@ + +HighlightPrefsUI +Olivier Goffart + + + HighlighPrefsUI + + + + 0 + 0 + 513 + 504 + + + + HighlighPrefsUI + + + + unnamed + + + + groupBox1 + + + + 1 + 3 + 0 + 0 + + + + Available Filters + + + + unnamed + + + + m_add + + + Add + + + + + m_remove + + + false + + + Remove + + + + + m_rename + + + false + + + Rename... + + + + + + Filters + + + true + + + true + + + + m_list + + + + 7 + 7 + 0 + 0 + + + + + + + + groupBox2 + + + + 7 + 5 + 0 + 0 + + + + Criteria + + + + unnamed + + + + textLabel1 + + + + 1 + 0 + 0 + 0 + + + + If the message contains: + + + + + m_search + + + + + layout3 + + + + unnamed + + + + m_regexp + + + Regular expression + + + + + m_editregexp + + + + 5 + 0 + 0 + 0 + + + + Edit... + + + + + spacer3 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + + + m_case + + + Case sensitive + + + + + + + buttonGroup2 + + + + 7 + 5 + 0 + 0 + + + + Action + + + + unnamed + + + + layout4 + + + + unnamed + + + + m_setImportance + + + + 1 + 0 + 0 + 0 + + + + Set the message importance to: + + + + + + Low + + + + + Normal + + + + + Highlight + + + + m_importance + + + + 3 + 0 + 0 + 0 + + + + + + spacer4 + + + Horizontal + + + Expanding + + + + 31 + 21 + + + + + + + + layout5 + + + + unnamed + + + + m_setBG + + + Change the background color to: + + + + + m_BG + + + + 5 + 0 + 0 + 0 + + + + + + + + + spacer5 + + + Horizontal + + + Expanding + + + + 31 + 21 + + + + + + + + layout6 + + + + unnamed + + + + m_setFG + + + Change the foreground color to: + + + + + m_FG + + + + 5 + 0 + 0 + 0 + + + + + + + + + spacer6 + + + Horizontal + + + Expanding + + + + 41 + 21 + + + + + + + + layout7 + + + + unnamed + + + + m_sound + + + Play a sound: + + + + + m_soundFN + + + + + + + layout8 + + + + unnamed + + + + m_raise + + + Raise window + + + + + + + + + + m_list + m_add + m_remove + m_rename + m_search + m_regexp + m_editregexp + m_case + m_setImportance + m_importance + m_setBG + m_BG + m_setFG + m_FG + m_sound + m_soundFN + m_raise + + + + klistview.h + klineedit.h + kcombobox.h + kcolorbutton.h + kcolorbutton.h + kurlrequester.h + klineedit.h + kpushbutton.h + + diff --git a/kopete/plugins/highlight/icons/Makefile.am b/kopete/plugins/highlight/icons/Makefile.am new file mode 100644 index 00000000..224eb420 --- /dev/null +++ b/kopete/plugins/highlight/icons/Makefile.am @@ -0,0 +1,3 @@ +kopeteicondir = $(kde_datadir)/kopete/icons +kopeteicon_ICON = AUTO + diff --git a/kopete/plugins/highlight/icons/cr32-app-highlight.png b/kopete/plugins/highlight/icons/cr32-app-highlight.png new file mode 100644 index 00000000..54f6736d Binary files /dev/null and b/kopete/plugins/highlight/icons/cr32-app-highlight.png differ diff --git a/kopete/plugins/highlight/kopete_highlight.desktop b/kopete/plugins/highlight/kopete_highlight.desktop new file mode 100644 index 00000000..0d43c122 --- /dev/null +++ b/kopete/plugins/highlight/kopete_highlight.desktop @@ -0,0 +1,129 @@ +[Desktop Entry] +Type=Service +X-Kopete-Version=1000900 +Icon=highlight +ServiceTypes=Kopete/Plugin +X-KDE-Library=kopete_highlight +X-KDE-PluginInfo-Author=Olivier Goffart +X-KDE-PluginInfo-Email=ogoffart@tiscalinet.be +X-KDE-PluginInfo-Name=kopete_highlight +X-KDE-PluginInfo-Version=0.8.0 +X-KDE-PluginInfo-Website=http://kopete.kde.org +X-KDE-PluginInfo-Category=Plugins +X-KDE-PluginInfo-Depends= +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=false +Name=Highlight +Name[ar]=تمييز +Name[bg]=Открояване +Name[bn]=গুরুত্বপূর্ণ +Name[br]=Splannadur +Name[bs]=Isticanje +Name[ca]=Ressaltat +Name[cs]=Zvýraznění +Name[cy]=Amlygu +Name[da]=Fremhæv +Name[de]=Hervorhebung +Name[el]=Τονισμός +Name[eo]=Lumaĵo +Name[es]=Resaltar +Name[et]=Esiletõstmine +Name[eu]=Nabarmendu +Name[fa]=مشخص +Name[fi]=Korostus +Name[fr]=Surlignement +Name[ga]=Aibhsiú +Name[gl]=Resaltar +Name[he]=מודגש +Name[hi]=उभारें +Name[hr]=Isticanje +Name[hu]=Kiemelés +Name[is]=Merkja +Name[it]=Evidenziazione +Name[ja]=強調 +Name[ka]=მარკირებული +Name[kk]=Ерекше +Name[km]=សំខាន់ +Name[lt]=Paryškinti +Name[mk]=Осветлување +Name[nb]=Marker +Name[nds]=Rutheven +Name[ne]=हाइलाइट +Name[nl]=Aanwijzen +Name[nn]=Marker +Name[pa]=ਉਘਾੜਨ +Name[pl]=Podświetlenie +Name[pt]=Realce +Name[pt_BR]=Destaque +Name[ro]=Evidenţiat +Name[ru]=Выделение +Name[se]=Merke +Name[sk]=Zvýrazniť +Name[sl]=Poudarjeno sporočilo +Name[sr]=Истицање +Name[sr@Latn]=Isticanje +Name[sv]=Markera +Name[ta]=முனைப்புறுத்தல் +Name[tg]=Равшаннамоӣ +Name[tr]=Vurgu +Name[uk]=Підсвічування +Name[wa]=E sorbiyance +Name[zh_CN]=突出显示 +Name[zh_HK]=加強顯示 +Name[zh_TW]=高亮度 +Comment=Highlight messages +Comment[ar]=الرسائل المميزة +Comment[bg]=Открояване на съобщения +Comment[bn]=বার্তা প্রজ্জ্বলন +Comment[bs]=Istakni poruke +Comment[ca]=Missatges a ressaltar +Comment[cs]=Zvýraznit zprávy +Comment[cy]=Amlygu negeseuon +Comment[da]=Fremhæv beskeder +Comment[de]=Hervorhebung von Nachrichten +Comment[el]=Τονισμός μηνυμάτων +Comment[eo]=Elstarigi mesaĝojn +Comment[es]=Resaltar mensajes +Comment[et]=Sõnumite esiletõstmine +Comment[eu]=Nabarmendu mezuak +Comment[fa]=پیامهای مشخص +Comment[fi]=Korosta viestit +Comment[fr]=Surligner les messages +Comment[ga]=Aibhsigh teachtaireachtaí +Comment[gl]=Resaltar mensaxes +Comment[he]=מדגיש הודעות +Comment[hi]=संदेशों को उभारें +Comment[hr]=Isticanje poruka +Comment[hu]=Szövegkiemelés +Comment[is]=Merkja skeyti +Comment[it]=Evidenzia i messaggi +Comment[ja]=メッセージを強調 +Comment[ka]=მარკირებული შეტყობინება +Comment[kk]=Хабарларды бояулау +Comment[km]=សារ​សំខាន់ +Comment[lt]=Paryškinti žinutes +Comment[mk]=Обележете пораки +Comment[nb]=Marker meldinger +Comment[nds]=Narichten rutheven +Comment[ne]=सन्देश हाइलाइट गर्नुहोस् +Comment[nl]=Laat berichten oplichten +Comment[nn]=Marker meldingar +Comment[pl]=Podświetlanie wiadomości +Comment[pt]=Realçar as mensagens +Comment[pt_BR]=Destaca mensagens +Comment[ro]=Evidenţiază mesajele +Comment[ru]=Подсвечивание сообщений +Comment[se]=Merke dieđuid +Comment[sk]=Zvýraznenie správ +Comment[sl]=Poudarjanje sporočil +Comment[sr]=Истицање порука +Comment[sr@Latn]=Isticanje poruka +Comment[sv]=Markera meddelanden +Comment[ta]=தகவல் தனிப்படுத்தல் +Comment[tg]=Равшансозии пайёмҳо +Comment[tr]=Vurgulanmış mesajlar +Comment[uk]=Підсвічування повідомлень +Comment[wa]=Mete les messaedjes e sorbriyance +Comment[zh_CN]=突出显示消息 +Comment[zh_HK]=將訊息加強顯示 +Comment[zh_TW]=高亮度訊息 diff --git a/kopete/plugins/highlight/kopete_highlight_config.desktop b/kopete/plugins/highlight/kopete_highlight_config.desktop new file mode 100644 index 00000000..ae29a289 --- /dev/null +++ b/kopete/plugins/highlight/kopete_highlight_config.desktop @@ -0,0 +1,125 @@ +[Desktop Entry] +Icon=highlight +Type=Service +ServiceTypes=KCModule + +X-KDE-ModuleType=Library +X-KDE-Library=kopete_highlight +X-KDE-FactoryName=HighlightConfigFactory +X-KDE-ParentApp=kopete_highlight +X-KDE-ParentComponents=kopete_highlight + +Name=Highlight +Name[ar]=تمييز +Name[bg]=Открояване +Name[bn]=গুরুত্বপূর্ণ +Name[br]=Splannadur +Name[bs]=Isticanje +Name[ca]=Ressaltat +Name[cs]=Zvýraznění +Name[cy]=Amlygu +Name[da]=Fremhæv +Name[de]=Hervorhebung +Name[el]=Τονισμός +Name[eo]=Lumaĵo +Name[es]=Resaltar +Name[et]=Esiletõstmine +Name[eu]=Nabarmendu +Name[fa]=مشخص +Name[fi]=Korostus +Name[fr]=Surlignement +Name[ga]=Aibhsiú +Name[gl]=Resaltar +Name[he]=מודגש +Name[hi]=उभारें +Name[hr]=Isticanje +Name[hu]=Kiemelés +Name[is]=Merkja +Name[it]=Evidenziazione +Name[ja]=強調 +Name[ka]=მარკირებული +Name[kk]=Ерекше +Name[km]=សំខាន់ +Name[lt]=Paryškinti +Name[mk]=Осветлување +Name[nb]=Marker +Name[nds]=Rutheven +Name[ne]=हाइलाइट +Name[nl]=Aanwijzen +Name[nn]=Marker +Name[pa]=ਉਘਾੜਨ +Name[pl]=Podświetlenie +Name[pt]=Realce +Name[pt_BR]=Destaque +Name[ro]=Evidenţiat +Name[ru]=Выделение +Name[se]=Merke +Name[sk]=Zvýrazniť +Name[sl]=Poudarjeno sporočilo +Name[sr]=Истицање +Name[sr@Latn]=Isticanje +Name[sv]=Markera +Name[ta]=முனைப்புறுத்தல் +Name[tg]=Равшаннамоӣ +Name[tr]=Vurgu +Name[uk]=Підсвічування +Name[wa]=E sorbiyance +Name[zh_CN]=突出显示 +Name[zh_HK]=加強顯示 +Name[zh_TW]=高亮度 +Comment=Highlights text based on filters +Comment[ar]=تميز النصوص بناءا على التصفية +Comment[be]=Падсвечвае тэкст згодна з фільтрамі +Comment[bg]=Открояване на текст в съобщенията на базата на ключови думи +Comment[bn]=ফিল্টারের ওপর ভিত্তি করে টেক্সট প্রজ্জ্বল করে +Comment[bs]=Ističe poruke na osnovu filtera +Comment[ca]=Ressalta el text basant-se en filtres +Comment[cs]=Zvýraznit text podle filtrů +Comment[cy]=Amlygu testun ar sail hidlau +Comment[da]=Fremhæv tekst baseret på filtre +Comment[de]=Texthervorhebung mit Hilfe von Filtern +Comment[el]=Τονίζει το κείμενο βασισμένο σε φίλτρα +Comment[es]=Realza el texto basándose en filtros +Comment[et]=Teksti esiletõstmine filtrite põhjal +Comment[eu]=Iragazkietan oinarritutako testua nabarmentzen du +Comment[fa]=متن را بر اساس پالایه‌ها مشخص می‌کند +Comment[fi]=Korostaa tekstin suotimien perusteella +Comment[fr]=Surligne les messages qui répondent à certains critères +Comment[ga]=Aibhsíonn seo téacs de réir scagairí +Comment[gl]=Resalta texto usando filtros +Comment[he]=מדגיש מילים על פי מסננים +Comment[hi]=फ़िल्टर आधारित पाठ उभारें +Comment[hr]=Isticanje poruka na osnovu filtera +Comment[hu]=Szövegkiemelés üzenetekben megadott szempontok szerint +Comment[is]=Merkir texta með tilliti til síunar +Comment[it]=Evidenzia i testi attraverso dei filtri +Comment[ja]=条件に従ってテキストを強調 +Comment[ka]=ტექსტის მარკირებას აკეთებს ფილტრების მეშვეობით +Comment[kk]=Мәтінді сүзгілеп бояулау +Comment[km]=សារ​សំខាន់​ដែល​ផ្អែក​លើ​តម្រង +Comment[lt]=Paryškinamas tekstas, atsižvelgiant į filtrus +Comment[mk]=Го обележува текстот базирано на филтри +Comment[nb]=Marker meldinger ved bruk av filtere +Comment[nds]=Filterbaseert Rutheven vun Text +Comment[ne]=फिल्टरमा आधारित पाठ हाइलाइट गर्दछ +Comment[nl]=Laat tekst oplichten gebaseerd op filters +Comment[nn]=Marker meldingar ved bruk av filter +Comment[pl]=Podświetla tekst na podstawie ustawionych filtrów +Comment[pt]=Realça o texto com base em filtros +Comment[pt_BR]=Destaca o texto baseado em filtros +Comment[ro]=Evidenţiază mesajele pe baza unor filtre +Comment[ru]=Подсвечивание текста основывается на фильтрах +Comment[se]=Merke teavstta silliid bokte +Comment[sk]=Zvýrazňuje text pomocou filtrov +Comment[sl]=Poudarjanje besedila glede na filtre +Comment[sr]=Истицање порука на основу филтера +Comment[sr@Latn]=Isticanje poruka na osnovu filtera +Comment[sv]=Markerar text baserat på filter +Comment[ta]=வடிகட்டியை பொருத்து உரையை தனிப்படுத்து +Comment[tg]=Равшансозии матн дар асоси полоягарҳо +Comment[tr]=Süzgeçlerde metin temelli vurgular +Comment[uk]=Підсвічування тексту базується на фільтрах +Comment[wa]=Mete li tecse e sorbriyance d' après les passetes +Comment[zh_CN]=根据过滤器突出显示文字 +Comment[zh_HK]=根據過濾器將訊息加強顯示 +Comment[zh_TW]=基於過濾器的高亮度訊息 -- cgit v1.2.1