1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-13 17:43:59 +02:00

Bye bye callOnResolver

This commit is contained in:
Dominik Schmidt
2015-11-19 01:44:54 +01:00
parent 90d6f0d4e5
commit 1b4efa8f4a
2 changed files with 5 additions and 38 deletions

View File

@@ -259,9 +259,9 @@ JSResolver::init()
// HACK: register resolver object
d->scriptAccount->evaluateJavaScript( "Tomahawk.PluginManager.registerPlugin('resolver', Tomahawk.resolver.instance);" );
// init resolver
resolverInit();
scriptObject()->syncInvoke( "init" );
QVariantMap m = resolverSettings();
QVariantMap m = scriptObject()->syncInvoke( "settings" ).toMap();
d->name = m.value( "name" ).toString();
d->weight = m.value( "weight", 0 ).toUInt();
d->timeout = m.value( "timeout", 25 ).toUInt() * 1000;
@@ -582,7 +582,7 @@ JSResolver::loadUi()
{
Q_D( JSResolver );
QVariantMap m = callOnResolver( "getConfigUi()" ).toMap();
QVariantMap m = scriptObject()->syncInvoke( "getConfigUi" ).toMap();
bool compressed = m.value( "compressed", "false" ).toBool();
qDebug() << "Resolver has a preferences widget! compressed?" << compressed;
@@ -634,7 +634,7 @@ JSResolver::saveConfig()
// qDebug() << Q_FUNC_INFO << saveData;
d->resolverHelper->setResolverConfig( saveData.toMap() );
callOnResolver( "saveUserConfig()" );
scriptObject()->syncInvoke( "saveUserConfig" );
}
@@ -665,41 +665,10 @@ JSResolver::onCapabilitiesChanged( Tomahawk::ExternalResolver::Capabilities capa
}
QVariantMap
JSResolver::resolverSettings()
{
return callOnResolver( "settings" ).toMap();
}
QVariantMap
JSResolver::resolverUserConfig()
{
return callOnResolver( "getUserConfig()" ).toMap();
}
QVariantMap
JSResolver::resolverInit()
{
return callOnResolver( "init()" ).toMap();
}
QVariant
JSResolver::callOnResolver( const QString& scriptSource )
{
Q_D( JSResolver );
QString propertyName = scriptSource.split('(').first();
return d->scriptAccount->evaluateJavaScriptWithResult( QString(
"if(Tomahawk.resolver.instance['_adapter_%1']) {"
" Tomahawk.resolver.instance._adapter_%2;"
"} else {"
" Tomahawk.resolver.instance.%2"
"}"
).arg( propertyName ).arg( scriptSource ) );
return scriptObject()->syncInvoke( "getUserConfig" ).toMap();
}

View File

@@ -102,9 +102,7 @@ private:
void onCapabilitiesChanged( Capabilities capabilities );
// encapsulate javascript calls
QVariantMap resolverSettings();
QVariantMap resolverUserConfig();
QVariantMap resolverInit();
Q_DECLARE_PRIVATE( JSResolver )
QScopedPointer<JSResolverPrivate> d_ptr;