mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-19 15:29:42 +01:00
implement adding in getnewstuffmodel for attica resolvers
This commit is contained in:
parent
b300279e30
commit
4e450b36ee
@ -32,6 +32,8 @@
|
||||
#include <QTimer>
|
||||
|
||||
#include "utils/logger.h"
|
||||
#include "accounts/ResolverAccount.h"
|
||||
#include "accounts/AccountManager.h"
|
||||
|
||||
using namespace Attica;
|
||||
|
||||
@ -374,6 +376,9 @@ AtticaManager::payloadFetched()
|
||||
|
||||
// Do the install / add to tomahawk
|
||||
Tomahawk::Pipeline::instance()->addScriptResolver( resolverPath, true );
|
||||
Tomahawk::Accounts::Account* resolver = Tomahawk::Accounts::ResolverAccountFactory::createFromPath( resolverPath, true );
|
||||
Tomahawk::Accounts::AccountManager::instance()->addAccount( resolver );
|
||||
|
||||
m_resolverStates[ resolverId ].state = Installed;
|
||||
TomahawkSettingsGui::instanceGui()->setAtticaResolverStates( m_resolverStates );
|
||||
emit resolverInstalled( resolverId );
|
||||
|
@ -45,6 +45,16 @@ ResolverAccountFactory::createAccount( const QString& accountId )
|
||||
}
|
||||
|
||||
|
||||
Account*
|
||||
ResolverAccountFactory::createFromPath( const QString& path, bool isAttica )
|
||||
{
|
||||
if ( isAttica )
|
||||
return new AtticaResolverAccount( generateId( "resolveraccount" ), path );
|
||||
else
|
||||
return new ResolverAccount( generateId( "resolveraccount" ), path );
|
||||
}
|
||||
|
||||
|
||||
ResolverAccount::ResolverAccount( const QString& accountId )
|
||||
: Account( accountId )
|
||||
{
|
||||
@ -65,6 +75,25 @@ ResolverAccount::ResolverAccount( const QString& accountId )
|
||||
}
|
||||
|
||||
|
||||
ResolverAccount::ResolverAccount( const QString& accountId, const QString& path )
|
||||
: Account( accountId )
|
||||
{
|
||||
QVariantHash configuration;
|
||||
configuration[ "path" ] = path;
|
||||
setConfiguration( configuration );
|
||||
setEnabled( true );
|
||||
|
||||
m_resolver = qobject_cast< ExternalResolverGui* >( Pipeline::instance()->addScriptResolver( path, true ) );
|
||||
connect( m_resolver, SIGNAL( changed() ), this, SLOT( resolverChanged() ) );
|
||||
|
||||
// What resolver do we have here? Should only be types that are 'real' resolvers
|
||||
Q_ASSERT ( m_resolver );
|
||||
|
||||
setAccountFriendlyName( m_resolver->name() );
|
||||
setTypes( AccountType( ResolverType ) );
|
||||
}
|
||||
|
||||
|
||||
ResolverAccount::~ResolverAccount()
|
||||
{
|
||||
delete m_resolver;
|
||||
@ -152,19 +181,34 @@ ResolverAccount::resolverChanged()
|
||||
AtticaResolverAccount::AtticaResolverAccount( const QString& accountId )
|
||||
: ResolverAccount( accountId )
|
||||
{
|
||||
const QFileInfo fi( m_resolver->filePath() );
|
||||
QDir codeDir = fi.absoluteDir();
|
||||
codeDir.cd( "../images" );
|
||||
|
||||
if ( codeDir.exists() && codeDir.exists( "icon.png" ) )
|
||||
m_icon.load( codeDir.absoluteFilePath( "icon.png" ) );
|
||||
loadIcon();
|
||||
}
|
||||
|
||||
AtticaResolverAccount::AtticaResolverAccount( const QString& accountId, const QString& path )
|
||||
: ResolverAccount( accountId, path )
|
||||
{
|
||||
loadIcon();
|
||||
}
|
||||
|
||||
|
||||
AtticaResolverAccount::~AtticaResolverAccount()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
AtticaResolverAccount::loadIcon()
|
||||
{
|
||||
const QFileInfo fi( m_resolver->filePath() );
|
||||
QDir codeDir = fi.absoluteDir();
|
||||
codeDir.cd( "../images" );
|
||||
|
||||
if ( codeDir.exists() && codeDir.exists( "icon.png" ) )
|
||||
m_icon.load( codeDir.absoluteFilePath( "icon.png" ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
QPixmap
|
||||
AtticaResolverAccount::icon() const
|
||||
{
|
||||
|
@ -39,6 +39,10 @@ public:
|
||||
virtual QString description() const { return QString(); }
|
||||
virtual QString prettyName() const { return QString(); } // Internal, not displayed
|
||||
virtual bool allowUserCreation() const { return false; }
|
||||
|
||||
// Used to create a new resolver from a script on disk, either chosen by
|
||||
// the user, or installed from synchrotron
|
||||
static Account* createFromPath( const QString& path, bool isAttica );
|
||||
};
|
||||
|
||||
/**
|
||||
@ -74,7 +78,10 @@ private slots:
|
||||
void resolverChanged();
|
||||
|
||||
protected:
|
||||
ResolverAccount( const QString& accountId, const QString& path );
|
||||
ExternalResolverGui* m_resolver;
|
||||
|
||||
friend class ResolverAccountFactory;
|
||||
};
|
||||
|
||||
|
||||
@ -92,7 +99,13 @@ public:
|
||||
virtual QPixmap icon() const;
|
||||
|
||||
private:
|
||||
AtticaResolverAccount( const QString& accountId, const QString& path );
|
||||
|
||||
void loadIcon();
|
||||
|
||||
QPixmap m_icon;
|
||||
|
||||
friend class ResolverAccountFactory;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user