]> git.sesse.net Git - vlc/commitdiff
Qt4 - Info Panels: Rewrite Meta Data and Dionoea's feature request. (1)
authorJean-Baptiste Kempf <jb@videolan.org>
Sat, 2 Jun 2007 18:21:27 +0000 (18:21 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Sat, 2 Jun 2007 18:21:27 +0000 (18:21 +0000)
modules/gui/qt4/components/infopanels.cpp
modules/gui/qt4/components/infopanels.hpp
modules/gui/qt4/dialogs/mediainfo.cpp

index 7e9f237f834c7002d7323401858e0eb84b64b59c..431cc15976302bfc9b0d2e2d1007028cb72768bc 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#include "components/infopanels.hpp"
 #include "qt4.hpp"
+#include "components/infopanels.hpp"
 
 #include <QTreeWidget>
+#include <QListView>
 #include <QPushButton>
 #include <QHeaderView>
 #include <QList>
 #include <QGridLayout>
-
+#include <QLineEdit>
+#include <QLabel>
+#include <QSpinBox>
+#include <QTabWidget>
 
 /************************************************************************
  * Single panels
@@ -43,25 +47,63 @@ MetaPanel::MetaPanel( QWidget *parent, intf_thread_t *_p_intf ) :
 {
     int line = 0;
     QGridLayout *l = new QGridLayout( this );
-#define ADD_META( string, widget ) {                            \
-    l->addWidget( new QLabel( qtr( string ) ), line, 0 );       \
-    widget = new QLabel( "" );                                  \
-    l->addWidget( widget, line, 1 );                            \
+    l->setColumnStretch( 2, 5 );
+    l->setColumnStretch( 5, 3 );
+
+#define ADD_META( string, widget ) {                             \
+    l->addWidget( new QLabel( qtr( string ) + " :" ), line, 0 ); \
+    widget = new QLineEdit;                                      \
+    l->addWidget( widget, line, 1, 1, 7 );                       \
     line++;            }
-    ADD_META( "Name", name_text );
-    ADD_META( "URI", uri_text );
-    ADD_META( VLC_META_ARTIST, artist_text );
-    ADD_META( VLC_META_GENRE, genre_text );
-    ADD_META( VLC_META_COPYRIGHT, copyright_text );
-    ADD_META( VLC_META_COLLECTION, collection_text );
-    ADD_META( VLC_META_SEQ_NUM, seqnum_text );
-    ADD_META( VLC_META_DESCRIPTION, description_text );
-    ADD_META( VLC_META_RATING, rating_text );
-    ADD_META( VLC_META_DATE, date_text );
-    ADD_META( VLC_META_LANGUAGE, language_text );
+
+    ADD_META( VLC_META_TITLE, title_text ); /* OK */
+    ADD_META( VLC_META_ARTIST, artist_text ); /* OK */
+    ADD_META( VLC_META_GENRE, genre_text ); /* FIXME List id3genres.h is not
+                                               includable yet ? */
+
+    /* Album Name */
+    l->addWidget( new QLabel( qfu( VLC_META_COLLECTION ) + " :" ), line, 0 );
+    collection_text = new QLineEdit;
+    l->addWidget( collection_text, line, 1, 1, 5 );
+    l->addWidget( new QLabel( qfu( VLC_META_DATE ) + " :" ), line, 6 );
+    /* Date (Should be in years) */
+    date_text = new QSpinBox; setSpinBounds( date_text );
+    l->addWidget( date_text, line, 7 );
+    line++;
+
+    /* Number and Rating */
+    l->addWidget( new QLabel( qfu( _("Track number/Position" ) ) + " :" ),
+                  line, 0 );
+    seqnum_text = new QSpinBox; setSpinBounds( seqnum_text );
+    l->addWidget( seqnum_text, line, 1, 1, 3 );
+
+    l->addWidget( new QLabel( qfu( VLC_META_RATING ) + " :" ), line, 4 );
+    rating_text = new QSpinBox; setSpinBounds( rating_text) ;
+    l->addWidget( rating_text, line, 5, 1, 3 );
+    line++;
+
     ADD_META( VLC_META_NOW_PLAYING, nowplaying_text );
+
+    /* Language and settings */
+    l->addWidget( new QLabel( qfu( VLC_META_LANGUAGE ) + " :" ), line, 0 );
+    language_text = new QLineEdit;
+    l->addWidget( language_text, line, 1, 1, 3 );
+    l->addWidget( new QLabel( qfu( VLC_META_SETTING ) + " :" ), line, 4 );
+    setting_text = new QLineEdit;
+    l->addWidget( setting_text, line, 5, 1, 3 );
+    line++;
+
+    ADD_META( VLC_META_COPYRIGHT, copyright_text );
     ADD_META( VLC_META_PUBLISHER, publisher_text );
-    ADD_META( VLC_META_SETTING, setting_text );
+
+    ADD_META( VLC_META_ENCODED_BY, publisher_text );
+    ADD_META( VLC_META_DESCRIPTION, description_text ); // Comment Two lines?
+
+    /*  ADD_META( TRACKID)  DO NOT SHOW it */
+
+    // ADD_META( _( "URI" ), uri_text ); // FIXME URI outside
+    //    ADD_META( VLC_META_URL, setting_text );
+    /* ART_URL */
 }
 
 MetaPanel::~MetaPanel()
