1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-24 01:39:42 +01:00

Merge remote-tracking branch 'origin/master' into binaryghns

This commit is contained in:
Leo Franchi 2012-05-18 08:01:52 -04:00
commit 8ce4b3587d
64 changed files with 538 additions and 338 deletions

View File

@ -86,7 +86,7 @@ macro(add_tomahawk_plugin)
endif()
# add link targets
target_link_libraries(${TOMAHAWK_LIBRARIES})
target_link_libraries(${target} tomahawklib)
if(PLUGIN_LINK_LIBRARIES)
target_link_libraries(${target} ${PLUGIN_LINK_LIBRARIES})
endif()

View File

@ -544,7 +544,8 @@ AudioControls::onAlbumClicked()
void
AudioControls::onTrackClicked()
{
ViewManager::instance()->showCurrentTrack();
ViewManager::instance()->show( m_currentTrack->toQuery() );
// ViewManager::instance()->showCurrentTrack();
}

View File

@ -430,6 +430,8 @@ TomahawkApp::registerMetaTypes()
qRegisterMetaType< Tomahawk::collection_ptr >("Tomahawk::collection_ptr");
qRegisterMetaType< Tomahawk::result_ptr >("Tomahawk::result_ptr");
qRegisterMetaType< Tomahawk::query_ptr >("Tomahawk::query_ptr");
qRegisterMetaType< Tomahawk::album_ptr >("Tomahawk::album_ptr");
qRegisterMetaType< Tomahawk::artist_ptr >("Tomahawk::artist_ptr");
qRegisterMetaType< Tomahawk::source_ptr >("Tomahawk::source_ptr");
qRegisterMetaType< Tomahawk::dyncontrol_ptr >("Tomahawk::dyncontrol_ptr");
qRegisterMetaType< Tomahawk::playlist_ptr >("Tomahawk::playlist_ptr");

View File

@ -1 +1,9 @@
ADD_SUBDIRECTORY( generic )
add_subdirectory( generic )
if(UNIX AND NOT APPLE)
add_subdirectory( linux )
endif()
if(APPLE)
add_subdirectory( mac )
endif()

View File

@ -1,3 +1,21 @@
ADD_SUBDIRECTORY( echonest )
ADD_SUBDIRECTORY( hypem )
ADD_SUBDIRECTORY( charts )
include_directories(${LIBECHONEST_INCLUDE_DIR})
list(APPEND simple_plugins
Echonest
Charts
NewReleases
Spotify
Hypem
MusixMatch
MusicBrainz
Rovi
)
foreach(simple_plugin ${simple_plugins})
STRING(TOLOWER "${simple_plugin}" dir)
add_tomahawk_plugin(${dir}
TYPE infoplugin EXPORT_MACRO INFOPLUGINDLLEXPORT_PRO
SOURCES "${dir}/${simple_plugin}Plugin.cpp"
)
endforeach()

View File

@ -36,13 +36,15 @@
#include "utils/Logger.h"
#include "utils/TomahawkCache.h"
#define CHART_URL "http://charts.tomahawk-player.org/"
//#define CHART_URL "http://localhost:8080/"
#include <qjson/parser.h>
#include <qjson/serializer.h>
namespace Tomahawk
{
#define CHART_URL "http://charts.tomahawk-player.org/"
//#define CHART_URL "http://localhost:8080/"
using namespace Tomahawk::InfoSystem;
namespace InfoSystem
{
@ -640,4 +642,4 @@ ChartsPlugin::chartReturned()
}
Q_EXPORT_PLUGIN2( Tomahawk::InfoSystem::InfoPlugin, Tomahawk::InfoSystem::ChartsPlugin )
Q_EXPORT_PLUGIN2( Tomahawk::InfoSystem::InfoPlugin, Tomahawk::InfoSystem::ChartsPlugin )

View File

@ -1,45 +0,0 @@
project( tomahawk )
include( ${QT_USE_FILE} )
add_definitions( ${QT_DEFINITIONS} )
add_definitions( -DQT_PLUGIN )
add_definitions( -DQT_SHARED )
add_definitions( -DINFOPLUGINDLLEXPORT_PRO )
set( echonestInfoPluginSources
EchonestPlugin.cpp
)
set( echonestInfoPluginHeaders
EchonestPlugin.h
)
include_directories(
${QT_INCLUDE_DIR}
${LIBECHONEST_INCLUDE_DIR}
)
qt4_wrap_cpp( echonestInfoPluginMoc ${echonestInfoPluginHeaders} )
add_library( tomahawk_infoplugin_echonest SHARED ${echonestInfoPluginSources} ${echonestInfoPluginMoc} ${RC_SRCS} )
IF( WIN32 )
SET( OS_SPECIFIC_LINK_LIBRARIES
${OS_SPECIFIC_LINK_LIBRARIES}
"winmm.dll"
"iphlpapi.a"
)
ENDIF( WIN32 )
target_link_libraries( tomahawk_infoplugin_echonest
${TOMAHAWK_LIBRARIES}
${LIBECHONEST_LIBRARY}
${QT_LIBRARIES}
${OS_SPECIFIC_LINK_LIBRARIES}
)
IF( APPLE )
# SET( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-undefined dynamic_lookup" )
ENDIF( APPLE )
install( TARGETS tomahawk_infoplugin_echonest DESTINATION ${CMAKE_INSTALL_LIBDIR} )

View File

@ -17,7 +17,7 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "musicbrainzPlugin.h"
#include "MusicBrainzPlugin.h"
#include <QNetworkReply>
#include <QDomDocument>

View File

@ -17,7 +17,7 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "spotifyPlugin.h"
#include "SpotifyPlugin.h"
#include <QDir>
#include <QSettings>

View File

@ -0,0 +1,25 @@
IF(BUILD_GUI AND X11_FOUND)
INCLUDE_DIRECTORIES( ${THIRDPARTY_DIR}/libqnetwm )
SET(fdo_srcs
fdonotify/FdoNotifyPlugin.cpp
fdonotify/ImageConverter.cpp
${THIRDPARTY_DIR}/libqnetwm/libqnetwm/netwm.cpp
)
SET(FDO_LINK_LIBRARIES ${LINK_LIBRARIES} ${X11_LIBRARIES})
add_tomahawk_plugin(fdonotify
TYPE infoplugin EXPORT_MACRO INFOPLUGINDLLEXPORT_PRO
SOURCES "${fdo_srcs}" LINK_LIBRARIES "${FDO_LINK_LIBRARIES}"
)
ENDIF()
SET(mpris_srcs
mpris/MprisPluginRootAdaptor.cpp
mpris/MprisPluginPlayerAdaptor.cpp
mpris/MprisPlugin.cpp
)
add_tomahawk_plugin(mpris
TYPE infoplugin EXPORT_MACRO INFOPLUGINDLLEXPORT_PRO
SOURCES "${mpris_srcs}"
)

View File

@ -44,10 +44,15 @@
#include <QtDBus/QDBusConnection>
#include <QtDBus/QDBusMessage>
#include <QtGui/QImage>
#include <QtPlugin>
#include "utils/Logger.h"
using namespace Tomahawk::InfoSystem;
namespace Tomahawk
{
namespace InfoSystem
{
FdoNotifyPlugin::FdoNotifyPlugin()
: InfoPlugin()
@ -162,3 +167,9 @@ FdoNotifyPlugin::nowPlaying( const QVariant &input )
if ( list.count() > 0 )
m_nowPlayingId = list.at( 0 ).toInt();
}
} //ns InfoSystem
} //ns Tomahawk
Q_EXPORT_PLUGIN2( Tomahawk::InfoSystem::InfoPlugin, Tomahawk::InfoSystem::FdoNotifyPlugin )

