mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-19 23:39:42 +01:00
Hook up some removing
This commit is contained in:
parent
b78a348712
commit
7e13f1ae62
@ -464,6 +464,9 @@ AtticaManager::extractPayload( const QString& filename, const QString& resolverI
|
||||
void
|
||||
AtticaManager::uninstallResolver( const QString& pathToResolver )
|
||||
{
|
||||
// when is this used? find and fix
|
||||
Q_ASSERT(false);
|
||||
|
||||
// User manually removed a resolver not through attica dialog, simple remove
|
||||
QRegExp r( ".*([^/]*)/contents/code/main.js" );
|
||||
r.indexIn( pathToResolver );
|
||||
@ -495,6 +498,19 @@ AtticaManager::uninstallResolver( const Content& resolver )
|
||||
|
||||
m_resolverStates[ resolver.id() ].state = Uninstalled;
|
||||
TomahawkSettingsGui::instanceGui()->setAtticaResolverState( resolver.id(), Uninstalled );
|
||||
|
||||
// remove account as well
|
||||
QList< Tomahawk::Accounts::Account* > accounts = Tomahawk::Accounts::AccountManager::instance()->accounts( Tomahawk::Accounts::ResolverType );
|
||||
foreach ( Tomahawk::Accounts::Account* account, accounts )
|
||||
{
|
||||
if ( Tomahawk::Accounts::AtticaResolverAccount* atticaAccount = qobject_cast< Tomahawk::Accounts::AtticaResolverAccount* >( account ) )
|
||||
{
|
||||
if ( atticaAccount->atticaId() == resolver.id() ) // this is the account we want to remove
|
||||
{
|
||||
Tomahawk::Accounts::AccountManager::instance()->removeAccount( atticaAccount );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Tomahawk::Pipeline::instance()->removeScriptResolver( pathFromId( resolver.id() ) );
|
||||
|
@ -49,7 +49,10 @@ Account*
|
||||
ResolverAccountFactory::createFromPath( const QString& path, bool isAttica )
|
||||
{
|
||||
if ( isAttica )
|
||||
return new AtticaResolverAccount( generateId( "resolveraccount" ), path );
|
||||
{
|
||||
QFileInfo info( path );
|
||||
return new AtticaResolverAccount( generateId( "resolveraccount" ), path, info.baseName() );
|
||||
}
|
||||
else
|
||||
return new ResolverAccount( generateId( "resolveraccount" ), path );
|
||||
}
|
||||
@ -159,11 +162,13 @@ void
|
||||
ResolverAccount::removeFromConfig()
|
||||
{
|
||||
// TODO
|
||||
Account::removeFromConfig();
|
||||
}
|
||||
|
||||
|
||||
void ResolverAccount::saveConfig()
|
||||
{
|
||||
Account::saveConfig();
|
||||
m_resolver->saveConfig();
|
||||
}
|
||||
|
||||
@ -188,12 +193,18 @@ ResolverAccount::resolverChanged()
|
||||
AtticaResolverAccount::AtticaResolverAccount( const QString& accountId )
|
||||
: ResolverAccount( accountId )
|
||||
{
|
||||
m_atticaId = configuration().value( "atticaId" ).toString();
|
||||
loadIcon();
|
||||
}
|
||||
|
||||
AtticaResolverAccount::AtticaResolverAccount( const QString& accountId, const QString& path )
|
||||
AtticaResolverAccount::AtticaResolverAccount( const QString& accountId, const QString& path, const QString& atticaId )
|
||||
: ResolverAccount( accountId, path )
|
||||
, m_atticaId( atticaId )
|
||||
{
|
||||
QVariantHash conf = configuration();
|
||||
conf[ "atticaid" ] = atticaId;
|
||||
setConfiguration( conf );
|
||||
|
||||
loadIcon();
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,7 @@ class ResolverAccount : public Account
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
// Loads from config. Must already exist.
|
||||
explicit ResolverAccount( const QString& accountId );
|
||||
virtual ~ResolverAccount();
|
||||
|
||||
@ -80,6 +81,7 @@ private slots:
|
||||
void resolverChanged();
|
||||
|
||||
protected:
|
||||
// Created by factory, when user installs a new resolver
|
||||
ResolverAccount( const QString& accountId, const QString& path );
|
||||
ExternalResolverGui* m_resolver;
|
||||
|
||||
@ -95,17 +97,21 @@ class AtticaResolverAccount : public ResolverAccount
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AtticaResolverAccount(const QString& accountId);
|
||||
// Loads from config
|
||||
explicit AtticaResolverAccount( const QString& accountId );
|
||||
virtual ~AtticaResolverAccount();
|
||||
|
||||
virtual QPixmap icon() const;
|
||||
|
||||
QString atticaId() const { return m_atticaId; }
|
||||
private:
|
||||
AtticaResolverAccount( const QString& accountId, const QString& path );
|
||||
// Created by factory, when user installs a new resolver
|
||||
AtticaResolverAccount( const QString& accountId, const QString& path, const QString& atticaId );
|
||||
|
||||
void loadIcon();
|
||||
|
||||
QPixmap m_icon;
|
||||
QString m_atticaId;
|
||||
|
||||
friend class ResolverAccountFactory;
|
||||
};
|
||||
|
@ -273,12 +273,17 @@ TomahawkSettings::doUpgrade( int oldVersion, int newVersion )
|
||||
|
||||
QVariantHash configuration;
|
||||
configuration[ "path" ] = resolver;
|
||||
setValue( "configuration", configuration );
|
||||
|
||||
// reasonably ugly check for attica resolvers
|
||||
if ( resolver.contains( "atticaresolvers" ) && resolver.contains( "code" ) )
|
||||
{
|
||||
setValue( "atticaresolver", true );
|
||||
|
||||
QFileInfo info( resolver );
|
||||
configuration[ "atticaId" ] = info.baseName();
|
||||
}
|
||||
|
||||
setValue( "configuration", configuration );
|
||||
endGroup();
|
||||
|
||||
}
|
||||
|
@ -573,7 +573,6 @@ SettingsDialog::accountCreateConfigClosed( int finished )
|
||||
void
|
||||
SettingsDialog::handleAccountAdded( Account* account, bool added )
|
||||
{
|
||||
AccountFactory* f = AccountManager::instance()->factoryForAccount( account );
|
||||
if ( added )
|
||||
{
|
||||
account->setEnabled( true );
|
||||
|
Loading…
x
Reference in New Issue
Block a user