@@ -70,39 +112,87 @@ MetaPanel::~MetaPanel()
 
 void MetaPanel::update( input_item_t *p_item )
 {
+    char *psz_meta;
 #define UPDATE_META( meta, widget ) {               \
-    char* psz_meta = p_item->p_meta->psz_##meta;    \
+    psz_meta = p_item->p_meta->psz_##meta;          \
     if( !EMPTY_STR( psz_meta ) )                    \
         widget->setText( qfu( psz_meta ) );         \
     else                                            \
         widget->setText( "" );          }
 
-    if( !EMPTY_STR( p_item->psz_name ) )
-        name_text->setText( qfu( p_item->psz_name ) );
-    else name_text->setText( "" );
-    if( !EMPTY_STR( p_item->psz_uri ) )
-        uri_text->setText( qfu( p_item->psz_uri ) );
-    else uri_text->setText( "" );
+#define UPDATE_META_INT( meta, widget ) {           \
+    psz_meta = p_item->p_meta->psz_##meta;          \
+    if( !EMPTY_STR( psz_meta ) )                    \
+        widget->setValue( atoi( psz_meta ) ); }/*FIXME Atoi ?*/
+
+    /* Name / Title */
+    psz_meta = p_item->p_meta->psz_title;
+    if( !EMPTY_STR( psz_meta ) )
+        title_text->setText( qfu( psz_meta ) );
+    else if( !EMPTY_STR( p_item->psz_name ) )
+        title_text->setText( qfu( p_item->psz_name ) );
+    else title_text->setText( "" );
+
+  /*  if( !EMPTY_STR( p_item->psz_uri ) )
+        uri_text->setText( qfu( p_item->psz_uri ) );*/
+///    else uri_text->setText( "" );
+
     UPDATE_META( artist, artist_text );
     UPDATE_META( genre, genre_text );
     UPDATE_META( copyright, copyright_text );
     UPDATE_META( album, collection_text );
-    UPDATE_META( tracknum, seqnum_text );
     UPDATE_META( description, description_text );
-    UPDATE_META( rating, rating_text );
-    UPDATE_META( date, date_text );
     UPDATE_META( language, language_text );
     UPDATE_META( nowplaying, nowplaying_text );
     UPDATE_META( publisher, publisher_text );
     UPDATE_META( setting, setting_text );
 
+    UPDATE_META_INT( date, date_text );
+    UPDATE_META_INT( tracknum, seqnum_text );
+    UPDATE_META_INT( rating, rating_text );
+
 #undef UPDATE_META
 }
 
-void MetaPanel::clear()
+void MetaPanel::clear(){}
+
+ExtraMetaPanel::ExtraMetaPanel( QWidget *parent, intf_thread_t *_p_intf ) :
+                                        QWidget( parent ), p_intf( _p_intf )
+{
+     QGridLayout *layout = new QGridLayout(this);
+     QLabel *topLabel = new QLabel( qtr( "Extra metadata and other information"
+                 " are shown in this list.\n" ) );
+     topLabel->setWordWrap( true );
+     layout->addWidget( topLabel, 0, 0 );
+
+     extraMetaTree = new QTreeWidget( this );
+     extraMetaTree->setAlternatingRowColors( true );
+     extraMetaTree->setColumnCount( 2 );
+
+     extraMetaTree->header()->hide();
+/*     QStringList *treeHeaders;
+     treeHeaders << qtr( "Test1" ) << qtr( "Test2" ); */
+
+     layout->addWidget( extraMetaTree, 1, 0 );
+}
+
+void ExtraMetaPanel::update( input_item_t *p_item )
 {
+    vlc_meta_t *p_meta = p_item->p_meta;
+    QStringList tempItem;
+
+    QList<QTreeWidgetItem *> items;
+    for (int i = 0; i < p_meta->i_extra; i++ )
+    {
+        tempItem.append( qfu( p_meta->ppsz_extra_name[i] ) + " : ");
+        tempItem.append( qfu( p_meta->ppsz_extra_value[i] ) );
+        items.append( new QTreeWidgetItem ( extraMetaTree, tempItem ) );
+    }
+    extraMetaTree->addTopLevelItems( items );
 }
 
