mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-04 21:27:58 +02:00
implement adding in getnewstuffmodel for attica resolvers
This commit is contained in:
@@ -32,6 +32,8 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
|
#include "accounts/ResolverAccount.h"
|
||||||
|
#include "accounts/AccountManager.h"
|
||||||
|
|
||||||
using namespace Attica;
|
using namespace Attica;
|
||||||
|
|
||||||
@@ -374,6 +376,9 @@ AtticaManager::payloadFetched()
|
|||||||
|
|
||||||
// Do the install / add to tomahawk
|
// Do the install / add to tomahawk
|
||||||
Tomahawk::Pipeline::instance()->addScriptResolver( resolverPath, true );
|
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;
|
m_resolverStates[ resolverId ].state = Installed;
|
||||||
TomahawkSettingsGui::instanceGui()->setAtticaResolverStates( m_resolverStates );
|
TomahawkSettingsGui::instanceGui()->setAtticaResolverStates( m_resolverStates );
|
||||||
emit resolverInstalled( resolverId );
|
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 )
|
ResolverAccount::ResolverAccount( const QString& accountId )
|
||||||
: Account( 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()
|
ResolverAccount::~ResolverAccount()
|
||||||
{
|
{
|
||||||
delete m_resolver;
|
delete m_resolver;
|
||||||
@@ -152,19 +181,34 @@ ResolverAccount::resolverChanged()
|
|||||||
AtticaResolverAccount::AtticaResolverAccount( const QString& accountId )
|
AtticaResolverAccount::AtticaResolverAccount( const QString& accountId )
|
||||||
: ResolverAccount( accountId )
|
: ResolverAccount( accountId )
|
||||||
{
|
{
|
||||||
const QFileInfo fi( m_resolver->filePath() );
|
loadIcon();
|
||||||
QDir codeDir = fi.absoluteDir();
|
|
||||||
codeDir.cd( "../images" );
|
|
||||||
|
|
||||||
if ( codeDir.exists() && codeDir.exists( "icon.png" ) )
|
|
||||||
m_icon.load( codeDir.absoluteFilePath( "icon.png" ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AtticaResolverAccount::AtticaResolverAccount( const QString& accountId, const QString& path )
|
||||||
|
: ResolverAccount( accountId, path )
|
||||||
|
{
|
||||||
|
loadIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
AtticaResolverAccount::~AtticaResolverAccount()
|
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
|
QPixmap
|
||||||
AtticaResolverAccount::icon() const
|
AtticaResolverAccount::icon() const
|
||||||
{
|
{
|
||||||
|
@@ -39,6 +39,10 @@ public:
|
|||||||
virtual QString description() const { return QString(); }
|
virtual QString description() const { return QString(); }
|
||||||
virtual QString prettyName() const { return QString(); } // Internal, not displayed
|
virtual QString prettyName() const { return QString(); } // Internal, not displayed
|
||||||
virtual bool allowUserCreation() const { return false; }
|
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();
|
void resolverChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
ResolverAccount( const QString& accountId, const QString& path );
|
||||||
ExternalResolverGui* m_resolver;
|
ExternalResolverGui* m_resolver;
|
||||||
|
|
||||||
|
friend class ResolverAccountFactory;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -92,7 +99,13 @@ public:
|
|||||||
virtual QPixmap icon() const;
|
virtual QPixmap icon() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
AtticaResolverAccount( const QString& accountId, const QString& path );
|
||||||
|
|
||||||
|
void loadIcon();
|
||||||
|
|
||||||
QPixmap m_icon;
|
QPixmap m_icon;
|
||||||
|
|
||||||
|
friend class ResolverAccountFactory;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user