]> git.sesse.net Git - vlc/commitdiff
qt4: CoverArtLabel and BackgroundWidget improvments
authorErwan Tulou <erwan10@videolan.org>
Thu, 13 Aug 2009 15:09:42 +0000 (17:09 +0200)
committerErwan Tulou <erwan10@videolan.org>
Fri, 14 Aug 2009 15:11:56 +0000 (17:11 +0200)
    - preserve apect ratio
    - alignment set to Center
    - signal-slot connection moved to a better place
    - Art updated in info Panel when artUrl is file://

modules/gui/qt4/components/info_panels.cpp
modules/gui/qt4/components/interface_widgets.cpp
modules/gui/qt4/components/interface_widgets.hpp
modules/gui/qt4/components/playlist/playlist.cpp

index dcd0417371e93138c75421b48f39f62bfea7ec9f..2ac9e5abb8cfc8f736d77af859a1f152a19e9fbe 100644 (file)
@@ -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 );
+
 }
 
 /**
index 603f0a186e4117233c4471139cc61c2fa2d361be..9e530c147189b5ae044288f2c6f91a7c16af8b54 100644 (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()
index 32e5e32c2f5e64cae123f6483ffc2d2d472ee65c..3c49f542fcd17043085edcc7332399806bdf034e 100644 (file)
@@ -204,10 +204,10 @@ public slots:
     {
         requestUpdate();
     }
+    void showArtUpdate( const QString& );
 
 private slots:
     void askForUpdate();
-    void showArtUpdate( const QString& );
 
 signals:
     void updateRequested();
index 1535332e8862dff86e2d43976c35a3d6e99a8943..8ad5d11f8f26c3b4e171e13021616a6b9e9bafa0 100644 (file)
@@ -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 );