mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 03:10:12 +02:00
Fix loading images from qtscriptresolvers
This commit is contained in:
@@ -34,8 +34,8 @@ QtScriptResolverHelper::QtScriptResolverHelper( const QString& scriptPath, QObje
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QByteArray
|
||||||
QtScriptResolverHelper::readFile( const QString& fileName )
|
QtScriptResolverHelper::readRaw( const QString& fileName )
|
||||||
{
|
{
|
||||||
QString path = QFileInfo( m_scriptPath ).absolutePath();
|
QString path = QFileInfo( m_scriptPath ).absolutePath();
|
||||||
// remove directories
|
// remove directories
|
||||||
@@ -45,7 +45,8 @@ QtScriptResolverHelper::readFile( const QString& fileName )
|
|||||||
QFile file( absoluteFilePath );
|
QFile file( absoluteFilePath );
|
||||||
if ( !file.exists() )
|
if ( !file.exists() )
|
||||||
{
|
{
|
||||||
return QString();
|
Q_ASSERT(false);
|
||||||
|
return QByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
file.open( QIODevice::ReadOnly );
|
file.open( QIODevice::ReadOnly );
|
||||||
@@ -61,6 +62,20 @@ QtScriptResolverHelper::compress( const QString& data )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
QtScriptResolverHelper::readCompressed(const QString& fileName)
|
||||||
|
{
|
||||||
|
return compress( readRaw( fileName ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
QtScriptResolverHelper::readBase64(const QString& fileName)
|
||||||
|
{
|
||||||
|
return readRaw( fileName ).toBase64();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariantMap
|
QVariantMap
|
||||||
QtScriptResolverHelper::resolverData()
|
QtScriptResolverHelper::resolverData()
|
||||||
{
|
{
|
||||||
@@ -224,18 +239,27 @@ QtScriptResolver::loadUi()
|
|||||||
|
|
||||||
|
|
||||||
bool compressed = m.value( "compressed", "false" ).toBool();
|
bool compressed = m.value( "compressed", "false" ).toBool();
|
||||||
bool base64 = m.value( "base64", "false" ).toBool();
|
|
||||||
|
|
||||||
qDebug() << "Resolver has a preferences widget! compressed?" << compressed << m;
|
qDebug() << "Resolver has a preferences widget! compressed?" << compressed << m;
|
||||||
|
|
||||||
QByteArray uiData = m[ "widget" ].toByteArray();
|
QByteArray uiData = m[ "widget" ].toByteArray();
|
||||||
if( base64 && compressed )
|
|
||||||
|
if( compressed )
|
||||||
uiData = qUncompress( QByteArray::fromBase64( uiData ) );
|
uiData = qUncompress( QByteArray::fromBase64( uiData ) );
|
||||||
else if( base64 )
|
else
|
||||||
uiData = QByteArray::fromBase64( uiData );
|
uiData = QByteArray::fromBase64( uiData );
|
||||||
|
|
||||||
|
QVariantMap images;
|
||||||
|
foreach(const QVariant& item, m[ "images" ].toList())
|
||||||
|
{
|
||||||
|
QString key = item.toMap().keys().first();
|
||||||
|
QVariant value = item.toMap().value(key);
|
||||||
|
images[key] = value;
|
||||||
|
}
|
||||||
|
|
||||||
if( m.contains( "images" ) )
|
if( m.contains( "images" ) )
|
||||||
uiData = fixDataImagePaths( uiData, compressed, m[ "images" ].toMap() );
|
uiData = fixDataImagePaths( uiData, compressed, images );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
m_configWidget = QWeakPointer< QWidget >( widgetFromData( uiData, 0 ) );
|
m_configWidget = QWeakPointer< QWidget >( widgetFromData( uiData, 0 ) );
|
||||||
|
|
||||||
|
@@ -42,7 +42,10 @@ public:
|
|||||||
void setResolverConfig( QVariantMap config );
|
void setResolverConfig( QVariantMap config );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
QString readFile( const QString& fileName );
|
QByteArray readRaw( const QString& fileName );
|
||||||
|
QString readBase64( const QString& fileName );
|
||||||
|
QString readCompressed( const QString& fileName );
|
||||||
|
|
||||||
QString compress( const QString& data );
|
QString compress( const QString& data );
|
||||||
QVariantMap resolverData();
|
QVariantMap resolverData();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user