mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-09 23:57:34 +02:00
use resolver icons from scriptresolver
This commit is contained in:
@@ -231,6 +231,13 @@ QtScriptResolver::QtScriptResolver( const QString& scriptPath )
|
|||||||
m_engine = new ScriptEngine( this );
|
m_engine = new ScriptEngine( this );
|
||||||
m_name = QFileInfo( filePath() ).baseName();
|
m_name = QFileInfo( filePath() ).baseName();
|
||||||
|
|
||||||
|
// set the icon, if we launch properly we'll get the icon the resolver reports
|
||||||
|
QString iconPath = QFileInfo( filePath() ).path() + "/../images/icon.png";
|
||||||
|
if ( !m_icon.load( iconPath ) )
|
||||||
|
{
|
||||||
|
m_icon = QPixmap( RESPATH "images/resolver-default.png" );
|
||||||
|
}
|
||||||
|
|
||||||
if ( !QFile::exists( filePath() ) )
|
if ( !QFile::exists( filePath() ) )
|
||||||
{
|
{
|
||||||
tLog() << Q_FUNC_INFO << "Failed loading JavaScript resolver:" << scriptPath;
|
tLog() << Q_FUNC_INFO << "Failed loading JavaScript resolver:" << scriptPath;
|
||||||
@@ -322,13 +329,18 @@ QtScriptResolver::init()
|
|||||||
m_name = m.value( "name" ).toString();
|
m_name = m.value( "name" ).toString();
|
||||||
m_weight = m.value( "weight", 0 ).toUInt();
|
m_weight = m.value( "weight", 0 ).toUInt();
|
||||||
m_timeout = m.value( "timeout", 25 ).toUInt() * 1000;
|
m_timeout = m.value( "timeout", 25 ).toUInt() * 1000;
|
||||||
|
QString iconPath = QFileInfo( filePath() ).path() + "/" + m.value( "icon" ).toString();
|
||||||
|
if ( !m_icon.load( iconPath ) )
|
||||||
|
{
|
||||||
|
iconPath = "none";
|
||||||
|
}
|
||||||
|
|
||||||
// load config widget and apply settings
|
// load config widget and apply settings
|
||||||
loadUi();
|
loadUi();
|
||||||
QVariantMap config = resolverUserConfig();
|
QVariantMap config = resolverUserConfig();
|
||||||
fillDataInWidgets( config );
|
fillDataInWidgets( config );
|
||||||
|
|
||||||
qDebug() << "JS" << filePath() << "READY," << "name" << m_name << "weight" << m_weight << "timeout" << m_timeout;
|
qDebug() << "JS" << filePath() << "READY," << "name" << m_name << "weight" << m_weight << "timeout" << m_timeout << "icon" << iconPath;
|
||||||
|
|
||||||
m_ready = true;
|
m_ready = true;
|
||||||
}
|
}
|
||||||
@@ -426,6 +438,7 @@ QtScriptResolver::parseResultVariantList( const QVariantList& reslist )
|
|||||||
rp->setSize( m.value( "size" ).toUInt() );
|
rp->setSize( m.value( "size" ).toUInt() );
|
||||||
rp->setRID( uuid() );
|
rp->setRID( uuid() );
|
||||||
rp->setFriendlySource( name() );
|
rp->setFriendlySource( name() );
|
||||||
|
rp->setSourceIcon( icon() );
|
||||||
rp->setScore( m.value( "score" ).toFloat() );
|
rp->setScore( m.value( "score" ).toFloat() );
|
||||||
rp->setDiscNumber( m.value( "discnumber" ).toUInt() );
|
rp->setDiscNumber( m.value( "discnumber" ).toUInt() );
|
||||||
|
|
||||||
|
@@ -130,6 +130,7 @@ public:
|
|||||||
static ExternalResolver* factory( const QString& scriptPath );
|
static ExternalResolver* factory( const QString& scriptPath );
|
||||||
|
|
||||||
virtual QString name() const { return m_name; }
|
virtual QString name() const { return m_name; }
|
||||||
|
virtual QPixmap icon() const { return m_icon; }
|
||||||
virtual unsigned int weight() const { return m_weight; }
|
virtual unsigned int weight() const { return m_weight; }
|
||||||
virtual unsigned int timeout() const { return m_timeout; }
|
virtual unsigned int timeout() const { return m_timeout; }
|
||||||
|
|
||||||
@@ -168,6 +169,7 @@ private:
|
|||||||
ScriptEngine* m_engine;
|
ScriptEngine* m_engine;
|
||||||
|
|
||||||
QString m_name;
|
QString m_name;
|
||||||
|
QPixmap m_icon;
|
||||||
unsigned int m_weight, m_timeout;
|
unsigned int m_weight, m_timeout;
|
||||||
|
|
||||||
bool m_ready, m_stopped;
|
bool m_ready, m_stopped;
|
||||||
|
@@ -35,7 +35,7 @@
|
|||||||
#include <shlwapi.h>
|
#include <shlwapi.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ScriptResolver::ScriptResolver( const QString& exe )
|
ScriptResolver::ScriptResolver(const QString& exe)
|
||||||
: Tomahawk::ExternalResolverGui( exe )
|
: Tomahawk::ExternalResolverGui( exe )
|
||||||
, m_num_restarts( 0 )
|
, m_num_restarts( 0 )
|
||||||
, m_msgsize( 0 )
|
, m_msgsize( 0 )
|
||||||
@@ -57,6 +57,13 @@ ScriptResolver::ScriptResolver( const QString& exe )
|
|||||||
|
|
||||||
// set the name to the binary, if we launch properly we'll get the name the resolver reports
|
// set the name to the binary, if we launch properly we'll get the name the resolver reports
|
||||||
m_name = QFileInfo( filePath() ).baseName();
|
m_name = QFileInfo( filePath() ).baseName();
|
||||||
|
|
||||||
|
// set the icon, if we launch properly we'll get the icon the resolver reports
|
||||||
|
QString iconPath = QFileInfo( filePath() ).path() + "/../images/icon.png";
|
||||||
|
if ( !m_icon.load( iconPath ) )
|
||||||
|
{
|
||||||
|
m_icon = QPixmap( RESPATH "images/resolver-default.png" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -279,6 +286,7 @@ ScriptResolver::handleMsg( const QByteArray& msg )
|
|||||||
rp->setSize( m.value( "size" ).toUInt() );
|
rp->setSize( m.value( "size" ).toUInt() );
|
||||||
rp->setRID( uuid() );
|
rp->setRID( uuid() );
|
||||||
rp->setFriendlySource( m_name );
|
rp->setFriendlySource( m_name );
|
||||||
|
rp->setSourceIcon( m_icon );
|
||||||
rp->setYear( m.value( "year").toUInt() );
|
rp->setYear( m.value( "year").toUInt() );
|
||||||
rp->setDiscNumber( m.value( "discnumber" ).toUInt() );
|
rp->setDiscNumber( m.value( "discnumber" ).toUInt() );
|
||||||
|
|
||||||
@@ -371,7 +379,13 @@ ScriptResolver::doSetup( const QVariantMap& m )
|
|||||||
m_name = m.value( "name" ).toString();
|
m_name = m.value( "name" ).toString();
|
||||||
m_weight = m.value( "weight", 0 ).toUInt();
|
m_weight = m.value( "weight", 0 ).toUInt();
|
||||||
m_timeout = m.value( "timeout", 5 ).toUInt() * 1000;
|
m_timeout = m.value( "timeout", 5 ).toUInt() * 1000;
|
||||||
qDebug() << "SCRIPT" << filePath() << "READY," << "name" << m_name << "weight" << m_weight << "timeout" << m_timeout;
|
QString iconPath = QFileInfo( filePath() ).path() + "/" + m.value( "icon" ).toString();
|
||||||
|
if ( !m_icon.load( iconPath ) )
|
||||||
|
{
|
||||||
|
iconPath = "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << "SCRIPT" << filePath() << "READY," << "name" << m_name << "weight" << m_weight << "timeout" << m_timeout << "icon" << iconPath;
|
||||||
|
|
||||||
m_ready = true;
|
m_ready = true;
|
||||||
m_configSent = false;
|
m_configSent = false;
|
||||||
|
@@ -42,6 +42,7 @@ public:
|
|||||||
static ExternalResolver* factory( const QString& exe );
|
static ExternalResolver* factory( const QString& exe );
|
||||||
|
|
||||||
virtual QString name() const { return m_name; }
|
virtual QString name() const { return m_name; }
|
||||||
|
virtual QPixmap icon() const { return m_icon; }
|
||||||
virtual unsigned int weight() const { return m_weight; }
|
virtual unsigned int weight() const { return m_weight; }
|
||||||
virtual unsigned int preference() const { return m_preference; }
|
virtual unsigned int preference() const { return m_preference; }
|
||||||
virtual unsigned int timeout() const { return m_timeout; }
|
virtual unsigned int timeout() const { return m_timeout; }
|
||||||
@@ -82,6 +83,7 @@ private:
|
|||||||
|
|
||||||
QProcess m_proc;
|
QProcess m_proc;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
|
QPixmap m_icon;
|
||||||
unsigned int m_weight, m_preference, m_timeout, m_num_restarts;
|
unsigned int m_weight, m_preference, m_timeout, m_num_restarts;
|
||||||
QWeakPointer< QWidget > m_configWidget;
|
QWeakPointer< QWidget > m_configWidget;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user