summaryrefslogtreecommitdiffstats
path: root/kopete/kopete/chatwindow/chatmessagepart.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kopete/kopete/chatwindow/chatmessagepart.cpp')
-rw-r--r--kopete/kopete/chatwindow/chatmessagepart.cpp55
1 files changed, 54 insertions, 1 deletions
diff --git a/kopete/kopete/chatwindow/chatmessagepart.cpp b/kopete/kopete/chatwindow/chatmessagepart.cpp
index 36523dac..3cf70b8a 100644
--- a/kopete/kopete/chatwindow/chatmessagepart.cpp
+++ b/kopete/kopete/chatwindow/chatmessagepart.cpp
@@ -43,6 +43,7 @@
#include <dom/html_base.h>
#include <dom/html_document.h>
#include <dom/html_inline.h>
+#include <qurloperator.h>
// KDE includes
@@ -60,8 +61,10 @@
#include <ktempfile.h>
#include <kurldrag.h>
#include <kio/netaccess.h>
+#include <kio/job.h>
#include <kstandarddirs.h>
#include <kiconloader.h>
+#include <kinputdialog.h>
// Kopete includes
#include "chatmemberslistwidget.h"
@@ -144,6 +147,7 @@ public:
KAction *printAction;
KAction *closeAction;
KAction *copyURLAction;
+ KAction *importEmoticon;
ChatWindowStyle *currentChatStyle;
Kopete::Contact *latestContact;
@@ -259,6 +263,7 @@ ChatMessagePart::ChatMessagePart( Kopete::ChatSession *mgr, QWidget *parent, con
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,53 @@ void ChatMessagePart::slotScrollingTo( int /*x*/, int y )
d->scrollPressed = true;
}
+void ChatMessagePart::slotImportEmoticon()
+{
+ QString emoticonString = KInputDialog::getText( i18n("Import Emoticon"),
+ i18n("<qt><img src=\"%1\"><br>Insert the string for the emoticon<br>separated by space if you want multiple strings</qt>").arg( d->activeElement.getAttribute("src").string() ) );
+ if (emoticonString.isNull() )
+ return;
+
+ QString emo = d->activeElement.getAttribute("src").string();
+ QString themeName = KopetePrefs::prefs()->iconTheme();
+
+ KIO::copy(emo, KGlobal::dirs()->saveLocation( "emoticons", themeName, false ));
+
+ QFile *fp = new QFile(KGlobal::dirs()->saveLocation( "emoticons", themeName, false ) + "/emoticons.xml");
+
+ QDomDocument themeXml;
+
+ if(!fp->exists() || !fp->open( IO_ReadOnly ) || !themeXml.setContent(fp))
+ return;
+
+ fp->close();
+
+ QDomNode lc = themeXml.lastChild();
+ if(lc.isNull())
+ return;
+
+ QDomElement emoticon = themeXml.createElement("emoticon");
+ emoticon.setAttribute("file", QFileInfo(emo).baseName());
+ lc.appendChild(emoticon);
+ QStringList splitted = QStringList::split(" ", emoticonString);
+ QStringList::const_iterator constIterator;
+ for(constIterator = splitted.begin(); constIterator != splitted.end(); constIterator++)
+ {
+ QDomElement emotext = themeXml.createElement("string");
+ QDomText txt = themeXml.createTextNode((*constIterator).stripWhiteSpace());
+ emotext.appendChild(txt);
+ emoticon.appendChild(emotext);
+ }
+
+ if(!fp->open( IO_WriteOnly ))
+ return;
+
+ QTextStream emoStream(fp);
+ emoStream << themeXml.toString(4);
+ fp->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 );
@@ -680,11 +732,12 @@ void ChatMessagePart::slotRightClick( const QString &, const QPoint &point )
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 );