mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 07:49:42 +01:00
* Properly center album icons.
This commit is contained in:
parent
b040870cf1
commit
e2bb4d7340
@ -117,7 +117,7 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
||||
oneLiner = true;
|
||||
else
|
||||
oneLiner = ( textRect.height() / 2 < painter->fontMetrics().boundingRect( item->album()->name() ).height() ||
|
||||
textRect.height() / 2 < painter->fontMetrics().boundingRect( item->album()->artist()->name() ).height() );
|
||||
textRect.height() / 2 < painter->fontMetrics().boundingRect( item->album()->artist()->name() ).height() );
|
||||
|
||||
if ( oneLiner )
|
||||
{
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <QKeyEvent>
|
||||
#include <QPainter>
|
||||
#include <QScrollBar>
|
||||
#include <qmath.h>
|
||||
|
||||
#include "audio/audioengine.h"
|
||||
#include "tomahawksettings.h"
|
||||
@ -47,7 +48,8 @@ AlbumView::AlbumView( QWidget* parent )
|
||||
setDropIndicatorShown( false );
|
||||
setDragDropOverwriteMode( false );
|
||||
setUniformItemSizes( true );
|
||||
setSpacing( 20 );
|
||||
setSpacing( 16 );
|
||||
setContentsMargins( 0, 0, 0, 0 );
|
||||
|
||||
setResizeMode( Adjust );
|
||||
setViewMode( IconMode );
|
||||
@ -179,6 +181,26 @@ AlbumView::paintEvent( QPaintEvent* event )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AlbumView::resizeEvent( QResizeEvent* event )
|
||||
{
|
||||
QListView::resizeEvent( event );
|
||||
|
||||
int scrollbar = !verticalScrollBar()->isVisible() ? verticalScrollBar()->rect().width() : 0;
|
||||
int rectWidth = contentsRect().width() - scrollbar - 16 - 3;
|
||||
QSize itemSize = m_proxyModel->data( QModelIndex(), Qt::SizeHintRole ).toSize();
|
||||
|
||||
int itemsPerRow = qFloor( rectWidth / ( itemSize.width() + 16 ) );
|
||||
int rightSpacing = rectWidth - ( itemsPerRow * ( itemSize.width() + 16 ) );
|
||||
int newSpacing = 16 + floor( rightSpacing / ( itemsPerRow + 1 ) );
|
||||
|
||||
if ( itemsPerRow < 1 )
|
||||
setSpacing( 16 );
|
||||
else
|
||||
setSpacing( newSpacing );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AlbumView::onFilterChanged( const QString& )
|
||||
{
|
||||
|
@ -63,6 +63,7 @@ protected:
|
||||
virtual void startDrag( Qt::DropActions supportedActions );
|
||||
|
||||
void paintEvent( QPaintEvent* event );
|
||||
void resizeEvent( QResizeEvent* event );
|
||||
|
||||
private slots:
|
||||
void onFilterChanged( const QString& filter );
|
||||
|
Loading…
x
Reference in New Issue
Block a user