]> git.sesse.net Git - vlc/commitdiff
Qt4 - MediaInfo, move the tabWidget to the Dialog class and remove it from components.
authorJean-Baptiste Kempf <jb@videolan.org>
Sat, 2 Jun 2007 20:18:24 +0000 (20:18 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Sat, 2 Jun 2007 20:18:24 +0000 (20:18 +0000)
modules/gui/qt4/components/infopanels.cpp
modules/gui/qt4/components/infopanels.hpp
modules/gui/qt4/dialogs/mediainfo.cpp
modules/gui/qt4/dialogs/mediainfo.hpp

index 431cc15976302bfc9b0d2e2d1007028cb72768bc..74b58e6d92c77d807ee1a7a55403146c0ab82894 100644 (file)
@@ -366,49 +366,3 @@ void InfoPanel::clear()
     InfoTree->clear();
 }
 
-/***************************************************************************
- * Tab widget
- ***************************************************************************/
-
-InfoTab::InfoTab( QWidget *parent,  intf_thread_t *_p_intf, bool _stats ) :
-                      QTabWidget( parent ), stats( _stats ), p_intf( _p_intf )
-{
-    MP = new MetaPanel( NULL, p_intf );
-    addTab( MP, qtr( "&General" ) );
-    EMP = new ExtraMetaPanel( NULL, p_intf );
-    addTab( EMP, qtr( "&Extra Metadata" ) );
-    IP = new InfoPanel( NULL, p_intf);
-    addTab(IP, qtr("&Codec Details"));
-    if( stats )
-    {
-        ISP = new InputStatsPanel( NULL, p_intf );
-        addTab(ISP, qtr("&Stats"));
-    }
-}
-
-InfoTab::~InfoTab()
-{
-}
-
-/* This function should be called approximately twice a second.
- * p_item should be locked
- * Stats will always be updated */
-void InfoTab::update( input_item_t *p_item, bool update_info,
-                      bool update_meta )
-{
-    if( update_info )
-        IP->update( p_item );
-    if( update_meta )
-        MP->update( p_item );
-        EMP->update( p_item );
-    if( stats )
-        ISP->update( p_item );
-}
-
-void InfoTab::clear()
-{
-    IP->clear();
-    MP->clear();
-    EMP->clear();
-    if( stats ) ISP->clear();
-}
index 5bed6774d3cb4ebc6f58ba13a0d891a1c69c79d6..6f3744474213e261be1e45d55efc0d4ca7c213af 100644 (file)
@@ -138,23 +138,4 @@ public slots:
     void update( input_item_t * );
     void clear();
 };
-
-class InfoTab: public QTabWidget
-{
-    Q_OBJECT;
-public:
-    InfoTab( QWidget *, intf_thread_t *, bool );
-    virtual ~InfoTab();
-    void update( input_item_t *, bool, bool );
-    void clear();
-private:
-    bool stats;
-    intf_thread_t *p_intf;
-    InputStatsPanel *ISP;
-    MetaPanel *MP;
-    InfoPanel *IP;
-    ExtraMetaPanel *EMP;
-    int i_runs;
-};
-
 #endif
index 43eabdec39620c5de11047ee24a65d0c3e11ccc2..55982f67139c4af8398e1f590cccd08ed5a93519 100644 (file)
@@ -37,8 +37,10 @@ static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
                         vlc_value_t oldval, vlc_value_t newval, void *param );
 MediaInfoDialog *MediaInfoDialog::instance = NULL;
 
-MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, bool _mainInput ) :
-                                    QVLCFrame( _p_intf ), mainInput(_mainInput)
+MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, bool _mainInput,
+                                  bool _stats ) :
+                                  QVLCFrame( _p_intf ), mainInput(_mainInput),
+                                  stats( _stats )
 {
     i_runs = 0;
     p_input = NULL;
@@ -47,17 +49,30 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, bool _mainInput ) :
     resize( 600 , 450 );
 
     QGridLayout *layout = new QGridLayout(this);
