mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-12 09:04:33 +02:00
* Sidebar font progress?
This commit is contained in:
@@ -89,12 +89,10 @@ SourceDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex&
|
|||||||
|
|
||||||
if ( type == SourcesModel::Collection )
|
if ( type == SourcesModel::Collection )
|
||||||
{
|
{
|
||||||
// return QSize( option.rect.width(), 40 );
|
return QSize( option.rect.width(), option.fontMetrics.height() * 2.8 );
|
||||||
return QSize( option.rect.width(), option.fontMetrics.height() * 2.6 );
|
|
||||||
}
|
}
|
||||||
else if ( type == SourcesModel::Divider )
|
else if ( type == SourcesModel::Divider )
|
||||||
{
|
{
|
||||||
// TODO: what is the divider?
|
|
||||||
return QSize( option.rect.width(), 6 );
|
return QSize( option.rect.width(), 6 );
|
||||||
}
|
}
|
||||||
else if ( type == SourcesModel::Group )
|
else if ( type == SourcesModel::Group )
|
||||||
@@ -158,6 +156,8 @@ SourceDelegate::paintDecorations( QPainter* painter, const QStyleOptionViewItem&
|
|||||||
void
|
void
|
||||||
SourceDelegate::paintCollection( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
SourceDelegate::paintCollection( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||||
{
|
{
|
||||||
|
painter->save();
|
||||||
|
|
||||||
QFont normal = option.font;
|
QFont normal = option.font;
|
||||||
QFont bold = option.font;
|
QFont bold = option.font;
|
||||||
bold.setBold( true );
|
bold.setBold( true );
|
||||||
@@ -165,7 +165,7 @@ SourceDelegate::paintCollection( QPainter* painter, const QStyleOptionViewItem&
|
|||||||
QFont figFont = bold;
|
QFont figFont = bold;
|
||||||
figFont.setFamily( "Arial Bold" );
|
figFont.setFamily( "Arial Bold" );
|
||||||
figFont.setWeight( QFont::Black );
|
figFont.setWeight( QFont::Black );
|
||||||
figFont.setPointSize( 10 );
|
figFont.setPointSize( normal.pointSize() - 1 );
|
||||||
|
|
||||||
SourceTreeItem* item = index.data( SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >();
|
SourceTreeItem* item = index.data( SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >();
|
||||||
SourceItem* colItem = qobject_cast< SourceItem* >( item );
|
SourceItem* colItem = qobject_cast< SourceItem* >( item );
|
||||||
@@ -275,6 +275,8 @@ SourceDelegate::paintCollection( QPainter* painter, const QStyleOptionViewItem&
|
|||||||
|
|
||||||
TomahawkUtils::drawBackgroundAndNumbers( painter, tracks, figRect );
|
TomahawkUtils::drawBackgroundAndNumbers( painter, tracks, figRect );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -283,10 +285,6 @@ SourceDelegate::paintCategory( QPainter* painter, const QStyleOptionViewItem& op
|
|||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
QFont font = painter->font();
|
|
||||||
font.setPointSize( 9 );
|
|
||||||
painter->setFont( font );
|
|
||||||
|
|
||||||
QTextOption to( Qt::AlignVCenter );
|
QTextOption to( Qt::AlignVCenter );
|
||||||
|
|
||||||
painter->setPen( option.palette.color( QPalette::Base ) );
|
painter->setPen( option.palette.color( QPalette::Base ) );
|
||||||
@@ -305,6 +303,7 @@ SourceDelegate::paintCategory( QPainter* painter, const QStyleOptionViewItem& op
|
|||||||
if ( option.state & QStyle::State_Open )
|
if ( option.state & QStyle::State_Open )
|
||||||
text = tr( "Hide" );
|
text = tr( "Hide" );
|
||||||
|
|
||||||
|
QFont font = option.font;
|
||||||
font.setBold( true );
|
font.setBold( true );
|
||||||
painter->setFont( font );
|
painter->setFont( font );
|
||||||
QTextOption to( Qt::AlignVCenter | Qt::AlignRight );
|
QTextOption to( Qt::AlignVCenter | Qt::AlignRight );
|
||||||
@@ -323,8 +322,10 @@ SourceDelegate::paintCategory( QPainter* painter, const QStyleOptionViewItem& op
|
|||||||
void
|
void
|
||||||
SourceDelegate::paintGroup( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
SourceDelegate::paintGroup( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||||
{
|
{
|
||||||
|
painter->save();
|
||||||
|
|
||||||
QFont font = painter->font();
|
QFont font = painter->font();
|
||||||
font.setPointSize( 10 );
|
font.setPointSize( option.font.pointSize() + 1 );
|
||||||
font.setBold( true );
|
font.setBold( true );
|
||||||
painter->setFont( font );
|
painter->setFont( font );
|
||||||
|
|
||||||
@@ -346,9 +347,7 @@ SourceDelegate::paintGroup( QPainter* painter, const QStyleOptionViewItem& optio
|
|||||||
if ( option.state & QStyle::State_Open )
|
if ( option.state & QStyle::State_Open )
|
||||||
text = tr( "Hide" );
|
text = tr( "Hide" );
|
||||||
|
|
||||||
QFont tmpFont = font;
|
painter->setFont( option.font );
|
||||||
font.setPointSize( font.pointSize() - 1 );
|
|
||||||
painter->setFont( font );
|
|
||||||
QTextOption to( Qt::AlignBottom | Qt::AlignRight );
|
QTextOption to( Qt::AlignBottom | Qt::AlignRight );
|
||||||
|
|
||||||
// draw close icon
|
// draw close icon
|
||||||
@@ -356,8 +355,9 @@ SourceDelegate::paintGroup( QPainter* painter, const QStyleOptionViewItem& optio
|
|||||||
painter->drawText( option.rect.translated( -4, 1 ), text, to );
|
painter->drawText( option.rect.translated( -4, 1 ), text, to );
|
||||||
painter->setPen( QColor( 99, 113, 128 ) );
|
painter->setPen( QColor( 99, 113, 128 ) );
|
||||||
painter->drawText( option.rect.translated( -4, 0 ), text, to );
|
painter->drawText( option.rect.translated( -4, 0 ), text, to );
|
||||||
painter->setFont( tmpFont );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -369,12 +369,6 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
|||||||
|
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
QFont font = painter->font();
|
|
||||||
font.setPointSize( 10 );
|
|
||||||
painter->setFont( font );
|
|
||||||
o.font = font;
|
|
||||||
o3.font = font;
|
|
||||||
|
|
||||||
SourcesModel::RowType type = static_cast< SourcesModel::RowType >( index.data( SourcesModel::SourceTreeItemTypeRole ).toInt() );
|
SourcesModel::RowType type = static_cast< SourcesModel::RowType >( index.data( SourcesModel::SourceTreeItemTypeRole ).toInt() );
|
||||||
SourceTreeItem* item = index.data( SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >();
|
SourceTreeItem* item = index.data( SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >();
|
||||||
Q_ASSERT( item );
|
Q_ASSERT( item );
|
||||||
@@ -469,8 +463,7 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
|||||||
painter->setPen( pen );
|
painter->setPen( pen );
|
||||||
|
|
||||||
QFont font = painter->font();
|
QFont font = painter->font();
|
||||||
|
font.setPointSize( option.font.pointSize() - 1 );
|
||||||
font.setPointSize( 8 );
|
|
||||||
painter->setFont( font );
|
painter->setFont( font );
|
||||||
QFont fontBold = painter->font();
|
QFont fontBold = painter->font();
|
||||||
fontBold.setBold( true );
|
fontBold.setBold( true );
|
||||||
|
@@ -68,12 +68,13 @@ SourceTreeView::SourceTreeView( QWidget* parent )
|
|||||||
setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
||||||
setContentsMargins( 0, 0, 0, 0 );
|
setContentsMargins( 0, 0, 0, 0 );
|
||||||
|
|
||||||
QFont dummyFont;
|
QFont font;
|
||||||
dummyFont.setPointSize( 9 );
|
font.setPointSize( 9 );
|
||||||
QFontMetrics fm( dummyFont );
|
QFontMetrics fm( font );
|
||||||
// This is sort of the longest string in there. With translations
|
// This is sort of the longest string in there. With translations
|
||||||
// we will never get it right so setting it to something reasonable for the average case
|
// we will never get it right so setting it to something reasonable for the average case
|
||||||
setMinimumWidth( fm.width( "Track Album Artist Local Top10") );
|
setMinimumWidth( fm.width( "Track Album Artist Local Top10") );
|
||||||
|
setFont( font );
|
||||||
|
|
||||||
setHeaderHidden( true );
|
setHeaderHidden( true );
|
||||||
setRootIsDecorated( true );
|
setRootIsDecorated( true );
|
||||||
|
Reference in New Issue
Block a user