mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-23 22:25:11 +02:00
Allow deleting of script resolvers and removal from pipeline
This commit is contained in:
@@ -67,6 +67,7 @@ public:
|
||||
#endif
|
||||
|
||||
void addScriptResolver( const QString& scriptPath );
|
||||
void removeScriptResolver( const QString& scriptPath );
|
||||
|
||||
signals:
|
||||
void settingsChanged();
|
||||
|
@@ -21,6 +21,11 @@ ScriptResolver::ScriptResolver(const QString& exe) :
|
||||
m_proc.start( m_cmd );
|
||||
}
|
||||
|
||||
ScriptResolver::~ScriptResolver()
|
||||
{
|
||||
Tomahawk::Pipeline::instance()->removeResolver( this );
|
||||
}
|
||||
|
||||
|
||||
void ScriptResolver::readStderr()
|
||||
{
|
||||
|
@@ -15,6 +15,7 @@ class ScriptResolver : public Tomahawk::Resolver
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ScriptResolver(const QString& exe);
|
||||
virtual ~ScriptResolver();
|
||||
|
||||
virtual QString name() const { return m_name; }
|
||||
virtual unsigned int weight() const { return m_weight; }
|
||||
@@ -23,6 +24,7 @@ public:
|
||||
|
||||
virtual void resolve( const QVariant& v );
|
||||
|
||||
QString exe() const { return m_cmd; }
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
@@ -348,7 +348,10 @@ SettingsDialog::removeScriptResolver()
|
||||
{
|
||||
// only one selection
|
||||
if( !ui->scriptList->selectedItems().isEmpty() ) {
|
||||
QString resolver = ui->scriptList->selectedItems().first()->data( 1, Qt::DisplayRole ).toString();
|
||||
delete ui->scriptList->takeTopLevelItem( ui->scriptList->indexOfTopLevelItem( ui->scriptList->selectedItems().first() ) );
|
||||
|
||||
TomahawkApp::instance()->removeScriptResolver( resolver );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -333,6 +333,19 @@ TomahawkApp::addScriptResolver( const QString& path )
|
||||
m_scriptResolvers << new ScriptResolver( path );
|
||||
}
|
||||
|
||||
void
|
||||
TomahawkApp::removeScriptResolver( const QString& path )
|
||||
{
|
||||
foreach( ScriptResolver* r, m_scriptResolvers ) {
|
||||
if( r->exe() == path ) {
|
||||
m_scriptResolvers.removeAll( r );
|
||||
|
||||
delete r;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TomahawkApp::initLocalCollection()
|
||||
{
|
||||
|
Reference in New Issue
Block a user