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

Add name() to JSPlugin.

This is more of a hack until JSResolver is ported to be a ScriptResolver
This commit is contained in:
Dominik Schmidt 2014-12-01 23:54:50 +01:00
parent 42343c81c4
commit cefa97af18
4 changed files with 16 additions and 4 deletions

View File

@ -35,7 +35,7 @@ JSInfoPlugin::JSInfoPlugin( int id, JSPlugin *resolver )
m_supportedGetTypes = parseSupportedTypes( callMethodOnInfoPluginWithResult( "supportedGetTypes" ) );
m_supportedPushTypes = parseSupportedTypes( callMethodOnInfoPluginWithResult( "supportedPushTypes" ) );
setFriendlyName( QString( "JSInfoPlugin: %1" ) ); // TODO: .arg( resolver->name() )
setFriendlyName( QString( "JSInfoPlugin: %1" ).arg( resolver->name() ) );
}

View File

@ -30,8 +30,9 @@
using namespace Tomahawk;
JSPlugin::JSPlugin()
JSPlugin::JSPlugin( const QString& name )
: m_engine( new ScriptEngine( this ) )
, m_name( name )
{
}
@ -123,3 +124,10 @@ JSPlugin::startJob( ScriptJob* scriptJob )
evaluateJavaScript( eval );
}
const QString
JSPlugin::name() const
{
return m_name;
}

View File

@ -40,10 +40,13 @@ class DLLEXPORT JSPlugin : public ScriptPlugin
Q_OBJECT
public:
JSPlugin();
// HACK: needs refactoring
JSPlugin( const QString& name );
void startJob( ScriptJob* scriptJob ) override;
const QString name() const;
/**
* Evaluate JavaScript on the WebKit thread
*/
@ -73,6 +76,7 @@ private:
QVariant evaluateJavaScriptInternal( const QString& scriptSource );
std::unique_ptr<ScriptEngine> m_engine;
QString m_name;
};

View File

@ -64,8 +64,8 @@ JSResolver::JSResolver( const QString& accountId, const QString& scriptPath, con
Q_D( JSResolver );
tLog() << Q_FUNC_INFO << "Loading JS resolver:" << scriptPath;
d->scriptPlugin = new JSPlugin();
d->name = QFileInfo( filePath() ).baseName();
d->scriptPlugin = new JSPlugin( d->name );
// set the icon, if we launch properly we'll get the icon the resolver reports
d->icon = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultResolver, TomahawkUtils::Original, QSize( 128, 128 ) );