Sorry.. wrong diff file.. this one is much better :P
--
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 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 &);
};
_______________________________________________
kopete-devel mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kopete-devel