View File

@ -20,6 +20,7 @@
#ifndef FDONOTIFYPLUGIN_H
#define FDONOTIFYPLUGIN_H
#include "infoplugins/InfoPluginDllMacro.h"
#include "infosystem/InfoSystem.h"
namespace Tomahawk
@ -28,9 +29,10 @@ namespace Tomahawk
namespace InfoSystem
{
class FdoNotifyPlugin : public InfoPlugin
class INFOPLUGINDLLEXPORT FdoNotifyPlugin : public InfoPlugin
{
Q_OBJECT
Q_INTERFACES( Tomahawk::InfoSystem::InfoPlugin )
public:
FdoNotifyPlugin();

View File

@ -20,6 +20,7 @@
#include <QApplication>
#include <QImage>
#include <QtDBus/QtDBus>
#include <QtPlugin>
#include "audio/AudioEngine.h"
#include "infosystem/InfoSystemWorker.h"
@ -35,7 +36,11 @@
#include "MprisPluginRootAdaptor.h"
#include "MprisPluginPlayerAdaptor.h"
using namespace Tomahawk::InfoSystem;
namespace Tomahawk
{
namespace InfoSystem
{
static QString s_mpInfoIdentifier = QString( "MPRISPLUGIN" );
@ -583,3 +588,8 @@ MprisPlugin::notifyPropertyChanged( const QString& interface, const QString& pro
QDBusConnection::sessionBus().send(signal);
}
} //ns InfoSystem
} //ns Tomahawk
Q_EXPORT_PLUGIN2( Tomahawk::InfoSystem::InfoPlugin, Tomahawk::InfoSystem::MprisPlugin )

View File

@ -22,6 +22,7 @@
#include "audio/AudioEngine.h"
#include "infosystem/InfoSystem.h"
#include "infoplugins/InfoPluginDllMacro.h"
#include <QObject>
#include <QVariant>
@ -33,9 +34,10 @@ namespace Tomahawk
namespace InfoSystem
{
class MprisPlugin : public InfoPlugin
class INFOPLUGINDLLEXPORT MprisPlugin : public InfoPlugin
{
Q_OBJECT
Q_INTERFACES( Tomahawk::InfoSystem::InfoPlugin )
public:
MprisPlugin();

View File

@ -0,0 +1,11 @@
set(adium_srcs
adium/AdiumPlugin.cpp
adium/Adium.mm
)
add_tomahawk_plugin(adium
TYPE infoplugin EXPORT_MACRO INFOPLUGINDLLEXPORT_PRO
SOURCES "${adium_srcs}"
)

View File

@ -19,6 +19,7 @@
#include <string.h>
#include <QtPlugin>
#include <QTimer>
#include "infosystem/InfoSystemWorker.h"
@ -46,7 +47,11 @@ static void setStatus(const QString &status)
script( scriptstr );
}
using namespace Tomahawk::InfoSystem;
namespace Tomahawk
{
namespace InfoSystem
{
AdiumPlugin::AdiumPlugin()
: InfoPlugin()
@ -148,7 +153,7 @@ AdiumPlugin::audioStarted( const Tomahawk::InfoSystem::PushInfoPair pushInfoPair
return;
InfoStringHash hash = map[ "trackinfo" ].value< Tomahawk::InfoSystem::InfoStringHash >();
if ( !hash.contains( "title" ) || !hash.contains( "artist" ) )
return;
@ -161,7 +166,7 @@ AdiumPlugin::audioStarted( const Tomahawk::InfoSystem::PushInfoPair pushInfoPair
QUrl shortUrl = m_currentLongUrl;
if ( pushInfoPair.first.contains( "shortUrl" ) )
shortUrl = pushInfoPair.first[ "shortUrl" ].toUrl();
QString nowPlaying = "";
nowPlaying.append( m_currentArtist );
nowPlaying.append(" - ");
@ -208,3 +213,8 @@ AdiumPlugin::audioResumed( const Tomahawk::InfoSystem::PushInfoPair pushInfoPair
audioStarted( pushInfoPair );
}
} //ns InfoSystem
} //ns Tomahawk
Q_EXPORT_PLUGIN2( Tomahawk::InfoSystem::InfoPlugin, Tomahawk::InfoSystem::AdiumPlugin )

View File

@ -20,6 +20,7 @@
#ifndef ADIUMPLUGIN_H
#define ADIUMPLUGIN_H
#include "infoplugins/InfoPluginDllMacro.h"
#include "infosystem/InfoSystem.h"
#include <QNetworkAccessManager>
@ -33,9 +34,10 @@ namespace Tomahawk {
namespace InfoSystem {
class AdiumPlugin : public InfoPlugin
class INFOPLUGINDLLEXPORT AdiumPlugin : public InfoPlugin
{
Q_OBJECT
Q_INTERFACES( Tomahawk::InfoSystem::InfoPlugin )
public:
AdiumPlugin();
@ -46,7 +48,7 @@ protected slots:
{
Q_UNUSED( requestData );
}
virtual void pushInfo( Tomahawk::InfoSystem::InfoPushData pushData );
public slots:

View File

@ -32,6 +32,8 @@ using namespace Tomahawk;
Album::~Album()
{
m_ownRef.clear();
#ifndef ENABLE_HEADLESS
delete m_cover;
#endif
@ -65,6 +67,8 @@ Album::get( unsigned int id, const QString& name, const Tomahawk::artist_ptr& ar
}
album_ptr a = album_ptr( new Album( id, name, artist ), &QObject::deleteLater );
a->setWeakRef( a.toWeakRef() );
if ( id > 0 )
s_albums.insert( id, a );
@ -87,13 +91,9 @@ Album::Album( unsigned int id, const QString& name, const Tomahawk::artist_ptr&
void
Album::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks )
Album::onTracksLoaded( Tomahawk::ModelMode mode, const Tomahawk::collection_ptr& collection )
{
Tomahawk::AlbumPlaylistInterface* api = dynamic_cast< Tomahawk::AlbumPlaylistInterface* >( playlistInterface().data() );
if ( api )
api->addQueries( tracks );
emit tracksAdded( tracks );
emit tracksAdded( playlistInterface( mode, collection )->tracks(), mode, collection );
}
@ -206,12 +206,25 @@ Album::infoSystemFinished( const QString& target )
Tomahawk::playlistinterface_ptr
Album::playlistInterface()
Album::playlistInterface( ModelMode mode, const Tomahawk::collection_ptr& collection )
{
if ( m_playlistInterface.isNull() )
playlistinterface_ptr pli = m_playlistInterface[ mode ][ collection ];
if ( pli.isNull() )
{
m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::AlbumPlaylistInterface( this ) );
pli = Tomahawk::playlistinterface_ptr( new Tomahawk::AlbumPlaylistInterface( this, mode, collection ) );
connect( pli.data(), SIGNAL( tracksLoaded( Tomahawk::ModelMode, Tomahawk::collection_ptr ) ),
SLOT( onTracksLoaded( Tomahawk::ModelMode, Tomahawk::collection_ptr ) ) );
m_playlistInterface[ mode ][ collection ] = pli;
}
return m_playlistInterface;
return pli;
}
QList<Tomahawk::query_ptr>
Album::tracks( ModelMode mode, const Tomahawk::collection_ptr& collection )
{
return playlistInterface( mode, collection )->tracks();
}

View File

@ -55,15 +55,19 @@ public:
#endif
bool infoLoaded() const { return m_infoLoaded; }
Tomahawk::playlistinterface_ptr playlistInterface();
QList<Tomahawk::query_ptr> tracks( ModelMode mode = Mixed, const Tomahawk::collection_ptr& collection = Tomahawk::collection_ptr() );
Tomahawk::playlistinterface_ptr playlistInterface( ModelMode mode, const Tomahawk::collection_ptr& collection = Tomahawk::collection_ptr() );
QWeakPointer< Tomahawk::Album > weakRef() { return m_ownRef; }
void setWeakRef( QWeakPointer< Tomahawk::Album > weakRef ) { m_ownRef = weakRef; }
signals:
void tracksAdded( const QList<Tomahawk::query_ptr>& tracks );
void tracksAdded( const QList<Tomahawk::query_ptr>& tracks, Tomahawk::ModelMode mode, const Tomahawk::collection_ptr& collection );
void updated();
void coverChanged();
private slots:
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks );
void onTracksLoaded(Tomahawk::ModelMode mode, const Tomahawk::collection_ptr& collection );
void infoSystemInfo( const Tomahawk::InfoSystem::InfoRequestData& requestData, const QVariant& output );
void infoSystemFinished( const QString& target );
@ -75,6 +79,7 @@ private:
QString m_name;
artist_ptr m_artist;
QByteArray m_coverBuffer;
bool m_infoLoaded;
mutable bool m_infoLoading;
mutable QString m_uuid;
@ -84,9 +89,13 @@ private:
mutable QHash< int, QPixmap > m_coverCache;
#endif
Tomahawk::playlistinterface_ptr m_playlistInterface;
QHash< Tomahawk::ModelMode, QHash< Tomahawk::collection_ptr, Tomahawk::playlistinterface_ptr > > m_playlistInterface;
QWeakPointer< Tomahawk::Album > m_ownRef;
};
} // ns
Q_DECLARE_METATYPE( Tomahawk::album_ptr )
#endif

View File

@ -23,7 +23,10 @@
#include "database/Database.h"
#include "database/DatabaseImpl.h"
#include "database/DatabaseCommand_AllTracks.h"
#include "Pipeline.h"
#include "Query.h"
#include "Source.h"
#include "SourceList.h"
#include "utils/Logger.h"
@ -31,10 +34,14 @@ using namespace Tomahawk;
AlbumPlaylistInterface::AlbumPlaylistInterface() {}
AlbumPlaylistInterface::AlbumPlaylistInterface( Tomahawk::Album *album )
AlbumPlaylistInterface::AlbumPlaylistInterface( Tomahawk::Album* album, Tomahawk::ModelMode mode, const Tomahawk::collection_ptr& collection )
: Tomahawk::PlaylistInterface()
, m_currentItem( 0 )
, m_currentTrack( 0 )
, m_infoSystemLoaded( false )
, m_databaseLoaded( false )
, m_mode( mode )
, m_collection( collection )
, m_album( QWeakPointer< Tomahawk::Album >( album ) )
{
}
@ -88,15 +95,35 @@ AlbumPlaylistInterface::tracks()
{
if ( m_queries.isEmpty() && m_album )
{
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks();
cmd->setAlbum( m_album );
cmd->setSortOrder( DatabaseCommand_AllTracks::AlbumPosition );
//this takes discnumber into account as well
if ( ( m_mode == Mixed || m_mode == InfoSystemMode ) && !m_infoSystemLoaded )
{
Tomahawk::InfoSystem::InfoStringHash artistInfo;
artistInfo["artist"] = m_album.data()->artist()->name();
artistInfo["album"] = m_album.data()->name();
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, QVariant ) ),
m_album.data(), SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ) );
Tomahawk::InfoSystem::InfoRequestData requestData;
requestData.caller = uuid();
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( artistInfo );
requestData.type = Tomahawk::InfoSystem::InfoAlbumSongs;
requestData.timeoutMillis = 0;
requestData.allSources = true;
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
}
else if ( m_mode == DatabaseMode && !m_databaseLoaded )
{
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( m_collection );
cmd->setAlbum( m_album );
cmd->setSortOrder( DatabaseCommand_AllTracks::AlbumPosition );
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, QVariant ) ),
SLOT( onTracksLoaded( QList<Tomahawk::query_ptr> ) ) );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
}
}
return m_queries;
@ -104,7 +131,121 @@ AlbumPlaylistInterface::tracks()
void
AlbumPlaylistInterface::addQueries( const QList< query_ptr >& tracks )
AlbumPlaylistInterface::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
{
m_queries << tracks;
switch ( requestData.type )
{
case Tomahawk::InfoSystem::InfoAlbumSongs:
{
QVariantMap returnedData = output.value< QVariantMap >();
if ( !returnedData.isEmpty() )
{
Tomahawk::InfoSystem::InfoStringHash inputInfo;
inputInfo = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
QStringList tracks = returnedData[ "tracks" ].toStringList();
QList<query_ptr> ql;
//TODO: Figure out how to do this with a multi-disk album without breaking the
// current behaviour. I just know too little about InfoSystem to deal with
// it right now, I've only taken the liberty of adding Query::setDiscNumber
// which should make this easier. --Teo 11/2011
unsigned int trackNo = 1;
foreach ( const QString& trackName, tracks )
{
query_ptr query = Query::get( inputInfo[ "artist" ], trackName, inputInfo[ "album" ] );
query->setAlbumPos( trackNo++ );
ql << query;
tDebug() << Q_FUNC_INFO << query->toString();
}
Pipeline::instance()->resolve( ql );
m_queries << ql;
}
break;
}
default:
{
Q_ASSERT( false );
break;
}
}
m_infoSystemLoaded = true;
disconnect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
this, SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
if ( m_queries.isEmpty() && m_mode == Mixed )
{
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( m_collection );
cmd->setAlbum( m_album );
//this takes discnumber into account as well
cmd->setSortOrder( DatabaseCommand_AllTracks::AlbumPosition );
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, QVariant ) ),
SLOT( onTracksLoaded( QList<Tomahawk::query_ptr> ) ) );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
}
else
{
emit tracksLoaded( m_mode, m_collection );
}
}
void
AlbumPlaylistInterface::onTracksLoaded( const QList< query_ptr >& tracks )
{
m_databaseLoaded = true;
if ( m_collection.isNull() )
m_queries << filterTracks( tracks );
else
m_queries << tracks;
emit tracksLoaded( m_mode, m_collection );
}
QList<Tomahawk::query_ptr>
AlbumPlaylistInterface::filterTracks( const QList<Tomahawk::query_ptr>& queries )
{
QList<Tomahawk::query_ptr> result;
for ( int i = 0; i < queries.count(); i++ )
{
bool picked = true;
const query_ptr q1 = queries.at( i );
for ( int j = 0; j < result.count(); j++ )
{
if ( !picked )
break;
const query_ptr& q2 = result.at( j );
if ( q1->track() == q2->track() )
{
picked = false;
}
}
if ( picked )
{
query_ptr q = Query::get( q1->artist(), q1->track(), q1->album(), uuid(), true );
q->setAlbumPos( q1->results().first()->albumpos() );
q->setDiscNumber( q1->discnumber() );
result << q;
}
}
foreach ( const query_ptr& q, result )
{
tDebug() << q->albumpos() << q->track();
}
return result;
}

