Hi! I just hacked a bit the emoticon selector widget, since it was lacking support for custom emoticons > 32x32 pixel, and wasn't able to display a high number of emoticons (no scrollbars). I reimplemented the widget as a KScrollView (i'm a bit undecided, anyway.. QScrollView doesn't have smooth scroll.. which maybe too slow on some systems), removed the 32x32 size limit, and i decided to set the maximum size of the selector widget based on the desktop size (making some room, of course..) The result is attached as a diff, while there's a screenshot too at http://zerogoki.homelinux.org/emoticons.png I don't know if it's too late for 0.12, if so it could be possible to add it later, with some more ehancements. Thanks Marco -- KMobileTools - Open Source meets Mobile Phones. http://www.kmobiletools.org
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 14:24:13.753767000 +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,66 @@
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;
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;
+ curheight=0;
+ curwidth=0;
col = 0;
row++;
}
else
col++;
}
- resize(minimumSizeHint());
+ setMinimumSize( lay->sizeHint().width() + ( (curmaxheight< lay->sizeHint().height())?20:0),
+ ((curmaxheight< lay->sizeHint().height()) ? curmaxheight : lay->sizeHint().height() ) );
}
void EmoticonSelector::emoticonClicked(const QString &str)
{
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 &);
};
pgpK9E2SeHp8L.pgp
Description: PGP signature
_______________________________________________ kopete-devel mailing list [email protected] https://mail.kde.org/mailman/listinfo/kopete-devel
