]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/info_panels.cpp
Qt: allow to change the art
[vlc] / modules / gui / qt4 / components / info_panels.cpp
index efa5aee55525085270b88fb6d06f1029e856cfbe..f1391162fef4d8b68590e7d4c2db736fc0c7b478 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * infopanels.cpp : Panels for the information dialogs
+ * info_panels.cpp : Panels for the information dialogs
  ****************************************************************************
  * Copyright (C) 2006-2007 the VideoLAN team
  * $Id$
@@ -64,7 +64,7 @@ MetaPanel::MetaPanel( QWidget *parent,
     metaLayout->setVerticalSpacing( 0 );
 
     QFont smallFont = QApplication::font();
-    smallFont.setPointSize( smallFont.pointSize() - 2 );
+    smallFont.setPointSize( smallFont.pointSize() - 1 );
     smallFont.setBold( true );
 
     int line = 0; /* Counter for GridLayout */
@@ -132,21 +132,28 @@ MetaPanel::MetaPanel( QWidget *parent,
 
     /* Language on the same line */
     ADD_META( VLC_META_LANGUAGE, language_text, 7, -1 ); line++;
+    ADD_META( VLC_META_PUBLISHER, publisher_text, 0, 7 ); line++;
+
+    lblURL = new QLabel;
+    lblURL->setOpenExternalLinks( true );
+    lblURL->setTextFormat( Qt::RichText );
+    metaLayout->addWidget( lblURL, line -1, 7, 1, -1 );
+
+    ADD_META( VLC_META_COPYRIGHT, copyright_text, 0,  7 ); line++;
 
     /* ART_URL */
     art_cover = new CoverArtLabel( this, p_intf );
-    metaLayout->addWidget( art_cover, line + 1, 7, 6, 3, Qt::AlignLeft );
+    metaLayout->addWidget( art_cover, line, 7, 6, 3, Qt::AlignLeft );
 
-    ADD_META( VLC_META_PUBLISHER, publisher_text, 0, 7 ); line++;
-    ADD_META( VLC_META_COPYRIGHT, copyright_text, 0,  7 ); line++;
     ADD_META( VLC_META_ENCODED_BY, encodedby_text, 0, 7 ); line++;
 
     label = new QLabel( qtr( N_("Comments") ) ); label->setFont( smallFont );
     label->setContentsMargins( 3, 2, 0, 0 );
     metaLayout->addWidget( label, line++, 0, 1, 7 );
     description_text = new QTextEdit;
+    description_text->setAcceptRichText( false );
     metaLayout->addWidget( description_text, line, 0, 1, 7 );
-    CONNECT( description_text, textEdited( QString ), this, enterEditMode() );
+    // CONNECT( description_text, textChanged(), this, enterEditMode() ); //FIXME
     line++;
 
     /* VLC_META_SETTING: Useless */
@@ -162,6 +169,7 @@ MetaPanel::MetaPanel( QWidget *parent,
     CONNECT( seqtot_text, textEdited( QString ), this, enterEditMode() );
 
     CONNECT( date_text, textEdited( QString ), this, enterEditMode() );
+    CONNECT( THEMIM->getIM(), artChanged( QString ), this, enterEditMode() );
 /*    CONNECT( rating_text, valueChanged( QString ), this, enterEditMode( QString ) );*/
 
     /* We are not yet in Edit Mode */
@@ -184,13 +192,10 @@ void MetaPanel::update( input_item_t *p_item )
     else p_input = p_item;
 
     char *psz_meta;
-#define UPDATE_META( meta, widget ) {               \
-    psz_meta = input_item_Get##meta( p_item );      \
-    if( !EMPTY_STR( psz_meta ) )                    \
-        widget->setText( qfu( psz_meta ) );         \
-    else                                            \
-        widget->setText( "" ); }                    \
-    free( psz_meta );
+#define UPDATE_META( meta, widget ) {                                   \
+    psz_meta = input_item_Get##meta( p_item );                          \
+    widget->setText( !EMPTY_STR( psz_meta ) ? qfu( psz_meta ) : "" );   \
+    free( psz_meta ); }
 
 #define UPDATE_META_INT( meta, widget ) {           \
     psz_meta = input_item_Get##meta( p_item );      \
@@ -209,16 +214,9 @@ void MetaPanel::update( input_item_t *p_item )
         title_text->setText( "" );
 
     /* URL / URI */
-    psz_meta = input_item_GetURL( p_item );
+    psz_meta = input_item_GetURI( p_item );
     if( !EMPTY_STR( psz_meta ) )
-        emit uriSet( qfu( psz_meta ) );
-    else
-    {
-        free( psz_meta );
-        psz_meta = input_item_GetURI( p_item );
-        if( !EMPTY_STR( psz_meta ) )
-            emit uriSet( qfu( psz_meta ) );
-    }
+         emit uriSet( qfu( psz_meta ) );
     free( psz_meta );
 
     /* Other classic though */
@@ -234,9 +232,23 @@ void MetaPanel::update( input_item_t *p_item )
 
     UPDATE_META( Date, date_text );
     UPDATE_META( TrackNum, seqnum_text );
+    UPDATE_META( TrackTotal, seqtot_text );
 //    UPDATE_META( Setting, setting_text );
 //    UPDATE_META_INT( Rating, rating_text );
 
+    /* URL */
+    psz_meta = input_item_GetURL( p_item );
+    if( !EMPTY_STR( psz_meta ) )
+    {
+        QString newURL = qfu(psz_meta);
+        if( currentURL != newURL )
+        {
+            currentURL = newURL;
+            lblURL->setText( "<a href='" + currentURL + "'>" +
+                             currentURL.remove( QRegExp( ".*://") ) + "</a>" );
+        }
+    }
+    free( psz_meta );
 #undef UPDATE_META_INT
 #undef UPDATE_META
 
@@ -253,7 +265,7 @@ void MetaPanel::update( input_item_t *p_item )
     }
 
     art_cover->showArtUpdate( file );
