diff --git a/resources.qrc b/resources.qrc
index 602774165..1bfbbf679 100644
--- a/resources.qrc
+++ b/resources.qrc
@@ -9,6 +9,8 @@
data/images/not-loved.png
data/images/no-album-art-placeholder.png
data/images/no-artist-image-placeholder.png
+ data/images/artist-placeholder-grid.png
+ data/images/album-placeholder-grid.png
data/images/track-placeholder.png
data/images/now-playing-panel.png
data/images/now-playing-speaker.png
diff --git a/src/libtomahawk/playlist/AlbumItemDelegate.cpp b/src/libtomahawk/playlist/AlbumItemDelegate.cpp
index 533ed8fb2..b8a3b2a78 100644
--- a/src/libtomahawk/playlist/AlbumItemDelegate.cpp
+++ b/src/libtomahawk/playlist/AlbumItemDelegate.cpp
@@ -71,7 +71,7 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
painter->save();
painter->setRenderHint( QPainter::Antialiasing );
- if ( !( option.state & QStyle::State_Selected ) )
+/* if ( !( option.state & QStyle::State_Selected ) )
{
QRect shadowRect = option.rect.adjusted( 5, 4, -5, -40 );
painter->setPen( QColor( 90, 90, 90 ) );
@@ -92,9 +92,10 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
painter->drawLine( shadowRect.topLeft() + QPoint( -2, 3 ), shadowRect.bottomLeft() + QPoint( -2, 1 ) );
painter->drawLine( shadowRect.topRight() + QPoint( 3, 3 ), shadowRect.bottomRight() + QPoint( 3, 1 ) );
painter->drawLine( shadowRect.bottomLeft() + QPoint( 0, 4 ), shadowRect.bottomRight() + QPoint( 0, 4 ) );
- }
+ }*/
- QRect r = option.rect.adjusted( 6, 5, -6, -41 );
+// QRect r = option.rect.adjusted( 6, 5, -6, -41 );
+ QRect r = option.rect;
QString top, bottom;
if ( !item->album().isNull() )
@@ -118,15 +119,15 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
{
if ( !item->album().isNull() )
{
- m_covers.insert( index, QSharedPointer< Tomahawk::PixmapDelegateFader >( new Tomahawk::PixmapDelegateFader( item->album(), r.size(), TomahawkUtils::CoverInCase ) ) );
+ m_covers.insert( index, QSharedPointer< Tomahawk::PixmapDelegateFader >( new Tomahawk::PixmapDelegateFader( item->album(), r.size(), TomahawkUtils::Grid ) ) );
}
else if ( !item->artist().isNull() )
{
- m_covers.insert( index, QSharedPointer< Tomahawk::PixmapDelegateFader >( new Tomahawk::PixmapDelegateFader( item->artist(), r.size(), TomahawkUtils::CoverInCase ) ) );
+ m_covers.insert( index, QSharedPointer< Tomahawk::PixmapDelegateFader >( new Tomahawk::PixmapDelegateFader( item->artist(), r.size(), TomahawkUtils::Grid ) ) );
}
else
{
- m_covers.insert( index, QSharedPointer< Tomahawk::PixmapDelegateFader >( new Tomahawk::PixmapDelegateFader( item->query(), r.size(), TomahawkUtils::CoverInCase ) ) );
+ m_covers.insert( index, QSharedPointer< Tomahawk::PixmapDelegateFader >( new Tomahawk::PixmapDelegateFader( item->query(), r.size(), TomahawkUtils::Grid ) ) );
}
_detail::Closure* closure = NewClosure( m_covers[ index ], SIGNAL( repaintRequest() ), const_cast(this), SLOT( doUpdateIndex( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );
@@ -135,11 +136,10 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
const QPixmap cover = m_covers[ index ]->currentPixmap();
- if ( option.state & QStyle::State_Selected )
+ if ( false && option.state & QStyle::State_Selected )
{
#if defined(Q_WS_MAC) || defined(Q_WS_WIN)
painter->save();
- painter->setRenderHint( QPainter::Antialiasing );
QPainterPath border;
border.addRoundedRect( r.adjusted( -2, -2, 2, 2 ), 3, 3 );
@@ -154,19 +154,41 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
#endif
}
- painter->drawPixmap( r, cover );
+ painter->drawPixmap( r, cover.scaled( r.size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) );
- painter->setPen( opt.palette.color( QPalette::Text ) );
+ if ( m_hoverIndex == index )
+ {
+ painter->save();
+
+ painter->setPen( QColor( 33, 33, 33 ) );
+ painter->setBrush( QColor( 33, 33, 33 ) );
+ painter->setOpacity( 0.5 );
+ painter->drawRect( r );
+
+ painter->restore();
+ }
+
+ painter->save();
+
+ painter->setPen( QColor( 33, 33, 33 ) );
+ painter->setBrush( QColor( 33, 33, 33 ) );
+ painter->setOpacity( 0.5 );
+ painter->drawRoundedRect( r.adjusted( 4, +r.height() - 36, -4, -4 ), 3, 3 );
+
+ painter->restore();
+
+ painter->setPen( opt.palette.color( QPalette::HighlightedText ) );
QTextOption to;
to.setWrapMode( QTextOption::NoWrap );
QString text;
QFont font = opt.font;
- font.setPixelSize( 11 );
+ font.setPixelSize( 10 );
QFont boldFont = font;
boldFont.setBold( true );
+ boldFont.setPixelSize( 14 );
- QRect textRect = option.rect.adjusted( 0, option.rect.height() - 32, 0, -2 );
+ QRect textRect = option.rect.adjusted( 6, option.rect.height() - 36, -4, -6 );
painter->setFont( boldFont );
bool oneLiner = false;
@@ -188,6 +210,7 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
text = painter->fontMetrics().elidedText( top, Qt::ElideRight, textRect.width() - 3 );
painter->drawText( textRect, text, to );
+ painter->setFont( font );
// If the user is hovering over an artist rect, draw a background so she knows it's clickable
QRect r = textRect;
r.setTop( r.bottom() - painter->fontMetrics().height() );
@@ -199,12 +222,12 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
}
else
{
- if ( !( option.state & QStyle::State_Selected ) )
+/* if ( !( option.state & QStyle::State_Selected ) )
#ifdef Q_WS_MAC
painter->setPen( opt.palette.color( QPalette::Dark ).darker( 200 ) );
#else
painter->setPen( opt.palette.color( QPalette::Dark ) );
-#endif
+#endif*/
}
to.setAlignment( Qt::AlignHCenter | Qt::AlignBottom );
@@ -231,6 +254,9 @@ AlbumItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const
event->type() != QEvent::Leave )
return false;
+ if ( event->type() == QEvent::MouseMove )
+ m_hoverIndex = index;
+
if ( m_artistNameRects.contains( index ) )
{
QMouseEvent* ev = static_cast< QMouseEvent* >( event );
diff --git a/src/libtomahawk/playlist/AlbumItemDelegate.h b/src/libtomahawk/playlist/AlbumItemDelegate.h
index cb25c7889..45b8853f3 100644
--- a/src/libtomahawk/playlist/AlbumItemDelegate.h
+++ b/src/libtomahawk/playlist/AlbumItemDelegate.h
@@ -61,6 +61,7 @@ private:
mutable QHash< QPersistentModelIndex, QSharedPointer< Tomahawk::PixmapDelegateFader > > m_covers;
QPersistentModelIndex m_hoveringOver;
+ QPersistentModelIndex m_hoverIndex;
QPixmap m_shadowPixmap;
};
diff --git a/src/libtomahawk/playlist/AlbumModel.cpp b/src/libtomahawk/playlist/AlbumModel.cpp
index b04a8e203..98ad354e0 100644
--- a/src/libtomahawk/playlist/AlbumModel.cpp
+++ b/src/libtomahawk/playlist/AlbumModel.cpp
@@ -110,7 +110,7 @@ AlbumModel::data( const QModelIndex& index, int role ) const
{
if ( role == Qt::SizeHintRole )
{
- return QSize( 116, 150 );
+ return m_itemSize;
}
AlbumItem* entry = itemFromIndex( index );
diff --git a/src/libtomahawk/playlist/AlbumModel.h b/src/libtomahawk/playlist/AlbumModel.h
index 71d7743d8..3a1d80437 100644
--- a/src/libtomahawk/playlist/AlbumModel.h
+++ b/src/libtomahawk/playlist/AlbumModel.h
@@ -72,6 +72,9 @@ public:
virtual void setTitle( const QString& title ) { m_title = title; }
virtual void setDescription( const QString& description ) { m_description = description; }
+ QSize itemSize() const { return m_itemSize; }
+ void setItemSize( const QSize& size ) { m_itemSize = size; }
+
AlbumItem* findItem( const Tomahawk::artist_ptr& artist ) const;
AlbumItem* findItem( const Tomahawk::album_ptr& album ) const;
@@ -116,6 +119,8 @@ private:
QString m_description;
bool m_overwriteOnAdd;
+ QSize m_itemSize;
+
Tomahawk::collection_ptr m_collection;
};
diff --git a/src/libtomahawk/playlist/AlbumView.cpp b/src/libtomahawk/playlist/AlbumView.cpp
index b9af8d5ff..8db466435 100644
--- a/src/libtomahawk/playlist/AlbumView.cpp
+++ b/src/libtomahawk/playlist/AlbumView.cpp
@@ -54,9 +54,10 @@ AlbumView::AlbumView( QWidget* parent )
setDropIndicatorShown( false );
setDragDropOverwriteMode( false );
setUniformItemSizes( true );
- setSpacing( 16 );
+ setSpacing( 0 );
setContentsMargins( 0, 0, 0, 0 );
setMouseTracking( true );
+ setStyleSheet( "QListView { background-color: #323435; }" );
setResizeMode( Adjust );
setViewMode( IconMode );
@@ -181,21 +182,22 @@ AlbumView::resizeEvent( QResizeEvent* event )
if ( autoFitItems() )
{
#ifdef Q_WS_X11
- int scrollbar = verticalScrollBar()->isVisible() ? verticalScrollBar()->width() : 0;
+ int scrollbar = verticalScrollBar()->isVisible() ? verticalScrollBar()->width() + 16 : 0;
#else
int scrollbar = verticalScrollBar()->rect().width();
#endif
- int rectWidth = contentsRect().width() - scrollbar - 16 - 3;
+ int rectWidth = contentsRect().width() - scrollbar - 3;
+ int itemWidth = 160;
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 ) );
+ int itemsPerRow = qFloor( rectWidth / itemWidth );
+// int rightSpacing = rectWidth - ( itemsPerRow * ( itemSize.width() + 16 ) );
+// int newSpacing = 16 + floor( rightSpacing / ( itemsPerRow + 1 ) );
- if ( itemsPerRow < 1 )
- setSpacing( 16 );
- else
- setSpacing( newSpacing );
+ int remSpace = rectWidth - ( itemsPerRow * itemWidth );
+ int extraSpace = remSpace / itemsPerRow;
+ int newItemWidth = itemWidth + extraSpace;
+ m_model->setItemSize( QSize( newItemWidth, newItemWidth ) );
if ( !m_inited )
{
diff --git a/src/libtomahawk/utils/PixmapDelegateFader.cpp b/src/libtomahawk/utils/PixmapDelegateFader.cpp
index 9148150b1..232e9e886 100644
--- a/src/libtomahawk/utils/PixmapDelegateFader.cpp
+++ b/src/libtomahawk/utils/PixmapDelegateFader.cpp
@@ -59,6 +59,7 @@ PixmapDelegateFader::PixmapDelegateFader( const artist_ptr& artist, const QSize&
init();
}
+
PixmapDelegateFader::PixmapDelegateFader( const album_ptr& album, const QSize& size, TomahawkUtils::ImageMode mode, bool forceLoad )
: m_album( album )
, m_size( size )
@@ -99,7 +100,6 @@ PixmapDelegateFader::PixmapDelegateFader( const query_ptr& track, const QSize& s
PixmapDelegateFader::~PixmapDelegateFader()
{
-
}
@@ -117,7 +117,7 @@ PixmapDelegateFader::init()
else if ( !m_artist.isNull() )
m_current = m_currentReference = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultArtistImage, m_mode, m_size );
else if ( !m_track.isNull() )
- m_current = m_currentReference = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultTrackImage, m_mode, m_size );
+ m_current = m_currentReference = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultArtistImage, m_mode, m_size );
return;
}
@@ -139,6 +139,7 @@ PixmapDelegateFader::albumChanged()
QMetaObject::invokeMethod( this, "setPixmap", Qt::QueuedConnection, Q_ARG( QPixmap, m_album->cover( m_size ) ) );
}
+
void
PixmapDelegateFader::artistChanged()
{
diff --git a/src/libtomahawk/utils/TomahawkUtils.h b/src/libtomahawk/utils/TomahawkUtils.h
index 8269d3134..b2211a488 100644
--- a/src/libtomahawk/utils/TomahawkUtils.h
+++ b/src/libtomahawk/utils/TomahawkUtils.h
@@ -53,12 +53,14 @@ namespace TomahawkUtils
NowPlayingSpeaker,
InfoIcon
};
+
enum ImageMode
{
Original,
CoverInCase,
AvatarInFrame,
- ScaledCover
+ ScaledCover,
+ Grid
};
diff --git a/src/libtomahawk/utils/TomahawkUtilsGui.cpp b/src/libtomahawk/utils/TomahawkUtilsGui.cpp
index 5e9f5478d..7bc83dc8f 100644
--- a/src/libtomahawk/utils/TomahawkUtilsGui.cpp
+++ b/src/libtomahawk/utils/TomahawkUtilsGui.cpp
@@ -338,11 +338,16 @@ defaultPixmap( ImageType type, ImageMode mode, const QSize& size )
case DefaultAlbumCover:
if ( mode == CoverInCase )
pixmap = QPixmap( RESPATH "images/no-album-art-placeholder.png" );
+ else if ( mode == Grid )
+ pixmap = QPixmap( RESPATH "images/album-placeholder-grid.png" );
else
pixmap = QPixmap( RESPATH "images/no-album-no-case.png" );
break;
case DefaultArtistImage:
+ if ( mode == Grid )
+ pixmap = QPixmap( RESPATH "images/artist-placeholder-grid.png" );
+ else
pixmap = QPixmap( RESPATH "images/no-artist-image-placeholder.png" );
break;