]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/dialogs/mediainfo.cpp
Forgotten tooltips.
[vlc] / modules / gui / qt4 / dialogs / mediainfo.cpp
index fc69d0e71d849c3deb1ebca5a62460789afea24b..f10733eef737655826d4bc2fdf63373bad704db6 100644 (file)
@@ -21,6 +21,9 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  ******************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
 
 #include "dialogs/mediainfo.hpp"
 #include "input_manager.hpp"
 
 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,
@@ -40,12 +48,11 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf,
                                   QVLCFrame( _p_intf ), mainInput(_mainInput),
                                   stats( _stats )
 {
-    i_runs = 0;
     p_item = _p_item;
-    b_need_update = true;
     b_cleaned = true;
+    i_runs = 0;
 
-    setWindowTitle( qtr( "Media information" ) );
+    setWindowTitle( qtr( "Media Information" ) );
     resize( 600 , 480 );
 
     /* TabWidgets and Tabs creation */
@@ -71,7 +78,7 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf,
     closeButton->setDefault( true );
 
     uriLine = new QLineEdit;
-    QLabel *uriLabel = new QLabel( qtr( "Location :" ) );
+    QLabel *uriLabel = new QLabel( qtr( "Location:" ) );
 
     layout->addWidget( IT, 0, 0, 1, 8 );
     layout->addWidget( uriLabel, 1, 0, 1, 1 );
@@ -82,7 +89,7 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf,
     BUTTONACT( closeButton, close() );
 
     /* The tabs buttons are shown in the main dialog for space and cosmetics */
-    CONNECT( saveMetaButton, clicked(), this, saveMeta() );
+    BUTTONACT( saveMetaButton, saveMeta() );
 
     /* Let the MetaData Panel update the URI */
     CONNECT( MP, uriSet( QString ), uriLine, setText( QString ) );
@@ -90,9 +97,23 @@ 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 * ) );
+
+        if( THEMIM->getInput() )
+            p_item = input_GetItem( THEMIM->getInput() );
+    }
+
     /* Call update by hand, so info is shown from current item too */
-    update( input_GetItem(THEMIM->getInput()), true, true );
+    if( p_item )
+        update( p_item, true, true );
+
+    if( stats )
+        ON_TIMEOUT( updateOnTimeOut() );
 }
 
 MediaInfoDialog::~MediaInfoDialog()
@@ -133,13 +154,28 @@ void MediaInfoDialog::update( input_thread_t *p_input )
     /* Launch the update in all the panels */
     vlc_object_yield( p_input );
 
-    update( input_GetItem(p_input), b_need_update, b_need_update );
-    b_need_update = false;
-    b_cleaned = false;
+    update( input_GetItem(p_input), true, true);
 
     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 )
@@ -166,8 +202,14 @@ void MediaInfoDialog::clear()
 
 void MediaInfoDialog::close()
 {
-    this->toggleVisible();
+    toggleVisible();
 
+    /* if dialog is closed, revert editing if not saved */
+    if( MP->isInEditMode() )
+    {
+        MP->setEditMode( false );
+        updateButtons( 0 );
+    }
     if( mainInput == false ) {
         deleteLater();
     }