Get rid of hardcoded pixel sizes in the plugin browser and side bar

The PluginDescWidget doesn't use calls to pointSize anymore. Also the
name of the plugin is only painted bold when hovered over with the
mouse. The animation speed was increased a bit as well. Hope it is not
too fast for displays with smaller resolutions. The problem with the
current implementation is that it increases the height by incremental
steps of 1 pixel (triggered by a QTimer) which gives a slower speed on
high DPI displays. In the future this implementation might be improved,
e.g. by using the animation classes provided by Qt.

The SideBarWidget also does not use calls to pointSize anymore. Instead
the standard font is increased by 2 (typographical) points and then
rendered at the right place using information from QFontMetrics. In the
long run the header of the SideBarWidget should be organized using a
layout, e.g. a layout with one QLabel to render the icon and one QLabel
to render the header text. This would ensure that the black background
would always be large enough and that the fonts do not protude into the
actual content.
This commit is contained in:
Michael Gregorius
2015-07-30 21:08:35 +02:00
parent cd0176b5af
commit 76e4859ef0
2 changed files with 14 additions and 10 deletions

View File

@@ -68,7 +68,6 @@ PluginBrowser::PluginBrowser( QWidget * _parent ) :
"Beat+Bassline Editor or into an "
"existing instrument track." ),
m_view );
hint->setFont( pointSize<8>( hint->font() ) );
hint->setWordWrap( true );
QScrollArea* scrollarea = new QScrollArea( m_view );
@@ -153,8 +152,12 @@ void PluginDescWidget::paintEvent( QPaintEvent * )
p.drawRect( 0, 0, rect().right(), rect().bottom() );
p.drawPixmap( 4, 4, logo );
QFont f = pointSize<8>( p.font() );
f.setBold( true );
QFont f = p.font();
if ( m_mouseOver )
{
f.setBold( true );
}
p.setFont( f );
p.drawText( 10 + logo_size.width(), 15,
m_pluginDescriptor.displayName );
@@ -162,7 +165,7 @@ void PluginDescWidget::paintEvent( QPaintEvent * )
if( height() > 24 || m_mouseOver )
{
f.setBold( false );
p.setFont( pointSize<8>( f ) );
p.setFont( f );
QRect br;
p.drawText( 10 + logo_size.width(), 20, width() - 58 - 5, 999,
Qt::TextWordWrap,
@@ -231,7 +234,7 @@ void PluginDescWidget::updateHeight()
if( !m_updateTimer.isActive() )
{
m_updateTimer.start( 15 );
m_updateTimer.start( 10 );
}
}

View File

@@ -55,21 +55,22 @@ SideBarWidget::~SideBarWidget()
void SideBarWidget::paintEvent( QPaintEvent * )
{
const int TITLE_FONT_HEIGHT = 13;
QPainter p( this );
p.fillRect( 0, 0, width(), 27, palette().highlight().color() );
QFont f = p.font();
f.setBold( true );
p.setFont( pointSize<TITLE_FONT_HEIGHT>( f ) );
f.setUnderline( true );
f.setPointSize( f.pointSize() + 2 );
p.setFont( f );
p.setPen( palette().highlightedText().color() );
const int tx = m_icon.width()+4;
const int ty = 2+TITLE_FONT_HEIGHT;
QFontMetrics metrics( f );
const int ty = metrics.ascent();
p.drawText( tx, ty, m_title );
p.drawLine( tx, ty+4, width()-4, ty+4 );
p.drawPixmap( 2, 2, m_icon.transformed( QTransform().rotate( -90 ) ) );
}