From 632dee611dfb1c47299c67591ee613050edee690 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Wed, 28 Jul 2010 20:13:19 +0200 Subject: [PATCH] TextFloat: fixed size calculation in simple mode The height of TextFloat objects was not sufficient e.g. when used as tooltips for knobs (while changing their values). Fixed improper geometry calculation and static values in TextFloat::paintEvent(). (cherry picked from commit db8de3450c96c082e55c4b1f93313aaadd89382f) --- src/gui/widgets/text_float.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/gui/widgets/text_float.cpp b/src/gui/widgets/text_float.cpp index eede3884f..24d75043c 100644 --- a/src/gui/widgets/text_float.cpp +++ b/src/gui/widgets/text_float.cpp @@ -1,8 +1,8 @@ /* * text_float.cpp - class textFloat, a floating text-label * - * Copyright (c) 2005-2008 Tobias Doerffel - * + * Copyright (c) 2005-2010 Tobias Doerffel + * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or @@ -22,7 +22,6 @@ * */ - #include #include @@ -35,8 +34,8 @@ textFloat::textFloat() : QWidget( engine::mainWindow(), Qt::ToolTip ), - m_title( "" ), - m_text( "" ), + m_title(), + m_text(), m_pixmap() { resize( 20, 20 ); @@ -138,9 +137,9 @@ void textFloat::paintEvent( QPaintEvent * _pe ) // p.setPen( Qt::black ); // small message? - if( m_title == "" ) + if( m_title.isEmpty() ) { - p.drawText( 2, 10, m_text ); + p.drawText( 2, p.fontMetrics().height()-2, m_text ); } else { @@ -173,7 +172,7 @@ void textFloat::updateSize() { QFontMetrics metrics( pointSize<8>( font() ) ); QRect textBound = metrics.boundingRect( m_text ); - if( m_title != "" ) + if( !m_title.isEmpty() ) { QFont f = pointSize<8>( font() ); f.setBold( true ); @@ -182,13 +181,13 @@ void textFloat::updateSize() { textBound.setWidth( title_w ); } - textBound.setHeight( textBound.height() * 2 + 14 ); + textBound.setHeight( textBound.height() * 2 + 8 ); } if( m_pixmap.isNull() == false ) { textBound.setWidth( textBound.width() + m_pixmap.width() + 10 ); } - resize( textBound.width() + 5, textBound.height()*3/4+2 ); + resize( textBound.width() + 5, textBound.height()+2 ); //move( QPoint( parentWidget()->width() + 5, 5 ) ); update(); }