-
+    art_cover->setItem( p_item );
 }
 
 /**
@@ -270,6 +282,7 @@ void MetaPanel::saveMeta()
     input_item_SetAlbum(  p_input, qtu( collection_text->text() ) );
     input_item_SetGenre(  p_input, qtu( genre_text->text() ) );
     input_item_SetTrackNum(  p_input, qtu( seqnum_text->text() ) );
+    input_item_SetTrackTotal(  p_input, qtu( seqtot_text->text() ) );
     input_item_SetDate(  p_input, qtu( date_text->text() ) );
 
     input_item_SetCopyright( p_input, qtu( copyright_text->text() ) );
@@ -292,7 +305,6 @@ bool MetaPanel::isInEditMode()
 
 void MetaPanel::enterEditMode()
 {
-    msg_Dbg( p_intf, "Entering Edit MetaData Mode" );
     setEditMode( true );
 }
 
@@ -313,11 +325,13 @@ void MetaPanel::clear()
     copyright_text->clear();
     collection_text->clear();
     seqnum_text->clear();
+    seqtot_text->clear();
     description_text->clear();
     date_text->clear();
     language_text->clear();
     nowplaying_text->clear();
     publisher_text->clear();
+    encodedby_text->clear();
 
     setEditMode( false );
     emit uriSet( "" );
@@ -326,9 +340,7 @@ void MetaPanel::clear()
 /**
  * Second Panel - Shows the extra metadata in a tree, non editable.
  **/
