ScrobblesListWidget::ScrobblesListWidget( QWidget* parent ) :QListWidget( parent ), m_trackItem( 0 ) { setVerticalScrollMode( QAbstractItemView::ScrollPerPixel ); #ifdef Q_OS_MAC connect( verticalScrollBar(), SIGNAL(valueChanged(int)), SLOT(scroll()) ); #endif setAttribute( Qt::WA_MacNoClickThrough ); setAttribute( Qt::WA_MacShowFocusRect, false ); setUniformItemSizes( false ); setSortingEnabled( false ); setSelectionMode( QAbstractItemView::NoSelection ); setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); connect( qApp, SIGNAL( sessionChanged(unicorn::Session)), SLOT(onSessionChanged(unicorn::Session))); connect( &ScrobbleService::instance(), SIGNAL(scrobblesCached(QList<lastfm::Track>)), SLOT(onScrobblesSubmitted(QList<lastfm::Track>) ) ); connect( &ScrobbleService::instance(), SIGNAL(scrobblesSubmitted(QList<lastfm::Track>)), SLOT(onScrobblesSubmitted(QList<lastfm::Track>) ) ); connect( &ScrobbleService::instance(), SIGNAL(trackStarted(lastfm::Track,lastfm::Track)), SLOT(onTrackStarted(lastfm::Track,lastfm::Track))); connect( &ScrobbleService::instance(), SIGNAL(paused()), SLOT(onPaused())); connect( &ScrobbleService::instance(), SIGNAL(resumed()), SLOT(onResumed())); connect( &ScrobbleService::instance(), SIGNAL(stopped()), SLOT(onStopped())); onSessionChanged( aApp->currentSession() ); }
ScrobblerAdapter::ScrobblerAdapter( const QString &clientId, const LastFmServiceConfigPtr &config ) : m_scrobbler( clientId ) , m_config( config ) { // work around a bug in liblastfm -- -it doesn't create its config dir, so when it // tries to write the track cache, it fails silently. Last check: liblastfm 1.0.! QList<QDir> dirs; dirs << lastfm::dir::runtimeData() << lastfm::dir::cache() << lastfm::dir::logs(); foreach( QDir dir, dirs ) { if( !dir.exists() ) { debug() << "creating" << dir.absolutePath() << "directory for liblastfm"; dir.mkpath( "." ); } } connect( The::mainWindow(), SIGNAL(loveTrack(Meta::TrackPtr)), SLOT(loveTrack(Meta::TrackPtr)) ); connect( The::mainWindow(), SIGNAL(banTrack(Meta::TrackPtr)), SLOT(banTrack(Meta::TrackPtr)) ); connect( &m_scrobbler, SIGNAL(scrobblesSubmitted(QList<lastfm::Track>)), SLOT(slotScrobblesSubmitted(QList<lastfm::Track>)) ); connect( &m_scrobbler, SIGNAL(nowPlayingError(int,QString)), SLOT(slotNowPlayingError(int,QString))); }
void ScrobbleService::resetScrobbler() { /// audioscrobbler if( m_as ) delete m_as; m_as = new Audioscrobbler( "ass" ); connect( m_as, SIGNAL(scrobblesCached(QList<lastfm::Track>)), SIGNAL(scrobblesCached(QList<lastfm::Track>))); connect( m_as, SIGNAL(scrobblesSubmitted(QList<lastfm::Track>)), SIGNAL(scrobblesSubmitted(QList<lastfm::Track>))); /// DeviceScrobbler if( m_deviceScrobbler ) delete m_deviceScrobbler; m_deviceScrobbler = new DeviceScrobbler; connect( m_deviceScrobbler, SIGNAL(foundScrobbles( QList<lastfm::Track>, QString)), this, SIGNAL( foundIPodScrobbles(QList<lastfm::Track>, QString) )); connect( m_deviceScrobbler, SIGNAL(foundScrobbles( QList<lastfm::Track>, QString )), m_as, SLOT( cacheBatch( QList<lastfm::Track>, QString))); m_deviceScrobbler->checkCachedIPodScrobbles(); }