1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 11:20:22 +02:00

* JobStatusView::instance()->model()->addJob() calls will be ignored when ENABLE_HEADLESS is setted.

This commit is contained in:
Lucas Lira Gomes
2012-07-01 17:57:54 -03:00
committed by Dominik Schmidt
parent d8a7669df8
commit 0278f82c2a
12 changed files with 87 additions and 8 deletions

View File

@@ -959,13 +959,15 @@ TomahawkWindow::onXSPFError( XSPFLoader::XSPFErrorCode error )
void void
TomahawkWindow::onAudioEngineError( AudioEngine::AudioErrorCode /* error */ ) TomahawkWindow::onAudioEngineError( AudioEngine::AudioErrorCode /* error */ )
{ {
#ifndef ENABLE_HEADLESS
QString msg; QString msg;
#ifdef Q_WS_X11 #ifdef Q_WS_X11
msg = tr( "Sorry, there is a problem accessing your audio device or the desired track, current track will be skipped. Make sure you have a suitable Phonon backend and required plugins installed." ); msg = tr( "Sorry, there is a problem accessing your audio device or the desired track, current track will be skipped. Make sure you have a suitable Phonon backend and required plugins installed." );
#else #else
msg = tr( "Sorry, there is a problem accessing your audio device or the desired track, current track will be skipped." ); msg = tr( "Sorry, there is a problem accessing your audio device or the desired track, current track will be skipped." );
#endif #endif
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( msg, 15 ) ); JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( msg, 15 ) );
#endif
if ( m_audioRetryCounter < 3 ) if ( m_audioRetryCounter < 3 )
AudioEngine::instance()->play(); AudioEngine::instance()->play();

View File

@@ -754,11 +754,14 @@ DropJob::onTracksAdded( const QList<Tomahawk::query_ptr>& tracksList )
{ {
tDebug() << Q_FUNC_INFO << tracksList.count(); tDebug() << Q_FUNC_INFO << tracksList.count();
#ifndef ENABLE_HEADLESS
/* if ( results.isEmpty() ) /* if ( results.isEmpty() )
{ {
const QString which = album.isEmpty() ? "artist" : "album"; const QString which = album.isEmpty() ? "artist" : "album";
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( tr( "No tracks found for given %1" ).arg( which ), 5 ) ); JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( tr( "No tracks found for given %1" ).arg( which ), 5 ) );
}*/ }*/
#endif
if ( !m_dropJob.isEmpty() ) if ( !m_dropJob.isEmpty() )
{ {
@@ -861,8 +864,10 @@ DropJob::getArtist( const QString &artist, Tomahawk::ModelMode mode )
connect( artistPtr.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ), connect( artistPtr.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ),
SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ) ); SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ) );
#ifndef ENABLE_HEADLESS
m_dropJob << new DropJobNotifier( QPixmap( RESPATH "images/album-icon.png" ), Album ); m_dropJob << new DropJobNotifier( QPixmap( RESPATH "images/album-icon.png" ), Album );
JobStatusView::instance()->model()->addJob( m_dropJob.last() ); JobStatusView::instance()->model()->addJob( m_dropJob.last() );
#endif
m_queryCount++; m_queryCount++;
} }
@@ -891,8 +896,10 @@ DropJob::getAlbum( const QString& artist, const QString& album )
connect( albumPtr.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ), connect( albumPtr.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ),
SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ) ); SLOT( onTracksAdded( QList<Tomahawk::query_ptr> ) ) );
#ifndef ENABLE_HEADLESS
m_dropJob << new DropJobNotifier( QPixmap( RESPATH "images/album-icon.png" ), Album ); m_dropJob << new DropJobNotifier( QPixmap( RESPATH "images/album-icon.png" ), Album );
JobStatusView::instance()->model()->addJob( m_dropJob.last() ); JobStatusView::instance()->model()->addJob( m_dropJob.last() );
#endif
m_queryCount++; m_queryCount++;
} }

View File

