diff --git a/src/libtomahawk/resolver.h b/src/libtomahawk/resolver.h index a7dfdcacb..6694224fe 100644 --- a/src/libtomahawk/resolver.h +++ b/src/libtomahawk/resolver.h @@ -67,7 +67,8 @@ Q_OBJECT public: enum ErrorState { NoError, - FileNotFound + FileNotFound, + FailedToLoad }; ExternalResolver( const QString& filePath ) { m_filePath = filePath; } diff --git a/src/libtomahawk/resolvers/qtscriptresolver.cpp b/src/libtomahawk/resolvers/qtscriptresolver.cpp index 14c4f3dd1..607662e60 100644 --- a/src/libtomahawk/resolvers/qtscriptresolver.cpp +++ b/src/libtomahawk/resolvers/qtscriptresolver.cpp @@ -170,6 +170,8 @@ QtScriptResolver::QtScriptResolver( const QString& scriptPath ) tLog() << Q_FUNC_INFO << "Loading JS resolver:" << scriptPath; m_engine = new ScriptEngine( this ); + m_name = QFileInfo( filePath() ).baseName(); + if ( !QFile::exists( filePath() ) ) { tLog() << Q_FUNC_INFO << "Failed loading JavaScript resolver:" << scriptPath; diff --git a/src/libtomahawk/resolvers/scriptresolver.cpp b/src/libtomahawk/resolvers/scriptresolver.cpp index 509e19eb5..9ea3d2308 100644 --- a/src/libtomahawk/resolvers/scriptresolver.cpp +++ b/src/libtomahawk/resolvers/scriptresolver.cpp @@ -59,6 +59,9 @@ ScriptResolver::ScriptResolver( const QString& exe ) if ( !TomahawkUtils::nam() ) return; + // set the name to the binary, if we launch properly we'll get the name the resolver reports + m_name = QFileInfo( filePath() ).baseName(); + sendConfig(); } @@ -125,8 +128,8 @@ ScriptResolver::reload() m_error = Tomahawk::ExternalResolver::FileNotFound; else { - m_proc.start( filePath() ); m_error = Tomahawk::ExternalResolver::NoError; + m_proc.start( filePath() ); sendConfig(); } @@ -271,6 +274,9 @@ ScriptResolver::cmdExited( int code, QProcess::ExitStatus status ) tLog() << Q_FUNC_INFO << "SCRIPT EXITED, code" << code << "status" << status << filePath(); Tomahawk::Pipeline::instance()->removeResolver( this ); + m_error = ExternalResolver::FailedToLoad; + emit changed(); + if ( m_stopped ) { tLog() << "*** Script resolver stopped "; diff --git a/src/resolverconfigdelegate.cpp b/src/resolverconfigdelegate.cpp index 38c087218..9ff6c8f1a 100644 --- a/src/resolverconfigdelegate.cpp +++ b/src/resolverconfigdelegate.cpp @@ -53,7 +53,9 @@ ResolverConfigDelegate::paint( QPainter* painter, const QStyleOptionViewItem& op path.setItalic( true ); path.setPointSize( path.pointSize() - 1 ); - const bool fileFound = (Tomahawk::ExternalResolver::ErrorState)index.data( ResolversModel::ErrorState ).toInt() == Tomahawk::ExternalResolver::FileNotFound; + const bool error = (Tomahawk::ExternalResolver::ErrorState)index.data( ResolversModel::ErrorState ).toInt() != Tomahawk::ExternalResolver::NoError; + const bool fileNotFound = (Tomahawk::ExternalResolver::ErrorState)index.data( ResolversModel::ErrorState ).toInt() == Tomahawk::ExternalResolver::FileNotFound; + const bool failedToLoad = (Tomahawk::ExternalResolver::ErrorState)index.data( ResolversModel::ErrorState ).toInt() == Tomahawk::ExternalResolver::FailedToLoad; QFontMetrics bfm( name ); QFontMetrics sfm( path ); @@ -97,14 +99,20 @@ ResolverConfigDelegate::paint( QPainter* painter, const QStyleOptionViewItem& op painter->save(); painter->setFont( path ); QString pathStr = index.data( ResolversModel::ResolverPath ).toString(); - if( fileFound ) + if( error ) { painter->setPen( QColor( Qt::red ).lighter( 150 ) ); - pathStr = tr( "Not found: %1" ).arg( pathStr ); - } else - { + } else { painter->setPen( Qt::gray ); } + + if( fileNotFound ) { + pathStr = tr( "Not found: %1" ).arg( pathStr ); + } else if ( failedToLoad ) + { + pathStr = tr( "Failed to load: %1" ).arg( pathStr ); + } + textRect.moveTop( itemRect.height() / 2 + top ); pathStr = sfm.elidedText( pathStr, Qt::ElideMiddle, textRect.width() ); painter->drawText( textRect, pathStr );