Commit 8551d47c authored by Jean-Philippe André's avatar Jean-Philippe André

Qt: show embedded icons of Lua extensions

parent cdcd09f9
...@@ -52,6 +52,9 @@ ...@@ -52,6 +52,9 @@
#include <QStyleOptionViewItem> #include <QStyleOptionViewItem>
#include <QKeyEvent> #include <QKeyEvent>
#include <QPushButton> #include <QPushButton>
#include <QPixmap>
static QPixmap *loadPixmapFromData( char *, int size );
PluginDialog::PluginDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) PluginDialog::PluginDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
...@@ -272,10 +275,12 @@ public: ...@@ -272,10 +275,12 @@ public:
author = qfu( p_ext->psz_author ); author = qfu( p_ext->psz_author );
version = qfu( p_ext->psz_version ); version = qfu( p_ext->psz_version );
url = qfu( p_ext->psz_url ); url = qfu( p_ext->psz_url );
icon = loadPixmapFromData( p_ext->p_icondata, p_ext->i_icondata_size );
} }
~ExtensionCopy() {} ~ExtensionCopy() {}
QString name, title, description, shortdesc, author, version, url; QString name, title, description, shortdesc, author, version, url;
QPixmap *icon;
}; };
/* Extensions list model for the QListView */ /* Extensions list model for the QListView */
...@@ -418,19 +423,27 @@ void ExtensionItemDelegate::paint( QPainter *painter, ...@@ -418,19 +423,27 @@ void ExtensionItemDelegate::paint( QPainter *painter,
pixpaint->setPen( pen ); pixpaint->setPen( pen );
QFontMetrics metrics = option.fontMetrics; QFontMetrics metrics = option.fontMetrics;
/// @todo Add extension's icon // Icon
if( ext->icon != NULL )
{
pixpaint->drawPixmap( 7, 7, 2*metrics.height(), 2*metrics.height(),
*ext->icon );
}
// Title: bold // Title: bold
pixpaint->setRenderHint( QPainter::TextAntialiasing ); pixpaint->setRenderHint( QPainter::TextAntialiasing );
font.setBold( true ); font.setBold( true );
pixpaint->setFont( font ); pixpaint->setFont( font );
pixpaint->drawText( QRect( 10, 7, width - 70, metrics.height() ), pixpaint->drawText( QRect( 17 + 2 * metrics.height(), 7,
width - 40 - 2 * metrics.height(),
metrics.height() ),
Qt::AlignLeft, ext->title ); Qt::AlignLeft, ext->title );
// Short description: normal // Short description: normal
font.setBold( false ); font.setBold( false );
pixpaint->setFont( font ); pixpaint->setFont( font );
pixpaint->drawText( QRect( 10, 7 + metrics.height(), width - 40, pixpaint->drawText( QRect( 17 + 2 * metrics.height(),
7 + metrics.height(), width - 40,
metrics.height() ), metrics.height() ),
Qt::AlignLeft, ext->shortdesc ); Qt::AlignLeft, ext->shortdesc );
...@@ -471,10 +484,18 @@ ExtensionInfoDialog::ExtensionInfoDialog( const ExtensionCopy& extension, ...@@ -471,10 +484,18 @@ ExtensionInfoDialog::ExtensionInfoDialog( const ExtensionCopy& extension,
QGridLayout *layout = new QGridLayout( this ); QGridLayout *layout = new QGridLayout( this );
// Icon // Icon
/// @todo Use the extension's icon, when extensions will support icons :)
QLabel *icon = new QLabel( this ); QLabel *icon = new QLabel( this );
if( !extension.icon )
{
QPixmap pix( ":/logo/vlc48.png" ); QPixmap pix( ":/logo/vlc48.png" );
icon->setPixmap( pix ); icon->setPixmap( pix );
}
else
{
icon->setPixmap( *extension.icon );
}
icon->setAlignment( Qt::AlignCenter );
icon->setFixedSize( 48, 48 );
layout->addWidget( icon, 1, 0, 2, 1 ); layout->addWidget( icon, 1, 0, 2, 1 );
// Title // Title
...@@ -542,3 +563,16 @@ ExtensionInfoDialog::~ExtensionInfoDialog() ...@@ -542,3 +563,16 @@ ExtensionInfoDialog::~ExtensionInfoDialog()
{ {
delete extension; delete extension;
} }
static QPixmap *loadPixmapFromData( char *data, int size )
{
if( !data || size <= 0 )
return NULL;
QPixmap *pixmap = new QPixmap();
if( !pixmap->loadFromData( (const uchar*) data, (uint) size ) )
{
delete pixmap;
return NULL;
}
return pixmap;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment