[vlc-devel] commit: qt4: CoverArtLabel and BackgroundWidget improvments (Erwan Tulou )
git version control
git at videolan.org
Fri Aug 14 17:15:13 CEST 2009
vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Thu Aug 13 17:09:42 2009 +0200| [799802878dc2959b9e5bf4ae1552369496f55977] | committer: 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://
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=799802878dc2959b9e5bf4ae1552369496f55977
---
modules/gui/qt4/components/info_panels.cpp | 16 ++++++++++++++++
modules/gui/qt4/components/interface_widgets.cpp | 22 ++++++++++++++++------
modules/gui/qt4/components/interface_widgets.hpp | 2 +-
modules/gui/qt4/components/playlist/playlist.cpp | 3 +++
4 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/modules/gui/qt4/components/info_panels.cpp b/modules/gui/qt4/components/info_panels.cpp
index dcd0417..2ac9e5a 100644
--- a/modules/gui/qt4/components/info_panels.cpp
+++ b/modules/gui/qt4/components/info_panels.cpp
@@ -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 );
+
}
/**
diff --git a/modules/gui/qt4/components/interface_widgets.cpp b/modules/gui/qt4/components/interface_widgets.cpp
index 603f0a1..9e530c1 100644
--- a/modules/gui/qt4/components/interface_widgets.cpp
+++ b/modules/gui/qt4/components/interface_widgets.cpp
@@ -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()
diff --git a/modules/gui/qt4/components/interface_widgets.hpp b/modules/gui/qt4/components/interface_widgets.hpp
index 32e5e32..3c49f54 100644
--- a/modules/gui/qt4/components/interface_widgets.hpp
+++ b/modules/gui/qt4/components/interface_widgets.hpp
@@ -204,10 +204,10 @@ public slots:
{
requestUpdate();
}
+ void showArtUpdate( const QString& );
private slots:
void askForUpdate();
- void showArtUpdate( const QString& );
signals:
void updateRequested();
diff --git a/modules/gui/qt4/components/playlist/playlist.cpp b/modules/gui/qt4/components/playlist/playlist.cpp
index 1535332..8ad5d11 100644
--- a/modules/gui/qt4/components/playlist/playlist.cpp
+++ b/modules/gui/qt4/components/playlist/playlist.cpp
@@ -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 );
More information about the vlc-devel
mailing list