@@ -1003,8 +1003,10 @@ SpotifyAccount::resolverMessage( const QString &msgType, const QVariantMap &msg
if ( msg.value( "isDebugMsg" ).toBool() ) if ( msg.value( "isDebugMsg" ).toBool() )
tDebug( LOGVERBOSE ) << "SpotifyResolverError: " << error; tDebug( LOGVERBOSE ) << "SpotifyResolverError: " << error;
#ifndef ENABLE_HEADLESS
else else
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( QString( "Spotify: %1" ).arg( error ) ) ); JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( QString( "Spotify: %1" ).arg( error ) ) );
#endif
} }
else if ( msgType == "userChanged" ) else if ( msgType == "userChanged" )
{ {

View File

@@ -24,11 +24,14 @@
#include "JobStatusModel.h" #include "JobStatusModel.h"
#include "JobStatusItem.h" #include "JobStatusItem.h"
#include "JobStatusDelegate.h" #include "JobStatusDelegate.h"
#include "utils/Logger.h"
#include "Source.h"
#ifndef ENABLE_HEADLESS
#include "PipelineStatusItem.h" #include "PipelineStatusItem.h"
#include "TransferStatusItem.h" #include "TransferStatusItem.h"
#include "LatchedStatusItem.h" #include "LatchedStatusItem.h"
#include "utils/Logger.h" #endif
#include "Source.h"
#include <QHeaderView> #include <QHeaderView>
#include <QVBoxLayout> #include <QVBoxLayout>
@@ -62,9 +65,24 @@ JobStatusView::JobStatusView( AnimatedSplitter* parent )
m_view->setAttribute( Qt::WA_MacShowFocusRect, 0 ); m_view->setAttribute( Qt::WA_MacShowFocusRect, 0 );
m_view->setUniformItemSizes( false ); m_view->setUniformItemSizes( false );
#ifndef ENABLE_HEADLESS
#ifndef Q_WS_WIN
QFont f = font();
f.setPointSize( f.pointSize() - 1 );
setFont( f );
#endif
#ifdef Q_WS_MAC
QFont f = font();
f.setPointSize( f.pointSize() - 2 );
setFont( f );
#endif
new PipelineStatusManager( this ); new PipelineStatusManager( this );
new TransferStatusManager( this ); new TransferStatusManager( this );
new LatchedStatusManager( this ); new LatchedStatusManager( this );
#endif
setMouseTracking( true ); setMouseTracking( true );
m_view->setMouseTracking( true ); m_view->setMouseTracking( true );

View File

@@ -24,6 +24,10 @@
#include "JobStatusModel.h" #include "JobStatusModel.h"
#include "utils/TomahawkUtilsGui.h" #include "utils/TomahawkUtilsGui.h"
#ifndef ENABLE_HEADLESS
#include "JobStatusModel.h"
#include "JobStatusView.h"
#endif
LatchedStatusItem::LatchedStatusItem( const Tomahawk::source_ptr& from, const Tomahawk::source_ptr& to, LatchedStatusManager* parent ) LatchedStatusItem::LatchedStatusItem( const Tomahawk::source_ptr& from, const Tomahawk::source_ptr& to, LatchedStatusManager* parent )
: JobStatusItem() : JobStatusItem()
@@ -76,9 +80,11 @@ LatchedStatusManager::latchedOn( const Tomahawk::source_ptr& from, const Tomahaw
if ( to->isLocal() ) if ( to->isLocal() )
{ {
#ifndef ENABLE_HEADLESS
LatchedStatusItem* item = new LatchedStatusItem( from, to, this ); LatchedStatusItem* item = new LatchedStatusItem( from, to, this );
m_jobs[ from->userName() ] = item; m_jobs[ from->userName() ] = item;
JobStatusView::instance()->model()->addJob( item ); JobStatusView::instance()->model()->addJob( item );
#endif
connect( from.data(), SIGNAL( offline() ), this, SLOT( sourceOffline() ), Qt::UniqueConnection ); connect( from.data(), SIGNAL( offline() ), this, SLOT( sourceOffline() ), Qt::UniqueConnection );
} }

View File

@@ -22,9 +22,13 @@
#include "utils/TomahawkUtilsGui.h" #include "utils/TomahawkUtilsGui.h"
#include "Pipeline.h" #include "Pipeline.h"
#include "TomahawkApp.h"
#include "Source.h"
#ifndef ENABLE_HEADLESS
#include "JobStatusModel.h" #include "JobStatusModel.h"
#include "JobStatusView.h" #include "JobStatusView.h"
#include "Source.h" #endif
PipelineStatusItem::PipelineStatusItem( const Tomahawk::query_ptr& q ) PipelineStatusItem::PipelineStatusItem( const Tomahawk::query_ptr& q )
@@ -98,10 +102,14 @@ PipelineStatusManager::PipelineStatusManager( QObject* parent )
void void
PipelineStatusManager::resolving( const Tomahawk::query_ptr& p ) PipelineStatusManager::resolving( const Tomahawk::query_ptr& p )
{ {
Q_UNUSED( p );
#ifndef ENABLE_HEADLESS
if ( m_curItem.isNull() ) if ( m_curItem.isNull() )
{ {
// No current query item and we're resolving something, so show it // No current query item and we're resolving something, so show it
m_curItem = QPointer< PipelineStatusItem >( new PipelineStatusItem( p ) ); m_curItem = QPointer< PipelineStatusItem >( new PipelineStatusItem( p ) );
JobStatusView::instance()->model()->addJob( m_curItem.data() ); JobStatusView::instance()->model()->addJob( m_curItem.data() );
} }
#endif
} }

View File

@@ -18,8 +18,12 @@
#include "TransferStatusItem.h" #include "TransferStatusItem.h"
#include "JobStatusView.h" #include "JobStatusView.h"
#include "JobStatusModel.h" #include "JobStatusModel.h"
#include "network/StreamConnection.h"
#include "network/Servent.h"
#include "utils/TomahawkUtils.h"
#include "Result.h" #include "Result.h"
#include "Source.h" #include "Source.h"
#include "Artist.h" #include "Artist.h"
@@ -28,6 +32,11 @@
#include "utils/TomahawkUtilsGui.h" #include "utils/TomahawkUtilsGui.h"
#ifndef ENABLE_HEADLESS
#include "JobStatusModel.h"
#include "JobStatusView.h"
#endif
TransferStatusItem::TransferStatusItem( TransferStatusManager* p, StreamConnection* sc ) TransferStatusItem::TransferStatusItem( TransferStatusManager* p, StreamConnection* sc )
: m_parent( p ) : m_parent( p )
, m_stream( QPointer< StreamConnection >( sc ) ) , m_stream( QPointer< StreamConnection >( sc ) )
@@ -104,10 +113,13 @@ TransferStatusManager::TransferStatusManager( QObject* parent )
connect( Servent::instance(), SIGNAL( streamStarted( StreamConnection* ) ), SLOT( streamRegistered( StreamConnection* ) ) ); connect( Servent::instance(), SIGNAL( streamStarted( StreamConnection* ) ), SLOT( streamRegistered( StreamConnection* ) ) );
} }
void void
TransferStatusManager::streamRegistered( StreamConnection* sc ) TransferStatusManager::streamRegistered( StreamConnection* sc )
{ {
#ifndef ENABLE_HEADLESS
JobStatusView::instance()->model()->addJob( new TransferStatusItem( this, sc ) ); JobStatusView::instance()->model()->addJob( new TransferStatusItem( this, sc ) );
#endif
} }

View File

@@ -136,8 +136,10 @@ GroovesharkParser::lookupGroovesharkPlaylist( const QString& linkRaw )
NetworkReply* reply = new NetworkReply( TomahawkUtils::nam()->post( QNetworkRequest( url ), data ) ); NetworkReply* reply = new NetworkReply( TomahawkUtils::nam()->post( QNetworkRequest( url ), data ) );
connect( reply, SIGNAL( finished() ), SLOT( groovesharkLookupFinished() ) ); connect( reply, SIGNAL( finished() ), SLOT( groovesharkLookupFinished() ) );
#ifndef ENABLE_HEADLESS
m_browseJob = new DropJobNotifier( pixmap(), "Grooveshark", type, reply ); m_browseJob = new DropJobNotifier( pixmap(), "Grooveshark", type, reply );
JobStatusView::instance()->model()->addJob( m_browseJob ); JobStatusView::instance()->model()->addJob( m_browseJob );
#endif
m_queries.insert( reply ); m_queries.insert( reply );
} }
@@ -151,8 +153,10 @@ GroovesharkParser::lookupGroovesharkTrack( const QString& track )
NetworkReply* reply = new NetworkReply( TomahawkUtils::nam()->get( QNetworkRequest( QUrl( track ) ) ) ); NetworkReply* reply = new NetworkReply( TomahawkUtils::nam()->get( QNetworkRequest( QUrl( track ) ) ) );
connect( reply, SIGNAL( finished() ), SLOT( trackPageFetchFinished() ) ); connect( reply, SIGNAL( finished() ), SLOT( trackPageFetchFinished() ) );
#ifndef ENABLE_HEADLESS
m_browseJob = new DropJobNotifier( pixmap(), "Grooveshark", DropJob::Track, reply ); m_browseJob = new DropJobNotifier( pixmap(), "Grooveshark", DropJob::Track, reply );
JobStatusView::instance()->model()->addJob( m_browseJob ); JobStatusView::instance()->model()->addJob( m_browseJob );
#endif
m_queries << reply; m_queries << reply;
} }
@@ -235,7 +239,10 @@ GroovesharkParser::groovesharkLookupFinished()
} }
else else
{ {
#ifndef ENABLE_HEADLESS
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( tr( "Error fetching Grooveshark information from the network!" ) ) ); JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( tr( "Error fetching Grooveshark information from the network!" ) ) );
#endif
tLog() << "Error in network request to grooveshark for track decoding:" << r->reply()->errorString(); tLog() << "Error in network request to grooveshark for track decoding:" << r->reply()->errorString();
} }

View File

@@ -109,8 +109,10 @@ ItunesParser::lookupItunesUri( const QString& link )
NetworkReply* reply = new NetworkReply( TomahawkUtils::nam()->get( QNetworkRequest( url ) ) ); NetworkReply* reply = new NetworkReply( TomahawkUtils::nam()->get( QNetworkRequest( url ) ) );
connect( reply, SIGNAL( finished() ), SLOT( itunesResponseLookupFinished() ) ); connect( reply, SIGNAL( finished() ), SLOT( itunesResponseLookupFinished() ) );
#ifndef ENABLE_HEADLESS
DropJobNotifier* j = new DropJobNotifier( pixmap(), QString( "Itunes" ), type, reply ); DropJobNotifier* j = new DropJobNotifier( pixmap(), QString( "Itunes" ), type, reply );
JobStatusView::instance()->model()->addJob( j ); JobStatusView::instance()->model()->addJob( j );
#endif
m_queries.insert( reply ); m_queries.insert( reply );
} }
@@ -171,7 +173,9 @@ ItunesParser::itunesResponseLookupFinished()
} }
else else
{ {
#ifndef ENABLE_HEADLESS
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( tr( "Error fetching iTunes information from the network!" ) ) ); JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( tr( "Error fetching iTunes information from the network!" ) ) );
#endif
tLog() << "Error in network request to Itunes for track decoding:" << r->reply()->errorString(); tLog() << "Error in network request to Itunes for track decoding:" << r->reply()->errorString();
} }

