diff --git a/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.cpp b/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.cpp index e5a61c1c8..79c17ab37 100644 --- a/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.cpp +++ b/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.cpp @@ -22,11 +22,15 @@ #include "ui_AlbumInfoWidget.h" #include "AlbumInfoWidget_p.h" +#include +#include + #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_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_tracksModel = new TreeModel( ui->tracks ); 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 ); + 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 ); - m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultAlbumCover, TomahawkUtils::ScaledCover, QSize( 48, 48 ) ); + 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,26 +177,7 @@ 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(); } @@ -130,19 +185,24 @@ 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() ) ); } @@ -187,6 +245,13 @@ AlbumInfoWidget::gotAlbums( const QList& albums ) } +void +AlbumInfoWidget::onArtistClicked() +{ + ViewManager::instance()->show( m_album->artist() ); +} + + void AlbumInfoWidget::changeEvent( QEvent* e ) { diff --git a/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.h b/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.h index c4f756e51..ac96ed578 100644 --- a/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.h +++ b/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.h @@ -62,15 +62,14 @@ public: 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 @@ protected: private slots: void loadAlbums( bool autoRefetch = false ); void gotAlbums( const QList& albums ); - void onAlbumCoverUpdated(); + + void onArtistClicked(); + void onAlbumImageUpdated(); private: Ui::AlbumInfoWidget* ui; diff --git a/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.ui b/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.ui index ec146f484..7f66f9714 100644 --- a/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.ui +++ b/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.ui @@ -6,56 +6,342 @@ 0 0 - 902 - 696 + 965 + 912 Form - + - - - Qt::Vertical + + + 12 - - 1 + + 12 - - + + 16 + + + 12 + + + + 0 + - + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 4 + + + 8 + + + 4 + + + 8 + + + 8 + + + + + + 18 + 75 + true + + + + Tracklist + + + 0 + + + + + + + + 0 + 300 + + + + true + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 16 + + + + + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 4 + + + 8 + + + 4 + + + 8 + + + 4 + + + + + + Arial + 18 + 75 + true + + + + Other Albums + + + 0 + + + + + + + + 0 + 0 + + + + + 0 + 190 + + + + + + + + + + + + + -1 + + + 16 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 220 + 220 + + - Other Albums by Artist + Cover + + + Qt::AlignCenter - + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 13 + + + + + + + + 4 + + + 0 + + + + + 4 + + + 0 + + + + + Album + + + Qt::AlignCenter + + + + + + + + + 4 + + + 0 + + + + + Artist + + + Qt::AlignCenter + + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 13 + + + + + + + + + 0 + 0 + + + + + 0 + 240 + + + + Qt::ScrollBarAlwaysOff + + - - + + - HeaderLabel - QLabel -
widgets/HeaderLabel.h
+ GridView + QListView +
GridView.h
TreeView QTreeView -
TreeView.h
+
playlist/TreeView.h
- GridView - QListView -
playlist/GridView.h
+ QueryLabel + QLabel +
widgets/QueryLabel.h
diff --git a/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget_p.h b/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget_p.h index b39fe65eb..f8bac3ea5 100644 --- a/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget_p.h +++ b/src/libtomahawk/widgets/infowidgets/AlbumInfoWidget_p.h @@ -36,38 +36,38 @@ public: : PlaylistInterface() , m_w( w ) { - connect( m_w->ui->tracksView->proxyModel()->playlistInterface().data(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistModes::RepeatMode ) ), + connect( m_w->ui->tracks->proxyModel()->playlistInterface().data(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistModes::RepeatMode ) ), SIGNAL( repeatModeChanged( Tomahawk::PlaylistModes::RepeatMode ) ) ); - connect( m_w->ui->tracksView->proxyModel()->playlistInterface().data(), SIGNAL( shuffleModeChanged( bool ) ), + connect( m_w->ui->tracks->proxyModel()->playlistInterface().data(), SIGNAL( shuffleModeChanged( bool ) ), SIGNAL( shuffleModeChanged( bool ) ) ); } virtual ~MetaAlbumInfoInterface() {} - virtual Tomahawk::PlaylistModes::RepeatMode repeatMode() const { return m_w->ui->tracksView->proxyModel()->playlistInterface()->repeatMode(); } - virtual bool shuffled() const { return m_w->ui->tracksView->proxyModel()->playlistInterface()->shuffled(); } + virtual Tomahawk::PlaylistModes::RepeatMode repeatMode() const { return m_w->ui->tracks->proxyModel()->playlistInterface()->repeatMode(); } + virtual bool shuffled() const { return m_w->ui->tracks->proxyModel()->playlistInterface()->shuffled(); } - virtual Tomahawk::result_ptr currentItem() const { return m_w->ui->tracksView->proxyModel()->playlistInterface()->currentItem(); } - virtual Tomahawk::result_ptr siblingItem( int itemsAway ) { return m_w->ui->tracksView->proxyModel()->playlistInterface()->siblingItem( itemsAway ); } - virtual int trackCount() const { return m_w->ui->tracksView->proxyModel()->playlistInterface()->trackCount(); } - virtual QList< Tomahawk::query_ptr > tracks() { return m_w->ui->tracksView->proxyModel()->playlistInterface()->tracks(); } + virtual Tomahawk::result_ptr currentItem() const { return m_w->ui->tracks->proxyModel()->playlistInterface()->currentItem(); } + virtual Tomahawk::result_ptr siblingItem( int itemsAway ) { return m_w->ui->tracks->proxyModel()->playlistInterface()->siblingItem( itemsAway ); } + virtual int trackCount() const { return m_w->ui->tracks->proxyModel()->playlistInterface()->trackCount(); } + virtual QList< Tomahawk::query_ptr > tracks() { return m_w->ui->tracks->proxyModel()->playlistInterface()->tracks(); } virtual bool hasChildInterface( Tomahawk::playlistinterface_ptr other ) { - return m_w->ui->tracksView->proxyModel()->playlistInterface() == other || - m_w->ui->tracksView->proxyModel()->playlistInterface()->hasChildInterface( other ) || - m_w->ui->albumsView->playlistInterface()->hasChildInterface( other ); + return m_w->ui->tracks->proxyModel()->playlistInterface() == other || + m_w->ui->tracks->proxyModel()->playlistInterface()->hasChildInterface( other ) || + m_w->ui->albums->playlistInterface()->hasChildInterface( other ); } virtual void setRepeatMode( Tomahawk::PlaylistModes::RepeatMode mode ) { - m_w->ui->tracksView->proxyModel()->playlistInterface()->setRepeatMode( mode ); + m_w->ui->tracks->proxyModel()->playlistInterface()->setRepeatMode( mode ); } virtual void setShuffled( bool enabled ) { - m_w->ui->tracksView->proxyModel()->playlistInterface()->setShuffled( enabled ); + m_w->ui->tracks->proxyModel()->playlistInterface()->setShuffled( enabled ); } private: