[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdenetwork/kopete/protocols/oscar/icq/ui
From:       Roman Jarosz <kedgedev () centrum ! cz>
Date:       2008-07-21 21:12:43
Message-ID: 1216674763.569438.10536.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 836186 by rjarosz:

Fix bug when for some fonts the xtraz icons aren't painted correctly (probably for \
all antialiased fonts). It looks like it's Qt bug.



 M  +13 -6     iconcells.cpp  


--- trunk/KDE/kdenetwork/kopete/protocols/oscar/icq/ui/iconcells.cpp #836185:836186
@@ -31,7 +31,6 @@
 
 	QList<QIcon> icons;
 	int selected;
-	QSize iconSize;
 };
 
 IconCells::IconCells( QWidget *parent )
@@ -44,12 +43,20 @@
 	horizontalHeader()->hide();
 
 	d->selected = 0;
+	int pm = style()->pixelMetric( QStyle::PM_SmallIconSize, 0, this );
+	setIconSize( QSize( pm, pm ) );
 
 	setSelectionMode( QAbstractItemView::SingleSelection );
 	setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
 	setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
 	viewport()->setBackgroundRole( QPalette::Background );
 	setBackgroundRole( QPalette::Background );
+
+	// HACK: Looks like any antialiased font brakes grid and icon painting.
+	// We only have icons so we can set the font to one which isn't antialiased.
+	QFont timesFont( "Times", 10, QFont::Normal );
+	setFont( timesFont );
+
 	connect( this, SIGNAL(cellActivated( int, int )), this, SLOT(selected(int, int)) );
 	connect( this, SIGNAL(cellPressed( int, int )), this, SLOT(selected(int, int)) );
 }
@@ -87,8 +94,8 @@
 
 QSize IconCells::sizeHint () const
 {
-	int width = columnCount() * (d->iconSize.width() + 8) + 2 * frameWidth();
-	int height = rowCount() * (d->iconSize.height() + 8) + 2 * frameWidth();
+	int width = columnCount() * (iconSize().width() + 8) + 2 * frameWidth();
+	int height = rowCount() * (iconSize().height() + 8) + 2 * frameWidth();
 	return QSize( width, height );
 }
 
@@ -114,11 +121,11 @@
 			if ( index < d->icons.count() )
 			{
 				QIcon icon = d->icons.at(index);
-				d->iconSize = QSize(16,16); /*d->iconSize.expandedTo( icon.size() );*/
 				tableItem->setData( Qt::DecorationRole, icon );
 			}
 		}
 	}
+	setMinimumSize( sizeHint() );
 }
 
 void IconCells::selected( int row, int column )
@@ -151,12 +158,12 @@
 
 int IconCells::sizeHintForColumn(int /*column*/) const
 {
-	return (width() - 2 * frameWidth()) / columnCount() ;
+	return (int)floor((double)(width() - 2 * frameWidth()) / columnCount());
 }
 
 int IconCells::sizeHintForRow(int /*row*/) const
 {
-	return (height() - 2 * frameWidth()) / rowCount() ;
+	return (int)floor((double)(height() - 2 * frameWidth()) / rowCount());
 }
 
 int IconCells::rowFromIndex( int index ) const


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic