1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-30 09:10:53 +02:00

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

This commit is contained in:
Christian Muehlhaeuser
2012-11-14 10:20:11 +01:00
parent 732604f0a3
commit 732c1d6848
4 changed files with 438 additions and 86 deletions

View File

@@ -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_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<Tomahawk::album_ptr>& albums )
}
void
AlbumInfoWidget::onArtistClicked()
{
ViewManager::instance()->show( m_album->artist() );
}
void
AlbumInfoWidget::changeEvent( QEvent* e )
{

View File

@@ -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<Tomahawk::album_ptr>& albums );
void onAlbumCoverUpdated();
void onArtistClicked();
void onAlbumImageUpdated();
private:
Ui::AlbumInfoWidget* ui;

View File

@@ -6,56 +6,342 @@
<rect>
<x>0</x>
<y>0</y>
<width>902</width>
<height>696</height>
<width>965</width>
<height>912</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>12</number>
</property>
<property name="handleWidth">
<number>1</number>
<property name="topMargin">
<number>12</number>
</property>
<widget class="TreeView" name="tracksView"/>
<widget class="QWidget" name="">
<property name="rightMargin">
<number>16</number>
</property>
<property name="bottomMargin">
<number>12</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="HeaderLabel" name="albumsLabel">
<widget class="QFrame" name="trackFrame">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="spacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>8</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>8</number>
</property>
<property name="bottomMargin">
<number>8</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>18</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Tracklist</string>
</property>
<property name="margin">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="TreeView" name="tracks">
<property name="minimumSize">
<size>
<width>0</width>
<height>300</height>
</size>
</property>
<property name="headerHidden">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>16</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QFrame" name="albumFrame">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="spacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>8</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>8</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<family>Arial</family>
<pointsize>18</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Other Albums</string>
</property>
<property name="margin">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="GridView" name="albums">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>190</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_8">
<property name="spacing">
<number>-1</number>
</property>
<property name="leftMargin">
<number>16</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="cover">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>220</width>
<height>220</height>
</size>
</property>
<property name="text">
<string>Other Albums by Artist</string>
<string>Cover</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="GridView" name="albumsView"/>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_7">
<property name="spacing">
<number>4</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>4</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="albumLabel">
<property name="text">
<string>Album</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>4</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QueryLabel" name="artistLabel">
<property name="text">
<string>Artist</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QTextBrowser" name="biography">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>240</height>
</size>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>HeaderLabel</class>
<extends>QLabel</extends>
<header location="global">widgets/HeaderLabel.h</header>
<class>GridView</class>
<extends>QListView</extends>
<header location="global">GridView.h</header>
</customwidget>
<customwidget>
<class>TreeView</class>
<extends>QTreeView</extends>
<header location="global">TreeView.h</header>
<header>playlist/TreeView.h</header>
</customwidget>
<customwidget>
<class>GridView</class>
<extends>QListView</extends>
<header>playlist/GridView.h</header>
<class>QueryLabel</class>
<extends>QLabel</extends>
<header>widgets/QueryLabel.h</header>
</customwidget>
</customwidgets>
<resources/>

View File

@@ -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: