QPixmap SvgHandler::imageWithBorder( Meta::AlbumPtr album, int size, int borderWidth ) { const int imageSize = size - ( borderWidth * 2 ); const QString &loc = album->imageLocation( imageSize ).url(); const QString &key = !loc.isEmpty() ? loc : album->name(); return addBordersToPixmap( The::coverCache()->getCover( album, imageSize ), borderWidth, key ); }
void ScrobblerAdapter::copyTrackMetadata( lastfm::MutableTrack &to, const Meta::TrackPtr &track ) { to.setTitle( track->name() ); QString artistOrComposer; Meta::ComposerPtr composer = track->composer(); if( m_config->scrobbleComposer() && composer ) artistOrComposer = composer->name(); Meta::ArtistPtr artist = track->artist(); if( artistOrComposer.isEmpty() && artist ) artistOrComposer = artist->name(); to.setArtist( artistOrComposer ); Meta::AlbumPtr album = track->album(); Meta::ArtistPtr albumArtist; if( album ) { to.setAlbum( album->name() ); albumArtist = album->hasAlbumArtist() ? album->albumArtist() : Meta::ArtistPtr(); } if( albumArtist ) to.setAlbumArtist( albumArtist->name() ); to.setDuration( track->length() / 1000 ); if( track->trackNumber() >= 0 ) to.setTrackNumber( track->trackNumber() ); lastfm::Track::Source source = lastfm::Track::Player; if( track->type() == "stream/lastfm" ) source = lastfm::Track::LastFmRadio; else if( track->type().startsWith( "stream" ) ) source = lastfm::Track::NonPersonalisedBroadcast; else if( track->collection() && track->collection()->collectionId() != "localCollection" ) source = lastfm::Track::MediaDevice; to.setSource( source ); }
foreach( Meta::AlbumPtr album, albums ) { m_albums << album->name(); }
void CurrentTrack::setupLayoutActions( Meta::TrackPtr track ) { if( !track ) return; PERF_LOG( "Begin actions layout setup" ); //first, add any global CurrentTrackActions (iow, actions that are shown for all tracks) QList<QAction *> actions = The::globalCurrentTrackActions()->actions(); using namespace Capabilities; QScopedPointer<ActionsCapability> ac( track->create<ActionsCapability>() ); if( ac ) { QList<QAction*> trackActions = ac->actions(); // ensure that the actions get deleted afterwards foreach( QAction* action, trackActions ) { if( !action->parent() ) action->setParent( this ); actions << action; } } QScopedPointer<BookmarkThisCapability> btc( track->create<BookmarkThisCapability>() ); if( btc && btc->bookmarkAction() ) { actions << btc->bookmarkAction(); } if( m_showEditTrackDetailsAction && track->editor() ) { QAction *editAction = new QAction( KIcon("media-track-edit-amarok"), i18n("Edit Track Details"), this ); connect( editAction, SIGNAL(triggered()), SLOT(editTrack()) ); m_customActions << editAction; } if( track->has<FindInSourceCapability>() ) { if( !m_findInSourceSignalMapper ) { m_findInSourceSignalMapper = new QSignalMapper( this ); connect( m_findInSourceSignalMapper, SIGNAL(mapped(QString)), SLOT(findInSource(QString)) ); } Meta::AlbumPtr album = track->album(); Meta::ArtistPtr artist = track->artist(); Meta::ComposerPtr composer = track->composer(); Meta::GenrePtr genre = track->genre(); Meta::YearPtr year = track->year(); QAction *act( 0 ); if( album && !album->name().isEmpty() ) { act = new QAction( KIcon("current-track-amarok"), i18n("Show Album in Media Sources"), this ); connect( act, SIGNAL(triggered()), m_findInSourceSignalMapper, SLOT(map()) ); m_findInSourceSignalMapper->setMapping( act, QLatin1String("album") ); m_customActions << act; } if( artist && !artist->name().isEmpty() ) { act = new QAction( KIcon("filename-artist-amarok"), i18n("Show Artist in Media Sources"), this ); connect( act, SIGNAL(triggered()), m_findInSourceSignalMapper, SLOT(map()) ); m_findInSourceSignalMapper->setMapping( act, QLatin1String("artist") ); m_customActions << act; KPluginInfo::List services = The::pluginManager()->plugins( QLatin1String("Service") ); foreach( const KPluginInfo &service, services ) { if( service.pluginName() == QLatin1String("amarok_service_amazonstore") ) { if( service.isPluginEnabled() ) { act = new QAction( KIcon("view-services-amazon-amarok"), i18n("Search for Artist in the MP3 Music Store"), this ); connect( act, SIGNAL(triggered()), this, SLOT(findInStore()) ); m_customActions << act; } break; } } } if( composer && !composer->name().isEmpty() && (composer->name() != i18n("Unknown Composer")) ) { act = new QAction( KIcon("filename-composer-amarok"), i18n("Show Composer in Media Sources"), this ); connect( act, SIGNAL(triggered()), m_findInSourceSignalMapper, SLOT(map()) ); m_findInSourceSignalMapper->setMapping( act, QLatin1String("composer") ); m_customActions << act; } if( genre && !genre->name().isEmpty() ) { act = new QAction( KIcon("filename-genre-amarok"), i18n("Show Genre in Media Sources"), this ); connect( act, SIGNAL(triggered()), m_findInSourceSignalMapper, SLOT(map()) ); m_findInSourceSignalMapper->setMapping( act, QLatin1String("genre") ); m_customActions << act; } if( year && !year->name().isEmpty() ) { act = new QAction( KIcon("filename-year-amarok"), i18n("Show Year in Media Sources"), this ); connect( act, SIGNAL(triggered()), m_findInSourceSignalMapper, SLOT(map()) ); m_findInSourceSignalMapper->setMapping( act, QLatin1String("year") ); m_customActions << act; } }