View File

@ -26,6 +26,7 @@
#include "Album.h"
#include "Typedefs.h"
#include "PlaylistInterface.h"
#include "infosystem/InfoSystem.h"
#include "DllMacro.h"
namespace Tomahawk
@ -36,7 +37,7 @@ class DLLEXPORT AlbumPlaylistInterface : public Tomahawk::PlaylistInterface
Q_OBJECT
public:
AlbumPlaylistInterface( Tomahawk::Album *album );
AlbumPlaylistInterface( Tomahawk::Album* album, Tomahawk::ModelMode mode, const Tomahawk::collection_ptr& collection );
virtual ~AlbumPlaylistInterface();
QList<Tomahawk::query_ptr> tracks();
@ -57,8 +58,6 @@ public:
virtual void setFilter( const QString& /*pattern*/ ) {}
virtual void addQueries( const QList<Tomahawk::query_ptr>& tracks );
signals:
void repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode );
void shuffleModeChanged( bool enabled );
@ -68,12 +67,26 @@ signals:
void nextTrackReady();
void tracksLoaded( Tomahawk::ModelMode mode, const Tomahawk::collection_ptr& collection );
private slots:
void onTracksLoaded( const QList< Tomahawk::query_ptr >& tracks );
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
private:
AlbumPlaylistInterface();
QList<Tomahawk::query_ptr> filterTracks( const QList<Tomahawk::query_ptr>& queries );
QList< Tomahawk::query_ptr > m_queries;
result_ptr m_currentItem;
unsigned int m_currentTrack;
bool m_infoSystemLoaded;
bool m_databaseLoaded;
Tomahawk::ModelMode m_mode;
Tomahawk::collection_ptr m_collection;
QWeakPointer< Tomahawk::Album > m_album;
};