View File

@@ -133,8 +133,10 @@ RdioParser::fetchObjectsFromUrl( const QString& url, DropJob::DropType type )
NetworkReply* reply = new NetworkReply( TomahawkUtils::nam()->post( request, data ) ); NetworkReply* reply = new NetworkReply( TomahawkUtils::nam()->post( request, data ) );
connect( reply, SIGNAL( finished() ), SLOT( rdioReturned() ) ); connect( reply, SIGNAL( finished() ), SLOT( rdioReturned() ) );
#ifndef ENABLE_HEADLESS
m_browseJob = new DropJobNotifier( pixmap(), QString( "Rdio" ), type, reply ); m_browseJob = new DropJobNotifier( pixmap(), QString( "Rdio" ), type, reply );
JobStatusView::instance()->model()->addJob( m_browseJob ); JobStatusView::instance()->model()->addJob( m_browseJob );
#endif
m_reqQueries.insert( reply ); m_reqQueries.insert( reply );
} }
@@ -198,7 +200,10 @@ RdioParser::rdioReturned()
} }
else else
{ {
#ifndef ENABLE_HEADLESS
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( tr( "Error fetching Rdio information from the network!" ) ) ); JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( tr( "Error fetching Rdio information from the network!" ) ) );
#endif
tLog() << "Error in network request to Rdio for track decoding:" << r->reply()->errorString(); tLog() << "Error in network request to Rdio for track decoding:" << r->reply()->errorString();
} }