-ExtraMetaPanel::ExtraMetaPanel( QWidget *parent,
-                                intf_thread_t *_p_intf )
-                                : QWidget( parent ), p_intf( _p_intf )
+ExtraMetaPanel::ExtraMetaPanel( QWidget *parent ) : QWidget( parent )
 {
      QGridLayout *layout = new QGridLayout(this);
 
@@ -341,7 +353,7 @@ ExtraMetaPanel::ExtraMetaPanel( QWidget *parent,
      extraMetaTree->setAlternatingRowColors( true );
      extraMetaTree->setColumnCount( 2 );
      extraMetaTree->resizeColumnToContents( 0 );
-     extraMetaTree->header()->hide();
+     extraMetaTree->setHeaderHidden( true );
      layout->addWidget( extraMetaTree, 1, 0 );
 }
 
@@ -398,9 +410,7 @@ void ExtraMetaPanel::clear()
  * Third panel - Stream info
  * Display all codecs and muxers info that we could gather.
  **/
-InfoPanel::InfoPanel( QWidget *parent,
-                      intf_thread_t *_p_intf )
-                      : QWidget( parent ), p_intf( _p_intf )
+InfoPanel::InfoPanel( QWidget *parent ) : QWidget( parent )
 {
      QGridLayout *layout = new QGridLayout(this);
 
@@ -475,9 +485,7 @@ void InfoPanel::saveCodecsInfo()
  * Fourth Panel - Stats
  * Displays the Statistics for reading/streaming/encoding/displaying in a tree
  */
-InputStatsPanel::InputStatsPanel( QWidget *parent,
-                                  intf_thread_t *_p_intf )
-                                  : QWidget( parent ), p_intf( _p_intf )
+InputStatsPanel::InputStatsPanel( QWidget *parent ): QWidget( parent )
 {
      QGridLayout *layout = new QGridLayout(this);
 
@@ -488,7 +496,7 @@ InputStatsPanel::InputStatsPanel( QWidget *parent,
 
      StatsTree = new QTreeWidget(this);
      StatsTree->setColumnCount( 3 );
-     StatsTree->header()->hide();
+     StatsTree->setHeaderHidden( true );
 
 #define CREATE_TREE_ITEM( itemName, itemText, itemValue, unit ) {              \
     itemName =                                                                 \
@@ -561,35 +569,40 @@ InputStatsPanel::InputStatsPanel( QWidget *parent,
  **/
 void InputStatsPanel::update( input_item_t *p_item )
 {
+    if ( !isVisible() ) return;
     assert( p_item );
     vlc_mutex_lock( &p_item->p_stats->lock );
 
-#define UPDATE( widget, format, calc... ) \
+#define UPDATE_INT( widget, calc... ) \
+    { widget->setText( 1, QString::number( (qulonglong)calc ) ); }
+
+#define UPDATE_FLOAT( widget, format, calc... ) \
     { QString str; widget->setText( 1 , str.sprintf( format, ## calc ) );  }
 
-    UPDATE( read_media_stat,     "%"PRIu64, (p_item->p_stats->i_read_bytes / 1024 ) );
-    UPDATE( input_bitrate_stat,  "%6.0f", (float)(p_item->p_stats->f_input_bitrate *  8000  ));
-    UPDATE( demuxed_stat,        "%"PRIu64, (p_item->p_stats->i_demux_read_bytes / 1024 ) );
-    UPDATE( stream_bitrate_stat, "%6.0f", (float)(p_item->p_stats->f_demux_bitrate *  8000  ));
-    UPDATE( corrupted_stat,      "%"PRIu64, p_item->p_stats->i_demux_corrupted );
-    UPDATE( discontinuity_stat,  "%"PRIu64, p_item->p_stats->i_demux_discontinuity );
+    UPDATE_INT( read_media_stat, (p_item->p_stats->i_read_bytes / 1024 ) );
+    UPDATE_FLOAT( input_bitrate_stat,  "%6.0f", (float)(p_item->p_stats->f_input_bitrate *  8000  ));
+    UPDATE_INT( demuxed_stat,    (p_item->p_stats->i_demux_read_bytes / 1024 ) );
+    UPDATE_FLOAT( stream_bitrate_stat, "%6.0f", (float)(p_item->p_stats->f_demux_bitrate *  8000  ));
+    UPDATE_INT( corrupted_stat,      p_item->p_stats->i_demux_corrupted );
+    UPDATE_INT( discontinuity_stat,  p_item->p_stats->i_demux_discontinuity );
 
     /* Video */
-    UPDATE( vdecoded_stat,     "%"PRIu64, p_item->p_stats->i_decoded_video );
-    UPDATE( vdisplayed_stat,   "%"PRIu64, p_item->p_stats->i_displayed_pictures );
-    UPDATE( vlost_frames_stat, "%"PRIu64, p_item->p_stats->i_lost_pictures );
+    UPDATE_INT( vdecoded_stat,     p_item->p_stats->i_decoded_video );
+    UPDATE_INT( vdisplayed_stat,   p_item->p_stats->i_displayed_pictures );
+    UPDATE_INT( vlost_frames_stat, p_item->p_stats->i_lost_pictures );
 
     /* Sout */
-    UPDATE( send_stat,        "%"PRIu64, p_item->p_stats->i_sent_packets );
-    UPDATE( send_bytes_stat,  "%"PRIu64, (p_item->p_stats->i_sent_bytes)/ 1024 );
-    UPDATE( send_bitrate_stat, "%6.0f", (float)(p_item->p_stats->f_send_bitrate * 8000 ) );
+    UPDATE_INT( send_stat,        p_item->p_stats->i_sent_packets );
+    UPDATE_INT( send_bytes_stat,  (p_item->p_stats->i_sent_bytes)/ 1024 );
+    UPDATE_FLOAT( send_bitrate_stat, "%6.0f", (float)(p_item->p_stats->f_send_bitrate * 8000 ) );
 
     /* Audio*/
-    UPDATE( adecoded_stat, "%"PRIu64, p_item->p_stats->i_decoded_audio );
-    UPDATE( aplayed_stat,  "%"PRIu64, p_item->p_stats->i_played_abuffers );
-    UPDATE( alost_stat,    "%"PRIu64, p_item->p_stats->i_lost_abuffers );
+    UPDATE_INT( adecoded_stat, p_item->p_stats->i_decoded_audio );
+    UPDATE_INT( aplayed_stat,  p_item->p_stats->i_played_abuffers );
+    UPDATE_INT( alost_stat,    p_item->p_stats->i_lost_abuffers );
 
-#undef UPDATE
+#undef UPDATE_INT
+#undef UPDATE_FLOAT
 
     vlc_mutex_unlock(& p_item->p_stats->lock );
 }