]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/dialogs/mediainfo.cpp
Qt4 - Fix the SINGLE Item mode of the Media Information! Be Carefull again !
[vlc] / modules / gui / qt4 / dialogs / mediainfo.cpp
index 328bb9f84524e2aa8b72578c4e7970cbc6da4b08..63e31bf567ee9d6bdcc695acdbf37519113cbe51 100644 (file)
 
 MediaInfoDialog *MediaInfoDialog::instance = NULL;
 
+/* This Dialog has two main modes:
+    - General Mode that shows the current Played item, and the stats
+    - Single mode that shows the info on ONE SINGLE Item on the playlist
+   Please be Careful of not breaking one the modes behaviour... */
+
 MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf,
                                   input_item_t *_p_item,
                                   bool _mainInput,
@@ -42,6 +47,7 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf,
 {
     p_item = _p_item;
     b_cleaned = true;
+    i_runs = 0;
 
     setWindowTitle( qtr( "Media information" ) );
     resize( 600 , 480 );
@@ -88,11 +94,22 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf,
 
     CONNECT( IT, currentChanged( int ), this, updateButtons( int ) );
 
-    CONNECT( THEMIM, inputChanged( input_thread_t * ), this, update( input_thread_t * ) );
+    /* If using the General Mode */
+    if( !p_item )
+    {
+        msg_Dbg( p_intf, "Using a general windows" );
+        CONNECT( THEMIM, inputChanged( input_thread_t * ),
+                 this, update( input_thread_t * ) );
+
+        p_item = input_GetItem( THEMIM->getInput() );
+    }
 
     /* Call update by hand, so info is shown from current item too */
-    if( THEMIM->getInput() )
-        update( input_GetItem(THEMIM->getInput()), true, true );
+    if( p_item )
+        update( p_item, true, true );
+
+    if( stats )
+        ON_TIMEOUT( updateOnTimeOut() );
 }
 
 MediaInfoDialog::~MediaInfoDialog()
@@ -138,6 +155,23 @@ void MediaInfoDialog::update( input_thread_t *p_input )
     vlc_object_release( p_input );
 }
 
+void MediaInfoDialog::updateOnTimeOut() 
+{
+    /* Timer runs at 150 ms, dont' update more than 2 times per second */ 
+    i_runs++; 
+    if( i_runs % 4 != 0 ) return; 
+
+    /* Get Input and clear if non-existant */ 
+    input_thread_t *p_input = THEMIM->getInput(); 
+
+    if( p_input && !p_input->b_dead )
+    {
+        vlc_object_yield( p_input );
+        update( input_GetItem(p_input), false, false);
+        vlc_object_release( p_input );
+    }
+}
+
 void MediaInfoDialog::update( input_item_t *p_item,
                               bool update_info,
                               bool update_meta )