Commit 79980287 authored by Erwan Tulou's avatar Erwan Tulou

qt4: CoverArtLabel and BackgroundWidget improvments

    - preserve apect ratio
    - alignment set to Center
    - signal-slot connection moved to a better place
    - Art updated in info Panel when artUrl is file://
parent 5eb13a62
......@@ -32,6 +32,7 @@
#include "components/interface_widgets.hpp"
#include <assert.h>
#include <vlc_url.h>
#include <QTreeWidget>
#include <QHeaderView>
......@@ -226,6 +227,21 @@ void MetaPanel::update( input_item_t *p_item )
#undef UPDATE_META_INT
#undef UPDATE_META
// If a artURL is available as a local file, directly display it !
QString file;
char *psz_art = input_item_GetArtURL( p_item );
if( psz_art && !strncmp( psz_art, "file://", 7 ) &&
decode_URI( psz_art + 7 ) )
#ifdef WIN32
file = qfu( psz_art + 8 ); // Remove extra / on Win32 URI.
#else
file = qfu( psz_art + 7 );
#endif
free( psz_art );
art_cover->showArtUpdate( file );
}
/**
......
......@@ -245,6 +245,7 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i )
label->setMaximumWidth( MAX_BG_SIZE );
label->setMinimumHeight( MIN_BG_SIZE );
label->setMinimumWidth( MIN_BG_SIZE );
label->setAlignment( Qt::AlignCenter );
if( QDate::currentDate().dayOfYear() >= 354 )
label->setPixmap( QPixmap( ":/logo/vlc128-christmas.png" ) );
else
......@@ -281,7 +282,15 @@ void BackgroundWidget::updateArt( const QString& url )
}
else
{
label->setPixmap( QPixmap( url ) );
QPixmap pixmap( url );
if( pixmap.width() > label->maximumWidth() ||
pixmap.height() > label->maximumHeight() )
{
pixmap = pixmap.scaled( label->maximumWidth(),
label->maximumHeight(), Qt::KeepAspectRatio );
}
label->setPixmap( pixmap );
}
}
......@@ -479,14 +488,13 @@ CoverArtLabel::CoverArtLabel( QWidget *parent, intf_thread_t *_p_i )
{
setContextMenuPolicy( Qt::ActionsContextMenu );
CONNECT( this, updateRequested(), this, askForUpdate() );
CONNECT( THEMIM->getIM(), artChanged( QString ),
this, showArtUpdate( const QString& ) );
setMinimumHeight( 128 );
setMinimumWidth( 128 );
setMaximumHeight( 128 );
setMaximumWidth( 128 );
setScaledContents( true );
setScaledContents( false );
setAlignment( Qt::AlignCenter );
QList< QAction* > artActions = actions();
QAction *action = new QAction( qtr( "Download cover art" ), this );
......@@ -508,12 +516,14 @@ void CoverArtLabel::showArtUpdate( const QString& url )
QPixmap pix;
if( !url.isEmpty() && pix.load( url ) )
{
setPixmap( pix );
pix = pix.scaled( maximumWidth(), maximumHeight(),
Qt::KeepAspectRatioByExpanding );
}
else
{
setPixmap( QPixmap( ":/noart.png" ) );
pix = QPixmap( ":/noart.png" );
}
setPixmap( pix );
}
void CoverArtLabel::askForUpdate()
......
......@@ -204,10 +204,10 @@ public slots:
{
requestUpdate();
}
void showArtUpdate( const QString& );
private slots:
void askForUpdate();
void showArtUpdate( const QString& );
signals:
void updateRequested();
......
......@@ -60,6 +60,9 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i ) : p_intf ( _p_i )
art = new ArtLabel( artContainer, p_intf );
art->setToolTip( qtr( "Double click to get media information" ) );
CONNECT( THEMIM->getIM(), artChanged( QString ),
art, showArtUpdate( const QString& ) );
artContLay->addWidget( art, 1 );
leftW->addWidget( artContainer );
......
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