+void ExtraMetaPanel::clear(){}
+
 /* Second Panel - Stats */
 
 InputStatsPanel::InputStatsPanel( QWidget *parent, intf_thread_t *_p_intf ) :
@@ -111,48 +201,60 @@ InputStatsPanel::InputStatsPanel( QWidget *parent, intf_thread_t *_p_intf ) :
      QGridLayout *layout = new QGridLayout(this);
      StatsTree = new QTreeWidget(this);
      QList<QTreeWidgetItem *> items;
+     QLabel *topLabel = new QLabel( qtr( "Various statistics about the current"
+                 " media or stream.\n Played and streamed info are shown." ) );
+     topLabel->setWordWrap( true );
+     layout->addWidget( topLabel, 0, 0 );
 
-     layout->addWidget(StatsTree, 0, 0 );
      StatsTree->setColumnCount( 3 );
      StatsTree->header()->hide();
 
 #define CREATE_TREE_ITEM( itemName, itemText, itemValue, unit ) {              \
-    itemName =                                                           \
-        new QTreeWidgetItem((QStringList () << itemText << itemValue << unit ));  \
+    itemName =                                                                 \
+      new QTreeWidgetItem((QStringList () << itemText << itemValue << unit )); \
     itemName->setTextAlignment( 1 , Qt::AlignRight ) ; }
 
-
 #define CREATE_CATEGORY( catName, itemText ) {                           \
     CREATE_TREE_ITEM( catName, itemText , "", "" );                      \
     catName->setExpanded( true );                                        \
     StatsTree->addTopLevelItem( catName );    }
 
-#define CREATE_AND_ADD_TO_CAT( itemName, itemText, itemValue, catName, unit ) { \
-    CREATE_TREE_ITEM( itemName, itemText, itemValue, unit );             \
+#define CREATE_AND_ADD_TO_CAT( itemName, itemText, itemValue, catName, unit ){ \
+    CREATE_TREE_ITEM( itemName, itemText, itemValue, unit );                   \
     catName->addChild( itemName ); }
 
+    /* Create the main categories */
     CREATE_CATEGORY( input, qtr("Input") );
     CREATE_CATEGORY( video, qtr("Video") );
     CREATE_CATEGORY( streaming, qtr("Streaming") );
     CREATE_CATEGORY( audio, qtr("Audio") );
 
-
-    CREATE_AND_ADD_TO_CAT( read_media_stat, qtr("Read at media"), "0", input , "kB") ;
-    CREATE_AND_ADD_TO_CAT( input_bitrate_stat, qtr("Input bitrate"), "0", input, "kb/s") ;
+    CREATE_AND_ADD_TO_CAT( read_media_stat, qtr("Read at media"),
+                           "0", input , "kB" );
+    CREATE_AND_ADD_TO_CAT( input_bitrate_stat, qtr("Input bitrate"),
+                           "0", input, "kb/s" );
     CREATE_AND_ADD_TO_CAT( demuxed_stat, qtr("Demuxed"), "0", input, "kB") ;
-    CREATE_AND_ADD_TO_CAT( stream_bitrate_stat, qtr("Stream bitrate"), "0", input, "kb/s") ;
-
-    CREATE_AND_ADD_TO_CAT( vdecoded_stat, qtr("Decoded blocks"), "0", video, "" ) ;
-    CREATE_AND_ADD_TO_CAT( vdisplayed_stat, qtr("Displayed frames"), "0", video, "") ;
-    CREATE_AND_ADD_TO_CAT( vlost_frames_stat, qtr("Lost frames"), "0", video, "") ;
-
-    CREATE_AND_ADD_TO_CAT( send_stat, qtr("Sent packets"), "0", streaming, "") ;
-    CREATE_AND_ADD_TO_CAT( send_bytes_stat, qtr("Sent bytes"), "0", streaming, "kB") ;
-    CREATE_AND_ADD_TO_CAT( send_bitrate_stat, qtr("Sent bitrates"), "0", streaming, "kb/s") ;
-
-    CREATE_AND_ADD_TO_CAT( adecoded_stat, qtr("Decoded blocks"), "0", audio, "") ;
-    CREATE_AND_ADD_TO_CAT( aplayed_stat, qtr("Played buffers"), "0", audio, "") ;
-    CREATE_AND_ADD_TO_CAT( alost_stat, qtr("Lost buffers"), "0", audio, "") ;
+    CREATE_AND_ADD_TO_CAT( stream_bitrate_stat, qtr("Stream bitrate"),
+                           "0", input, "kb/s" );
+
+    CREATE_AND_ADD_TO_CAT( vdecoded_stat, qtr("Decoded blocks"),
+                           "0", video, "" );
+    CREATE_AND_ADD_TO_CAT( vdisplayed_stat, qtr("Displayed frames"),
+                           "0", video, "" );
+    CREATE_AND_ADD_TO_CAT( vlost_frames_stat, qtr("Lost frames"),
+                           "0", video, "" );
+
+    CREATE_AND_ADD_TO_CAT( send_stat, qtr("Sent packets"), "0", streaming, "" );
+    CREATE_AND_ADD_TO_CAT( send_bytes_stat, qtr("Sent bytes"),
+                           "0", streaming, "kB" );
+    CREATE_AND_ADD_TO_CAT( send_bitrate_stat, qtr("Sent bitrates"),
+                           "0", streaming, "kb/s" );
+
+    CREATE_AND_ADD_TO_CAT( adecoded_stat, qtr("Decoded blocks"),
+                           "0", audio, "" );
+    CREATE_AND_ADD_TO_CAT( aplayed_stat, qtr("Played buffers"),
+                           "0", audio, "" );
+    CREATE_AND_ADD_TO_CAT( alost_stat, qtr("Lost buffers"), "0", audio, "" );
 
     input->setExpanded( true );
     video->setExpanded( true );
@@ -161,6 +263,8 @@ InputStatsPanel::InputStatsPanel( QWidget *parent, intf_thread_t *_p_intf ) :
 
     StatsTree->resizeColumnToContents( 0 );
     StatsTree->setColumnWidth( 1 , 100 );
+
+    layout->addWidget(StatsTree, 1, 0 );
 }
 
 InputStatsPanel::~InputStatsPanel()
