mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-09 07:36:48 +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_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() ) )
|
||||
{
|
||||
tLog() << Q_FUNC_INFO << "Failed loading JavaScript resolver:" << scriptPath;
|
||||
@@ -322,13 +329,18 @@ QtScriptResolver::init()
|
||||
m_name = m.value( "name" ).toString();
|
||||
m_weight = m.value( "weight", 0 ).toUInt();
|
||||
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
|
||||
loadUi();
|
||||
QVariantMap config = resolverUserConfig();
|
||||
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;
|
||||
}
|
||||
@@ -426,6 +438,7 @@ QtScriptResolver::parseResultVariantList( const QVariantList& reslist )
|
||||
rp->setSize( m.value( "size" ).toUInt() );
|
||||
rp->setRID( uuid() );
|
||||
rp->setFriendlySource( name() );
|
||||
rp->setSourceIcon( icon() );
|
||||
rp->setScore( m.value( "score" ).toFloat() );
|
||||
rp->setDiscNumber( m.value( "discnumber" ).toUInt() );
|
||||
|
||||
|
@@ -130,6 +130,7 @@ public:
|
||||
static ExternalResolver* factory( const QString& scriptPath );
|
||||
|
||||
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 timeout() const { return m_timeout; }
|
||||
|
||||
@@ -168,6 +169,7 @@ private:
|
||||
ScriptEngine* m_engine;
|
||||
|
||||
QString m_name;
|
||||
QPixmap m_icon;
|
||||
unsigned int m_weight, m_timeout;
|
||||
|
||||
bool m_ready, m_stopped;
|
||||
|
@@ -35,7 +35,7 @@
|
||||
#include <shlwapi.h>
|
||||
#endif
|
||||
|
||||
ScriptResolver::ScriptResolver( const QString& exe )
|
||||
ScriptResolver::ScriptResolver(const QString& exe)
|
||||
: Tomahawk::ExternalResolverGui( exe )
|
||||
, m_num_restarts( 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
|
||||
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->setRID( uuid() );
|
||||
rp->setFriendlySource( m_name );
|
||||
rp->setSourceIcon( m_icon );
|
||||
rp->setYear( m.value( "year").toUInt() );
|
||||
rp->setDiscNumber( m.value( "discnumber" ).toUInt() );
|
||||
|
||||
@@ -371,7 +379,13 @@ ScriptResolver::doSetup( const QVariantMap& m )
|
||||
m_name = m.value( "name" ).toString();
|
||||
m_weight = m.value( "weight", 0 ).toUInt();
|
||||
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_configSent = false;
|
||||
|
@@ -42,6 +42,7 @@ public:
|
||||
static ExternalResolver* factory( const QString& exe );
|
||||
|
||||
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 preference() const { return m_preference; }
|
||||
virtual unsigned int timeout() const { return m_timeout; }
|
||||
@@ -82,6 +83,7 @@ private:
|
||||
|
||||
QProcess m_proc;
|
||||
QString m_name;
|
||||
QPixmap m_icon;
|
||||
unsigned int m_weight, m_preference, m_timeout, m_num_restarts;
|
||||
QWeakPointer< QWidget > m_configWidget;
|
||||
|
||||
|
Reference in New Issue
Block a user