View File

@ -121,4 +121,6 @@ private:
} // ns
Q_DECLARE_METATYPE( Tomahawk::artist_ptr )
#endif

View File

@ -254,12 +254,6 @@ set( libSources
infosystem/InfoSystemCache.cpp
infosystem/InfoSystemWorker.cpp
infosystem/infoplugins/generic/NewReleasesPlugin.cpp
infosystem/infoplugins/generic/spotifyPlugin.cpp
infosystem/infoplugins/generic/MusixMatchPlugin.cpp
infosystem/infoplugins/generic/musicbrainzPlugin.cpp
infosystem/infoplugins/generic/RoviPlugin.cpp
network/BufferIoDevice.cpp
network/MsgProcessor.cpp
network/StreamConnection.cpp
@ -346,19 +340,6 @@ IF(LIBATTICA_FOUND)
ENDIF(LIBATTICA_FOUND)
IF( UNIX AND NOT APPLE )
LIST(APPEND libGuiSources
infosystem/infoplugins/unix/MprisPluginRootAdaptor.cpp
infosystem/infoplugins/unix/MprisPluginPlayerAdaptor.cpp
infosystem/infoplugins/unix/MprisPlugin.cpp
infosystem/infoplugins/unix/FdoNotifyPlugin.cpp
infosystem/infoplugins/unix/ImageConverter.cpp )
LIST(APPEND libGuiHeaders
infosystem/infoplugins/unix/MprisPluginRootAdaptor.h
infosystem/infoplugins/unix/MprisPluginPlayerAdaptor.h
infosystem/infoplugins/unix/MprisPlugin.h
infosystem/infoplugins/unix/FdoNotifyPlugin.h )
IF( BUILD_GUI AND X11_FOUND )
INCLUDE_DIRECTORIES( ${THIRDPARTY_DIR}/libqnetwm )
SET( libSources ${libSources} ${THIRDPARTY_DIR}/libqnetwm/libqnetwm/netwm.cpp )
@ -388,8 +369,6 @@ IF( APPLE )
MARK_AS_ADVANCED( COREAUDIO_LIBRARY COREFOUNDATION_LIBRARY FOUNDATION_LIBRARY SCRIPTINGBRIDGE_LIBRARY )
SET( libSources ${libSources}
infosystem/infoplugins/mac/Adium.mm
infosystem/infoplugins/mac/AdiumPlugin.cpp
utils/TomahawkUtils_Mac.mm
mac/FileHelpers.mm
thirdparty/Qocoa/qsearchfield_mac.mm )

View File

@ -855,7 +855,7 @@ DropJob::getArtist( const QString &artist )
QList< query_ptr >
DropJob::getAlbum(const QString &artist, const QString &album)
DropJob::getAlbum( const QString& artist, const QString& album )
{
artist_ptr artistPtr = Artist::get( artist );
album_ptr albumPtr = Album::get( artistPtr, album );
@ -863,7 +863,8 @@ DropJob::getAlbum(const QString &artist, const QString &album)
if ( albumPtr.isNull() )
return QList< query_ptr >();
if ( albumPtr->playlistInterface()->tracks().isEmpty() )
//FIXME: should check tracksLoaded()
if ( albumPtr->playlistInterface( Mixed )->tracks().isEmpty() )
{
// For albums that don't exist until this moment, we are the main shared pointer holding on.
// fetching the tracks is asynchronous, so the resulting signal is queued. when we go out of scope we delete
@ -871,7 +872,7 @@ DropJob::getAlbum(const QString &artist, const QString &album)
m_albumsToKeep.insert( albumPtr );
m_dropJob = new DropJobNotifier( QPixmap( RESPATH "images/album-icon.png" ), Album );
connect( albumPtr.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr> ) ),
connect( albumPtr.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ),
SLOT( tracksFromDB( QList<Tomahawk::query_ptr> ) ) );
JobStatusView::instance()->model()->addJob( m_dropJob );
@ -879,7 +880,7 @@ DropJob::getAlbum(const QString &artist, const QString &album)
return QList< query_ptr >();
}
else
return albumPtr->playlistInterface()->tracks();
return albumPtr->playlistInterface( Mixed )->tracks();
}

View File

@ -239,12 +239,12 @@ ViewManager::show( const Tomahawk::artist_ptr& artist )
Tomahawk::ViewPage*
ViewManager::show( const Tomahawk::album_ptr& album, Tomahawk::ModelMode initialMode )
ViewManager::show( const Tomahawk::album_ptr& album )
{
AlbumInfoWidget* swidget;
if ( !m_albumViews.contains( album ) || m_albumViews.value( album ).isNull() )
{
swidget = new AlbumInfoWidget( album, initialMode );
swidget = new AlbumInfoWidget( album );
m_albumViews.insert( album, swidget );
}
else

View File

@ -151,7 +151,7 @@ public slots:
Tomahawk::ViewPage* show( const Tomahawk::playlist_ptr& playlist );
Tomahawk::ViewPage* show( const Tomahawk::dynplaylist_ptr& playlist );
Tomahawk::ViewPage* show( const Tomahawk::artist_ptr& artist );
Tomahawk::ViewPage* show( const Tomahawk::album_ptr& album, Tomahawk::ModelMode withInitialMode = Tomahawk::InfoSystemMode );
Tomahawk::ViewPage* show( const Tomahawk::album_ptr& album );
Tomahawk::ViewPage* show( const Tomahawk::query_ptr& query );
Tomahawk::ViewPage* show( const Tomahawk::collection_ptr& collection );
Tomahawk::ViewPage* show( const Tomahawk::source_ptr& source );

View File

@ -576,6 +576,55 @@ AudioEngine::playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk:
}
void
AudioEngine::playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk::query_ptr& query )
{
tDebug() << query->toString();
if ( !query.isNull() && query->numResults() )
playItem( playlist, query->results().first() );
}
void
AudioEngine::playItem( const Tomahawk::artist_ptr& artist )
{
if ( artist->playlistInterface()->trackCount() )
{
playItem( artist->playlistInterface(), artist->playlistInterface()->tracks().first() );
}
else
{
_detail::Closure* closure = NewClosure( artist.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr> ) ), const_cast<AudioEngine*>(this), SLOT( playItem( Tomahawk::artist_ptr ) ), artist );
artist->playlistInterface()->tracks();
}
}
void
AudioEngine::playItem( const Tomahawk::album_ptr& album )
{
playlistinterface_ptr pli = album->playlistInterface( Mixed );
if ( pli->trackCount() )
{
if ( pli->tracks().first()->resolvingFinished() )
{
playItem( pli, pli->tracks().first() );
}
else
{
_detail::Closure* closure = NewClosure( pli->tracks().first().data(), SIGNAL( resolvingFinished( bool ) ),
const_cast<AudioEngine*>(this), SLOT( playItem( Tomahawk::album_ptr ) ), album );
}
}
else
{
_detail::Closure* closure = NewClosure( album.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ),
const_cast<AudioEngine*>(this), SLOT( playItem( Tomahawk::album_ptr ) ), album );
pli->tracks();
}
}
void
AudioEngine::onPlaylistNextTrackReady()
{

View File

@ -93,6 +93,9 @@ public slots:
void mute();
void playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk::result_ptr& result );
void playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk::query_ptr& query );
void playItem( const Tomahawk::artist_ptr& artist );
void playItem( const Tomahawk::album_ptr& album );
void setPlaylist( Tomahawk::playlistinterface_ptr playlist );
void setQueue( Tomahawk::playlistinterface_ptr queue ) { m_queue = queue; }

View File

@ -163,8 +163,6 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
ql << qry;
}
qDebug() << Q_FUNC_INFO << ql.length();
emit tracks( ql, data() );
emit done( m_collection );
}

View File

@ -54,6 +54,7 @@ InfoBar::InfoBar( QWidget* parent )
ui->captionLabel->setElideMode( Qt::ElideRight );
boldFont.setPixelSize( 12 );
boldFont.setBold( false );
ui->descriptionLabel->setFont( boldFont );
QFont regFont = ui->longDescriptionLabel->font();

View File

@ -29,25 +29,10 @@
#include "HeadlessCheck.h"
#include "InfoSystemWorker.h"
#include "InfoSystemCache.h"
#include "infoplugins/generic/echonest/EchonestPlugin.h"
#include "infoplugins/generic/MusixMatchPlugin.h"
#include "infoplugins/generic/NewReleasesPlugin.h"
#include "infoplugins/generic/spotifyPlugin.h"
#include "infoplugins/generic/musicbrainzPlugin.h"
#include "GlobalActionManager.h"
#include "utils/TomahawkUtils.h"
#include "utils/Logger.h"
#ifdef Q_WS_MAC
#include "infoplugins/mac/AdiumPlugin.h"
#endif
#ifdef Q_WS_X11
#include "infoplugins/unix/FdoNotifyPlugin.h"
#include "infoplugins/unix/MprisPlugin.h"
#endif
#include "infoplugins/generic/RoviPlugin.h"
namespace Tomahawk
{
@ -86,24 +71,6 @@ InfoSystemWorker::init( Tomahawk::InfoSystem::InfoSystemCache* cache )
m_cache = cache;
loadInfoPlugins( findInfoPlugins() );
#ifndef ENABLE_HEADLESS
addInfoPlugin( InfoPluginPtr( new MusixMatchPlugin() ) );
addInfoPlugin( InfoPluginPtr( new MusicBrainzPlugin() ) );
addInfoPlugin( InfoPluginPtr( new NewReleasesPlugin() ) );
addInfoPlugin( InfoPluginPtr( new RoviPlugin() ) );
addInfoPlugin( InfoPluginPtr( new SpotifyPlugin() ) );
#endif
#ifdef Q_WS_MAC
addInfoPlugin( InfoPluginPtr( new AdiumPlugin() ) );
#endif
#ifndef ENABLE_HEADLESS
#ifdef Q_WS_X11
addInfoPlugin( InfoPluginPtr( new FdoNotifyPlugin() ) );
addInfoPlugin( InfoPluginPtr( new MprisPlugin() ) );
#endif
#endif
}

View File

@ -165,6 +165,12 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
painter->setOpacity( 0.5 );
painter->drawRect( r );
painter->setOpacity( 1.0 );
QPixmap playButton = QPixmap( RESPATH "images/play-rest.png" );
int delta = ( r.width() - playButton.width() ) / 2;
m_playButtonRect = r.adjusted( delta, delta, -delta, -delta );
painter->drawPixmap( m_playButtonRect, playButton );
painter->restore();
}
@ -189,14 +195,16 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
boldFont.setPixelSize( 14 );
QRect textRect = option.rect.adjusted( 6, option.rect.height() - 36, -4, -6 );
painter->setFont( font );
int bottomHeight = painter->fontMetrics().boundingRect( bottom ).height();
painter->setFont( boldFont );
int topHeight = painter->fontMetrics().boundingRect( top ).height();
bool oneLiner = false;
if ( bottom.isEmpty() )
oneLiner = true;
else
oneLiner = ( textRect.height() / 2 < painter->fontMetrics().boundingRect( top ).height() ||
textRect.height() / 2 < painter->fontMetrics().boundingRect( bottom ).height() );
oneLiner = ( textRect.height() < topHeight + bottomHeight );
if ( oneLiner )
{
@ -257,9 +265,27 @@ AlbumItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const
if ( event->type() == QEvent::MouseMove )
m_hoverIndex = index;
QMouseEvent* ev = static_cast< QMouseEvent* >( event );
if ( event->type() == QEvent::MouseButtonRelease )
{
if ( m_playButtonRect.contains( ev->pos() ) )
{
AlbumItem* item = m_model->sourceModel()->itemFromIndex( m_model->mapToSource( index ) );
if ( !item->query().isNull() )
AudioEngine::instance()->playItem( Tomahawk::playlistinterface_ptr(), item->query() );
else if ( !item->album().isNull() )
AudioEngine::instance()->playItem( item->album() );
else if ( !item->artist().isNull() )
AudioEngine::instance()->playItem( item->artist() );
event->accept();
return true;
}
}
if ( m_artistNameRects.contains( index ) )
{
QMouseEvent* ev = static_cast< QMouseEvent* >( event );
QRect artistNameRect = m_artistNameRects[ index ];
if ( artistNameRect.contains( ev->pos() ) )
{

View File

@ -62,6 +62,7 @@ private:
QPersistentModelIndex m_hoveringOver;
QPersistentModelIndex m_hoverIndex;
mutable QRect m_playButtonRect;
QPixmap m_shadowPixmap;
};

View File

@ -57,11 +57,13 @@ AlbumView::AlbumView( QWidget* parent )
setSpacing( 0 );
setContentsMargins( 0, 0, 0, 0 );
setMouseTracking( true );
setStyleSheet( "QListView { background-color: #323435; }" );
setResizeMode( Adjust );
setViewMode( IconMode );
setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
setAutoFitItems( true );
setProxyModel( new AlbumProxyModel( this ) );
@ -179,10 +181,13 @@ AlbumView::paintEvent( QPaintEvent* event )
void
AlbumView::resizeEvent( QResizeEvent* event )
{
QListView::resizeEvent( event );
if ( autoFitItems() )
{
#ifdef Q_WS_X11
int scrollbar = verticalScrollBar()->isVisible() ? verticalScrollBar()->width() + 16 : 0;
// int scrollbar = verticalScrollBar()->isVisible() ? verticalScrollBar()->width() + 16 : 0;
int scrollbar = 0; verticalScrollBar()->rect().width();
#else
int scrollbar = verticalScrollBar()->rect().width();
#endif
@ -205,8 +210,6 @@ AlbumView::resizeEvent( QResizeEvent* event )
repaint();
}
}
QListView::resizeEvent( event );
}

View File

@ -84,6 +84,8 @@ private slots:
void onFilterChanged( const QString& filter );
private:
void adjustItemSize( const QRect& rect );
AlbumModel* m_model;
AlbumProxyModel* m_proxyModel;
AlbumItemDelegate* m_delegate;
@ -92,6 +94,8 @@ private:
bool m_inited;
bool m_autoFitItems;
QRect m_paintRect;
};
#endif // ALBUMVIEW_H

