Permalink
Browse files

Merge branch 'master' into decltest

  • Loading branch information...
2 parents 467cb26 + c6101fb commit a4d01685cf4ee673c0cc0b0a26bfe4ae104accdb @mzanetti mzanetti committed Aug 3, 2012
@@ -38,11 +38,12 @@ ContextProxyPage::paint( QPainter* painter, const QStyleOptionGraphicsItem* opti
QFont f( font() );
f.setBold( true );
- f.setPixelSize( 14 );
+ f.setPointSize( 8 );
painter->setFont( f );
painter->setPen( Qt::white );
- QRect r( 1, 1, option->rect.width(), 19 );
+ QFontMetrics fm( f );
+ QRect r( 1, 1, option->rect.width(), fm.height() * 1.1 );
QTextOption to( Qt::AlignCenter );
painter->drawText( r, m_page->title(), to );
@@ -65,8 +66,12 @@ ContextProxyPage::setPage( Tomahawk::ContextPage* page )
}
#endif
+ QFont f( font() );
+ f.setBold( true );
+ f.setPointSize( 8 );
+ QFontMetrics fm( f );
QGraphicsLinearLayout* layout = new QGraphicsLinearLayout();
- layout->setContentsMargins( 4, 20, 4, 4 );
+ layout->setContentsMargins( 4, fm.height() * 1.1, 4, 4 );
layout->addItem( page->widget() );
setLayout( layout );
@@ -43,7 +43,6 @@ using namespace Tomahawk;
ContextWidget::ContextWidget( QWidget* parent )
: QWidget( parent )
, ui( new Ui::ContextWidget )
- , m_minHeight( 22 )
, m_currentView( 0 )
, m_visible( false )
{
@@ -87,9 +86,14 @@ ContextWidget::ContextWidget( QWidget* parent )
ui->toggleButton->setCursor( Qt::PointingHandCursor );
QFont boldFont = ui->toggleButton->font();
- boldFont.setPixelSize( 12 );
+ boldFont.setPointSize( 10 );
boldFont.setBold( true );
ui->toggleButton->setFont( boldFont );
+ QFontMetrics fm( boldFont );
+
+ m_minHeight = fm.height() * 1.2;
+
+ ui->toggleButton->setMinimumHeight( fm.height() * 1.2 );
setAutoFillBackground( true );
setFixedHeight( m_minHeight );
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>774</width>
- <height>72</height>
+ <height>173</height>
</rect>
</property>
<property name="sizePolicy">
@@ -44,22 +44,31 @@ InfoBar::InfoBar( QWidget* parent )
, ui( new Ui::InfoBar )
, m_queryLabel( 0 )
{
+ int requiredHeight = 0;
+
ui->setupUi( this );
TomahawkUtils::unmarginLayout( layout() );
layout()->setContentsMargins( 8, 4, 8, 4 );
+ requiredHeight += 8; // Top + bottom margins
QFont boldFont = ui->captionLabel->font();
- boldFont.setPixelSize( 18 );
+ boldFont.setPointSize( 16 );
boldFont.setBold( true );
ui->captionLabel->setFont( boldFont );
ui->captionLabel->setElideMode( Qt::ElideRight );
- boldFont.setPixelSize( 12 );
+ QFontMetrics boldFontMetrics( boldFont );
+ requiredHeight += boldFontMetrics.height();
+
+ boldFont.setPointSize( 10 );
boldFont.setBold( false );
ui->descriptionLabel->setFont( boldFont );
+ boldFontMetrics = QFontMetrics( boldFont );
+ requiredHeight += boldFontMetrics.height();
+
QFont regFont = ui->longDescriptionLabel->font();
- regFont.setPixelSize( 11 );
+ regFont.setPointSize( 9 );
ui->longDescriptionLabel->setFont( regFont );
m_whitePal = ui->captionLabel->palette();
@@ -70,7 +79,11 @@ InfoBar::InfoBar( QWidget* parent )
ui->longDescriptionLabel->setPalette( m_whitePal );
ui->captionLabel->setMargin( 6 );
+ requiredHeight += 2*6;
+
ui->descriptionLabel->setMargin( 6 );
+ requiredHeight += 2*6;
+
ui->longDescriptionLabel->setMargin( 4 );
ui->captionLabel->setText( QString() );
@@ -95,8 +108,8 @@ InfoBar::InfoBar( QWidget* parent )
setAutoFillBackground( true );
- setMinimumHeight( geometry().height() );
- setMaximumHeight( geometry().height() );
+ setMinimumHeight( requiredHeight );
+ setMaximumHeight( requiredHeight );
createTile();
@@ -7,11 +7,11 @@
<x>0</x>
<y>0</y>
<width>774</width>
- <height>80</height>
+ <height>72</height>
</rect>
</property>
<property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -28,9 +28,6 @@
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
- <property name="sizeConstraint">
- <enum>QLayout::SetDefaultConstraint</enum>
- </property>
<item>
<widget class="QLabel" name="imageLabel">
<property name="minimumSize">
@@ -59,16 +56,13 @@
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
- <property name="sizeConstraint">
- <enum>QLayout::SetDefaultConstraint</enum>
- </property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="ElidedLabel" name="captionLabel">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -81,7 +75,7 @@
<item>
<widget class="ElidedLabel" name="descriptionLabel">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -104,16 +98,13 @@
<property name="sizeHint" stdset="0">
<size>
<width>16</width>
- <height>20</height>
+ <height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
- <property name="sizeConstraint">
- <enum>QLayout::SetMaximumSize</enum>
- </property>
<item>
<widget class="ElidedLabel" name="longDescriptionLabel">
<property name="sizePolicy">
@@ -51,11 +51,11 @@ FlexibleHeader::FlexibleHeader( FlexibleView* parent )
ui->descLabel->setPalette( pal );
QFont font = ui->captionLabel->font();
- font.setPixelSize( 16 );
+ font.setPointSize( 13 );
font.setBold( true );
ui->captionLabel->setFont( font );
- font.setPixelSize( 11 );
+ font.setPointSize( 8 );
ui->descLabel->setFont( font );
ui->radioNormal->setFocusPolicy( Qt::NoFocus );
@@ -157,43 +157,44 @@ PlaylistChartItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
}
QFont figureFont = opt.font;
- figureFont.setPixelSize( 18 );
+ figureFont.setPointSize( 17 );
figureFont.setWeight( 99 );
QFont boldFont = opt.font;
- boldFont.setPixelSize( 15 );
+ boldFont.setPointSize( 12 );
boldFont.setWeight( 99 );
QFont smallBoldFont = opt.font;
- smallBoldFont.setPixelSize( 12 );
+ smallBoldFont.setPointSize( 9 );
smallBoldFont.setWeight( 60 );
QFont durationFont = opt.font;
- durationFont.setPixelSize( 12 );
+ durationFont.setPointSize( 9 );
durationFont.setWeight( 80 );
+ QFontMetrics durationFontMetrics( durationFont );
if ( index.row() == 0 )
{
- figureFont.setPixelSize( 36 );
- boldFont.setPixelSize( 26 );
- smallBoldFont.setPixelSize( 22 );
+ figureFont.setPointSize( 34 );
+ boldFont.setPointSize( 24 );
+ smallBoldFont.setPointSize( 20 );
}
else if ( index.row() == 1 )
{
- figureFont.setPixelSize( 30 );
- boldFont.setPixelSize( 22 );
- smallBoldFont.setPixelSize( 18 );
+ figureFont.setPointSize( 28 );
+ boldFont.setPointSize( 20 );
+ smallBoldFont.setPointSize( 15 );
}
else if ( index.row() == 2 )
{
- figureFont.setPixelSize( 24 );
- boldFont.setPixelSize( 18 );
- smallBoldFont.setPixelSize( 14 );
+ figureFont.setPointSize( 20 );
+ boldFont.setPointSize( 15 );
+ smallBoldFont.setPointSize( 11 );
}
else if ( index.row() >= 10 )
{
- boldFont.setPixelSize( 12 );
- smallBoldFont.setPixelSize( 11 );
+ boldFont.setPointSize( 9 );
+ smallBoldFont.setPointSize( 8 );
}
QRect figureRect = r.adjusted( 0, 0, -option.rect.width() + 60 - 6 + r.left(), 0 );
@@ -215,8 +216,7 @@ PlaylistChartItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
painter->drawPixmap( pixmapRect, pixmap );
r.adjust( pixmapRect.width() + figureRect.width() + 18, 1, -28, 0 );
- QRect leftRect = r.adjusted( 0, 0, -48, 0 );
- QRect rightRect = r.adjusted( r.width() - 40, 0, 0, 0 );
+ QRect leftRect = r.adjusted( 0, 0, -durationFontMetrics.width( TomahawkUtils::timeToString( duration ) ) - 8, 0 );
painter->setFont( boldFont );
QString text = painter->fontMetrics().elidedText( track, Qt::ElideRight, leftRect.width() );
@@ -229,6 +229,7 @@ PlaylistChartItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
if ( duration > 0 )
{
painter->setFont( durationFont );
+ QRect rightRect = r.adjusted( r.width() - durationFontMetrics.width( TomahawkUtils::timeToString( duration ) ), 0, 0, 0 );
text = painter->fontMetrics().elidedText( TomahawkUtils::timeToString( duration ), Qt::ElideRight, rightRect.width() );
painter->drawText( rightRect, text, m_centerRightOption );
}
@@ -72,6 +72,9 @@ PlaylistItemDelegate::sizeHint( const QStyleOptionViewItem& option, const QModel
{
int rowHeight = option.fontMetrics.height() + 8;
size.setHeight( rowHeight * 2 );
+ } else if ( style == PlayableProxyModel::Detailed ) {
+ int rowHeight = option.fontMetrics.height() * 1.4;
+ size.setHeight( rowHeight );
}
}
@@ -230,7 +233,7 @@ PlaylistItemDelegate::paintDetailed( QPainter* painter, const QStyleOptionViewIt
if ( m_view->hoveredIndex().row() == index.row() && m_view->hoveredIndex().column() == index.column() && !index.data().toString().isEmpty() &&
( index.column() == PlayableModel::Artist || index.column() == PlayableModel::Album || index.column() == PlayableModel::Track ) )
{
- opt.rect.setWidth( opt.rect.width() - 16 );
+ opt.rect.setWidth( opt.rect.width() - opt.rect.height() - 2 );
QRect arrowRect( opt.rect.x() + opt.rect.width(), opt.rect.y() + 1, opt.rect.height() - 2, opt.rect.height() - 2 );
QPixmap infoIcon = TomahawkUtils::defaultPixmap( TomahawkUtils::InfoIcon, TomahawkUtils::Original, arrowRect.size() );
@@ -205,28 +205,30 @@ PlaylistLargeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
painter->drawPixmap( avatarRect, avatar );
QFont boldFont = opt.font;
- boldFont.setPixelSize( 15 );
+ boldFont.setPointSize( 11 );
boldFont.setWeight( 99 );
+ QFontMetrics boldFontMetrics( boldFont );
QFont smallBoldFont = opt.font;
- smallBoldFont.setPixelSize( 12 );
+ smallBoldFont.setPointSize( 8 );
smallBoldFont.setBold( true );
smallBoldFont.setWeight( 60 );
+ QFontMetrics smallBoldFontMetrics( smallBoldFont );
QFont smallFont = opt.font;
- smallFont.setPixelSize( 10 );
+ smallFont.setPointSize( 7 );
r.adjust( pixmapRect.width() + 12, 1, -28 - avatar.width(), 0 );
QRect leftRect = r.adjusted( 0, 0, -48, 0 );
- QRect rightRect = r.adjusted( r.width() - 40, 0, 0, 0 );
+ QRect rightRect = r.adjusted( r.width() - smallBoldFontMetrics.width( TomahawkUtils::timeToString( duration ) ), 0, 0, 0 );
painter->setFont( boldFont );
QString text = painter->fontMetrics().elidedText( track, Qt::ElideRight, leftRect.width() );
painter->drawText( leftRect, text, m_topOption );
painter->setFont( smallBoldFont );
text = painter->fontMetrics().elidedText( artist, Qt::ElideRight, leftRect.width() );
- painter->drawText( leftRect.adjusted( 0, 19, 0, 0 ), text, m_topOption );
+ painter->drawText( leftRect.adjusted( 0, boldFontMetrics.height(), 0, 0 ), text, m_topOption );
painter->setFont( smallFont );
painter->setPen( Qt::gray );
@@ -41,7 +41,10 @@ QueueView::QueueView( AnimatedSplitter* parent )
TomahawkUtils::unmarginLayout( layout() );
setContentsMargins( 0, 0, 0, 0 );
- setHiddenSize( QSize( 0, 22 ) );
+ QFont f;
+ f.setPointSize( 10 );
+ QFontMetrics fm( f );
+ setHiddenSize( QSize( 0, fm.height() * 1.2 ) );
ui->queue->setProxyModel( new QueueProxyModel( ui->queue ) );
ui->queue->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Ignored );
@@ -26,7 +26,7 @@
#include "utils/StyleHelper.h"
#include "utils/TomahawkUtilsGui.h"
-static const int s_defaultFontSize = 12;
+static const int s_defaultFontSize = 9;
HeaderLabel::HeaderLabel( QWidget* parent )
@@ -37,10 +37,11 @@ HeaderLabel::HeaderLabel( QWidget* parent )
{
QFont f( font() );
f.setBold( true );
- f.setPixelSize( s_defaultFontSize );
+ f.setPointSize( s_defaultFontSize );
+ QFontMetrics fm( f );
setFont( f );
- setFixedHeight( TomahawkUtils::headerHeight() );
+ setFixedHeight( fm.height() * 1.4 );
setMouseTracking( true );
}
@@ -81,7 +81,7 @@ OverlayButton::setText( const QString& text )
m_text = text;
QFont f( font() );
- f.setPixelSize( FONT_SIZE );
+ f.setPointSize( FONT_SIZE );
f.setBold( true );
QFontMetrics fm( f );
Oops, something went wrong. Retry.

0 comments on commit a4d0168

Please sign in to comment.