mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-21 16:29:43 +01:00
Added almost-finished AlbumInfoWidget.
This commit is contained in:
parent
53f812ed42
commit
744f31bb45
@ -186,6 +186,7 @@ set( libSources
|
||||
widgets/SocialPlaylistWidget.cpp
|
||||
widgets/infowidgets/sourceinfowidget.cpp
|
||||
widgets/infowidgets/ArtistInfoWidget.cpp
|
||||
widgets/infowidgets/AlbumInfoWidget.cpp
|
||||
|
||||
kdsingleapplicationguard/kdsingleapplicationguard.cpp
|
||||
kdsingleapplicationguard/kdsharedmemorylocker.cpp
|
||||
@ -366,6 +367,7 @@ set( libHeaders
|
||||
widgets/SocialPlaylistWidget.h
|
||||
widgets/infowidgets/sourceinfowidget.h
|
||||
widgets/infowidgets/ArtistInfoWidget.h
|
||||
widgets/infowidgets/AlbumInfoWidget.h
|
||||
|
||||
kdsingleapplicationguard/kdsingleapplicationguard.h
|
||||
)
|
||||
@ -389,6 +391,7 @@ set( libUI ${libUI}
|
||||
widgets/SocialPlaylistWidget.ui
|
||||
widgets/infowidgets/sourceinfowidget.ui
|
||||
widgets/infowidgets/ArtistInfoWidget.ui
|
||||
widgets/infowidgets/AlbumInfoWidget.ui
|
||||
playlist/topbar/topbar.ui
|
||||
playlist/infobar/infobar.ui
|
||||
)
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "widgets/welcomewidget.h"
|
||||
#include "widgets/infowidgets/sourceinfowidget.h"
|
||||
#include "widgets/infowidgets/ArtistInfoWidget.h"
|
||||
#include "widgets/infowidgets/AlbumInfoWidget.h"
|
||||
#include "widgets/newplaylistwidget.h"
|
||||
|
||||
#include "utils/logger.h"
|
||||
@ -237,27 +238,19 @@ ViewManager::show( const Tomahawk::artist_ptr& artist )
|
||||
Tomahawk::ViewPage*
|
||||
ViewManager::show( const Tomahawk::album_ptr& album )
|
||||
{
|
||||
PlaylistView* view;
|
||||
AlbumInfoWidget* swidget;
|
||||
if ( !m_albumViews.contains( album ) )
|
||||
{
|
||||
view = new PlaylistView();
|
||||
PlaylistModel* model = new PlaylistModel();
|
||||
model->append( album );
|
||||
view->setPlaylistModel( model );
|
||||
view->setFrameShape( QFrame::NoFrame );
|
||||
view->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
||||
|
||||
m_albumViews.insert( album, view );
|
||||
swidget = new AlbumInfoWidget( album );
|
||||
m_albumViews.insert( album, swidget );
|
||||
}
|
||||
else
|
||||
{
|
||||
view = m_albumViews.value( album );
|
||||
swidget = m_albumViews.value( album );
|
||||
}
|
||||
|
||||
setPage( view );
|
||||
emit numSourcesChanged( 1 );
|
||||
|
||||
return view;
|
||||
setPage( swidget );
|
||||
return swidget;
|
||||
}
|
||||
|
||||
|
||||
|
@ -33,6 +33,7 @@
|
||||
class AnimatedSplitter;
|
||||
class AlbumModel;
|
||||
class AlbumView;
|
||||
class AlbumInfoWidget;
|
||||
class ArtistInfoWidget;
|
||||
class ArtistView;
|
||||
class CollectionModel;
|
||||
@ -188,7 +189,7 @@ private:
|
||||
QHash< Tomahawk::collection_ptr, ArtistView* > m_treeViews;
|
||||
QHash< Tomahawk::collection_ptr, AlbumView* > m_collectionAlbumViews;
|
||||
QHash< Tomahawk::artist_ptr, ArtistInfoWidget* > m_artistViews;
|
||||
QHash< Tomahawk::album_ptr, PlaylistView* > m_albumViews;
|
||||
QHash< Tomahawk::album_ptr, AlbumInfoWidget* > m_albumViews;
|
||||
QHash< Tomahawk::playlist_ptr, PlaylistView* > m_playlistViews;
|
||||
QHash< Tomahawk::source_ptr, SourceInfoWidget* > m_sourceViews;
|
||||
|
||||
|
171
src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.cpp
Normal file
171
src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.cpp
Normal file
@ -0,0 +1,171 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "AlbumInfoWidget.h"
|
||||
#include "ui_AlbumInfoWidget.h"
|
||||
|
||||
#include "viewmanager.h"
|
||||
#include "playlist/treemodel.h"
|
||||
#include "playlist/albummodel.h"
|
||||
|
||||
#include "database/databasecommand_alltracks.h"
|
||||
#include "database/databasecommand_allalbums.h"
|
||||
|
||||
#include "utils/tomahawkutils.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
#include "widgets/overlaywidget.h"
|
||||
|
||||
static QString s_aiInfoIdentifier = QString( "AlbumInfoWidget" );
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
AlbumInfoWidget::AlbumInfoWidget( const Tomahawk::album_ptr& album, QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, ui( new Ui::AlbumInfoWidget )
|
||||
, m_album( album )
|
||||
{
|
||||
ui->setupUi( this );
|
||||
|
||||
ui->albumsView->setFrameShape( QFrame::NoFrame );
|
||||
ui->albumsView->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
||||
ui->tracksView->setFrameShape( QFrame::NoFrame );
|
||||
ui->tracksView->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
||||
|
||||
TomahawkUtils::unmarginLayout( layout() );
|
||||
|
||||
m_albumsModel = new AlbumModel( ui->albumsView );
|
||||
ui->albumsView->setAlbumModel( m_albumsModel );
|
||||
|
||||
m_tracksModel = new TreeModel( ui->tracksView );
|
||||
ui->tracksView->setTreeModel( m_tracksModel );
|
||||
|
||||
m_pixmap = QPixmap( RESPATH "images/no-album-art-placeholder.png" ).scaledToWidth( 48, Qt::SmoothTransformation );
|
||||
|
||||
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
|
||||
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
|
||||
|
||||
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
|
||||
|
||||
// Apparently headers can only be removed when it's already visible / layed-out
|
||||
QTimer::singleShot( 0, this, SLOT( removeHeaders() ) );
|
||||
|
||||
load( album );
|
||||
}
|
||||
|
||||
|
||||
AlbumInfoWidget::~AlbumInfoWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AlbumInfoWidget::load( const album_ptr& album )
|
||||
{
|
||||
m_title = album->name();
|
||||
m_description = album->artist()->name();
|
||||
m_tracksModel->addTracks( album, QModelIndex() );
|
||||
|
||||
QList<album_ptr> al;
|
||||
al << album;
|
||||
m_albumsModel->addAlbums( al );
|
||||
|
||||
Tomahawk::InfoSystem::InfoCriteriaHash trackInfo;
|
||||
trackInfo["artist"] = album->artist()->name();
|
||||
trackInfo["album"] = album->name();
|
||||
|
||||
Tomahawk::InfoSystem::InfoRequestData requestData;
|
||||
requestData.caller = s_aiInfoIdentifier;
|
||||
requestData.type = Tomahawk::InfoSystem::InfoAlbumCoverArt;
|
||||
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo );
|
||||
requestData.customData = QVariantMap();
|
||||
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AlbumInfoWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
|
||||
{
|
||||
if ( requestData.caller != s_aiInfoIdentifier )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
InfoSystem::InfoCriteriaHash trackInfo;
|
||||
trackInfo = requestData.input.value< InfoSystem::InfoCriteriaHash >();
|
||||
|
||||
if ( output.canConvert< QVariantMap >() )
|
||||
{
|
||||
if ( trackInfo["album"] != m_album->name() )
|
||||
{
|
||||
qDebug() << "Returned info was for:" << trackInfo["album"] << "- was looking for:" << m_album->name();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QVariantMap returnedData = output.value< QVariantMap >();
|
||||
switch ( requestData.type )
|
||||
{
|
||||
case Tomahawk::InfoSystem::InfoAlbumCoverArt:
|
||||
{
|
||||
QVariantMap returnedData = output.value< QVariantMap >();
|
||||
const QByteArray ba = returnedData["imgbytes"].toByteArray();
|
||||
if ( ba.length() )
|
||||
{
|
||||
m_pixmap.loadFromData( ba );
|
||||
emit pixmapChanged( m_pixmap );
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AlbumInfoWidget::infoSystemFinished( QString target )
|
||||
{
|
||||
Q_UNUSED( target );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AlbumInfoWidget::changeEvent( QEvent* e )
|
||||
{
|
||||
QWidget::changeEvent( e );
|
||||
switch ( e->type() )
|
||||
{
|
||||
case QEvent::LanguageChange:
|
||||
ui->retranslateUi( this );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AlbumInfoWidget::removeHeaders()
|
||||
{
|
||||
}
|
108
src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.h
Normal file
108
src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.h
Normal file
@ -0,0 +1,108 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \class AlbumInfoWidget
|
||||
* \brief ViewPage, which displays an album for an artist and recommends others.
|
||||
*
|
||||
* This Tomahawk ViewPage displays the tracks of any given album
|
||||
* It is our default ViewPage when showing an artist via ViewManager.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ALBUMINFOWIDGET_H
|
||||
#define ALBUMINFOWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "artist.h"
|
||||
#include "result.h"
|
||||
#include "playlistinterface.h"
|
||||
#include "viewpage.h"
|
||||
#include "infosystem/infosystem.h"
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
class AlbumModel;
|
||||
class TreeModel;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class AlbumInfoWidget;
|
||||
}
|
||||
|
||||
class DLLEXPORT AlbumInfoWidget : public QWidget, public Tomahawk::ViewPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AlbumInfoWidget( const Tomahawk::album_ptr& album, QWidget* parent = 0 );
|
||||
~AlbumInfoWidget();
|
||||
|
||||
/** \brief Loads information for a given album.
|
||||
* \param album The album that you want to load information for.
|
||||
*
|
||||
* Calling this method will make AlbumInfoWidget load information about
|
||||
* an album, and related other albums. This method will be automatically
|
||||
* called by the constructor, but you can use it to load another album's
|
||||
* information at any point.
|
||||
*/
|
||||
void load( const Tomahawk::album_ptr& album );
|
||||
|
||||
virtual QWidget* widget() { return this; }
|
||||
virtual Tomahawk::PlaylistInterface* playlistInterface() const { return 0; }
|
||||
|
||||
virtual QString title() const { return m_title; }
|
||||
virtual QString description() const { return m_description; }
|
||||
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 showStatsBar() const { return false; }
|
||||
|
||||
virtual bool jumpToCurrentTrack() { return false; }
|
||||
|
||||
signals:
|
||||
void longDescriptionChanged( const QString& description );
|
||||
void descriptionChanged( const QString& description );
|
||||
void pixmapChanged( const QPixmap& pixmap );
|
||||
|
||||
protected:
|
||||
void changeEvent( QEvent* e );
|
||||
|
||||
private slots:
|
||||
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||
void infoSystemFinished( QString target );
|
||||
|
||||
void removeHeaders();
|
||||
|
||||
private:
|
||||
Ui::AlbumInfoWidget *ui;
|
||||
|
||||
Tomahawk::album_ptr m_album;
|
||||
|
||||
AlbumModel* m_albumsModel;
|
||||
TreeModel* m_tracksModel;
|
||||
|
||||
QString m_title;
|
||||
QString m_description;
|
||||
QString m_longDescription;
|
||||
QPixmap m_pixmap;
|
||||
};
|
||||
|
||||
#endif // ALBUMINFOWIDGET_H
|
55
src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.ui
Normal file
55
src/libtomahawk/widgets/infowidgets/AlbumInfoWidget.ui
Normal file
@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AlbumInfoWidget</class>
|
||||
<widget class="QWidget" name="AlbumInfoWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>902</width>
|
||||
<height>696</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="ArtistView" name="tracksView"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="HeaderLabel" name="albumsLabel">
|
||||
<property name="text">
|
||||
<string>Other Albums by Artist</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AlbumView" name="albumsView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>HeaderLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header location="global">widgets/HeaderLabel.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>ArtistView</class>
|
||||
<extends>QTreeView</extends>
|
||||
<header location="global">artistview.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>AlbumView</class>
|
||||
<extends>QListView</extends>
|
||||
<header>playlist/albumview.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -59,6 +59,8 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
|
||||
|
||||
m_relatedModel = new TreeModel( ui->relatedArtists );
|
||||
ui->relatedArtists->setTreeModel( m_relatedModel );
|
||||
ui->relatedArtists->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||
ui->relatedArtists->header()->setVisible( false );
|
||||
|
||||
m_topHitsModel = new PlaylistModel( ui->topHits );
|
||||
m_topHitsModel->setStyle( TrackModel::Short );
|
||||
@ -72,12 +74,10 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
|
||||
|
||||
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
|
||||
|
||||
// Apparently headers can only be removed when it's already visible / layed-out
|
||||
QTimer::singleShot( 0, this ,SLOT( removeHeaders() ) );
|
||||
|
||||
load( artist );
|
||||
}
|
||||
|
||||
|
||||
ArtistInfoWidget::~ArtistInfoWidget()
|
||||
{
|
||||
delete ui;
|
||||
@ -125,7 +125,6 @@ ArtistInfoWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestD
|
||||
// qDebug() << "Info of wrong type or not with our identifier";
|
||||
return;
|
||||
}
|
||||
qDebug() << Q_FUNC_INFO << requestData.caller << requestData.type << s_aiInfoIdentifier;
|
||||
|
||||
InfoSystem::InfoCriteriaHash trackInfo;
|
||||
trackInfo = requestData.input.value< InfoSystem::InfoCriteriaHash >();
|
||||
@ -207,7 +206,6 @@ void
|
||||
ArtistInfoWidget::infoSystemFinished( QString target )
|
||||
{
|
||||
Q_UNUSED( target );
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
|
||||
@ -225,10 +223,3 @@ ArtistInfoWidget::changeEvent( QEvent* e )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ArtistInfoWidget::removeHeaders()
|
||||
{
|
||||
for ( int i = 1; i < ui->relatedArtists->header()->count(); i++ )
|
||||
ui->relatedArtists->header()->hideSection( ui->relatedArtists->header()->logicalIndex( i ) );
|
||||
}
|
||||
|
@ -90,7 +90,6 @@ private slots:
|
||||
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||
void infoSystemFinished( QString target );
|
||||
|
||||
void removeHeaders();
|
||||
private:
|
||||
Ui::ArtistInfoWidget *ui;
|
||||
|
||||
@ -106,4 +105,4 @@ private:
|
||||
QPixmap m_pixmap;
|
||||
};
|
||||
|
||||
#endif // SOURCEINFOWIDGET_H
|
||||
#endif // ARTISTINFOWIDGET_H
|
||||
|
@ -190,6 +190,7 @@ WelcomeWidget::changeEvent( QEvent* e )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QSize
|
||||
PlaylistDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user