@@ -174,7 +278,8 @@ void InputStatsPanel::update( input_item_t *p_item )
 #define UPDATE( widget, format, calc... ) \
     { QString str; widget->setText( 1 , str.sprintf( format, ## calc ) );  }
 
-    UPDATE( read_media_stat, "%8.0f", (float)(p_item->p_stats->i_read_bytes)/1000);
+    UPDATE( read_media_stat, "%8.0f",
+            (float)(p_item->p_stats->i_read_bytes)/1000);
     UPDATE( input_bitrate_stat, "%6.0f",
                     (float)(p_item->p_stats->f_input_bitrate * 8000 ));
     UPDATE( demuxed_stat, "%8.0f",
@@ -215,9 +320,15 @@ InfoPanel::InfoPanel( QWidget *parent, intf_thread_t *_p_intf ) :
      InfoTree = new QTreeWidget(this);
      QList<QTreeWidgetItem *> items;
 
-     layout->addWidget(InfoTree, 0, 0 );
+     QLabel *topLabel = new QLabel( qtr( "Information about what your media or"
+              " stream is made of.\n Muxer, Audio and Video Codecs, Subtitles "
+              "are shown." ) );
+     topLabel->setWordWrap( true );
+     layout->addWidget( topLabel, 0, 0 );
+
      InfoTree->setColumnCount( 1 );
      InfoTree->header()->hide();
+     layout->addWidget(InfoTree, 1, 0 );
 }
 
 InfoPanel::~InfoPanel()
@@ -262,12 +373,12 @@ void InfoPanel::clear()
 InfoTab::InfoTab( QWidget *parent,  intf_thread_t *_p_intf, bool _stats ) :
                       QTabWidget( parent ), stats( _stats ), p_intf( _p_intf )
 {
-//    setGeometry(0, 0, 400, 500);
-
-    MP = new MetaPanel(NULL, p_intf);
-    addTab(MP, qtr("&General"));
-    IP = new InfoPanel(NULL, p_intf);
-    addTab(IP, qtr("&Details"));
+    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 );
@@ -289,6 +400,7 @@ void InfoTab::update( input_item_t *p_item, bool update_info,
         IP->update( p_item );
     if( update_meta )
         MP->update( p_item );
+        EMP->update( p_item );
     if( stats )
         ISP->update( p_item );
 }
@@ -297,5 +409,6 @@ void InfoTab::clear()
 {
     IP->clear();
     MP->clear();
+    EMP->clear();
     if( stats ) ISP->clear();
 }
index 85d12d1a45a2236d0320c6cd4cf7a9c2f5be3fed..5bed6774d3cb4ebc6f58ba13a0d891a1c69c79d6 100644 (file)
 
 #include <QWidget>
 #include <QTabWidget>
-#include <QLabel>
+
+#ifdef HAVE_LIMITS_H
+#   include <limits.h>
+#endif
+
+#define setSpinBounds( spinbox ) {               \
+    spinbox->setRange( 0, INT_MAX );             \
+    spinbox->setAccelerated( true ) ;            \
+    spinbox->setAlignment( Qt::AlignRight );     \
+    spinbox->setSpecialValueText(""); }
 
 class QTreeWidget;
 class QTreeWidgetItem;
+class QTreeView;
+class QSpinBox;
+class QLineEdit;
 
 class MetaPanel: public QWidget
 {
@@ -43,26 +55,39 @@ public:
     virtual ~MetaPanel();
 private:
     intf_thread_t *p_intf;
-    QLabel *uri_text;
-    QLabel *name_text;
-    QLabel *artist_text;
-    QLabel *genre_text;
-    QLabel *copyright_text;
-    QLabel *collection_text;
-    QLabel *seqnum_text;
-    QLabel *description_text;
-    QLabel *rating_text;
-    QLabel *date_text;
-    QLabel *setting_text;
-    QLabel *language_text;
-    QLabel *nowplaying_text;
-    QLabel *publisher_text;
+    QLineEdit *uri_text;
+    QLineEdit *title_text;
+    QLineEdit *artist_text;
+    QLineEdit *genre_text;
+    QLineEdit *copyright_text;
+    QLineEdit *collection_text;
+    QSpinBox *seqnum_text;
+    QLineEdit *description_text;
+    QSpinBox *rating_text;
+    QSpinBox *date_text;
+    QLineEdit *setting_text;
+    QLineEdit *language_text;
+    QLineEdit *nowplaying_text;
+    QLineEdit *publisher_text;
 
 public slots:
     void update( input_item_t * );
     void clear();
 };
 
+class ExtraMetaPanel: public QWidget
+{
+    Q_OBJECT;
+public:
+    ExtraMetaPanel( QWidget *, intf_thread_t * );
+    virtual  ~ExtraMetaPanel() {};
+private:
+    intf_thread_t *p_intf;
+    QTreeWidget *extraMetaTree;
+public slots:
+    void update( input_item_t * );
+    void clear();
+};
 
 class InputStatsPanel: public QWidget
 {
@@ -128,6 +153,7 @@ private:
     InputStatsPanel *ISP;
     MetaPanel *MP;
     InfoPanel *IP;
+    ExtraMetaPanel *EMP;
     int i_runs;
 };
 
index e062e4429769d3943f1c473df3ba7a1bae17e321..43eabdec39620c5de11047ee24a65d0c3e11ccc2 100644 (file)
@@ -44,7 +44,7 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, bool _mainInput ) :
     p_input = NULL;
 
     setWindowTitle( qtr( "Media information" ) );
-    resize( 500 , 450 );
+    resize( 600 , 450 );
 
     QGridLayout *layout = new QGridLayout(this);
     IT = new InfoTab( this, p_intf, true ) ;
@@ -95,8 +95,8 @@ void MediaInfoDialog::setInput(input_item_t *p_input)
 void MediaInfoDialog::update()
 {
     /* Timer runs at 150 ms, dont' update more than 2 times per second */
-    i_runs++;
     if( i_runs % 3 != 0 ) return;
+    i_runs++;
 
     input_thread_t *p_input =
              MainInputManager::getInstance( p_intf )->getInput();