[Kalzium] [Bug 112492] Gradient: Unit not shown and fonts to big

cniehaus@gmx.de cniehaus at gmx.de
Thu Sep 15 11:48:18 CEST 2005


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=112492         




------- Additional Comments From cniehaus gmx de  2005-09-15 11:48 -------
SVN commit 460807 by cniehaus:

Part one of this bug: Fix the size of the font

CCBUG: 112492


 M  +16 -0     periodictableview.cpp  


--- branches/KDE/3.5/kdeedu/kalzium/src/periodictableview.cpp #460806:460807
 @ -983,6 +983,7  @
 	EList::ConstIterator it = d->ElementList.begin();
 	const EList::ConstIterator itEnd = d->ElementList.end();
 
+
 	/**
 	 * this loop iterates through all elements. The Elements
 	 * draw themselves, the PerodicTableView only tells them to do so
 @ -1105,6 +1106,21  @
 	QImage img = KImageEffect::gradient ( s, Qt::white, Qt::red, 
 										  KImageEffect::HorizontalGradient );
 	QPixmap pm( img );
+	
+	/**
+	 * now find the optimum stringsize for the caption
+	 * i18n( "Gradient: van der Waals Radius" ); is at least 
+	 * for english the longest possible string. As "van der Waals"
+	 * is a name it should be the same in all languages and be
+	 * probably always the longest string
+	 */
+	QString tmp = i18n( "Gradient: van der Waals Radius" );
+	QRect rect(x+5, y+50, ELEMENTSIZE*10,20);
+	QFont font = p->font();
+	int maxSize = KalziumUtils::maxSize( tmp, rect, p->font(), p, 8, 24 );
+	kdDebug() << "maxSize: " << maxSize << endl;
+	font.setPointSize(maxSize);
+	p->setFont(font);
 
 	p->drawText( x+5, y+50, ELEMENTSIZE*10,20, Qt::AlignCenter, title ); 
 	p->drawPixmap( x+50, y+80, pm );


More information about the Kalzium mailing list