Lines 43-48
Link Here
|
43 |
#include <dom/html_base.h> |
43 |
#include <dom/html_base.h> |
44 |
#include <dom/html_document.h> |
44 |
#include <dom/html_document.h> |
45 |
#include <dom/html_inline.h> |
45 |
#include <dom/html_inline.h> |
|
|
46 |
#include <qurloperator.h> |
46 |
|
47 |
|
47 |
|
48 |
|
48 |
// KDE includes |
49 |
// KDE includes |
Lines 60-67
Link Here
|
60 |
#include <ktempfile.h> |
61 |
#include <ktempfile.h> |
61 |
#include <kurldrag.h> |
62 |
#include <kurldrag.h> |
62 |
#include <kio/netaccess.h> |
63 |
#include <kio/netaccess.h> |
|
|
64 |
#include <kio/job.h> |
63 |
#include <kstandarddirs.h> |
65 |
#include <kstandarddirs.h> |
64 |
#include <kiconloader.h> |
66 |
#include <kiconloader.h> |
|
|
67 |
#include <kinputdialog.h> |
65 |
|
68 |
|
66 |
// Kopete includes |
69 |
// Kopete includes |
67 |
#include "chatmemberslistwidget.h" |
70 |
#include "chatmemberslistwidget.h" |
Lines 118-124
Link Here
|
118 |
Private() |
121 |
Private() |
119 |
: tt(0L), manager(0L), scrollPressed(false), |
122 |
: tt(0L), manager(0L), scrollPressed(false), |
120 |
copyAction(0L), saveAction(0L), printAction(0L), |
123 |
copyAction(0L), saveAction(0L), printAction(0L), |
121 |
closeAction(0L),copyURLAction(0L), currentChatStyle(0L), latestContact(0L), |
124 |
closeAction(0L),copyURLAction(0L), currentChatStyle(0L), latestContact(0L), importEmoticon(0L), |
122 |
latestDirection(Kopete::Message::Inbound), latestType(Kopete::Message::TypeNormal) |
125 |
latestDirection(Kopete::Message::Inbound), latestType(Kopete::Message::TypeNormal) |
123 |
{} |
126 |
{} |
124 |
|
127 |
|
Lines 144-149
Link Here
|
144 |
KAction *printAction; |
147 |
KAction *printAction; |
145 |
KAction *closeAction; |
148 |
KAction *closeAction; |
146 |
KAction *copyURLAction; |
149 |
KAction *copyURLAction; |
|
|
150 |
KAction *importEmoticon; |
147 |
|
151 |
|
148 |
ChatWindowStyle *currentChatStyle; |
152 |
ChatWindowStyle *currentChatStyle; |
149 |
Kopete::Contact *latestContact; |
153 |
Kopete::Contact *latestContact; |
Lines 259-264
Link Here
|
259 |
d->saveAction = KStdAction::saveAs( this, SLOT(save()), actionCollection() ); |
263 |
d->saveAction = KStdAction::saveAs( this, SLOT(save()), actionCollection() ); |
260 |
d->printAction = KStdAction::print( this, SLOT(print()),actionCollection() ); |
264 |
d->printAction = KStdAction::print( this, SLOT(print()),actionCollection() ); |
261 |
d->closeAction = KStdAction::close( this, SLOT(slotCloseView()),actionCollection() ); |
265 |
d->closeAction = KStdAction::close( this, SLOT(slotCloseView()),actionCollection() ); |
|
|
266 |
d->importEmoticon = new KAction( i18n( "Import Emoticon"), QString::fromLatin1( "importemot" ), 0, this, SLOT( slotImportEmoticon() ), actionCollection() ); |
262 |
d->copyURLAction = new KAction( i18n( "Copy Link Address" ), QString::fromLatin1( "editcopy" ), 0, this, SLOT( slotCopyURL() ), actionCollection() ); |
267 |
d->copyURLAction = new KAction( i18n( "Copy Link Address" ), QString::fromLatin1( "editcopy" ), 0, this, SLOT( slotCopyURL() ), actionCollection() ); |
263 |
|
268 |
|
264 |
// read formatting override flags |
269 |
// read formatting override flags |
Lines 281-286
Link Here
|
281 |
d->scrollPressed = true; |
286 |
d->scrollPressed = true; |
282 |
} |
287 |
} |
283 |
|
288 |
|
|
|
289 |
void ChatMessagePart::slotImportEmoticon() |
290 |
{ |
291 |
kdDebug() << "ChatMessagePart::slotImportEmoticon()" << d->activeElement.getAttribute("src") << endl; |
292 |
QString emoticonString = KInputDialog::getText( i18n("Import Emoticon"), i18n("<qt><img src=\"%1\"><br>Insert here a shortcut that will be replaced by this emoticon (for instance :P ).</qt>").arg( d->activeElement.getAttribute("src").string() ) ); |
293 |
if (emoticonString.isNull() ) return; |
294 |
QString xmldirname = KGlobal::dirs()->saveLocation( "emoticons", QString::fromLatin1( "~custom" ), true ); |
295 |
// check if xmlname exists, if not create it |
296 |
if(xmldirname.isNull() ) |
297 |
{ |
298 |
KMessageBox::error( view(), i18n("There was an error creating the directory for imported emoticons.") ); |
299 |
return; |
300 |
} |
301 |
QString xmlname= xmldirname + QString::fromLatin1("/emoticons.xml"); |
302 |
QFile xmlfile(xmlname); |
303 |
QString text; |
304 |
QRegExp emoticonMap("(<[\\s]*/[\\s]*messaging-emoticon-map[\\s]*>)"); |
305 |
|
306 |
if( xmlfile.exists() && xmlfile.open(IO_ReadOnly) ) |
307 |
{ |
308 |
text=static_cast<QCString>(xmlfile.readAll()); |
309 |
if(text.contains(emoticonMap)<=0) text=QString::null; |
310 |
xmlfile.close(); |
311 |
} |
312 |
if(text.isNull() ) |
313 |
{ |
314 |
text= "<?xml version=\"1.0\"?>\n"; |
315 |
text+= "<messaging-emoticon-map >\n"; |
316 |
text+= "</messaging-emoticon-map>\n"; |
317 |
} |
318 |
KIO::copy( d->activeElement.getAttribute("src").string(), xmldirname); |
319 |
QString toAppend="<emoticon file=\"" + QFileInfo(d->activeElement.getAttribute("src").string() ).baseName() + "\">\n"; |
320 |
toAppend+=" <string>" + emoticonString + "</string>\n</emoticon>\n\\1"; |
321 |
xmlfile.open( IO_WriteOnly | IO_Truncate ); |
322 |
QTextStream stream( &xmlfile ); |
323 |
emoticonMap.setCaseSensitive(false); |
324 |
text=text.replace(emoticonMap, toAppend); |
325 |
stream << text; |
326 |
xmlfile.close(); |
327 |
QTimer::singleShot(1500, Kopete::Emoticons::self(), SLOT(reload() ) ); |
328 |
} |
329 |
|
284 |
void ChatMessagePart::save() |
330 |
void ChatMessagePart::save() |
285 |
{ |
331 |
{ |
286 |
KFileDialog dlg( QString::null, QString::fromLatin1( "text/html text/plain" ), view(), "fileSaveDialog", false ); |
332 |
KFileDialog dlg( QString::null, QString::fromLatin1( "text/html text/plain" ), view(), "fileSaveDialog", false ); |
Lines 666-676
Link Here
|
666 |
d->copyURLAction->plug( chatWindowPopup ); |
712 |
d->copyURLAction->plug( chatWindowPopup ); |
667 |
chatWindowPopup->insertSeparator(); |
713 |
chatWindowPopup->insertSeparator(); |
668 |
} |
714 |
} |
669 |
|
715 |
kdDebug() << "ChatMessagePart::slotRightClick(): " << d->activeElement.tagName().lower() << endl; |
670 |
d->copyAction->setEnabled( hasSelection() ); |
716 |
d->copyAction->setEnabled( hasSelection() ); |
671 |
d->copyAction->plug( chatWindowPopup ); |
717 |
d->copyAction->plug( chatWindowPopup ); |
672 |
d->saveAction->plug( chatWindowPopup ); |
718 |
d->saveAction->plug( chatWindowPopup ); |
673 |
d->printAction->plug( chatWindowPopup ); |
719 |
d->printAction->plug( chatWindowPopup ); |
|
|
720 |
if( d->activeElement.tagName().lower() == "img" ) d->importEmoticon->plug( chatWindowPopup ); |
674 |
chatWindowPopup->insertSeparator(); |
721 |
chatWindowPopup->insertSeparator(); |
675 |
d->closeAction->plug( chatWindowPopup ); |
722 |
d->closeAction->plug( chatWindowPopup ); |
676 |
|
723 |
|