mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 22:26:32 +02:00
* Hardcoded a bunch of font-sizes. Should be properly fixed eventually.
This commit is contained in:
@@ -129,7 +129,8 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
|
|
||||||
QString text;
|
QString text;
|
||||||
QFont font = opt.font;
|
QFont font = opt.font;
|
||||||
QFont boldFont = opt.font;
|
font.setPixelSize( 11 );
|
||||||
|
QFont boldFont = font;
|
||||||
boldFont.setBold( true );
|
boldFont.setBold( true );
|
||||||
|
|
||||||
QRect textRect = option.rect.adjusted( 0, option.rect.height() - 32, 0, -2 );
|
QRect textRect = option.rect.adjusted( 0, option.rect.height() - 32, 0, -2 );
|
||||||
@@ -140,6 +141,7 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
else if ( !item->artist().isNull() )
|
else if ( !item->artist().isNull() )
|
||||||
name = item->artist()->name();
|
name = item->artist()->name();
|
||||||
|
|
||||||
|
painter->setFont( boldFont );
|
||||||
bool oneLiner = false;
|
bool oneLiner = false;
|
||||||
if ( item->album().isNull() || item->album()->artist().isNull() )
|
if ( item->album().isNull() || item->album()->artist().isNull() )
|
||||||
oneLiner = true;
|
oneLiner = true;
|
||||||
@@ -149,14 +151,12 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
|
|
||||||
if ( oneLiner )
|
if ( oneLiner )
|
||||||
{
|
{
|
||||||
painter->setFont( boldFont );
|
|
||||||
to.setAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
|
to.setAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
|
||||||
text = painter->fontMetrics().elidedText( name, Qt::ElideRight, textRect.width() - 3 );
|
text = painter->fontMetrics().elidedText( name, Qt::ElideRight, textRect.width() - 3 );
|
||||||
painter->drawText( textRect, text, to );
|
painter->drawText( textRect, text, to );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
painter->setFont( boldFont );
|
|
||||||
to.setAlignment( Qt::AlignHCenter | Qt::AlignTop );
|
to.setAlignment( Qt::AlignHCenter | Qt::AlignTop );
|
||||||
text = painter->fontMetrics().elidedText( item->album()->name(), Qt::ElideRight, textRect.width() - 3 );
|
text = painter->fontMetrics().elidedText( item->album()->name(), Qt::ElideRight, textRect.width() - 3 );
|
||||||
painter->drawText( textRect, text, to );
|
painter->drawText( textRect, text, to );
|
||||||
|
@@ -79,7 +79,10 @@ PlaylistItemDelegate::sizeHint( const QStyleOptionViewItem& option, const QModel
|
|||||||
{
|
{
|
||||||
int style = index.data( TrackModel::StyleRole ).toInt();
|
int style = index.data( TrackModel::StyleRole ).toInt();
|
||||||
if ( style == TrackModel::Short || style == TrackModel::ShortWithAvatars )
|
if ( style == TrackModel::Short || style == TrackModel::ShortWithAvatars )
|
||||||
size.setHeight( 44 );
|
{
|
||||||
|
int rowHeight = option.fontMetrics.height() + 8;
|
||||||
|
size.setHeight( rowHeight * 2 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
@@ -235,8 +238,7 @@ PlaylistItemDelegate::paintShort( QPainter* painter, const QStyleOptionViewItem&
|
|||||||
QString text = painter->fontMetrics().elidedText( upperText, Qt::ElideRight, r.width() );
|
QString text = painter->fontMetrics().elidedText( upperText, Qt::ElideRight, r.width() );
|
||||||
painter->drawText( r.adjusted( 0, 1, 0, 0 ), text, m_topOption );
|
painter->drawText( r.adjusted( 0, 1, 0, 0 ), text, m_topOption );
|
||||||
|
|
||||||
|
painter->setFont( opt.font );
|
||||||
painter->setFont( opt.font);
|
|
||||||
text = painter->fontMetrics().elidedText( lowerText, Qt::ElideRight, r.width() );
|
text = painter->fontMetrics().elidedText( lowerText, Qt::ElideRight, r.width() );
|
||||||
painter->drawText( r.adjusted( 0, 1, 0, 0 ), text, m_bottomOption );
|
painter->drawText( r.adjusted( 0, 1, 0, 0 ), text, m_bottomOption );
|
||||||
}
|
}
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
PlaylistInterface::PlaylistInterface ()
|
PlaylistInterface::PlaylistInterface ()
|
||||||
|
: QObject()
|
||||||
{
|
{
|
||||||
qRegisterMetaType<Tomahawk::PlaylistInterface::RepeatMode>( "Tomahawk::PlaylistInterface::RepeatMode" );
|
qRegisterMetaType<Tomahawk::PlaylistInterface::RepeatMode>( "Tomahawk::PlaylistInterface::RepeatMode" );
|
||||||
}
|
}
|
||||||
|
@@ -20,12 +20,14 @@
|
|||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
|
#include <QAbstractScrollArea>
|
||||||
|
#include <QScrollBar>
|
||||||
|
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
|
|
||||||
#define CORNER_ROUNDNESS 8.0
|
#define CORNER_ROUNDNESS 8.0
|
||||||
#define FADING_DURATION 500
|
#define FADING_DURATION 500
|
||||||
#define FONT_SIZE 16
|
#define FONT_SIZE 12
|
||||||
#define OPACITY 0.70
|
#define OPACITY 0.70
|
||||||
|
|
||||||
|
|
||||||
@@ -34,7 +36,7 @@ OverlayButton::OverlayButton( QWidget* parent )
|
|||||||
, m_opacity( 0.0 )
|
, m_opacity( 0.0 )
|
||||||
, m_parent( parent )
|
, m_parent( parent )
|
||||||
{
|
{
|
||||||
resize( 0, 26 );
|
resize( 0, 28 );
|
||||||
setAttribute( Qt::WA_TranslucentBackground, true );
|
setAttribute( Qt::WA_TranslucentBackground, true );
|
||||||
|
|
||||||
setOpacity( m_opacity );
|
setOpacity( m_opacity );
|
||||||
@@ -78,8 +80,12 @@ OverlayButton::setText( const QString& text )
|
|||||||
{
|
{
|
||||||
m_text = text;
|
m_text = text;
|
||||||
|
|
||||||
QFontMetrics fm( font() );
|
QFont f( font() );
|
||||||
resize( fm.width( text ) + 16, height() );
|
f.setPixelSize( FONT_SIZE );
|
||||||
|
f.setBold( true );
|
||||||
|
|
||||||
|
QFontMetrics fm( f );
|
||||||
|
resize( fm.width( text ) + 24, height() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -120,7 +126,13 @@ void
|
|||||||
OverlayButton::paintEvent( QPaintEvent* event )
|
OverlayButton::paintEvent( QPaintEvent* event )
|
||||||
{
|
{
|
||||||
Q_UNUSED( event );
|
Q_UNUSED( event );
|
||||||
QPoint corner( m_parent->contentsRect().width() - width() - 12, m_parent->height() - height() - 12 );
|
|
||||||
|
int scrollBarWidth = 0;
|
||||||
|
QAbstractScrollArea* scrollArea = qobject_cast<QAbstractScrollArea*>( m_parent );
|
||||||
|
if ( scrollArea && scrollArea->verticalScrollBar()->isVisible() )
|
||||||
|
scrollBarWidth = scrollArea->verticalScrollBar()->width();
|
||||||
|
|
||||||
|
QPoint corner( m_parent->contentsRect().width() - width() - scrollBarWidth - 12, m_parent->height() - height() - 12 );
|
||||||
move( corner );
|
move( corner );
|
||||||
|
|
||||||
QPainter p( this );
|
QPainter p( this );
|
||||||
@@ -141,25 +153,10 @@ OverlayButton::paintEvent( QPaintEvent* event )
|
|||||||
|
|
||||||
// shrink to fit if needed
|
// shrink to fit if needed
|
||||||
QFont f( font() );
|
QFont f( font() );
|
||||||
f.setPointSize( FONT_SIZE );
|
f.setPixelSize( FONT_SIZE );
|
||||||
f.setBold( true );
|
f.setBold( true );
|
||||||
|
|
||||||
QRectF textRect = r.adjusted( 8, 8, -8, -8 );
|
|
||||||
qreal availHeight = textRect.height();
|
|
||||||
|
|
||||||
QFontMetricsF fm( f );
|
|
||||||
qreal textHeight = fm.boundingRect( textRect, Qt::AlignCenter | Qt::TextWordWrap, text() ).height();
|
|
||||||
while ( textHeight > availHeight )
|
|
||||||
{
|
|
||||||
if ( f.pointSize() <= 4 ) // don't try harder
|
|
||||||
break;
|
|
||||||
|
|
||||||
f.setPointSize( f.pointSize() - 1 );
|
|
||||||
fm = QFontMetricsF( f );
|
|
||||||
textHeight = fm.boundingRect( textRect, Qt::AlignCenter | Qt::TextWordWrap, text() ).height();
|
|
||||||
}
|
|
||||||
|
|
||||||
p.setFont( f );
|
p.setFont( f );
|
||||||
p.setPen( Qt::white );
|
p.setPen( Qt::white );
|
||||||
p.drawText( r.adjusted( 8, 8, -8, -8 ), text(), to );
|
p.drawText( r, text(), to );
|
||||||
}
|
}
|
||||||
|
@@ -265,12 +265,11 @@ PlaylistDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
QTextOption to;
|
QTextOption to;
|
||||||
to.setAlignment( Qt::AlignCenter );
|
to.setAlignment( Qt::AlignCenter );
|
||||||
QFont font = opt.font;
|
QFont font = opt.font;
|
||||||
#ifdef Q_WS_MAC
|
font.setPixelSize( 10 );
|
||||||
font.setPointSize( font.pointSize() - 2 );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QFont boldFont = font;
|
QFont boldFont = font;
|
||||||
boldFont.setBold( true );
|
boldFont.setBold( true );
|
||||||
|
boldFont.setPixelSize( 11 );
|
||||||
|
|
||||||
QPixmap icon;
|
QPixmap icon;
|
||||||
RecentlyPlayedPlaylistsModel::PlaylistTypes type = (RecentlyPlayedPlaylistsModel::PlaylistTypes)index.data( RecentlyPlayedPlaylistsModel::PlaylistTypeRole ).toInt();
|
RecentlyPlayedPlaylistsModel::PlaylistTypes type = (RecentlyPlayedPlaylistsModel::PlaylistTypes)index.data( RecentlyPlayedPlaylistsModel::PlaylistTypeRole ).toInt();
|
||||||
@@ -314,9 +313,7 @@ PlaylistDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
QRect r( option.rect.width() - avatar.width() - 10, option.rect.top() + option.rect.height()/2 - avatar.height()/2, avatar.width(), avatar.height() );
|
QRect r( option.rect.width() - avatar.width() - 10, option.rect.top() + option.rect.height()/2 - avatar.height()/2, avatar.width(), avatar.height() );
|
||||||
painter->drawPixmap( r, avatar );
|
painter->drawPixmap( r, avatar );
|
||||||
|
|
||||||
QFont font2 = font;
|
painter->setFont( font );
|
||||||
font2.setPointSize( font2.pointSize() - 1 );
|
|
||||||
painter->setFont( font2 );
|
|
||||||
QString author = index.data( RecentlyPlayedPlaylistsModel::PlaylistRole ).value< Tomahawk::playlist_ptr >()->author()->friendlyName();
|
QString author = index.data( RecentlyPlayedPlaylistsModel::PlaylistRole ).value< Tomahawk::playlist_ptr >()->author()->friendlyName();
|
||||||
if ( author.contains( "@" ) )
|
if ( author.contains( "@" ) )
|
||||||
author = author.mid( 0, author.indexOf( '@' ) );
|
author = author.mid( 0, author.indexOf( '@' ) );
|
||||||
|
@@ -140,6 +140,8 @@ SourceDelegate::paintCollection( QPainter* painter, const QStyleOptionViewItem&
|
|||||||
QFont normal = painter->font();
|
QFont normal = painter->font();
|
||||||
QFont bold = painter->font();
|
QFont bold = painter->font();
|
||||||
bold.setBold( true );
|
bold.setBold( true );
|
||||||
|
QFont figFont = bold;
|
||||||
|
figFont.setPixelSize( 10 );
|
||||||
|
|
||||||
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 );
|
||||||
@@ -153,7 +155,7 @@ SourceDelegate::paintCollection( QPainter* painter, const QStyleOptionViewItem&
|
|||||||
if ( status && colItem && !colItem->source().isNull() )
|
if ( status && colItem && !colItem->source().isNull() )
|
||||||
{
|
{
|
||||||
tracks = QString::number( colItem->source()->trackCount() );
|
tracks = QString::number( colItem->source()->trackCount() );
|
||||||
figWidth = painter->fontMetrics().width( tracks );
|
figWidth = QFontMetrics( figFont ).width( tracks );
|
||||||
name = colItem->source()->friendlyName();
|
name = colItem->source()->friendlyName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,10 +233,8 @@ SourceDelegate::paintCollection( QPainter* painter, const QStyleOptionViewItem&
|
|||||||
QRect figRect = option.rect.adjusted( option.rect.width() - figWidth - 8, 0, -13, -option.rect.height() + 16 );
|
QRect figRect = option.rect.adjusted( option.rect.width() - figWidth - 8, 0, -13, -option.rect.height() + 16 );
|
||||||
int hd = ( option.rect.height() - figRect.height() ) / 2;
|
int hd = ( option.rect.height() - figRect.height() ) / 2;
|
||||||
figRect.adjust( 0, hd, 0, hd );
|
figRect.adjust( 0, hd, 0, hd );
|
||||||
#ifdef Q_WS_WIN
|
|
||||||
figRect.adjust( -3, 0, 3, 0 );
|
painter->setFont( figFont );
|
||||||
#endif
|
|
||||||
painter->setFont( bold );
|
|
||||||
|
|
||||||
QColor figColor( 167, 183, 211 );
|
QColor figColor( 167, 183, 211 );
|
||||||
painter->setPen( figColor );
|
painter->setPen( figColor );
|
||||||
|
Reference in New Issue
Block a user