Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 245604
Collapse All | Expand All

(-)kopete-0.12.1.orig/kopete/kopete/chatwindow/chatmessagepart.cpp (-2 / +49 lines)
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
(-)kopete-0.12.1.orig/kopete/kopete/chatwindow/chatmessagepart.h (+1 lines)
Lines 148-153 Link Here
148
	void slotCopyURL();
148
	void slotCopyURL();
149
149
150
	void slotCloseView( bool force = false );
150
	void slotCloseView( bool force = false );
151
    void slotImportEmoticon();
151
152
152
	/**
153
	/**
153
	 * Do the actual style change.
154
	 * Do the actual style change.
(-)kopete-0.12.1.orig/kopete/kopete/config/appearance/appearanceconfig.cpp (-1 / +1 lines)
Lines 515-521 Link Here
515
		{
515
		{
516
			QStringList themes = themeQDir.entryList(QDir::Dirs, QDir::Name);
516
			QStringList themes = themeQDir.entryList(QDir::Dirs, QDir::Name);
517
			// We don't care for '.' and '..'
517
			// We don't care for '.' and '..'
518
			if ( themeQDir[y] != "." && themeQDir[y] != ".." )
518
            if ( themeQDir[y] != "." && themeQDir[y] != ".." && themeQDir[y] != "~custom" )
519
			{
519
			{
520
				// Add ourselves to the list, using our directory name  FIXME:  use the first emoticon of the theme.
520
				// Add ourselves to the list, using our directory name  FIXME:  use the first emoticon of the theme.
521
				QPixmap previewPixmap = QPixmap(locate("emoticons", themeQDir[y]+"/smile.png"));
521
				QPixmap previewPixmap = QPixmap(locate("emoticons", themeQDir[y]+"/smile.png"));
(-)kopete-0.12.1.orig/kopete/libkopete/private/kopeteemoticons.cpp (-2 / +11 lines)
Lines 345-352 Link Here
345
	}
345
	}
346
}
346
}
347
347
348
void Emoticons::reload()
349
{
350
  initEmoticons( QString::null );
351
}
352
348
void Emoticons::initEmoticons( const QString &theme )
353
void Emoticons::initEmoticons( const QString &theme )
349
{
354
{
355
  if(theme.compare( QString::fromLatin1("~custom") ) )
356
  {
357
    d->emoticonAndPicList.clear();
358
    d->emoticonMap.clear();
359
    initEmoticons( QString::fromLatin1("~custom") );
360
  }
350
	if(theme.isNull())
361
	if(theme.isNull())
351
	{
362
	{
352
		if ( d->theme == KopetePrefs::prefs()->iconTheme() )
363
		if ( d->theme == KopetePrefs::prefs()->iconTheme() )
Lines 360-367 Link Here
360
	}
371
	}
361
372
362
//	kdDebug(14010) << k_funcinfo << "Called" << endl;
373
//	kdDebug(14010) << k_funcinfo << "Called" << endl;
363
	d->emoticonAndPicList.clear();
364
	d->emoticonMap.clear();
365
374
366
	QString filename= KGlobal::dirs()->findResource( "emoticons",  d->theme + QString::fromLatin1( "/emoticons.xml" ) );
375
	QString filename= KGlobal::dirs()->findResource( "emoticons",  d->theme + QString::fromLatin1( "/emoticons.xml" ) );
367
	if(!filename.isEmpty())
376
	if(!filename.isEmpty())
(-)kopete-0.12.1.orig/kopete/libkopete/private/kopeteemoticons.h (+7 lines)
Lines 162-167 Link Here
162
	struct EmoticonNode;
162
	struct EmoticonNode;
163
	class Private;
163
	class Private;
164
	Private *d;
164
	Private *d;
165
public slots:
166
    /**
167
     * Reload emoticons
168
     * Use this when changing current theme, for instance.
169
     */
170
    void reload();
171
165
private slots:
172
private slots:
166
173
167
	/**
174
	/**
168
175

Return to bug 245604