Sul sito del creatore di KmobileTools, che tra l'altro e' un ragazzo italiano, ho scoperto due patch per Kopete entrambe utili per gestire le emoticons.
1) La prima serve per correggere una imperfezione grafica di Kopete: quando si clicca nella chat window sull'icona delle emoticons puo' capitare di non visualizzare nella loro interezza le icone animate in quanto hanno uno spazio piu' grande di quello a loro concesso. Bene la prima patch permette di visualizzare le icone nella loro interezza e aggiunge una barra di scorrimento laterale per visualizzarle facilmente tutte.
2) La seconda path invece serve ad importare le icone!!! Durante una sessione di chat e' sufficiente cliccare con il tasto destro sull'emoticons e nel menu' che si apre compare la scritta "Import Emoticons". Cliccandoci sopra si apre una finestra dove assegnare all'icona animata una combinazione di tasti e il gioco e' fatto!
Il link delle patch e' questo:
http://rockman.altervista.org/?p=patches.php
C'e' un pero'... Le patch sono scritte per Kopete 0.12.0 e non funzionano (o meglio, solo la seconda non funziona!) su Kopete 0.12.2. Non sapendo programmare in C++ ma solo in C ho provato a dargli un'occhiata e credo di averle messe a posto. Ho compilato Kopete 0.12.2 con le 2 patch e sembra che funzioni tutto (ho testato solo il protocollo MSN). Se per caso vuoi patchare kopete con queste due (secondo me utilissime) patch te le spedisco come le ho usate io aggiungendo anche il tuo slackbuild modificato per usarle. Se vuoi creare il pacchetto patchato e metterlo nel repository... E ovviamente se qualche volenteroso ha voglia di testarle a fondo (e magari migliorarle...) per vedere se danno problemi...
Tra l'altro, se qualcuno ha voglia di scrivere al gruppo che gestisce la realizzazione di Kopete per avvertirli dell'esistenza di queste patch... Come ho detto prima mi sembrano utilissime e a questi due problemi non ero mai riuscito a trovare la soluzione da nessuna parte!!!
Ciao ciao...
GiAn
kopete-0.12_bigemoticons.patch
Codice: Seleziona tutto
diff -U 4 -H -b -w -B -E -d -i -r -- kopete-0.12-beta2-orig/kopete/kopete/chatwindow/emoticonselector.cpp kopete-0.12-beta2/kopete/kopete/chatwindow/emoticonselector.cpp
--- kopete-0.12-beta2-orig/kopete/kopete/chatwindow/emoticonselector.cpp 2006-03-21 03:19:20.000000000 +0100
+++ kopete-0.12-beta2/kopete/kopete/chatwindow/emoticonselector.cpp 2006-05-16 15:16:39.834384750 +0200
@@ -28,8 +28,10 @@
#include <qlayout.h>
#include <qobjectlist.h>
#include <qtooltip.h>
#include <qobjectlist.h>
+#include <kwin.h>
+#include <qdesktopwidget.h>
#include <kdebug.h>
EmoticonLabel::EmoticonLabel(const QString &emoticonText, const QString &pixmapPath, QWidget *parent, const char *name)
@@ -42,14 +44,8 @@
// Somehow QLabel doesn't tell a reasonable size when you use setMovie
// although it does it correctly for setPixmap. Therefore here is a little workaround
// to tell our minimum size.
QPixmap p(pixmapPath);
- //
- // Some of the custom icons are rather large
- // so lets limit them to a maximum size for this display panel
- //
- if (p.width() > 32 || p.height() > 32)
- p.resize(32, 32);
setMinimumSize(p.size());
}
void EmoticonLabel::mouseReleaseEvent(QMouseEvent*)
@@ -57,51 +53,68 @@
emit clicked(mText);
}
EmoticonSelector::EmoticonSelector(QWidget *parent, const char *name)
- : QWidget(parent, name)
+ : KScrollView(parent, name)
{
// kdDebug(14000) << k_funcinfo << "called." << endl;
lay = 0L;
+ emot_mainWidget = 0L;
}
void EmoticonSelector::prepareList(void)
{
// kdDebug(14000) << k_funcinfo << "called." << endl;
+ if(deskRect.isEmpty() ) deskRect=QDesktopWidget().screenGeometry();
int row = 0;
int col = 0;
+ int curwidth=0;
+ int curheight=0;
+ int maxwidth=deskRect.width()-150;
+ int curmaxwidth=0;
+ int curmaxheight=0;
+ bool toscroll=false;
QMap<QString, QString> list = Kopete::Emoticons::self()->emoticonAndPicList();
- int emoticonsPerRow = static_cast<int>(sqrt(list.count()));
-// kdDebug(14000) << "emoticonsPerRow=" << emoticonsPerRow << endl;
+// kdDebug(14000) << "emoticonsPerRow=" << emoticonsPerRow << endl;
if ( lay )
{
QObjectList *list = queryList( "EmoticonLabel" );
// kdDebug(14000) << k_funcinfo << "There are " << list->count() << " EmoticonLabels to delete." << endl;
list->setAutoDelete(true);
list->clear();
delete list;
delete lay;
+ delete emot_mainWidget;
}
-
- lay = new QGridLayout(this, 0, 0, 4, 4, "emoticonLayout");
+ emot_mainWidget=new QWidget(viewport(), name() );
+ lay = new QGridLayout(emot_mainWidget, 0, 0, 4, 4, "emoticonLayout");
+ addChild(emot_mainWidget);
movieList.clear();
for (QMap<QString, QString>::Iterator it = list.begin(); it != list.end(); ++it )
{
- QWidget *w = new EmoticonLabel(it.key(), it.data(), this);
+ QWidget *w = new EmoticonLabel(it.key(), it.data(), emot_mainWidget);
movieList.push_back( ((QLabel*)w)->movie() );
connect(w, SIGNAL(clicked(const QString&)), this, SLOT(emoticonClicked(const QString&)));
// kdDebug(14000) << "adding Emoticon to row=" << row << ", col=" << col << "." << endl;
lay->addWidget(w, row, col);
- if ( col == emoticonsPerRow )
+ curheight=(curheight>w->height() ) ? curheight : w->height();
+ curwidth+=w->width()+4;
+ if ( curwidth>=maxwidth || col > static_cast<int>(sqrt(list.count()) ))
{
+ curmaxwidth=(curmaxwidth>curwidth) ? curmaxwidth : curwidth;
+ if(curmaxheight+curheight < (deskRect.height() - 150)) curmaxheight+= 4 + curheight;
+ else toscroll=true;
+ curheight=0;
+ curwidth=0;
col = 0;
row++;
}
else
col++;
}
- resize(minimumSizeHint());
+ setMinimumSize( lay->sizeHint().width() + ( (toscroll)?20:0),
+ ((toscroll) ? curmaxheight : lay->sizeHint().height() ) );
}
void EmoticonSelector::emoticonClicked(const QString &str)
{
Only in kopete-0.12-beta2/kopete/kopete/chatwindow: emoticonselector.cpp~
diff -U 4 -H -b -w -B -E -d -i -r -- kopete-0.12-beta2-orig/kopete/kopete/chatwindow/emoticonselector.h kopete-0.12-beta2/kopete/kopete/chatwindow/emoticonselector.h
--- kopete-0.12-beta2-orig/kopete/kopete/chatwindow/emoticonselector.h 2006-03-21 03:19:20.000000000 +0100
+++ kopete-0.12-beta2/kopete/kopete/chatwindow/emoticonselector.h 2006-05-16 14:04:45.328745000 +0200
@@ -21,8 +21,9 @@
#define __emoticonselector_h__
#include <qlabel.h>
#include <qwidget.h>
+#include <kscrollview.h>
class QGridLayout;
class QHideEvent;
class QShowEvent;
@@ -41,9 +42,9 @@
void mouseReleaseEvent(QMouseEvent*);
QString mText;
};
-class EmoticonSelector : public QWidget
+class EmoticonSelector : public KScrollView
{
Q_OBJECT
public:
@@ -66,8 +67,10 @@
virtual void hideEvent( QHideEvent* );
virtual void showEvent( QShowEvent* );
MovieList movieList;
QGridLayout *lay;
+ QWidget *emot_mainWidget;
+ QRect deskRect;
protected slots:
void emoticonClicked(const QString &);
};
Codice: Seleziona tutto
diff -U 4 -H -b -w -B -E -d -i -r -- kopete-0.12.2.orig/kopete/kopete/chatwindow/chatmessagepart.cpp kopete-0.12.2/kopete/kopete/chatwindow/chatmessagepart.cpp
--- kopete-0.12.2.orig/kopete/kopete/chatwindow/chatmessagepart.cpp 2006-05-31 02:24:04.000000000 +0200
+++ kopete-0.12.2/kopete/kopete/chatwindow/chatmessagepart.cpp 2006-06-02 12:34:05.476893500 +0200
@@ -34,8 +34,9 @@
#include <qregexp.h>
#include <qvaluelist.h>
#include <qtimer.h>
#include <qstylesheet.h>
+#include <qurloperator.h>
// KHTML::DOM includes
#include <dom/dom_doc.h>
#include <dom/dom_text.h>
@@ -59,10 +60,12 @@
#include <kstringhandler.h>
#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"
#include "kopetecontact.h"
@@ -117,9 +120,9 @@
public:
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)
{}
~Private()
@@ -143,8 +146,9 @@
KAction *saveAction;
KAction *printAction;
KAction *closeAction;
KAction *copyURLAction;
+ KAction *importEmoticon;
ChatWindowStyle *currentChatStyle;
Kopete::Contact *latestContact;
Kopete::Message::MessageDirection latestDirection;
@@ -258,8 +262,9 @@
d->copyAction = KStdAction::copy( this, SLOT(copy()), actionCollection() );
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
readOverrides();
@@ -280,8 +285,49 @@
else
d->scrollPressed = true;
}
+void ChatMessagePart::slotImportEmoticon()
+{
+ kdDebug() << "ChatMessagePart::slotImportEmoticon()" << d->activeElement.getAttribute("src") << endl;
+ 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() ) );
+ 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<QCString>(xmlfile.readAll());
+ if(text.contains(emoticonMap)<=0) text=QString::null;
+ xmlfile.close();
+ }
+ if(text.isNull() )
+ {
+ text= "<?xml version=\"1.0\"?>\n";
+ text+= "<messaging-emoticon-map >\n";
+ text+= "</messaging-emoticon-map>\n";
+ }
+ KIO::copy( d->activeElement.getAttribute("src").string(), xmldirname);
+ QString toAppend="<emoticon file=\"" + QFileInfo(d->activeElement.getAttribute("src").string() ).baseName() + "\">\n";
+ toAppend+=" <string>" + emoticonString + "</string>\n</emoticon>\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 );
dlg.setCaption( i18n( "Save Conversation" ) );
@@ -670,8 +716,9 @@
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 );
connect( chatWindowPopup, SIGNAL( aboutToHide() ), chatWindowPopup, SLOT( deleteLater() ) );
diff -U 4 -H -b -w -B -E -d -i -r -- kopete-0.12.0.orig/kopete/kopete/chatwindow/chatmessagepart.h kopete-0.12.0/kopete/kopete/chatwindow/chatmessagepart.h
--- kopete-0.12.0.orig/kopete/kopete/chatwindow/chatmessagepart.h 2006-05-31 02:24:04.000000000 +0200
+++ kopete-0.12.0/kopete/kopete/chatwindow/chatmessagepart.h 2006-06-02 12:34:05.480893750 +0200
@@ -147,8 +147,9 @@
void slotCopyURL();
void slotCloseView( bool force = false );
+ void slotImportEmoticon();
/**
* Do the actual style change.
*/
diff -U 4 -H -b -w -B -E -d -i -r -- kopete-0.12.0.orig/kopete/kopete/config/appearance/appearanceconfig.cpp kopete-0.12.0/kopete/kopete/config/appearance/appearanceconfig.cpp
--- kopete-0.12.0.orig/kopete/kopete/config/appearance/appearanceconfig.cpp 2006-05-31 02:24:04.000000000 +0200
+++ kopete-0.12.0/kopete/kopete/config/appearance/appearanceconfig.cpp 2006-06-02 12:34:05.480893750 +0200
@@ -514,9 +514,9 @@
for(unsigned int y = 0; y < themeQDir.count(); y++)
{
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"));
d->mPrfsEmoticons->icon_theme_list->insertItem(previewPixmap,themeQDir[y]);
diff -U 4 -H -b -w -B -E -d -i -r -- kopete-0.12.0.orig/kopete/libkopete/private/kopeteemoticons.cpp kopete-0.12.0/kopete/libkopete/private/kopeteemoticons.cpp
--- kopete-0.12.0.orig/kopete/libkopete/private/kopeteemoticons.cpp 2006-05-31 02:24:05.000000000 +0200
+++ kopete-0.12.0/kopete/libkopete/private/kopeteemoticons.cpp 2006-06-02 12:36:00.624089750 +0200
@@ -344,10 +344,21 @@
}
}
}
+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() )
return;
@@ -359,10 +370,8 @@
d->theme = theme;
}
// 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())
return initEmoticon_emoticonsxml( filename );
diff -U 4 -H -b -w -B -E -d -i -r -- kopete-0.12.0.orig/kopete/libkopete/private/kopeteemoticons.h kopete-0.12.0/kopete/libkopete/private/kopeteemoticons.h
--- kopete-0.12.0.orig/kopete/libkopete/private/kopeteemoticons.h 2006-05-31 02:24:05.000000000 +0200
+++ kopete-0.12.0/kopete/libkopete/private/kopeteemoticons.h 2006-06-02 12:34:05.480893750 +0200
@@ -161,8 +161,15 @@
struct Emoticon;
struct EmoticonNode;
class Private;
Private *d;
+public slots:
+ /**
+ * Reload emoticons
+ * Use this when changing current theme, for instance.
+ */
+ void reload();
+
private slots:
/**
* Fills the map with paths and emoticons
Codice: Seleziona tutto
#!/bin/sh
# Heavily based on the Slackware 10.2 SlackBuild
# Requirements: ortp 0.7.1, meanwhile, speex, openslp, gsmlib
# http://kopete.kde.org/
# Packager Vincenzi Loris - slacky@slacky.it
CWD=`pwd`
TMP=${TMP:-/tmp/tgz}
PKG=$TMP/package
NAME=kopete
VERSION=0.12.2
CHOST=i486
ARCH=${ARCH:-i486}
BUILD=2sl
if [ "$ARCH" = "i486" ]; then
SLKCFLAGS="-O2 -march=i486 -mcpu=i686"
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mcpu=i686"
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2"
fi
if [ ! -d $TMP ]; then
mkdir -p $TMP
fi
if [ ! -d $PKG ]; then
mkdir -p $PKG
fi
cd $TMP
tar xjvf $CWD/$NAME-$VERSION.tar.bz2
cd $NAME-$VERSION
patch -p1 <$CWD/kopete-0.12_importemoticons.patch
patch -p1 <$CWD/kopete-0.12_bigemoticons.patch
find . -perm 777 -exec chmod 755 {} \;
chown -R root.root .
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./configure --prefix=/opt/kde \
--enable-jingle \
--program-prefix="" \
--program-suffix="" \
$CHOST-slackware-linux
make
make install DESTDIR=$PKG
mkdir -p $PKG/usr/doc/$NAME-$VERSION
cp -a AUTHORS COPYING INSTALL README $PKG/usr/doc/$NAME-$VERSION
cd $PKG
find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/slack-desc > $PKG/usr/doc/$NAME-$VERSION/slack-desc
cat $CWD/$NAME.SlackBuild > $PKG/usr/doc/$NAME-$VERSION/$NAME.SlackBuild
requiredbuilder -v -y -s $CWD $PKG
makepkg -l y -c n $CWD/$NAME-$VERSION-$ARCH-$BUILD.tgz
if [ "$1" = "--cleanup" ]; then
rm -rf $TMP
fi



