]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/dialogs/mediainfo.cpp
Layout fixes in COPYING (and use spaces instead of tabs). Use a fixed width font...
[vlc] / modules / gui / qt4 / dialogs / mediainfo.cpp
index af65871d1b89cef7163c30ff41f2f28e5bdc0882..a80b687c7f25d0f536edfe7dfed217b48410a42d 100644 (file)
  ******************************************************************************/
 
 #include "dialogs/mediainfo.hpp"
+#include "components/infopanels.hpp"
 #include "input_manager.hpp"
 #include "dialogs_provider.hpp"
-#include "util/qvlcframe.hpp"
-#include "components/infopanels.hpp"
-#include "qt4.hpp"
 
 #include <QTabWidget>
 #include <QGridLayout>
@@ -45,10 +43,10 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, bool _mainInput,
 {
     i_runs = 0;
     p_input = NULL;
-    need_update = true;
+    b_need_update = true;
 
     setWindowTitle( qtr( "Media information" ) );
-    resize( 700 , 450 );
+    resize( 600 , 480 );
 
     /* TabWidgets and Tabs creation */
     IT = new QTabWidget;
@@ -61,13 +59,12 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, bool _mainInput,
     if( stats )
     {
         ISP = new InputStatsPanel( IT, p_intf );
-        IT->addTab( ISP, qtr( "&Stats" ) );
+        IT->addTab( ISP, qtr( "&Statistics" ) );
     }
 
     QGridLayout *layout = new QGridLayout( this );
 
     /* FIXME GNOME/KDE ? */
-    editMetaButton = new QPushButton( qtr( "&Edit Metadata" ) );
     saveMetaButton = new QPushButton( qtr( "&Save Metadata" ) );
     saveMetaButton->hide();
     QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
@@ -80,20 +77,18 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, bool _mainInput,
     layout->addWidget( uriLabel, 1, 0, 1, 1 );
     layout->addWidget( uriLine, 1, 1, 1, 7 );
     layout->addWidget( saveMetaButton, 2, 6 );
-    layout->addWidget( editMetaButton, 2, 6 );
     layout->addWidget( closeButton, 2, 7 );
 
     BUTTONACT( closeButton, close() );
 
     /* The tabs buttons are shown in the main dialog for space and cosmetics */
     CONNECT( saveMetaButton, clicked(), this, saveMeta() );
-    CONNECT( editMetaButton, clicked(), this, editMeta() );
 
     /* Let the MetaData Panel update the URI */
     CONNECT( MP, uriSet( QString ), uriLine, setText( QString ) );
+    CONNECT( MP, editing(), this, editMeta() );
 
-    CONNECT( IT, currentChanged ( int ), this, updateButtons( int ) );
-
+    CONNECT( IT, currentChanged( int ), this, updateButtons( int ) );
 
     /* Create the main Update function with a time (150ms) */
     if( mainInput ) {
@@ -118,25 +113,20 @@ void MediaInfoDialog::showTab( int i_tab = 0 )
 
 void MediaInfoDialog::editMeta()
 {
-    in_edit = true;
-    editMetaButton->hide();
     saveMetaButton->show();
-    MP->editMeta();
 }
 
 void MediaInfoDialog::saveMeta()
 {
     MP->saveMeta();
-    editMetaButton->show();
     saveMetaButton->hide();
-    in_edit = false;
 }
 
 static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
         vlc_value_t oldval, vlc_value_t newval, void *param )
 {
     MediaInfoDialog *p_d = (MediaInfoDialog *)param;
-    p_d->need_update = VLC_TRUE;
+    p_d->b_need_update = VLC_TRUE;
     return VLC_SUCCESS;
 }
 
@@ -144,6 +134,15 @@ void MediaInfoDialog::setInput( input_item_t *p_input )
 {
     clear();
     update( p_input, true, true );
+    /* if info is from current input, don't set default to edit, if user opens
+     * some other item, se default to edit, so it won't be updated to current item metas
+     *
+     * This really doesn't seem as clean solution as it could be
+     */
+    input_thread_t *p_current =
+                     MainInputManager::getInstance( p_intf )->getInput();
+    MP->setEditMode( ( !p_current || p_current->b_dead || input_GetItem( p_current ) != p_input ) ?
+                            true: false );
 }
 
 void MediaInfoDialog::update()
@@ -163,17 +162,17 @@ void MediaInfoDialog::update()
 
     vlc_object_yield( p_input );
 
-    update( input_GetItem(p_input), need_update, need_update );
-    need_update = false;
+    update( input_GetItem(p_input), b_need_update, b_need_update );
+    b_need_update = false;
 
     vlc_object_release( p_input );
 }
 
-void MediaInfoDialog::update( input_item_t *p_item, bool update_info,
-                                                    bool update_meta )
+void MediaInfoDialog::update( input_item_t *p_item,
+                                                 bool update_info,
+                                                 bool update_meta )
 {
-    if( in_edit ) return;
-    MP->p_input = p_item;
+    MP->setInput( p_item );
     if( update_info )
         IP->update( p_item );
     if( update_meta )
@@ -195,18 +194,18 @@ void MediaInfoDialog::clear()
 
 void MediaInfoDialog::close()
 {
-    in_edit = false;
     this->toggleVisible();
 
     if( mainInput == false ) {
         deleteLater();
     }
+    MP->setEditMode( false );
 }
 
 void MediaInfoDialog::updateButtons( int i_tab )
 {
-    msg_Dbg( p_intf, "Coin Coin, Tab number: %i", i_tab );
-
-    if( i_tab == 0 ) saveMetaButton->show();
-    else saveMetaButton->hide();
+    if( MP->isInEditMode() && i_tab == 0 )
+        saveMetaButton->show();
+    else
+        saveMetaButton->hide();
 }