View File

@ -94,7 +94,7 @@ ArtistView::ArtistView( QWidget* parent )
ArtistView::~ArtistView()
{
qDebug() << Q_FUNC_INFO;
tDebug() << Q_FUNC_INFO;
}
@ -224,7 +224,7 @@ ArtistView::onItemActivated( const QModelIndex& index )
if ( !item->artist().isNull() )
ViewManager::instance()->show( item->artist() );
else if ( !item->album().isNull() )
ViewManager::instance()->show( item->album(), m_model->mode() );
ViewManager::instance()->show( item->album() );
else if ( !item->result().isNull() && item->result()->isOnline() )
{
m_model->setCurrentItem( item->index );

View File

@ -138,7 +138,7 @@ PlaylistModel::append( const Tomahawk::album_ptr& album )
if ( album.isNull() )
return;
connect( album.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr> ) ),
connect( album.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ),
SLOT( append( QList<Tomahawk::query_ptr> ) ) );
if ( rowCount( QModelIndex() ) == 0 )
@ -148,7 +148,7 @@ PlaylistModel::append( const Tomahawk::album_ptr& album )
m_isTemporary = true;
}
append( album->playlistInterface()->tracks() );
append( album->playlistInterface( Mixed )->tracks() );
}

View File

@ -29,6 +29,7 @@
#include "database/DatabaseCommand_AllAlbums.h"
#include "database/DatabaseCommand_AllTracks.h"
#include "database/Database.h"
#include "AlbumPlaylistInterface.h"
#include "utils/TomahawkUtils.h"
#include "utils/Logger.h"
@ -55,6 +56,9 @@ TreeModel::TreeModel( QObject* parent )
TreeModel::~TreeModel()
{
tDebug() << Q_FUNC_INFO;
delete m_rootItem;
}
@ -619,11 +623,15 @@ TreeModel::onAlbumsFound( const QList<Tomahawk::album_ptr>& albums, ModelMode mo
if ( m_mode != mode )
return;
const artist_ptr artist = qobject_cast< Artist* >( sender() )->weakRef().toStrongRef();
disconnect( artist.data(), SIGNAL( albumsAdded( QList<Tomahawk::album_ptr>, Tomahawk::ModelMode ) ),
this, SLOT( onAlbumsFound( QList<Tomahawk::album_ptr>, Tomahawk::ModelMode ) ) );
Artist* artist = qobject_cast< Artist* >( sender() );
if ( !artist )
return;
const QModelIndex parent = indexFromArtist( artist );
const artist_ptr artistp = artist->weakRef().toStrongRef();
disconnect( artist, SIGNAL( albumsAdded( QList<Tomahawk::album_ptr>, Tomahawk::ModelMode ) ),
this, SLOT( onAlbumsFound( QList<Tomahawk::album_ptr>, Tomahawk::ModelMode ) ) );
const QModelIndex parent = indexFromArtist( artistp );
addAlbums( parent, albums );
}
@ -663,40 +671,10 @@ TreeModel::addTracks( const album_ptr& album, const QModelIndex& parent, bool au
{
emit loadingStarted();
QList< QVariant > rows;
rows << parent.row();
rows << parent.parent().row();
connect( album.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ),
SLOT( onTracksFound( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ) );
if ( m_mode == DatabaseMode )
{
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( m_collection );
cmd->setAlbum( album );
cmd->setData( QVariant( rows ) );
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, QVariant ) ),
SLOT( onTracksFound( QList<Tomahawk::query_ptr>, QVariant ) ) );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
}
else if ( m_mode == InfoSystemMode )
{
Tomahawk::InfoSystem::InfoStringHash artistInfo;
artistInfo["artist"] = album->artist()->name();
artistInfo["album"] = album->name();
m_receivedInfoData.removeAll( artistInfo );
Tomahawk::InfoSystem::InfoRequestData requestData;
requestData.caller = m_infoId;
requestData.customData["rows"] = rows;
requestData.customData["refetch"] = autoRefetch;
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( artistInfo );
requestData.type = Tomahawk::InfoSystem::InfoAlbumSongs;
requestData.timeoutMillis = 0;
requestData.allSources = true;
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
}
else
Q_ASSERT( false );
onTracksAdded( album->tracks( m_mode, m_collection ), parent );
}
@ -835,11 +813,14 @@ TreeModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const QModel
void
TreeModel::onTracksFound( const QList<Tomahawk::query_ptr>& tracks, const QVariant& variant )
TreeModel::onTracksFound( const QList<Tomahawk::query_ptr>& tracks, Tomahawk::ModelMode mode, Tomahawk::collection_ptr collection )
{
QList< QVariant > rows = variant.toList();
QModelIndex idx = index( rows.first().toUInt(), 0, index( rows.at( 1 ).toUInt(), 0, QModelIndex() ) );
if ( mode != m_mode || collection != m_collection )
return;
Album* album = qobject_cast<Album*>( sender() );
QModelIndex idx = indexFromAlbum( album->weakRef().toStrongRef() );
onTracksAdded( tracks, idx );
}
@ -977,3 +958,21 @@ TreeModel::indexFromArtist( const Tomahawk::artist_ptr& artist ) const
return QModelIndex();
}
QModelIndex
TreeModel::indexFromAlbum( const Tomahawk::album_ptr& album ) const
{
QModelIndex artistIdx = indexFromArtist( album->artist() );
for ( int i = 0; i < rowCount( artistIdx ); i++ )
{
QModelIndex idx = index( i, 0, artistIdx );
TreeModelItem* item = itemFromIndex( idx );
if ( item && item->album() == album )
{
return idx;
}
}
return QModelIndex();
}

View File

@ -112,6 +112,7 @@ public:
virtual void setIcon( const QPixmap& pixmap ) { m_icon = pixmap; }
QModelIndex indexFromArtist( const Tomahawk::artist_ptr& artist ) const;
QModelIndex indexFromAlbum( const Tomahawk::album_ptr& album ) const;
TreeModelItem* itemFromIndex( const QModelIndex& index ) const
{
if ( index.isValid() )
@ -150,7 +151,7 @@ private slots:
void onArtistsAdded( const QList<Tomahawk::artist_ptr>& artists );
void onAlbumsFound( const QList<Tomahawk::album_ptr>& albums, Tomahawk::ModelMode mode );
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const QModelIndex& index );
void onTracksFound( const QList<Tomahawk::query_ptr>& tracks, const QVariant& variant );
void onTracksFound( const QList<Tomahawk::query_ptr>& tracks, Tomahawk::ModelMode mode, Tomahawk::collection_ptr collection );
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );

