Permalink
Browse files

* Updated Album page to look similar to the Artist & Track page.

  • Loading branch information...
1 parent 732604f commit 732c1d6848c5d4b2e3d4592cf5e55b683367d31b @muesli muesli committed Nov 14, 2012
@@ -22,11 +22,15 @@
#include "ui_AlbumInfoWidget.h"
#include "AlbumInfoWidget_p.h"
+#include <QScrollArea>
+#include <QScrollBar>
+
#include "audio/AudioEngine.h"
#include "ViewManager.h"
#include "database/Database.h"
#include "playlist/TreeModel.h"
#include "playlist/PlayableModel.h"
+#include "playlist/GridItemDelegate.h"
#include "Source.h"
#include "database/DatabaseCommand_AllTracks.h"
@@ -42,28 +46,98 @@ AlbumInfoWidget::AlbumInfoWidget( const Tomahawk::album_ptr& album, QWidget* par
: QWidget( parent )
, ui( new Ui::AlbumInfoWidget )
{
- ui->setupUi( this );
+ QWidget* widget = new QWidget;
+ ui->setupUi( widget );
- TomahawkUtils::unmarginLayout( layout() );
- TomahawkUtils::unmarginLayout( ui->verticalLayout );
- TomahawkUtils::unmarginLayout( ui->verticalLayout_2 );
+ QPalette pal = palette();
+ pal.setColor( QPalette::Window, QColor( "#454e59" ) );
- m_albumsModel = new PlayableModel( ui->albumsView );
- ui->albumsView->setPlayableModel( m_albumsModel );
- ui->albumsView->setEmptyTip( tr( "Sorry, we could not find any other albums for this artist!" ) );
- ui->albumsView->proxyModel()->setHideDupeItems( true );
+ widget->setPalette( pal );
+ widget->setAutoFillBackground( true );
- m_tracksModel = new TreeModel( ui->tracksView );
- m_tracksModel->setMode( Mixed );
- ui->tracksView->setTreeModel( m_tracksModel );
- ui->tracksView->setRootIsDecorated( false );
- ui->tracksView->setEmptyTip( tr( "Sorry, we could not find any tracks for this album!" ) );
- ui->tracksView->proxyModel()->setStyle( PlayableProxyModel::Collection );
+ m_albumsModel = new PlayableModel( ui->albums );
+ ui->albums->setPlayableModel( m_albumsModel );
+ ui->albums->setEmptyTip( tr( "Sorry, we could not find any other albums for this artist!" ) );
- m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultAlbumCover, TomahawkUtils::ScaledCover, QSize( 48, 48 ) );
+ m_tracksModel = new TreeModel( ui->tracks );
+ m_tracksModel->setMode( Mixed );
+ ui->tracks->setTreeModel( m_tracksModel );
+ ui->tracks->setRootIsDecorated( false );
+ ui->tracks->setEmptyTip( tr( "Sorry, we could not find any tracks for this album!" ) );
+ ui->tracks->proxyModel()->setStyle( PlayableProxyModel::Collection );
+
+ ui->albums->setAutoFitItems( false );
+ ui->albums->setWrapping( false );
+ ui->albums->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
+ ui->albums->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded );
+ ui->albums->delegate()->setItemSize( QSize( 170, 170 ) );
+ ui->albums->proxyModel()->setHideDupeItems( true );
+
+ ui->tracks->setFrameShape( QFrame::StyledPanel );
+ ui->tracks->setAttribute( Qt::WA_MacShowFocusRect, 0 );
+
+ m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultArtistImage, TomahawkUtils::ScaledCover, QSize( 48, 48 ) );
+ ui->cover->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultAlbumCover, TomahawkUtils::ScaledCover, QSize( ui->cover->sizeHint() ) ) );
+
+ ui->biography->setFrameShape( QFrame::NoFrame );
+ ui->biography->setAttribute( Qt::WA_MacShowFocusRect, 0 );
+ TomahawkUtils::styleScrollBar( ui->biography->verticalScrollBar() );
+
+ QFont f = font();
+ f.setBold( true );
+ f.setPointSize( TomahawkUtils::defaultFontSize() + 7 );
+ ui->albumLabel->setFont( f );
+// ui->similarTracksLabel->setFont( f );
+
+ f.setPointSize( TomahawkUtils::defaultFontSize() + 4 );
+ ui->artistLabel->setFont( f );
+
+ QPalette p = ui->biography->palette();
+ p.setColor( QPalette::Foreground, Qt::white );
+ p.setColor( QPalette::Text, Qt::white );
+
+ ui->albumLabel->setPalette( p );
+ ui->artistLabel->setPalette( p );
+ ui->biography->setPalette( p );
+ ui->label->setPalette( p );
+ ui->label_2->setPalette( p );
+
+ ui->artistLabel->setType( QueryLabel::Artist );
+
+ QScrollArea* area = new QScrollArea();
+ area->setWidgetResizable( true );
+ area->setWidget( widget );
+
+ area->setStyleSheet( "QScrollArea { background-color: #454e59; }" );
+ area->setFrameShape( QFrame::NoFrame );
+ area->setAttribute( Qt::WA_MacShowFocusRect, 0 );
+
+ QVBoxLayout* layout = new QVBoxLayout();
+ layout->addWidget( area );
+ setLayout( layout );
+ TomahawkUtils::unmarginLayout( layout );
+
+ TomahawkUtils::styleScrollBar( ui->tracks->horizontalScrollBar() );
+ TomahawkUtils::styleScrollBar( ui->albums->horizontalScrollBar() );
+
+ ui->biography->setStyleSheet( "QTextBrowser#biography { background-color: transparent; }" );
+
+ ui->albums->setStyleSheet( "QListView { background-color: transparent; }" );
+ ui->albumFrame->setStyleSheet( "QFrame#albumFrame { background-color: transparent; }"
+ "QFrame#albumFrame { "
+ "border-image: url(" RESPATH "images/scrollbar-vertical-handle.png) 3 3 3 3 stretch stretch;"
+ "border-top: 3px transparent; border-bottom: 3px transparent; border-right: 3px transparent; border-left: 3px transparent; }" );
+
+// ui->topHits->setStyleSheet( "QTreeView#topHits { background-color: transparent; }" );
+ ui->trackFrame->setStyleSheet( "QFrame#trackFrame { background-color: transparent; }"
+ "QFrame#trackFrame { "
+ "border-image: url(" RESPATH "images/scrollbar-vertical-handle.png) 3 3 3 3 stretch stretch;"
+ "border-top: 3px transparent; border-bottom: 3px transparent; border-right: 3px transparent; border-left: 3px transparent; }" );
m_playlistInterface = playlistinterface_ptr( new MetaAlbumInfoInterface( this ) );
load( album );
+
+ connect( ui->artistLabel, SIGNAL( clickedArtist() ), SLOT( onArtistClicked() ) );
}
@@ -87,13 +161,13 @@ AlbumInfoWidget::isBeingPlayed() const
//tDebug() << Q_FUNC_INFO << "albumsView playlistInterface = " << ui->albumsView->playlistInterface()->id();
//tDebug() << Q_FUNC_INFO << "tracksView playlistInterface = " << ui->tracksView->playlistInterface()->id();
- if ( ui->albumsView && ui->albumsView->isBeingPlayed() )
+ if ( ui->albums && ui->albums->isBeingPlayed() )
return true;
- if ( ui->albumsView && ui->albumsView->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() )
+ if ( ui->albums && ui->albums->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() )
return true;
- if ( ui->tracksView && ui->tracksView->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() )
+ if ( ui->tracks && ui->tracks->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() )
return true;
return false;
@@ -103,46 +177,32 @@ AlbumInfoWidget::isBeingPlayed() const
bool
AlbumInfoWidget::jumpToCurrentTrack()
{
- return ui->albumsView && ui->albumsView->jumpToCurrentTrack();
-}
-
-
-artist_ptr AlbumInfoWidget::descriptionArtist() const
-{
- if ( !m_album.isNull() && !m_album->artist().isNull() )
- return m_album->artist();
-
- return artist_ptr();
-}
-
-
-ViewPage::DescriptionType
-AlbumInfoWidget::descriptionType()
-{
- if ( !m_album.isNull() && !m_album->artist().isNull() )
- return ViewPage::ArtistType;
-
- return ViewPage::TextType;
+ return ui->albums && ui->albums->jumpToCurrentTrack();
}
void
AlbumInfoWidget::load( const album_ptr& album )
{
if ( !m_album.isNull() )
- disconnect( m_album.data(), SIGNAL( updated() ), this, SLOT( onAlbumCoverUpdated() ) );
+ {
+ disconnect( m_album.data(), SIGNAL( updated() ), this, SLOT( onAlbumImageUpdated() ) );
+ }
m_album = album;
m_title = album->name();
- m_description = album->artist()->name();
- ui->albumsLabel->setText( tr( "Other Albums by %1" ).arg( album->artist()->name() ) );
+ connect( m_album.data(), SIGNAL( updated() ), SLOT( onArtistImageUpdated() ) );
+
+ ui->artistLabel->setArtist( album->artist() );
+ ui->albumLabel->setText( album->name() );
+ ui->label_2->setText( tr( "Other Albums by %1" ).arg( album->artist()->name() ) );
+ m_tracksModel->startLoading();
m_tracksModel->addTracks( album, QModelIndex(), true );
loadAlbums( true );
- connect( m_album.data(), SIGNAL( updated() ), SLOT( onAlbumCoverUpdated() ) );
- onAlbumCoverUpdated();
+ onAlbumImageUpdated();
}
@@ -158,21 +218,19 @@ AlbumInfoWidget::loadAlbums( bool autoRefetch )
if ( !m_album->artist()->albums( Mixed ).isEmpty() )
gotAlbums( m_album->artist()->albums( Mixed ) );
-
-/* tDebug() << "Auto refetching";
- m_buttonAlbums->setChecked( false );
- onAlbumsModeToggle();*/
}
void
-AlbumInfoWidget::onAlbumCoverUpdated()
+AlbumInfoWidget::onAlbumImageUpdated()
{
if ( m_album->cover( QSize( 0, 0 ) ).isNull() )
return;
m_pixmap = m_album->cover( QSize( 0, 0 ) );
emit pixmapChanged( m_pixmap );
+
+ ui->cover->setPixmap( m_album->cover( ui->cover->sizeHint() ) );
}
@@ -188,6 +246,13 @@ AlbumInfoWidget::gotAlbums( const QList<Tomahawk::album_ptr>& albums )
void
+AlbumInfoWidget::onArtistClicked()
+{
+ ViewManager::instance()->show( m_album->artist() );
+}
+
+
+void
AlbumInfoWidget::changeEvent( QEvent* e )
{
QWidget::changeEvent( e );
@@ -62,15 +62,14 @@ Q_OBJECT
virtual Tomahawk::playlistinterface_ptr playlistInterface() const;
virtual QString title() const { return m_title; }
- virtual DescriptionType descriptionType();
virtual QString description() const { return m_description; }
- virtual Tomahawk::artist_ptr descriptionArtist() const;
virtual QString longDescription() const { return m_longDescription; }
virtual QPixmap pixmap() const { if ( m_pixmap.isNull() ) return Tomahawk::ViewPage::pixmap(); else return m_pixmap; }
virtual bool isTemporaryPage() const { return true; }
- virtual bool isBeingPlayed() const;
+ virtual bool showInfoBar() const { return false; }
+ virtual bool isBeingPlayed() const;
virtual bool jumpToCurrentTrack();
public slots:
@@ -95,7 +94,9 @@ public slots:
private slots:
void loadAlbums( bool autoRefetch = false );
void gotAlbums( const QList<Tomahawk::album_ptr>& albums );
- void onAlbumCoverUpdated();
+
+ void onArtistClicked();
+ void onAlbumImageUpdated();
private:
Ui::AlbumInfoWidget* ui;
Oops, something went wrong. Retry.

0 comments on commit 732c1d6

Please sign in to comment.