Slightly improve placement of the text in the topic widget
authorManuel Nickschas <sputnick@quassel-irc.org>
Wed, 9 Sep 2009 09:52:52 +0000 (11:52 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 9 Sep 2009 09:56:15 +0000 (11:56 +0200)
StyledLabel properly obeys the frame margins now, and properly centers within the frame's
contentsRect. This means that in most styles, the topic should now be displayed with a small left margin
and vertically centered rather than too far up.

Sadly, Oxygen still seems to add some extra padding below the contentsRect(), such that the text appears
slightly misplaced.

src/uisupport/styledlabel.cpp

index a87aa8c..38250ea 100644 (file)
@@ -145,7 +145,7 @@ void StyledLabel::updateToolTip() {
 
 void StyledLabel::layout() {
   qreal h = 0;
 
 void StyledLabel::layout() {
   qreal h = 0;
-  qreal w = frameRect().width() - 2*frameWidth();
+  qreal w = contentsRect().width();
 
   _layout.beginLayout();
   forever {
 
   _layout.beginLayout();
   forever {
@@ -163,11 +163,12 @@ void StyledLabel::layout() {
   update();
 }
 
   update();
 }
 
-void StyledLabel::paintEvent(QPaintEvent *) {
+void StyledLabel::paintEvent(QPaintEvent *e) {
+  QFrame::paintEvent(e);
   QPainter painter(this);
 
   QPainter painter(this);
 
-  qreal y = (frameRect().height() - _layout.boundingRect().height()) / 2;
-  _layout.draw(&painter, QPointF(0, y), _extraLayoutList);
+  qreal y = contentsRect().y() + (contentsRect().height() - _layout.boundingRect().height()) / 2;
+  _layout.draw(&painter, QPointF(contentsRect().x(), y), _extraLayoutList);
 }
 
 int StyledLabel::posToCursor(const QPointF &pos) {
 }
 
 int StyledLabel::posToCursor(const QPointF &pos) {