View File

@ -39,7 +39,7 @@
using namespace Tomahawk;
AlbumInfoWidget::AlbumInfoWidget( const Tomahawk::album_ptr& album, ModelMode startingMode, QWidget* parent )
AlbumInfoWidget::AlbumInfoWidget( const Tomahawk::album_ptr& album, QWidget* parent )
: QWidget( parent )
, ui( new Ui::AlbumInfoWidget )
, m_infoId( uuid() )
@ -59,29 +59,12 @@ AlbumInfoWidget::AlbumInfoWidget( const Tomahawk::album_ptr& album, ModelMode st
ui->albumsView->setAlbumModel( m_albumsModel );
m_tracksModel = new TreeModel( ui->tracksView );
m_tracksModel->setMode( startingMode );
m_tracksModel->setMode( Mixed );
ui->tracksView->setTreeModel( m_tracksModel );
ui->tracksView->setRootIsDecorated( false );
m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultAlbumCover, TomahawkUtils::ScaledCover, QSize( 48, 48 ) );
m_button = new OverlayButton( ui->tracksView );
m_button->setCheckable( true );
m_button->setChecked( m_tracksModel->mode() == InfoSystemMode );
if ( m_button->isChecked() )
m_button->setText( tr( "Click to show SuperCollection Tracks" ) );
else
m_button->setText( tr( "Click to show Official Tracks" ) );
m_buttonAlbums = new OverlayButton( ui->albumsView );
m_buttonAlbums->setCheckable( true );
m_buttonAlbums->setChecked( true );
m_buttonAlbums->setText( tr( "Click to show SuperCollection Albums" ) );
m_buttonAlbums->show();
connect( m_button, SIGNAL( clicked() ), SLOT( onModeToggle() ) );
connect( m_buttonAlbums, SIGNAL( clicked() ), SLOT( onAlbumsModeToggle() ) );
connect( m_tracksModel, SIGNAL( modeChanged( Tomahawk::ModelMode ) ), SLOT( setMode( Tomahawk::ModelMode ) ) );
connect( m_tracksModel, SIGNAL( loadingStarted() ), SLOT( onLoadingStarted() ) );
connect( m_tracksModel, SIGNAL( loadingFinished() ), SLOT( onLoadingFinished() ) );
@ -102,54 +85,15 @@ AlbumInfoWidget::playlistInterface() const
}
void
AlbumInfoWidget::setMode( ModelMode mode )
{
m_button->setChecked( mode == InfoSystemMode );
if ( m_tracksModel->mode() != mode )
onModeToggle();
if ( mode == InfoSystemMode )
m_button->setText( tr( "Click to show SuperCollection Tracks" ) );
else
m_button->setText( tr( "Click to show Official Tracks" ) );
}
void
AlbumInfoWidget::onModeToggle()
{
m_tracksModel->setMode( m_button->isChecked() ? InfoSystemMode : DatabaseMode );
m_tracksModel->addTracks( m_album, QModelIndex() );
}
void
AlbumInfoWidget::onAlbumsModeToggle()
{
if ( m_buttonAlbums->isChecked() )
m_buttonAlbums->setText( tr( "Click to show SuperCollection Albums" ) );
else
m_buttonAlbums->setText( tr( "Click to show Official Albums" ) );
loadAlbums();
}
void
AlbumInfoWidget::onLoadingStarted()
{
m_button->setEnabled( false );
m_button->hide();
}
void
AlbumInfoWidget::onLoadingFinished()
{
m_button->setEnabled( true );
m_button->show();
}
@ -216,8 +160,7 @@ AlbumInfoWidget::loadAlbums( bool autoRefetch )
connect( m_album->artist().data(), SIGNAL( albumsAdded( QList<Tomahawk::album_ptr>, Tomahawk::ModelMode ) ),
SLOT( gotAlbums( QList<Tomahawk::album_ptr> ) ) );
ModelMode mode = m_buttonAlbums->isChecked() ? InfoSystemMode : DatabaseMode;
gotAlbums( m_album->artist()->albums( mode ) );
gotAlbums( m_album->artist()->albums( Mixed ) );
/* tDebug() << "Auto refetching";
m_buttonAlbums->setChecked( false );

View File

@ -53,7 +53,7 @@ class DLLEXPORT AlbumInfoWidget : public QWidget, public Tomahawk::ViewPage
Q_OBJECT
public:
AlbumInfoWidget( const Tomahawk::album_ptr& album, Tomahawk::ModelMode startingMode = Tomahawk::InfoSystemMode, QWidget* parent = 0 );
AlbumInfoWidget( const Tomahawk::album_ptr& album, QWidget* parent = 0 );
~AlbumInfoWidget();
virtual QWidget* widget() { return this; }
@ -73,8 +73,6 @@ public:
virtual bool isBeingPlayed() const;
public slots:
void setMode( Tomahawk::ModelMode mode );
/** \brief Loads information for a given album.
* \param album The album that you want to load information for.
*
@ -98,23 +96,17 @@ private slots:
void gotAlbums( const QList<Tomahawk::album_ptr>& albums );
void onAlbumCoverUpdated();
void onModeToggle();
void onAlbumsModeToggle();
void onLoadingStarted();
void onLoadingFinished();
private:
Ui::AlbumInfoWidget *ui;
Ui::AlbumInfoWidget* ui;
Tomahawk::album_ptr m_album;
AlbumModel* m_albumsModel;
TreeModel* m_tracksModel;
OverlayButton* m_button;
OverlayButton* m_buttonAlbums;
QString m_title;
QString m_description;
QString m_longDescription;

View File

@ -65,14 +65,13 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
TomahawkUtils::unmarginLayout( ui->layoutWidget2->layout() );
TomahawkUtils::unmarginLayout( ui->albumHeader->layout() );
m_albumsModel = new TreeModel( ui->albums );
m_albumsModel->setMode( InfoSystemMode );
ui->albums->setTreeModel( m_albumsModel );
m_albumsModel = new AlbumModel( ui->albums );
ui->albums->setAlbumModel( m_albumsModel );
m_relatedModel = new TreeModel( ui->relatedArtists );
m_relatedModel->setColumnStyle( TreeModel::TrackOnly );
ui->relatedArtists->setTreeModel( m_relatedModel );
ui->relatedArtists->setSortingEnabled( false );
m_relatedModel = new AlbumModel( ui->relatedArtists );
// m_relatedModel->setColumnStyle( TreeModel::TrackOnly );
ui->relatedArtists->setAlbumModel( m_relatedModel );
// ui->relatedArtists->setSortingEnabled( false );
ui->relatedArtists->proxyModel()->sort( -1 );
m_topHitsModel = new PlaylistModel( ui->topHits );
@ -82,13 +81,6 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultArtistImage, TomahawkUtils::ScaledCover, QSize( 48, 48 ) );
m_button = new OverlayButton( ui->albums );
m_button->setText( tr( "Click to show SuperCollection Albums" ) );
m_button->setCheckable( true );
m_button->setChecked( true );
connect( m_button, SIGNAL( clicked() ), SLOT( onModeToggle() ) );
connect( m_albumsModel, SIGNAL( modeChanged( Tomahawk::ModelMode ) ), SLOT( setMode( Tomahawk::ModelMode ) ) );
connect( m_albumsModel, SIGNAL( loadingStarted() ), SLOT( onLoadingStarted() ) );
connect( m_albumsModel, SIGNAL( loadingFinished() ), SLOT( onLoadingFinished() ) );
@ -113,42 +105,15 @@ ArtistInfoWidget::playlistInterface() const
}
void
ArtistInfoWidget::setMode( ModelMode mode )
{
m_button->setChecked( mode == InfoSystemMode );
if ( m_albumsModel->mode() != mode )
onModeToggle();
if ( mode == InfoSystemMode )
m_button->setText( tr( "Click to show SuperCollection Albums" ) );
else
m_button->setText( tr( "Click to show Official Albums" ) );
}
void
ArtistInfoWidget::onModeToggle()
{
m_albumsModel->setMode( m_button->isChecked() ? InfoSystemMode : DatabaseMode );
m_albumsModel->fetchAlbums( m_artist );
}
void
ArtistInfoWidget::onLoadingStarted()
{
m_button->setEnabled( false );
m_button->hide();
}
void
ArtistInfoWidget::onLoadingFinished()
{
m_button->setEnabled( true );
m_button->show();
}
@ -192,8 +157,11 @@ ArtistInfoWidget::load( const artist_ptr& artist )
m_artist = artist;
m_title = artist->name();
m_albumsModel->fetchAlbums( artist );
connect( artist.data(), SIGNAL( albumsAdded( QList<Tomahawk::album_ptr>, Tomahawk::ModelMode ) ),
SLOT( onAlbumsFound( QList<Tomahawk::album_ptr>, Tomahawk::ModelMode ) ) );
onAlbumsFound( artist->albums( Mixed ), Mixed );
Tomahawk::InfoSystem::InfoStringHash artistInfo;
artistInfo["artist"] = artist->name();
@ -224,6 +192,7 @@ ArtistInfoWidget::load( const artist_ptr& artist )
void
ArtistInfoWidget::onAlbumsFound( const QList<Tomahawk::album_ptr>& albums, ModelMode mode )
{
m_albumsModel->addAlbums( albums );
}
@ -284,10 +253,12 @@ ArtistInfoWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestD
case InfoSystem::InfoArtistSimilars:
{
const QStringList artists = returnedData["artists"].toStringList();
QList<artist_ptr> al;
foreach ( const QString& artist, artists )
{
m_relatedModel->addArtists( Artist::get( artist ) );
al << Artist::get( artist );
}
m_relatedModel->addArtists( al );
break;
}

View File

@ -39,8 +39,8 @@
#include "DllMacro.h"
class AlbumModel;
class PlaylistModel;
class TreeModel;
class OverlayButton;
namespace Ui
@ -91,14 +91,11 @@ protected:
void changeEvent( QEvent* e );
private slots:
void setMode( Tomahawk::ModelMode mode );
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
void onArtistImageUpdated();
void onAlbumsFound( const QList<Tomahawk::album_ptr>& albums, Tomahawk::ModelMode mode );
void onModeToggle();
void onLoadingStarted();
void onLoadingFinished();
@ -107,13 +104,11 @@ private:
Tomahawk::artist_ptr m_artist;
TreeModel* m_relatedModel;
TreeModel* m_albumsModel;
AlbumModel* m_relatedModel;
AlbumModel* m_albumsModel;
PlaylistModel* m_topHitsModel;
Tomahawk::playlistinterface_ptr m_plInterface;
OverlayButton* m_button;
QString m_title;
QString m_description;
QString m_longDescription;

View File

@ -57,10 +57,7 @@
</widget>
</item>
<item>
<widget class="ArtistView" name="relatedArtists">
<property name="headerHidden">
<bool>true</bool>
</property>
<widget class="AlbumView" name="relatedArtists">
</widget>
</item>
</layout>
@ -82,7 +79,7 @@
</widget>
</item>
<item>
<widget class="ArtistView" name="albums"/>
<widget class="AlbumView" name="albums"/>
</item>
</layout>
</widget>
@ -116,6 +113,11 @@
<extends>QTreeView</extends>
<header location="global">ArtistView.h</header>
</customwidget>
<customwidget>
<class>AlbumView</class>
<extends>QListView</extends>
<header location="global">AlbumView.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@ -37,17 +37,24 @@ TrackInfoWidget::TrackInfoWidget( const Tomahawk::query_ptr& query, QWidget* par
, m_infoId( uuid() )
{
ui->setupUi( this );
QPalette pal = palette();
pal.setColor( QPalette::Window, QColor( "#323435" ) );
setPalette( pal );
setAutoFillBackground( true );
layout()->setSpacing( 0 );
ui->headerWidget->setStyleSheet( "QWidget#headerWidget { background-image: url(" RESPATH "images/playlist-header-tiled.png); }" );
ui->tracksWidget->setStyleSheet( "QWidget#tracksWidget{background-color: #323435;}" );
// ui->headerWidget->setStyleSheet( "QWidget#headerWidget { background-image: url(" RESPATH "images/playlist-header-tiled.png); }" );
// ui->headerWidget->setStyleSheet( "background-color: #323435;" );
// ui->tracksWidget->setStyleSheet( "background-color: #323435;" );
ui->statsLabel->setStyleSheet( "QLabel { background-image:url(); border: 2px solid #dddddd; background-color: #faf9f9; border-radius: 4px; padding: 12px; }" );
QFont f = font();
f.setBold( true );
f.setPixelSize( 18 );
ui->trackLabel->setFont( f );
ui->similarTracksLabel->setFont( f );
// ui->similarTracksLabel->setFont( f );
f.setPixelSize( 14 );
ui->artistLabel->setFont( f );
@ -60,7 +67,7 @@ TrackInfoWidget::TrackInfoWidget( const Tomahawk::query_ptr& query, QWidget* par
ui->similarTracksView->setFrameShape( QFrame::NoFrame );
ui->similarTracksView->setAttribute( Qt::WA_MacShowFocusRect, 0 );
ui->similarTracksView->setStyleSheet( "QListView { background-color: transparent; } QListView::item { background-color: transparent; }" );
// ui->similarTracksView->setStyleSheet( "QListView { background-color: transparent; } QListView::item { background-color: transparent; }" );
QPalette p = ui->trackLabel->palette();
p.setColor( QPalette::Foreground, Qt::white );
@ -69,6 +76,7 @@ TrackInfoWidget::TrackInfoWidget( const Tomahawk::query_ptr& query, QWidget* par
ui->albumLabel->setPalette( p );
ui->byLabel->setPalette( p );
ui->fromLabel->setPalette( p );
// ui->similarTracksLabel->setPalette( p );
m_albumsModel = new AlbumModel( ui->similarTracksView );
ui->similarTracksView->setAlbumModel( m_albumsModel );

View File

@ -165,8 +165,23 @@
<item>
<widget class="QWidget" name="tracksWidget" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="similarTracksLabel">
<widget class="HeaderLabel" name="similarTracksLabel">
<property name="text">
<string>Similar Tracks</string>
</property>
@ -196,6 +211,11 @@
<extends>QListView</extends>
<header>playlist/AlbumView.h</header>
</customwidget>
<customwidget>
<class>HeaderLabel</class>
<extends>QLabel</extends>
<header>widgets/HeaderLabel.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>