Re: kdm and qt-3.1.2
On Tue, Mar 11, 2003 at 02:01:44PM +0100, Oswald Buddenhagen wrote:
> On Tue, Mar 11, 2003 at 10:43:24AM +0100, Ralf Nolden wrote:
> > On Dienstag, 11. März 2003 07:57, Bernt Christandl wrote:
> > > yesterday i upgrade my woody with 5 new qt-packages and realized
> > > that kdm then displayed (fixed width?) the possible users in a
> > > strange way:
> >
> yeah, i already heard about this problem.
>
> > That may be due to qt-3.1.2 fixes. Ossi, any problems known like fixed
> > width in the listview ?
> >
> dunno. i'll check shortly after the build finishes.
>
here we go ...
patch attached and commited to the 3.1 branch.
greetings
--
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
--
Chaos, panic, and disorder - my work here is done.
Index: kgreeter.h
===================================================================
RCS file: /home/kde/kdebase/kdm/kfrontend/kgreeter.h,v
retrieving revision 1.23
diff -u -r1.23 kgreeter.h
--- kgreeter.h 22 Oct 2002 03:46:21 -0000 1.23
+++ kgreeter.h 13 Mar 2003 18:51:20 -0000
@@ -81,6 +81,8 @@
};
+class UserListView;
+
class KGreeter : public FDialog {
Q_OBJECT
typedef FDialog inherited;
@@ -111,8 +113,8 @@
private:
void set_wm( const char * );
- void insertUsers( KListView * );
- void insertUser( KListView *, const QImage &, const QString &, struct passwd * );
+ void insertUsers( UserListView * );
+ void insertUser( UserListView *, const QImage &, const QString &, struct passwd * );
void MsgBox( QMessageBox::Icon typ, QString msg ) { KFMsgBox::box( this, typ, msg ); }
void Inserten( QPopupMenu *mnu, const QString& txt, const char *member );
bool verifyUser( bool );
@@ -122,7 +124,7 @@
WmStat wmstat;
QString enam;
KSimpleConfig *stsfile;
- KListView *user_view;
+ UserListView *user_view;
KdmClock *clock;
QLabel *pixLabel;
QLabel *loginLabel, *passwdLabel, *sessargLabel;
Index: kgreeter.cpp
===================================================================
RCS file: /home/kde/kdebase/kdm/kfrontend/kgreeter.cpp,v
retrieving revision 1.83.2.1
diff -u -r1.83.2.1 kgreeter.cpp
--- kgreeter.cpp 28 Dec 2002 02:01:34 -0000 1.83.2.1
+++ kgreeter.cpp 13 Mar 2003 18:51:20 -0000
@@ -36,6 +36,7 @@
#include <qaccel.h>
#include <qcursor.h>
#include <qheader.h>
+#include <qstyle.h>
#include <klocale.h>
#include <kglobal.h>
@@ -69,13 +70,6 @@
#include <strings.h>
-class GreeterListViewItem : public KListViewItem {
-public:
- GreeterListViewItem( KListView* parent, const QString& text )
- : KListViewItem( parent, text ) {};
- QString login;
-};
-
void
KLoginLineEdit::focusOutEvent( QFocusEvent *e )
{
@@ -84,6 +78,41 @@
}
+class UserListView : public KListView {
+public:
+ UserListView( QWidget* parent = 0, const char *name = 0 )
+ : KListView( parent, name )
+ , cachedSizeHint( -1, 0 )
+ {
+ setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Ignored );
+ header()->hide();
+ addColumn( QString::null );
+ setColumnAlignment( 0, AlignVCenter );
+ setResizeMode( QListView::LastColumn );
+ }
+
+ mutable QSize cachedSizeHint;
+
+protected:
+ virtual QSize sizeHint() const
+ {
+ if (!cachedSizeHint.isValid()) {
+ constPolish();
+ uint maxw = 0;
+ for (QListViewItem *itm = firstChild(); itm; itm = itm->nextSibling()) {
+ uint thisw = itm->width( fontMetrics(), this, 0 );
+ if (thisw > maxw)
+ maxw = thisw;
+ }
+ cachedSizeHint.setWidth(
+ style().pixelMetric( QStyle::PM_ScrollBarExtent ) +
+ frameWidth() * 2 + maxw );
+ }
+ return cachedSizeHint;
+ }
+};
+
+
KGreeter::KGreeter()
: inherited( 0, 0, true )
, user_view( 0 )
@@ -105,11 +134,7 @@
main_grid->addWidget( welcomeLabel, 0, 1 );
}
if (kdmcfg->_showUsers != SHOW_NONE) {
- user_view = new KListView( winFrame );
- user_view->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Ignored ) );
- user_view->addColumn(QString::null);
- user_view->setResizeMode(QListView::LastColumn);
- user_view->header()->hide();
+ user_view = new UserListView( winFrame );
insertUsers( user_view );
main_grid->addMultiCellWidget(user_view, 0, 3, 0, 0);
connect( user_view, SIGNAL(clicked( QListViewItem * )),
@@ -275,8 +300,24 @@
delete stsfile;
}
+class UserListViewItem : public KListViewItem {
+public:
+ UserListViewItem( UserListView *parent, const QString &text,
+ const QPixmap &pixmap, const QString &username )
+ : KListViewItem( parent )
+ , login( username )
+ {
+ setPixmap( 0, pixmap );
+ setMultiLinesEnabled( true );
+ setText( 0, text );
+ parent->cachedSizeHint.setWidth( -1 );
+ }
+
+ QString login;
+};
+
void
-KGreeter::insertUser( KListView *listview, const QImage &default_pix,
+KGreeter::insertUser( UserListView *listview, const QImage &default_pix,
const QString &username, struct passwd *ps )
{
QImage p;
@@ -296,17 +337,17 @@
else
p = p.smoothScale( 48, 48, QImage::ScaleMin );
QString realname = QFile::decodeName( ps->pw_gecos );
- realname = realname.left(realname.find(","));
- QString userlabel = realname.isEmpty() ?
- username :
- realname + "\n" + username;
- GreeterListViewItem *item = new GreeterListViewItem( listview, userlabel );
- item->setPixmap( 0, QPixmap( p ) );
- item->login = username;
+ realname.truncate( realname.find( ',' ) );
+ if (realname.isEmpty())
+ new UserListViewItem( listview, username, QPixmap( p ), username );
+ else {
+ realname.append( "\n" ).append( username );
+ new UserListViewItem( listview, realname, QPixmap( p ), username );
+ }
}
void
-KGreeter::insertUsers( KListView *listview )
+KGreeter::insertUsers( UserListView *listview )
{
QImage default_pix(
locate( "user_pic", QString::fromLatin1("default.png") ) );
@@ -372,7 +413,7 @@
QString login = loginEdit->text();
QListViewItem *item;
for (item = user_view->firstChild(); item; item = item->nextSibling())
- if (((GreeterListViewItem *)item)->login == login) {
+ if (((UserListViewItem *)item)->login == login) {
user_view->setCurrentItem( item );
user_view->ensureItemVisible( item );
break;
@@ -385,7 +426,7 @@
KGreeter::slot_user_name( QListViewItem *item )
{
if (item) {
- loginEdit->setText( ((GreeterListViewItem *)item)->login );
+ loginEdit->setText( ((UserListViewItem *)item)->login );
passwdEdit->erase();
passwdEdit->setFocus();
load_wm();
Reply to: