diff -ur kopete-0.12.1.orig/kopete/kopete/chatwindow/chatmessagepart.cpp kopete-0.12.1/kopete/kopete/chatwindow/chatmessagepart.cpp --- kopete-0.12.1.orig/kopete/kopete/chatwindow/chatmessagepart.cpp 2006-07-13 02:55:47.000000000 +0200 +++ kopete-0.12.1/kopete/kopete/chatwindow/chatmessagepart.cpp 2006-07-15 21:18:28.000000000 +0200 @@ -43,6 +43,7 @@ #include #include #include +#include // KDE includes @@ -60,8 +61,10 @@ #include #include #include +#include #include #include +#include // Kopete includes #include "chatmemberslistwidget.h" @@ -118,7 +121,7 @@ Private() : tt(0L), manager(0L), scrollPressed(false), copyAction(0L), saveAction(0L), printAction(0L), - closeAction(0L),copyURLAction(0L), currentChatStyle(0L), latestContact(0L), + closeAction(0L),copyURLAction(0L), currentChatStyle(0L), latestContact(0L), importEmoticon(0L), latestDirection(Kopete::Message::Inbound), latestType(Kopete::Message::TypeNormal) {} @@ -144,6 +147,7 @@ KAction *printAction; KAction *closeAction; KAction *copyURLAction; + KAction *importEmoticon; ChatWindowStyle *currentChatStyle; Kopete::Contact *latestContact; @@ -259,6 +263,7 @@ d->saveAction = KStdAction::saveAs( this, SLOT(save()), actionCollection() ); d->printAction = KStdAction::print( this, SLOT(print()),actionCollection() ); d->closeAction = KStdAction::close( this, SLOT(slotCloseView()),actionCollection() ); + d->importEmoticon = new KAction( i18n( "Import Emoticon"), QString::fromLatin1( "importemot" ), 0, this, SLOT( slotImportEmoticon() ), actionCollection() ); d->copyURLAction = new KAction( i18n( "Copy Link Address" ), QString::fromLatin1( "editcopy" ), 0, this, SLOT( slotCopyURL() ), actionCollection() ); // read formatting override flags @@ -281,6 +286,47 @@ d->scrollPressed = true; } +void ChatMessagePart::slotImportEmoticon() +{ + kdDebug() << "ChatMessagePart::slotImportEmoticon()" << d->activeElement.getAttribute("src") << endl; + QString emoticonString = KInputDialog::getText( i18n("Import Emoticon"), i18n("
Insert here a shortcut that will be replaced by this emoticon (for instance :P ).
").arg( d->activeElement.getAttribute("src").string() ) ); + if (emoticonString.isNull() ) return; + QString xmldirname = KGlobal::dirs()->saveLocation( "emoticons", QString::fromLatin1( "~custom" ), true ); + // check if xmlname exists, if not create it + if(xmldirname.isNull() ) + { + KMessageBox::error( view(), i18n("There was an error creating the directory for imported emoticons.") ); + return; + } + QString xmlname= xmldirname + QString::fromLatin1("/emoticons.xml"); + QFile xmlfile(xmlname); + QString text; + QRegExp emoticonMap("(<[\\s]*/[\\s]*messaging-emoticon-map[\\s]*>)"); + + if( xmlfile.exists() && xmlfile.open(IO_ReadOnly) ) + { + text=static_cast(xmlfile.readAll()); + if(text.contains(emoticonMap)<=0) text=QString::null; + xmlfile.close(); + } + if(text.isNull() ) + { + text= "\n"; + text+= "\n"; + text+= "\n"; + } + KIO::copy( d->activeElement.getAttribute("src").string(), xmldirname); + QString toAppend="activeElement.getAttribute("src").string() ).baseName() + "\">\n"; + toAppend+=" " + emoticonString + "\n\n\\1"; + xmlfile.open( IO_WriteOnly | IO_Truncate ); + QTextStream stream( &xmlfile ); + emoticonMap.setCaseSensitive(false); + text=text.replace(emoticonMap, toAppend); + stream << text; + xmlfile.close(); + QTimer::singleShot(1500, Kopete::Emoticons::self(), SLOT(reload() ) ); +} + void ChatMessagePart::save() { KFileDialog dlg( QString::null, QString::fromLatin1( "text/html text/plain" ), view(), "fileSaveDialog", false ); @@ -666,11 +712,12 @@ d->copyURLAction->plug( chatWindowPopup ); chatWindowPopup->insertSeparator(); } - + kdDebug() << "ChatMessagePart::slotRightClick(): " << d->activeElement.tagName().lower() << endl; d->copyAction->setEnabled( hasSelection() ); d->copyAction->plug( chatWindowPopup ); d->saveAction->plug( chatWindowPopup ); d->printAction->plug( chatWindowPopup ); + if( d->activeElement.tagName().lower() == "img" ) d->importEmoticon->plug( chatWindowPopup ); chatWindowPopup->insertSeparator(); d->closeAction->plug( chatWindowPopup ); Only in kopete-0.12.1/kopete/kopete/chatwindow: chatmessagepart.cpp.orig Only in kopete-0.12.1/kopete/kopete/chatwindow: chatmessagepart.cpp.rej diff -ur kopete-0.12.1.orig/kopete/kopete/chatwindow/chatmessagepart.h kopete-0.12.1/kopete/kopete/chatwindow/chatmessagepart.h --- kopete-0.12.1.orig/kopete/kopete/chatwindow/chatmessagepart.h 2006-07-13 02:55:47.000000000 +0200 +++ kopete-0.12.1/kopete/kopete/chatwindow/chatmessagepart.h 2006-07-15 21:17:45.000000000 +0200 @@ -148,6 +148,7 @@ void slotCopyURL(); void slotCloseView( bool force = false ); + void slotImportEmoticon(); /** * Do the actual style change. diff -ur kopete-0.12.1.orig/kopete/kopete/config/appearance/appearanceconfig.cpp kopete-0.12.1/kopete/kopete/config/appearance/appearanceconfig.cpp --- kopete-0.12.1.orig/kopete/kopete/config/appearance/appearanceconfig.cpp 2006-07-13 02:55:45.000000000 +0200 +++ kopete-0.12.1/kopete/kopete/config/appearance/appearanceconfig.cpp 2006-07-15 21:17:45.000000000 +0200 @@ -515,7 +515,7 @@ { QStringList themes = themeQDir.entryList(QDir::Dirs, QDir::Name); // We don't care for '.' and '..' - if ( themeQDir[y] != "." && themeQDir[y] != ".." ) + if ( themeQDir[y] != "." && themeQDir[y] != ".." && themeQDir[y] != "~custom" ) { // Add ourselves to the list, using our directory name FIXME: use the first emoticon of the theme. QPixmap previewPixmap = QPixmap(locate("emoticons", themeQDir[y]+"/smile.png")); diff -ur kopete-0.12.1.orig/kopete/libkopete/private/kopeteemoticons.cpp kopete-0.12.1/kopete/libkopete/private/kopeteemoticons.cpp --- kopete-0.12.1.orig/kopete/libkopete/private/kopeteemoticons.cpp 2006-07-13 02:55:52.000000000 +0200 +++ kopete-0.12.1/kopete/libkopete/private/kopeteemoticons.cpp 2006-07-15 21:17:45.000000000 +0200 @@ -345,8 +345,19 @@ } } +void Emoticons::reload() +{ + initEmoticons( QString::null ); +} + void Emoticons::initEmoticons( const QString &theme ) { + if(theme.compare( QString::fromLatin1("~custom") ) ) + { + d->emoticonAndPicList.clear(); + d->emoticonMap.clear(); + initEmoticons( QString::fromLatin1("~custom") ); + } if(theme.isNull()) { if ( d->theme == KopetePrefs::prefs()->iconTheme() ) @@ -360,8 +371,6 @@ } // kdDebug(14010) << k_funcinfo << "Called" << endl; - d->emoticonAndPicList.clear(); - d->emoticonMap.clear(); QString filename= KGlobal::dirs()->findResource( "emoticons", d->theme + QString::fromLatin1( "/emoticons.xml" ) ); if(!filename.isEmpty()) diff -ur kopete-0.12.1.orig/kopete/libkopete/private/kopeteemoticons.h kopete-0.12.1/kopete/libkopete/private/kopeteemoticons.h --- kopete-0.12.1.orig/kopete/libkopete/private/kopeteemoticons.h 2006-07-13 02:55:52.000000000 +0200 +++ kopete-0.12.1/kopete/libkopete/private/kopeteemoticons.h 2006-07-15 21:17:45.000000000 +0200 @@ -162,6 +162,13 @@ struct EmoticonNode; class Private; Private *d; +public slots: + /** + * Reload emoticons + * Use this when changing current theme, for instance. + */ + void reload(); + private slots: /**