1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-28 19:52:28 +01:00

* Properly center album icons.

This commit is contained in:
Christian Muehlhaeuser 2011-10-28 11:23:00 +02:00
parent b040870cf1
commit e2bb4d7340
3 changed files with 25 additions and 2 deletions
src/libtomahawk/playlist

@ -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 );