mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 21:57:41 +02:00
Install resolver AXE by passing the path as argument.
This commit is contained in:
@@ -23,8 +23,14 @@
|
|||||||
|
|
||||||
#include "GlobalActionManager.h"
|
#include "GlobalActionManager.h"
|
||||||
|
|
||||||
|
#include "accounts/AccountManager.h"
|
||||||
|
#include "accounts/spotify/SpotifyAccount.h"
|
||||||
|
#include "accounts/ResolverAccount.h"
|
||||||
#include "audio/AudioEngine.h"
|
#include "audio/AudioEngine.h"
|
||||||
#include "database/LocalCollection.h"
|
#include "database/LocalCollection.h"
|
||||||
|
#include "jobview/ErrorStatusMessage.h"
|
||||||
|
#include "jobview/JobStatusModel.h"
|
||||||
|
#include "jobview/JobStatusView.h"
|
||||||
#include "playlist/dynamic/GeneratorInterface.h"
|
#include "playlist/dynamic/GeneratorInterface.h"
|
||||||
#include "playlist/PlaylistTemplate.h"
|
#include "playlist/PlaylistTemplate.h"
|
||||||
#include "playlist/PlaylistView.h"
|
#include "playlist/PlaylistView.h"
|
||||||
@@ -136,6 +142,60 @@ GlobalActionManager::openLink( const QString& title, const QString& artist, cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
GlobalActionManager::installResolverFromFile( const QString& resolverPath )
|
||||||
|
{
|
||||||
|
const QFileInfo resolverAbsoluteFilePath( resolverPath );
|
||||||
|
TomahawkSettings::instance()->setScriptDefaultPath( resolverAbsoluteFilePath.absolutePath() );
|
||||||
|
|
||||||
|
if ( resolverAbsoluteFilePath.baseName() == "spotify_tomahawkresolver" )
|
||||||
|
{
|
||||||
|
// HACK if this is a spotify resolver, we treat it specially.
|
||||||
|
// usually we expect the user to just download the spotify resolver from attica,
|
||||||
|
// however developers, those who build their own tomahawk, can't do that, or linux
|
||||||
|
// users can't do that. However, we have an already-existing SpotifyAccount that we
|
||||||
|
// know exists that we need to use this resolver path.
|
||||||
|
//
|
||||||
|
// Hence, we special-case the spotify resolver and directly set the path on it here.
|
||||||
|
Accounts::SpotifyAccount* acct = 0;
|
||||||
|
foreach ( Accounts::Account* account, Accounts::AccountManager::instance()->accounts() )
|
||||||
|
{
|
||||||
|
if ( Accounts::SpotifyAccount* spotify = qobject_cast< Accounts::SpotifyAccount* >( account ) )
|
||||||
|
{
|
||||||
|
acct = spotify;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( acct )
|
||||||
|
{
|
||||||
|
acct->setManualResolverPath( resolverPath );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Accounts::Account* acct =
|
||||||
|
Accounts::AccountManager::instance()->accountFromPath( resolverPath );
|
||||||
|
|
||||||
|
if ( !acct )
|
||||||
|
{
|
||||||
|
QFileInfo fi( resolverPath );
|
||||||
|
|
||||||
|
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage(
|
||||||
|
tr( "Resolver installation from file %1 failed." )
|
||||||
|
.arg( fi.fileName() ) ) );
|
||||||
|
|
||||||
|
tDebug() << "Resolver was not installed:" << resolverPath;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Accounts::AccountManager::instance()->addAccount( acct );
|
||||||
|
TomahawkSettings::instance()->addAccount( acct->accountId() );
|
||||||
|
Accounts::AccountManager::instance()->enableAccount( acct );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
GlobalActionManager::openUrl( const QString& url )
|
GlobalActionManager::openUrl( const QString& url )
|
||||||
{
|
{
|
||||||
|
@@ -46,6 +46,8 @@ public:
|
|||||||
|
|
||||||
QUrl openLink( const QString& title, const QString& artist, const QString& album ) const;
|
QUrl openLink( const QString& title, const QString& artist, const QString& album ) const;
|
||||||
|
|
||||||
|
void installResolverFromFile( const QString& resolverPath );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -790,6 +790,17 @@ TomahawkApp::loadUrl( const QString& url )
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if ( info.suffix() == "axe" )
|
||||||
|
{
|
||||||
|
QFileInfo fi( url );
|
||||||
|
if ( fi.exists() )
|
||||||
|
{
|
||||||
|
tDebug( LOGINFO ) << "Loading AXE from file:" << url;
|
||||||
|
GlobalActionManager::instance()->installResolverFromFile( fi.absoluteFilePath() );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return GlobalActionManager::instance()->openUrl( url );
|
return GlobalActionManager::instance()->openUrl( url );
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "AtticaManager.h"
|
#include "AtticaManager.h"
|
||||||
#include "network/acl/AclRegistry.h"
|
#include "network/acl/AclRegistry.h"
|
||||||
|
#include "GlobalActionManager.h"
|
||||||
#include "TomahawkApp.h"
|
#include "TomahawkApp.h"
|
||||||
#include "TomahawkSettings.h"
|
#include "TomahawkSettings.h"
|
||||||
#include "accounts/DelegateConfigWrapper.h"
|
#include "accounts/DelegateConfigWrapper.h"
|
||||||
@@ -510,54 +511,9 @@ SettingsDialog::installFromFile()
|
|||||||
0,
|
0,
|
||||||
QFileDialog::ReadOnly );
|
QFileDialog::ReadOnly );
|
||||||
|
|
||||||
if ( !resolver.isEmpty() )
|
if ( !resolver.isEmpty() && QFileInfo( resolver ).exists() )
|
||||||
{
|
{
|
||||||
const QFileInfo resolverAbsoluteFilePath( resolver );
|
GlobalActionManager::instance()->installResolverFromFile( resolver );
|
||||||
TomahawkSettings::instance()->setScriptDefaultPath( resolverAbsoluteFilePath.absolutePath() );
|
|
||||||
|
|
||||||
if ( resolverAbsoluteFilePath.baseName() == "spotify_tomahawkresolver" )
|
|
||||||
{
|
|
||||||
// HACK if this is a spotify resolver, we treat it specially.
|
|
||||||
// usually we expect the user to just download the spotify resolver from attica,
|
|
||||||
// however developers, those who build their own tomahawk, can't do that, or linux
|
|
||||||
// users can't do that. However, we have an already-existing SpotifyAccount that we
|
|
||||||
// know exists that we need to use this resolver path.
|
|
||||||
//
|
|
||||||
// Hence, we special-case the spotify resolver and directly set the path on it here.
|
|
||||||
SpotifyAccount* acct = 0;
|
|
||||||
foreach ( Account* account, AccountManager::instance()->accounts() )
|
|
||||||
{
|
|
||||||
if ( SpotifyAccount* spotify = qobject_cast< SpotifyAccount* >( account ) )
|
|
||||||
{
|
|
||||||
acct = spotify;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( acct )
|
|
||||||
{
|
|
||||||
acct->setManualResolverPath( resolver );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Account* acct = AccountManager::instance()->accountFromPath( resolver );
|
|
||||||
|
|
||||||
if ( !acct )
|
|
||||||
{
|
|
||||||
QFileInfo fi( resolver );
|
|
||||||
|
|
||||||
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage(
|
|
||||||
tr( "Resolver installation from file %1 failed." )
|
|
||||||
.arg( fi.fileName() ) ) );
|
|
||||||
|
|
||||||
tDebug() << "Resolver was not installed:" << resolver;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
AccountManager::instance()->addAccount( acct );
|
|
||||||
TomahawkSettings::instance()->addAccount( acct->accountId() );
|
|
||||||
AccountManager::instance()->enableAccount( acct );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user