From: Manuel Nickschas Date: Wed, 9 Sep 2009 09:52:52 +0000 (+0200) Subject: Slightly improve placement of the text in the topic widget X-Git-Tag: 0.5-rc2~79 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=446f89f4ef5ce2bad77e128fa793baa0c3a9bdd1 Slightly improve placement of the text in the topic widget 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. --- diff --git a/src/uisupport/styledlabel.cpp b/src/uisupport/styledlabel.cpp index a87aa8ce..38250ea2 100644 --- a/src/uisupport/styledlabel.cpp +++ b/src/uisupport/styledlabel.cpp @@ -145,7 +145,7 @@ void StyledLabel::updateToolTip() { void StyledLabel::layout() { qreal h = 0; - qreal w = frameRect().width() - 2*frameWidth(); + qreal w = contentsRect().width(); _layout.beginLayout(); forever { @@ -163,11 +163,12 @@ void StyledLabel::layout() { update(); } -void StyledLabel::paintEvent(QPaintEvent *) { +void StyledLabel::paintEvent(QPaintEvent *e) { + QFrame::paintEvent(e); 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) {