View File

@@ -83,8 +83,10 @@ ShortenedLinkParser::lookupUrl( const QString& url )
m_queries.insert( reply ); m_queries.insert( reply );
#ifndef ENABLE_HEADLESS
m_expandJob = new DropJobNotifier( pixmap(), "shortened", DropJob::Track, reply ); m_expandJob = new DropJobNotifier( pixmap(), "shortened", DropJob::Track, reply );
JobStatusView::instance()->model()->addJob( m_expandJob ); JobStatusView::instance()->model()->addJob( m_expandJob );
#endif
} }
@@ -94,8 +96,10 @@ ShortenedLinkParser::lookupFinished()
NetworkReply* r = qobject_cast< NetworkReply* >( sender() ); NetworkReply* r = qobject_cast< NetworkReply* >( sender() );
Q_ASSERT( r ); Q_ASSERT( r );
#ifndef ENABLE_HEADLESS
if ( r->reply()->error() != QNetworkReply::NoError ) if ( r->reply()->error() != QNetworkReply::NoError )
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( tr( "Network error parsing shortened link!" ) ) ); JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( tr( "Network error parsing shortened link!" ) ) );
#endif
tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Got an un-shortened url:" << r->reply()->url().toString(); tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Got an un-shortened url:" << r->reply()->url().toString();
m_links << r->reply()->url().toString(); m_links << r->reply()->url().toString();

View File

@@ -165,8 +165,10 @@ SpotifyParser::lookupSpotifyBrowse( const QString& link )
NetworkReply* reply = new NetworkReply( TomahawkUtils::nam()->get( QNetworkRequest( url ) ) ); NetworkReply* reply = new NetworkReply( TomahawkUtils::nam()->get( QNetworkRequest( url ) ) );
connect( reply, SIGNAL( finished() ), SLOT( spotifyBrowseFinished() ) ); connect( reply, SIGNAL( finished() ), SLOT( spotifyBrowseFinished() ) );
#ifndef ENABLE_HEADLESS
m_browseJob = new DropJobNotifier( pixmap(), "Spotify", type, reply ); m_browseJob = new DropJobNotifier( pixmap(), "Spotify", type, reply );
JobStatusView::instance()->model()->addJob( m_browseJob ); JobStatusView::instance()->model()->addJob( m_browseJob );
#endif
m_queries.insert( reply ); m_queries.insert( reply );
} }
@@ -192,8 +194,10 @@ SpotifyParser::lookupTrack( const QString& link )
NetworkReply* reply = new NetworkReply( TomahawkUtils::nam()->get( QNetworkRequest( url ) ) ); NetworkReply* reply = new NetworkReply( TomahawkUtils::nam()->get( QNetworkRequest( url ) ) );
connect( reply, SIGNAL( finished() ), SLOT( spotifyTrackLookupFinished() ) ); connect( reply, SIGNAL( finished() ), SLOT( spotifyTrackLookupFinished() ) );
#ifndef ENABLE_HEADLESS
DropJobNotifier* j = new DropJobNotifier( pixmap(), QString( "Spotify" ), DropJob::Track, reply ); DropJobNotifier* j = new DropJobNotifier( pixmap(), QString( "Spotify" ), DropJob::Track, reply );
JobStatusView::instance()->model()->addJob( j ); JobStatusView::instance()->model()->addJob( j );
#endif
m_queries.insert( reply ); m_queries.insert( reply );
} }