mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 13:47:26 +02:00
* Properly center album icons.
This commit is contained in:
@@ -117,7 +117,7 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
oneLiner = true;
|
oneLiner = true;
|
||||||
else
|
else
|
||||||
oneLiner = ( textRect.height() / 2 < painter->fontMetrics().boundingRect( item->album()->name() ).height() ||
|
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 )
|
if ( oneLiner )
|
||||||
{
|
{
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
#include <qmath.h>
|
||||||
|
|
||||||
#include "audio/audioengine.h"
|
#include "audio/audioengine.h"
|
||||||
#include "tomahawksettings.h"
|
#include "tomahawksettings.h"
|
||||||
@@ -47,7 +48,8 @@ AlbumView::AlbumView( QWidget* parent )
|
|||||||
setDropIndicatorShown( false );
|
setDropIndicatorShown( false );
|
||||||
setDragDropOverwriteMode( false );
|
setDragDropOverwriteMode( false );
|
||||||
setUniformItemSizes( true );
|
setUniformItemSizes( true );
|
||||||
setSpacing( 20 );
|
setSpacing( 16 );
|
||||||
|
setContentsMargins( 0, 0, 0, 0 );
|
||||||
|
|
||||||
setResizeMode( Adjust );
|
setResizeMode( Adjust );
|
||||||
setViewMode( IconMode );
|
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
|
void
|
||||||
AlbumView::onFilterChanged( const QString& )
|
AlbumView::onFilterChanged( const QString& )
|
||||||
{
|
{
|
||||||
|
@@ -63,6 +63,7 @@ protected:
|
|||||||
virtual void startDrag( Qt::DropActions supportedActions );
|
virtual void startDrag( Qt::DropActions supportedActions );
|
||||||
|
|
||||||
void paintEvent( QPaintEvent* event );
|
void paintEvent( QPaintEvent* event );
|
||||||
|
void resizeEvent( QResizeEvent* event );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onFilterChanged( const QString& filter );
|
void onFilterChanged( const QString& filter );
|
||||||
|
Reference in New Issue
Block a user