-    IT = new InfoTab( this, p_intf, true ) ;
+
+    IT = new QTabWidget;
+    MP = new MetaPanel( IT, p_intf );
+    IT->addTab( MP, qtr( "&General" ) );
+    EMP = new ExtraMetaPanel( IT, p_intf );
+    IT->addTab( EMP, qtr( "&Extra Metadata" ) );
+    IP = new InfoPanel( IT, p_intf);
+    IT->addTab( IP, qtr("&Codec Details"));
+    if( stats )
+    {
+        ISP = new InputStatsPanel( IT, p_intf );
+        IT->addTab(ISP, qtr("&Stats"));
+    }
+
     QPushButton *closeButton = new QPushButton(qtr("&Close"));
     closeButton->setDefault( true );
 
-    layout->addWidget(IT,0,0,1,3);
+    layout->addWidget( IT, 0, 0, 1, 3);
     layout->addWidget(closeButton,1,2);
 
     BUTTONACT( closeButton, close() );
+    ON_TIMEOUT( update() );
 
     if( mainInput ) {
-        ON_TIMEOUT( update() );
         var_AddCallback( THEPL, "item-change", ItemChanged, this );
     }
 }
@@ -86,36 +101,61 @@ static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
 
 void MediaInfoDialog::setInput(input_item_t *p_input)
 {
-    IT->clear();
+    clear();
     vlc_mutex_lock( &p_input->lock );
-    IT->update( p_input, true, true );
+    update( p_input, true, true );
     vlc_mutex_unlock( &p_input->lock );
 }
 
 void MediaInfoDialog::update()
 {
+    msg_Dbg( p_intf, "updating" );
     /* Timer runs at 150 ms, dont' update more than 2 times per second */
     if( i_runs % 3 != 0 ) return;
     i_runs++;
 
+    /* Get Input and clear if non-existant */
     input_thread_t *p_input =
              MainInputManager::getInstance( p_intf )->getInput();
     if( !p_input || p_input->b_dead )
     {
-        IT->clear();
+        clear();
         return;
     }
 
     vlc_object_yield( p_input );
     vlc_mutex_lock( &input_GetItem(p_input)->lock );
 
-    IT->update( input_GetItem(p_input), need_update, need_update );
+    update( input_GetItem(p_input), need_update, need_update );
     need_update = false;
 
     vlc_mutex_unlock( &input_GetItem(p_input)->lock );
     vlc_object_release( p_input );
 }
 
+void MediaInfoDialog::update( input_item_t *p_item, bool update_info,
+        bool update_meta )
+{
+    if( update_info )
+        IP->update( p_item );
+    if( update_meta )
+    {
+        MP->update( p_item );
+        EMP->update( p_item );
+    }
+    if( stats )
+        ISP->update( p_item );
+}
+
+void MediaInfoDialog::clear()
+{
+    IP->clear();
+    MP->clear();
+    EMP->clear();
+    if( stats ) ISP->clear();
+}
+
+
 void MediaInfoDialog::close()
 {
     this->toggleVisible();
index 31254903669a546b45ce77a9dd009b696e145279..ff88625f55cd25fd9b7f7fa9dd5e4ab129afe6ce 100644 (file)
@@ -26,6 +26,7 @@
 #define _MEDIAINFO_DIALOG_H_
 
 #include "util/qvlcframe.hpp"
+#include "components/infopanels.hpp"
 
 class QTabWidget;
 class InfoTab;
@@ -34,11 +35,12 @@ class MediaInfoDialog : public QVLCFrame
 {
     Q_OBJECT;
 public:
-    MediaInfoDialog( intf_thread_t *, bool mainInput = false );
+    MediaInfoDialog( intf_thread_t *, bool stats = true,
+                    bool mainInput = false );
     static MediaInfoDialog * getInstance( intf_thread_t *p_intf )
     {
         if( !instance)
-            instance = new MediaInfoDialog( p_intf, true);
+            instance = new MediaInfoDialog( p_intf, true, true );
         return instance;
     }
     static void killInstance()
@@ -53,13 +55,20 @@ public:
     void setInput( input_item_t * );
 private:
     input_thread_t *p_input;
-    InfoTab *IT;
+    QTabWidget *IT;
     static MediaInfoDialog *instance;
     int i_runs;
     bool mainInput;
+    bool stats;
+    InputStatsPanel *ISP;
+    MetaPanel *MP;
+    InfoPanel *IP;
+    ExtraMetaPanel *EMP;
 public slots:
     void update();
+    void update( input_item_t *, bool, bool );
     void close();
+    void clear();
 };
 
 #endif