mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-12 09:04:33 +02:00
Add a config setting to script resolvers
Save them across sessions
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "utils/tomahawkutils.h"
|
#include "utils/tomahawkutils.h"
|
||||||
|
|
||||||
|
class ScriptResolver;
|
||||||
class AudioEngine;
|
class AudioEngine;
|
||||||
class Database;
|
class Database;
|
||||||
class SipHandler;
|
class SipHandler;
|
||||||
@@ -65,6 +66,8 @@ public:
|
|||||||
TomahawkWindow* mainWindow() const { return m_mainwindow; }
|
TomahawkWindow* mainWindow() const { return m_mainwindow; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void addScriptResolver( const QString& scriptPath );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void settingsChanged();
|
void settingsChanged();
|
||||||
|
|
||||||
@@ -82,6 +85,7 @@ private:
|
|||||||
|
|
||||||
QList<Tomahawk::collection_ptr> m_collections;
|
QList<Tomahawk::collection_ptr> m_collections;
|
||||||
QList<TomahawkPlugin*> m_plugins;
|
QList<TomahawkPlugin*> m_plugins;
|
||||||
|
QList<ScriptResolver*> m_scriptResolvers;
|
||||||
|
|
||||||
Database* m_database;
|
Database* m_database;
|
||||||
AudioEngine* m_audioEngine;
|
AudioEngine* m_audioEngine;
|
||||||
|
@@ -445,3 +445,21 @@ TomahawkSettings::setXmppBotPort( const int port )
|
|||||||
{
|
{
|
||||||
setValue( "xmppBot/port", -1 );
|
setValue( "xmppBot/port", -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TomahawkSettings::addScriptResolver(const QString& resolver)
|
||||||
|
{
|
||||||
|
setValue( "script/resolvers", scriptResolvers() << resolver );
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList
|
||||||
|
TomahawkSettings::scriptResolvers() const
|
||||||
|
{
|
||||||
|
return value( "script/resolvers" ).toStringList();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TomahawkSettings::setScriptResolvers( const QStringList& resolver )
|
||||||
|
{
|
||||||
|
setValue( "script/resolvers", resolver );
|
||||||
|
}
|
||||||
|
@@ -109,6 +109,12 @@ public:
|
|||||||
int xmppBotPort() const;
|
int xmppBotPort() const;
|
||||||
void setXmppBotPort( const int port );
|
void setXmppBotPort( const int port );
|
||||||
|
|
||||||
|
/// Script resolver settings
|
||||||
|
|
||||||
|
QStringList scriptResolvers() const;
|
||||||
|
void setScriptResolvers( const QStringList& resolver );
|
||||||
|
void addScriptResolver( const QString& resolver );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static TomahawkSettings* s_instance;
|
static TomahawkSettings* s_instance;
|
||||||
};
|
};
|
||||||
|
@@ -128,6 +128,7 @@ void ScriptResolver::resolve( const QVariant& v )
|
|||||||
QVariantMap m = v.toMap();
|
QVariantMap m = v.toMap();
|
||||||
m.insert( "_msgtype", "rq" );
|
m.insert( "_msgtype", "rq" );
|
||||||
const QByteArray msg = m_serializer.serialize( m );
|
const QByteArray msg = m_serializer.serialize( m );
|
||||||
|
qDebug() << "ASKING SCRIPT RESOLVER TO RESOLVE:" << msg;
|
||||||
sendMsg( msg );
|
sendMsg( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -72,6 +72,17 @@ SettingsDialog::SettingsDialog( QWidget *parent )
|
|||||||
ui->lineEditLastfmPassword->setText(s->lastFmPassword() );
|
ui->lineEditLastfmPassword->setText(s->lastFmPassword() );
|
||||||
connect( ui->pushButtonTestLastfmLogin, SIGNAL( clicked( bool) ), this, SLOT( testLastFmLogin() ) );
|
connect( ui->pushButtonTestLastfmLogin, SIGNAL( clicked( bool) ), this, SLOT( testLastFmLogin() ) );
|
||||||
|
|
||||||
|
// SCRIPT RESOLVER
|
||||||
|
ui->removeScript->setEnabled( false );
|
||||||
|
foreach( const QString& resolver, s->scriptResolvers() ) {
|
||||||
|
QFileInfo info( resolver );
|
||||||
|
ui->scriptList->addTopLevelItem( new QTreeWidgetItem( QStringList() << info.baseName() << resolver ) );
|
||||||
|
|
||||||
|
}
|
||||||
|
connect( ui->scriptList, SIGNAL( itemClicked( QTreeWidgetItem*, int ) ), this, SLOT( scriptSelectionChanged() ) );
|
||||||
|
connect( ui->addScript, SIGNAL( clicked( bool ) ), this, SLOT( addScriptResolver() ) );
|
||||||
|
connect( ui->removeScript, SIGNAL( clicked( bool ) ), this, SLOT( removeScriptResolver() ) );
|
||||||
|
|
||||||
connect( ui->buttonBrowse, SIGNAL( clicked() ), SLOT( showPathSelector() ) );
|
connect( ui->buttonBrowse, SIGNAL( clicked() ), SLOT( showPathSelector() ) );
|
||||||
connect( ui->proxyButton, SIGNAL( clicked() ), SLOT( showProxySettings() ) );
|
connect( ui->proxyButton, SIGNAL( clicked() ), SLOT( showProxySettings() ) );
|
||||||
connect( this, SIGNAL( rejected() ), SLOT( onRejected() ) );
|
connect( this, SIGNAL( rejected() ), SLOT( onRejected() ) );
|
||||||
@@ -113,6 +124,12 @@ SettingsDialog::~SettingsDialog()
|
|||||||
s->setLastFmUsername( ui->lineEditLastfmUsername->text() );
|
s->setLastFmUsername( ui->lineEditLastfmUsername->text() );
|
||||||
s->setLastFmPassword( ui->lineEditLastfmPassword->text() );
|
s->setLastFmPassword( ui->lineEditLastfmPassword->text() );
|
||||||
|
|
||||||
|
QStringList resolvers;
|
||||||
|
for( int i = 0; i < ui->scriptList->topLevelItemCount(); i++ ) {
|
||||||
|
resolvers << ui->scriptList->topLevelItem( i )->data( 1, Qt::DisplayRole ).toString();
|
||||||
|
}
|
||||||
|
s->setScriptResolvers( resolvers );
|
||||||
|
|
||||||
if( rescan )
|
if( rescan )
|
||||||
{
|
{
|
||||||
MusicScanner* scanner = new MusicScanner(s->scannerPath() );
|
MusicScanner* scanner = new MusicScanner(s->scannerPath() );
|
||||||
@@ -313,3 +330,34 @@ ProxyDialog::saveSettings()
|
|||||||
|
|
||||||
QNetworkProxy::setApplicationProxy( proxy );
|
QNetworkProxy::setApplicationProxy( proxy );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SettingsDialog::addScriptResolver()
|
||||||
|
{
|
||||||
|
QString resolver = QFileDialog::getOpenFileName( this, tr( "Load script resolver file" ), qApp->applicationDirPath() );
|
||||||
|
if( !resolver.isEmpty() ) {
|
||||||
|
QFileInfo info( resolver );
|
||||||
|
ui->scriptList->addTopLevelItem( new QTreeWidgetItem( QStringList() << info.baseName() << resolver ) );
|
||||||
|
|
||||||
|
TomahawkApp::instance()->addScriptResolver( resolver );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SettingsDialog::removeScriptResolver()
|
||||||
|
{
|
||||||
|
// only one selection
|
||||||
|
if( !ui->scriptList->selectedItems().isEmpty() ) {
|
||||||
|
delete ui->scriptList->takeTopLevelItem( ui->scriptList->indexOfTopLevelItem( ui->scriptList->selectedItems().first() ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SettingsDialog::scriptSelectionChanged()
|
||||||
|
{
|
||||||
|
if( !ui->scriptList->selectedItems().isEmpty() ) {
|
||||||
|
ui->removeScript->setEnabled( true );
|
||||||
|
} else {
|
||||||
|
ui->removeScript->setEnabled( false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -51,6 +51,10 @@ private slots:
|
|||||||
void testLastFmLogin();
|
void testLastFmLogin();
|
||||||
void onLastFmFinished();
|
void onLastFmFinished();
|
||||||
|
|
||||||
|
void addScriptResolver();
|
||||||
|
void scriptSelectionChanged();
|
||||||
|
void removeScriptResolver();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::SettingsDialog *ui;
|
Ui::SettingsDialog *ui;
|
||||||
|
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tabJabber">
|
<widget class="QWidget" name="tabJabber">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@@ -456,6 +456,110 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QWidget" name="tabScriptResolvers">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Script Resolvers</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="scriptLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Loaded script resolvers:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="QTreeWidget" name="scriptList">
|
||||||
|
<property name="alternatingRowColors">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="selectionMode">
|
||||||
|
<enum>QAbstractItemView::SingleSelection</enum>
|
||||||
|
</property>
|
||||||
|
<property name="rootIsDecorated">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="itemsExpandable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="animated">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="columnCount">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<attribute name="headerVisible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="headerCascadingSectionResizes">
|
||||||
|
<bool>true</bool>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="headerDefaultSectionSize">
|
||||||
|
<number>150</number>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="headerHighlightSections">
|
||||||
|
<bool>true</bool>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="headerStretchLastSection">
|
||||||
|
<bool>true</bool>
|
||||||
|
</attribute>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">1</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">2</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="addScript">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../resources.qrc">
|
||||||
|
<normaloff>:/data/images/list-add.png</normaloff>:/data/images/list-add.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="removeScript">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../resources.qrc">
|
||||||
|
<normaloff>:/data/images/list-remove.png</normaloff>:/data/images/list-remove.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_4">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@@ -470,7 +574,9 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources>
|
||||||
|
<include location="../resources.qrc"/>
|
||||||
|
</resources>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>buttonBox</sender>
|
||||||
@@ -479,8 +585,8 @@
|
|||||||
<slot>accept()</slot>
|
<slot>accept()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>398</x>
|
<x>402</x>
|
||||||
<y>374</y>
|
<y>348</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>157</x>
|
<x>157</x>
|
||||||
@@ -495,8 +601,8 @@
|
|||||||
<slot>reject()</slot>
|
<slot>reject()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>466</x>
|
<x>470</x>
|
||||||
<y>380</y>
|
<y>348</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>286</x>
|
<x>286</x>
|
||||||
@@ -511,12 +617,12 @@
|
|||||||
<slot>setVisible(bool)</slot>
|
<slot>setVisible(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>480</x>
|
<x>489</x>
|
||||||
<y>124</y>
|
<y>117</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>496</x>
|
<x>595</x>
|
||||||
<y>154</y>
|
<y>145</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
@@ -527,12 +633,12 @@
|
|||||||
<slot>setVisible(bool)</slot>
|
<slot>setVisible(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>483</x>
|
<x>492</x>
|
||||||
<y>124</y>
|
<y>117</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>114</x>
|
<x>123</x>
|
||||||
<y>154</y>
|
<y>145</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
@@ -543,12 +649,12 @@
|
|||||||
<slot>setVisible(bool)</slot>
|
<slot>setVisible(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>461</x>
|
<x>470</x>
|
||||||
<y>124</y>
|
<y>117</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>114</x>
|
<x>123</x>
|
||||||
<y>182</y>
|
<y>173</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
@@ -563,8 +669,8 @@
|
|||||||
<y>112</y>
|
<y>112</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>439</x>
|
<x>594</x>
|
||||||
<y>163</y>
|
<y>172</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
@@ -322,9 +322,16 @@ TomahawkApp::setupPipeline()
|
|||||||
// setup resolvers for local content, and (cached) remote collection content
|
// setup resolvers for local content, and (cached) remote collection content
|
||||||
Pipeline::instance()->addResolver( new DatabaseResolver( 100 ) );
|
Pipeline::instance()->addResolver( new DatabaseResolver( 100 ) );
|
||||||
|
|
||||||
// new ScriptResolver("/home/rj/src/tomahawk-core/contrib/magnatune/magnatune-resolver.php");
|
// load script resolvers
|
||||||
|
foreach( QString resolver,TomahawkSettings::instance()->scriptResolvers() )
|
||||||
|
addScriptResolver( resolver );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TomahawkApp::addScriptResolver( const QString& path )
|
||||||
|
{
|
||||||
|
m_scriptResolvers << new ScriptResolver( path );
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TomahawkApp::initLocalCollection()
|
TomahawkApp::initLocalCollection()
|
||||||
|
Reference in New Issue
Block a user